|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: Dynamic arrays
dakline@vassar.edu wrote: > > It's not the size changing factor of the linked list that is necessarily > important. I also need a compact data structure. Let me give an example. > > Say I'm using OpenGL (or DirectX, although in DirectX you can use surfaces > instead, and there is no equivalent object in OpenGL to my knowledge. If > there is, just take this as an example; I'd still what to know how to > dyanamically size the arrays). So I'm using OpenGL, and I want to store the > color of every pixel in a resizable window, so when I have to redisplay the > window I don't have to recompute the color of each pixel. Now, one of the > best way I know of to do this is to make an array that is the maximum size > of the screen, and then only use the part of it that the window fills. Of > course, this has its weakness; if the user changes resolutions, then > maximizes the window, the array is now invalid. I'm missing something here. If they size of the window changes don't you have to recompute the pixels anyway? If the size changes your save buffer either has to many pixels or not enough pixels. You can also resize the currently visible buffer by scaling the image (look for glZoom()). Most of the time though it is easiest to just regenerate the values. Also, seems like the only time you would use floats for color values is when you are doing ultra high precision rendering. Most computers can't do that very fast. Not to mention that converting 96 bit floating point color to 24 bit color (or what ever tyhe frame buffer needs) is going to take quite a while. Bob P. > > What I'd like to be able to do is size the array to the size of the window > everytime the window is changed. Or at least size the array to the screen > resolution at the beginning of the program, rather then picking the biggest > possible resolution and using that for the array. Linked lists just won't > cut it here, they will be huge and require massive amounts of computational > time for what is essentially a just a store/retrive. As I said before, > vectors are better then linked lists, but still have more overhead then I > would like... significantly more. > > Just to give you an idea of the significance of the problem, say I > represent the colors as a RGB in OpenGL, using 3 floating point numbers. So > every point in the two dimensional array is 3*32-bits = 96 bits on an Intel > processor. Now if we size the array to a good resolution, say 1200 x 1000, > we have an array that takes up 115200000 bits, or 14400000 bytes, or 14.4 > megs! (assuming I did that right; regardless, it is still very large). This > is just using arrays... trying to manage that kind of linked list would be > a trmendous computational problem, plus the fact that it would have to be 2 > dimensional... makes it clear that linked lists will not work. > > I am sure there is a better way to solve this problem (I in fact know of > some, like maybe a color lookup up table, or starting off not using 96-bit > color! I've thought about this problem quite a bit and I would welcome > hearing ideas on it as a seperate topic) but the approach I was interested > in for this example is dynamically creating the 2d array to the window > size, thereby minimizing the size of the array as much as possible. > > Again, this is just an example of the problem to illustrate the need. Just > addressing solutions to the redraw problem really don't help me... I'm > interested in dynamically sized multi-dimensional arrays for a variety of > problems, and to further my C++ knowledge. > > So, does anyone know much about this? I think it involves either using the > method used for strings or the new operator. > > SirFern > > >You can change the size of a linked list. Maybe it isn't clear to me what > >the application is. > >----- Original Message ----- > >From: <dakline@vassar.edu> > >To: <gameprogrammer@gameprogrammer.com> > >Sent: Friday, September 22, 2000 10:17 PM > >Subject: Re: Dynamic arrays > > > > > >> Linked lists have the same problem as vectors, except they have even more > >> overhead. I'm thinking of situations where I don't need that much power > >and > >> definately anything that size/memory intensive. > >> > > ================================================================= > The GameProgrammer.Com mailing list is for the open discussion > of any topic related to the art, science, and business of > programming games. This list is especially tolerant of beginners. > We were all beginners once > > To SUBSCRIBE or UNSUBSCRIBE please visit: > http://gameprogrammer.com/mailinglist.html ================================================================= The GameProgrammer.Com mailing list is for the open discussion of any topic related to the art, science, and business of programming games. This list is especially tolerant of beginners. We were all beginners once To SUBSCRIBE or UNSUBSCRIBE please visit: http://gameprogrammer.com/mailinglist.html
|
|