Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: why i get a screensnap with OpenGL is black?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    2

    why i get a screensnap with OpenGL is black?

    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);

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    2

    Re: why i get a screensnap with OpenGL is black?

    this code from a mac sample screenshot,and it works ok under mac.
    But why can't the windows work?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •