Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CopyPBufferToImage(int width, int height)
- {
- // Copy the contents of the framebuffer - which in our case is our pixel buffer -
- // to our bitmap image (dummy target) in local system memory. Notice that we also need
- // to invert the pbuffer's pixel data since OpenGL by default orients the
- // bitmap image bottom up. Our Windows DIB wrapper expects images to be
- // top down in orientation.
- static BYTE *pixels = new BYTE[width * height * 4];
- memset(pixels, 0, width * height * 4);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
- for (int i = 0; i < height; ++i)
- {
- memcpy(&m_img.pPixels[m_img.pitch * i],
- &pixels[((height - 1) - i) * (width * 4)],
- width * 4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement