PDA

View Full Version : why i get a screensnap with OpenGL is black?



chinesealexander
09-26-2009, 10:39 PM
glReadBuffer(GL_FRONT);
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
glPixelStorei(GL_PACK_ALIGNMENT,4);
glPixelStorei(GL_PACK_ROW_LENGTH,0);
glPixelStorei(GL_PACK_SKIP_ROWS,0);
glPixelStorei(GL_PACK_SKIP_PIXELS,0);

int width = 1280;
int height = 1024;
int bytewidth = (width*4 +3 ) &~3;

char* raw_data = (char*)malloc( bytewidth* height);

glReadPixels(0,0,width,height,GL_BGRA_EXT,GL_UNSIG NED_INT,raw_data);

glPopClientAttrib();

wxImage image (width,height,raw_data );
image.SaveFile("C:\\test.bmp",wxBITMAP_TYPE_BMP);

chinesealexander
09-27-2009, 01:20 AM
this code from a mac sample screenshot,and it works ok under mac.
But why can't the windows work?