我的代码大致如下:
GLenum glewStatus = glewInit();
if (glewStatus != GLEW_OK)
exit(1);
if (!GLEW_ARB_framebuffer_object)
exit(1);
printf("%p\n", glFramebufferTexture);
这会打印 0,这解释了为什么调用 glFramebufferTexture()
会立即出现段错误。
但是,为什么是0呢?许多其他帧缓冲区函数都工作得很好(例如 glBindFramebuffer
、glFramebufferRenderbuffer
和 glBindFramebuffer
)。
我需要以不同的方式初始化 GLEW 或扩展吗?
最佳答案
glFramebufferTexture()
是比 glBindFramebuffer()
和其他 FBO 相关入口点更新的入口点。在核心 OpenGL 规范中,glFramebufferTexture()
是在 3.2 中添加的,而其余的 FBO 功能是 3.0 的一部分。 glFramebufferTexture()
也不是 ARB_framebuffer_object 的一部分。
在大多数情况下,您可以使用 glFramebufferTexture2D()
,这是原始 FBO 功能的一部分。 glFramebufferTexture()
仅对于纹理数组、立方体贴图等有所不同。
关于linux - 当 GLEW_ARB_framebuffer_object 不为零时,为什么 glFramebufferTexture 是 NULL 指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23550052/