void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) { int w = SCREENWIDTH; int h = SCREENHEIGHT; ReleaseScreenshotBuffer(); ScreenshotBuffer = new BYTE[w * h * 3]; glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer); glPixelStorei(GL_PACK_ALIGNMENT, 4); pitch = -w*3; color_type = SS_RGB; buffer = ScreenshotBuffer + w * 3 * (h - 1); }
void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) { int w = SCREENWIDTH; int h = SCREENHEIGHT; ReleaseScreenshotBuffer(); ScreenshotBuffer = new BYTE[w * h * 3]; // Stereo3d might have an incomplete framebuffer bound, so unbind it for screenshot. int currentFramebuffer = 0; glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, 0); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer); glPixelStorei(GL_PACK_ALIGNMENT, 4); pitch = -w*3; color_type = SS_RGB; buffer = ScreenshotBuffer + w * 3 * (h - 1); // Restore offscreen hud image, if any, for stereo 3d if (currentFramebuffer != 0) glBindFramebuffer(GL_FRAMEBUFFER, currentFramebuffer); }