我正在使用opengl将纹理设置为3d object.then快照并将其混合到其他图片中。 我想要高分辨率快照(3000 * 1500像素)。在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
test.png: http://i.imgur.com/1MKySdV.jpg
答案 0 :(得分:0)
看起来你在framebuffer中的视口很小。调用glViewport(g_fboWidth,g_fboHeight)。