低分辨率帧缓冲区重复自身 [英] Low-resolution Framebuffer repeats itself
问题描述
我创建了一个低分辨率的帧缓冲区对象,该对象具有复古风格的显示.
I created a low-resolution framebuffer object which has a retro-style display.
帧缓冲区似乎会自行显示,导致屏幕底部出现混乱的像素.
The framebuffer seems to display itself, causing a mess of pixels at the bottom of the screen.
这就是我制作帧缓冲区和渲染缓冲区的方式
This is how I made the Framebuffer and the Renderbuffer
FBO = glGenFramebuffers(1)
DBO = glGenRenderbuffers(1)
glBindRenderbuffer(GL_RENDERBUFFER, DBO)
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1280, 720)
glBindFramebuffer(GL_FRAMEBUFFER, FBO)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, DBO)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)
这是mainloop中的代码
And this is the code in mainloop
glDrawElements(GL_TRIANGLES, len(indices), GL_UNSIGNED_INT, None) # Drawing Stuff
###
glBindFramebuffer(GL_FRAMEBUFFER, 0)
glBlitFramebuffer(
640 - 128,
360 - 72,
640 + 128,
360 + 72,
0,
0,
1280,
720,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
GL_NEAREST
)
我正在将Python 3与PyOpenGL一起使用
I am using Python 3 with PyOpenGL
推荐答案
在对该问题的评论中,有关于驱动程序错误的推测.不是这种情况.正确的OpenGL行为的一个权威来源是 OpenGL规范,并且当前的GL 4.6规范在第18.3节复制像素"中进行了说明.(强调我的):
In the comments to this question, there are speculations about driver bugs. This is not the case. The one definitive source of correct OpenGL behavior is the OpenGL specification, and the current GL 4.6 spec states in section 18.3 "Copying Pixels" (emphasis mine):
几个命令在帧缓冲区的区域之间复制像素数据(请参阅第18.3.1节),或在纹理区域和渲染缓冲区之间(请参阅第18.3.2节).对于所有此类命令,如果源和目标相同或是同一基础纹理图像的不同视图,则源区域和目标区域在该帧缓冲区中重叠,复制产生的renderbuffer或纹理图像,像素值操作未定义.
Several commands copy pixel data between regions of the framebuffer (see section 18.3.1), or between regions of textures and renderbuffers (see section 18.3.2). For all such commands, if the source and destination are identical or are different views of the same underlying texture image, and if the source and destination regions overlap in that framebuffer, renderbuffer, or texture image, pixel values resulting from the copy operation are undefined.
请注意,绑定目标 GL_FRAMEBUFFER
是 GL_READ_FRAMEBUFFER
*(定义了blit的来源)和 GL_DRAW_FRAMEBUFFER
的快捷方式目的地),因此您将在此故意创建反馈循环.
Note that the binding target GL_FRAMEBUFFER
is a shortcut for both GL_READ_FRAMEBUFFER
*which defines the source for the blit) and GL_DRAW_FRAMEBUFFER
(which specifies the destination), so you are creating the feedback loop on purpose here.
但是,仍然不清楚您在做什么.从默认帧缓冲区到默认帧缓冲区的变暗意味着它根本不会显示FBO的内容,并且由于FBO idoes没有颜色附件,因此无法在其上呈现颜色数据.
However, it remains totally unclear what you are doing. The blit from default framebuffer to default framebuffer means it will not show the contents of your FBO at all, and since your FBO idoes not have a color attachment, you can't render color data to it anayway.
这篇关于低分辨率帧缓冲区重复自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!