PDA

View Full Version : Re: animation of a series of images using OpenGL



04-14-2002, 01:04 AM
Hi,
Thanks for the code fix, I just have three questions for you or anyone out here:

1) Do I have to declare pointers to an array of images before I can display them? I'm asking because I noticed that it takes sometime to load all the images into memory before display. I had in mind a case where I could load the images sequentially as the program was executing so as to minimise use of memory. As it is I can't load more than 250 images for my simulation unless my X server complains and can't open a window. I have a case in which the number of images is not known beforehand so the player needs to display an indeterminate number of images.

2) (This seems like a stupid question but i
I'll ask it anyway) I'm using ASCII data files now, would it make a difference if I used binary files instead?

3) The color problem: I can display animations in grayscale but I'm at a loss on how to display a color animation. My data file has one number for each data point. This number is scaled from 0 to 255 and I want the scale to move from 0 for blue to 255 for red, passing through green in the middle. Is it possible to arrange such a colormap?


Thanks a lot for your help with this project.

Otonski

2)

Rob The Bloke
04-14-2002, 02:34 AM
Originally posted by Otonski:

1) Do I have to declare pointers to an array of images before I can display them? I'm asking because I noticed that it takes sometime to load all the images into memory before display. I had in mind a case where I could load the images sequentially as the program was executing so as to minimise use of memory. As it is I can't load more than 250 images for my simulation unless my X server complains and can't open a window. I have a case in which the number of images is not known beforehand so the player needs to display an indeterminate number of images.


you could load them sequentually off the disk but that's generally slower than loading them into memory and reading them from there. It may of course hit the situation where the memory is being paged out to disk and being read in anyway.


Originally posted by Otonski:

2) (This seems like a stupid question but i
I'll ask it anyway) I'm using ASCII data files now, would it make a difference if I used binary files instead?

Nope. make sure you open the file with read binary mode and use fread instead of fscanf or whatever you are using. You'll have to no the exact layout of the data before reading the file (may want to search for a tga or other image format loading tutorial). You must also be aware of Least-Significant/Most-Significant byte orderings if you want it to be portable.

Originally posted by Otonski:

3) The color problem: I can display animations in grayscale but I'm at a loss on how to display a color animation. My data file has one number for each data point. This number is scaled from 0 to 255 and I want the scale to move from 0 for blue to 255 for red, passing through green in the middle. Is it possible to arrange such a colormap?

store the array as RGBRGBRGBR .... etc. Load the image onto the screen with GL_RGB. Each pixel will take up 3 bytes of data.