2

最近,我专注于玩 Godot。当我尝试将渲染目标设置为 opengl-es 帧缓冲区时遇到问题。我试过RasterizerGLES2::set_base_framebuffer了,但它不起作用。

我的示例代码:

// create framebuffer and attach texture
glGenFramebuffers(1, &my_target_framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, my_target_framebuffer);

glGenTextures(1, &my_target_texture);
glBindTexture(GL_TEXTURE_2D, my_target_texture);
glTexParameteri(...);
glTexImage2D(...);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, my_target_texture, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

// clear to RED
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBindFramebuffer(GL_FRAMEBUFFER, 0);

// then call set_base_framebuffer, something like:
RasterizerGLES2::set_base_framebuffer(my_target_framebuffer, 
Vector2(my_target_width, my_target_height));

它根本不起作用,并且my_target_framebuffer始终为红色(不绘制到 my_target_framebuffer),并且屏幕闪烁。

请帮忙!

顺便说一句,我使用 godot 2.1

4

0 回答 0