[info-performer] glReadPixels

Date view Thread view Subject view Author view

From: Myriam Lajon (myriam.lajon++at++oktal.fr)
Date: 09/06/2004 00:09:09


I try to create images from buffer
I use Performer 3.1.1.

Images created are ok if I do not resize the window. If I do, it's like the
row size is different from the real size or the first pixel is not at the
right place! :

--/-----
-/-----/
/-----/- (one or two lines cross the image)

Here is my code : (called before or after swap buffer is done, result is the
same)
Call at each step:

   glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

   // window size
   int x = _viewer->GetWidth();
   int y = _viewer->GetHeight();

   glPixelStorei(GL_PACK_ROW_LENGTH,x);

   int val = 3*(x+1)*(y+1);
   char * pixels = new char[val];

   glReadBuffer(GL_FRONT);
   glFinish();
   glReadPixels (0, 0, x, y, GL_RGB, GL_UNSIGNED_BYTE, pixels);

   // method call to create image in RGB format
   (*WriteImage)(name,(unsigned char*)pixels,x,y,3);

   pixels = 0;
   delete [] pixels;

Thanks for help
Myriam


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Sep 06 2004 - 00:09:29 PDT