我正在使用wlgGetProcAddress使用通过wglCreateContext创建的上下文获取函数。我已经使用wglMakeCurrent设置了上下文。我得到了glGetStringi的有效函数指针,但是我得到了NULLglGetString。我以为glGetStringglGetStringi是在同一版本的OpenGL(1.0)中引入的。有什么想法为什么我得到这个NULL吗?

const GLubyte* (*glGetString)(GLenum);
const GLubyte* (*glGetStringi)(GLenum, GLuint);
glGetString = reinterpret_cast<decltype(glGetString)>(wglGetProcAddress("glGetString"));
glGetStringi = reinterpret_cast<decltype(glGetStringi)>(wglGetProcAddress("glGetStringi"));

万一有问题,我有一个Radeon HD 7950,驱动程序版本为13.251.0.0。

最佳答案

glGetStringi的发布时间远晚于1.0-我相信它是3.3。更糟糕的是,在核心版本3.3+的配置文件中,您不能使用glGetString(GL_EXTENSIONS),但必须使用glGetStringi,较低版本的配置文件不提供该功能。

MSDN文档说wglGetProcAddress仅返回扩展功能的地址。用它们的术语来说,“扩展”是GL 1.1中没有的所有内容。

请阅读https://www.opengl.org/discussion_boards/showthread.php/168281-Can-t-get-wglGetProcAddress-to-work-in-opengl-3-1

09-06 06:34