I am using Windows 7 and Visual Studio 2010 express. What is the bare minimum of headers and libs that I need to include in a OpenGL project for it to be able to compile without any errors. And I talk about the minimum, without any additional libs like GLUT or GLFW or GLEW etc.
I thought that all I need to do is to add opengl32.lib in additional dependencies, but it looks like it’s not working, because VC can’t recognize some of the openGL syntax like “glGenBuffers()”.
The function prototypes declared inside
<GL/GL.h>on windows systems are only for OpenGL versions up to 1.1 (which is about 20 years old now). Every function for extensions or versions higher than that, likeglGenBuffers(which came with 1.5), has to be loaded dynamically usingwglGetProcAddressto retrieve a pointer to the function (if the version/extension is supported by your hardware and driver, of course).As this can be tedious work, there are libraries for automatic extension management, like GLEW, which do all this for you and present you with the needed function pointers in corresponding variables, so that you can directly use
glGenBuffersand the like as ordinary functions, but they are not declared anywhere in<GL/GL.h>.So no, you don’t need anything else than link against
opengl32.libto successfully compile an OpenGL project in VS2010, but you either need to manage extensions yourself whenever you need functionality higher than version 1.1 or use a third party library that does that for you, like GLEW.