In order for us to gain access to modern OpenGL functions we are going to need to get ourselves the OpenGL Extension Wrangler Library (GLEW). Which is a cross-platform open-source C/C++ extension loading library. We could also use GLAD to do this but for our purposes we are going to be using GLEW.

Step 1 : Downloading GLEWEdit

So our first step will be to go to the website  Then we need to click on the download for Windows 32-bit and 64-bit Binaries.

Once that download is complete, go into the downloaded zip folder and copy the glew-2.1.0 folder into our Dependencies folder of our project.


You can rename this folder to 'GLEW' if you like.

Step 2 : Check out the documentationEdit

If you look inside your new GLEW folder you will see a folder named 'doc'. In here you can find all the documentation for GLEW. This is important to look through to get a good idea of how all of this is supposed to be run. For example it tells us how we initialize GLEW if you go to index.html -> Usage.

Step 3 : Setting it up for our projectEdit

Inside Visual Studio right click on your project in Solution Explorer and go to 'Properties'. Then go to 'C/C++' and 'General'.

Go to 'Additional Include Directories', add a semicolon to the end of what is in there currently and add the location of the GLEW 'include' folder along with the macro for solution directory in front. In my case it will look like this : $(SolutionDir)Dependencies\GLEW\include

Next we want to link up the libraries. so we go into Dependencies -> GLEW -> lib ->Win32 copy that directory down and so the same as above except we are adding this into Links -> General ->Additional Library Dependencies. $(SolutionDir)Dependencies\GLEW\lib\Release\Win32

Then we want to go to Linker -> Input and then to Additional Dependencies and add glew32s.lib to the list of things we have in there.

Now we should be able to call glewInit(); in our Application.cpp file as well as add #inclue <GL/glew.h>. Make sure you have your #include line ABOVE any of your other #includes in your code. Otherwise you will get an error.

Also in our code we need to make sure that we define GLEW_STATIC, otherwise we will get a linking error. To do this we must go back into properties, go to C/C++ -> Preprocessor and in Preprocessor Definitions we add GLEW_STATIC;

Step 4 : The semantics of usageEdit

Now we have to make sure that we are calling glewInit() in the proper place AND we need to make sure that we create a valid rendering context BEFORE the init (as stated in the usage docs).


<- As you can see here, we call glewInit() AFTER glfMakeContextCurrent.

Now we have access to all current/modern functions!


Using Modern OpenGL in C++ - TheChernoProject

Community content is available under CC-BY-SA unless otherwise noted.