具有帧缓冲的OpenGL中的高分辨率快照



我正在使用OpenGL将纹理设置为3D对象,然后快照并混合其他图片。我想高分辨率快照(3000 * 1500 px)。在OPENGL中可能吗?我的代码是:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
DrawScene();
DrawText();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
if (g_fboSamples > 0)
{
// Multisample rendering so copy the pixel data in the multisample
// color render buffer image to the FBO containing the offscreen
// texture image.
    glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, g_fbo);
    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, g_fboResolveTarget);
    glBlitFramebufferEXT(0, 0, g_fboWidth, g_fboHeight,
        0, 0, g_fboWidth, g_fboHeight,
    GL_COLOR_BUFFER_BIT, GL_NEAREST);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
// At this point we now have our scene fully rendered to our offscreen
// texture 'g_offscreenTexture'. This is where you would perform any
// post processing to the offscreen texture.
// Finally to display the offscreen texture to the screen we draw a screen
// aligned full screen quad and attach the offscreen texture to it.
BYTE* pixels = new BYTE[ 3 *g_fboWidth*g_fboHeight];
//glPixelStorei(GL_PACK_ALIGNMENT, 1);

glReadPixels(0, 0, g_fboWidth, g_fboHeight, GL_RGB, GL_UNSIGNED_BYTE, pixels);
bitmap.create(g_fboWidth, g_fboHeight);
bitmap.setPixels(pixels,g_fboWidth, g_fboHeight,3);
bitmap.flipVertical();
bitmap.saveBitmap("test.png");
glViewport(0, 0, g_windowWidth, g_windowHeight);   
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
DrawFullScreenQuad();
//g_fboWidth= 2732, g_fboHeight=1536 , g_windowWidth=683 and g_windowHeight=384

测试.png:https://i.stack.imgur.com/BaYe4.jpg

看起来帧缓冲中的视口很小。调用 glViewport(g_fboWidth, g_fboHeight)。

最新更新