最近,我专注于和戈多一起玩。当我尝试将渲染目标设置为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
总是RED(不会绘制到my_target_framebuffer),屏幕闪烁。
plz help!
顺便说一下,我使用的是Godot 2.1