wglext - extension not installed in OpenGL context

会有一股神秘感。 提交于 2019-12-02 07:46:05

问题


I am trying to disable vsync in OpenGl with WGL_EXT_swap_control using wglSwapIntervalEXT(int interval).

I am trying to include the wglext header but after much searching it seems it is not installed on my pc (using opengl extension viewer to find this). I have tried installing the windows sdk and updating the .net framework but still cannot install this extension.

Is there anyway to include this. my graphics card is an nVidia GTX 770m. Or is there a simpler way to disable vsync.

Thanks


回答1:


Just to include header #include "gl\wglext.h" is not enough. You need to also register the extension to OpenGL. If you do not have a clue how to do it google for some tutorial but much much easier and safer is to use some extension registering library like GLEW see:

  • using GLEW
  • complete GL+VAO/VBO+GLSL+shaders example in C++
  • Multi-texturing example at the end is download link to complete C++ GL project with GLEW source included

After successful glewInit(); call your extension should be available (if present on the gfx card/driver.

Without registering extensions you got access to only basic OpenGL 1.0 stuff.




回答2:


So, a friend managed to figure this out without glew. So if anyone needs help with it this should be something similar to what you are looking for

void SetVSync(bool sync)  
{   
typedef BOOL(APIENTRY *PFNWGLSWAPINTERVALPROC)(int);
PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0;

const char *extensions = (char*)glGetString(GL_EXTENSIONS);

wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT");

if (wglSwapIntervalEXT)
    wglSwapIntervalEXT(sync);
}


来源:https://stackoverflow.com/questions/34063022/wglext-extension-not-installed-in-opengl-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!