3 headers(C/C++) in linux (with nvidia driver)
My SO is OpenSuse version 12.2 (x86_64) Mantis, with KDE desktop. I have currently the NVidia driver (319) installed from the repository. 3D acceleration work and the driver seem to support OpenGL 4.3.
I am trying to programme a simple OpenGL sample (just a triangle in a glut windows), but I am unable because GL/gl.h is outdated: the current header is the mesa with openGL 1.3, which does nos support glCreateShader, glAttachShader...
I have tryed $ sudo find / -name gl3.h (openGL 3.1 and further should include this header) but it does not return any result, so I suppose Nvidia driver does not include library/headers.
My question is: Where can I get the GL/gl.h for the installed NVidia driver? Onyone has got this same problem and solve it?
PS To install the NVidia driver, I just installed the driver from the NVidia repository for opensuse 12.2 (http://download.nvidia.com/opensuse/12.2/) (with Yast)
I have installed:
The correct way to access the newer features is via the GL extension mechanism. You are fine with mesa's GL.h
. What you need is a current version of glext.h
(which does come with the nivida drivers, iirc, but can also be found on the official opengl site). YOu then would have to query a function pointer for any function you plan to call, on your platform probably via glXGetProcAddress()
.
A more convenient way is to use an OpenGL loader library like glew, which will do all this for you.
Note that you could, in theory, #define GL_GLEXT_PROTOTYPES
before including glext.h
and directly call the functions. This is likely to work with the nvidia driver (and some others on your platform), but not guaranteed to work by any spec. And it is never going to work on other platforms, like Windows.
上一篇: OS X上的OpenGL版本支持