英特尔和英伟达之间的 OpenGL fbo 传输不一致
我正在将OpenGL中低分辨率的场景渲染到帧缓冲器中。然后我打算将此版本绘制到整个屏幕上(GL_NEAREST放大)。我使用纹理传输(glBlitFramebuffer)来做到这一点。在我的Nvidia GPU上,这可以工作,但是当在我的Intel i7集成显卡上执行完全相同的代码时,目标帧缓冲器上的y位置似乎是错误的(即图像渲染得太远)。
glGetError 不返回任何错误。由于Nvidia驱动程序往往非常宽容,我希望我在OpenGL规范中遗漏了Nvidia不关心的小细节。我搜索了互联网和堆栈溢出,找不到类似的问题描述。两个驱动程序都报告支持 OpenGL 3.0
我的绘图代码:
//setup viewport for small image
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, image.getWidth(), image.getHeight());
//bind small framebuffer
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glDrawBuffers(GL_COLOR_ATTACHMENT0);
glClear(GL_COLOR_BUFFER_BIT);
//draw
renderRotatedFull(1);//nothing interesting at all happening here
//reset Viewport
glPopAttrib();
//prepare and execute blitting
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glDrawBuffers(GL_BACK_LEFT);
glBlitFramebuffer(0, 0, image.getWidth(), image.getHeight(), 0, 0, Game.width,
Game.height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
//throws exception if there is an OpenGL error
org.lwjgl.opengl.Util.checkGLError();
初始化按如下方式完成:
fbo =glGenFramebuffers();
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
rbo = glGenRenderbuffers();
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, image.getWidth(), image.getHeight());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);