title: How can I load 8 bit bmp with OpenGL?
body: <p>Here is my situation: I need to preload 2000 images and display them in sequence to be an animation in 60 fps. Currently, I am using OpenGL to load bmp files, but due to memory limit, I can only preload up to 500+ images. How can I solve this problem? I can so far come up with two directions of solutions: First, maybe I can load 8 bit bmp images to save memory. But I have difficulty in using <em>glDrawPixels</em>.  Secondly, if possible can I load jpeg directly? Thanks for any advice!</p>
  
  <p>The reason for not using video is that I need to change to animation speed by skipping one or more images as you can see in the code (imgCount+=stp; // stp means how many images to escape. it can make video faster). And in my animation, frame rate is important, FPS lower than 50 shows flickering. </p>
  
  <p>Here is the code: </p>
  
  <pre><code>void Frame::LoadBMP(void){
  
   FILE *in;
  
  
   in=fopen(file,"rb");//open file 
   if(in==NULL){
  
       exit(0);
   }
   fread(&amp;(this-&gt;bmfh),sizeof(BITMAPFILEHEADER),1,in);//read bmp file header
   fread(&amp;(this-&gt;bmih),sizeof(BITMAPINFOHEADER),1,in);//read bmp infomation header
  
   colours=new RGBQUAD[bmih.biBitCount];
   fread(colours,sizeof(RGBQUAD),bmih.biBitCount,in);//read bmp colour table
  
   size=bmfh.bfSize-bmfh.bfOffBits;
   tempPixelData=new GLubyte[size];
  
   if(tempPixelData==NULL) {
       fclose(in);
   }
   fread(tempPixelData,sizeof(GLubyte),size,in);//read bmp image data
   fclose(in);
  }
  </code></pre>
  
  <p>and I will display the sequence of images, the display code:</p>
  
  <pre><code>void display(void){
  
  static clock_t start=clock();
  static clock_t end=clock();
  
  CurrtempPixelData=msFrame[offset]-&gt;tempPixelData;
  
  glEnable(GL_ALPHA_TEST);
  glEnable(GL_BLEND);
  
  glDrawPixels(frWidth, frHeight, GL_RGBA, GL_UNSIGNED_BYTE, msFrame[offset]-&gt;tempPixelData);
  
  for(int i=0;i&lt;m;i++){
      clock_t c=clock();
  }
  
  glutSwapBuffers();
  imgCount+=stp; // stp means how many images to escape. it can make video faster.
  offset=imgCount%numFrame;
  glutPostRedisplay();
  
  }
  </code></pre>