Setting Up OpenGL With Visual Studio using NuGet

In this article, I explained how to setup OpenGL in Visual Studio. A little hard if you ask me especially if you’re a beginner. But we can do this thing in a much simpler way using NuGet from Visual Studio. In just a few seconds you can install FreeGLUT and GLEW  without headaches.

  • FreeGLUT, which will help us setting up a window, initializing OpenGL contexts and getting input from mouse/keyboard. Beside FreeGLUT there are other libraries that can be used with OpenGL. eg: SDL, GLFW, GLUT, GLOW, native code, etc.
  • GLEW (GL Extension Wrangler), which adds support for the newest OpenGL versions eg. OpenGL  version 4.5. This means that we can access and play with OpenGL’s newest functions.

Note!!! that some NuGet packages might not install the latest library version.

Now, all you need is an Internet connection and you are ready to go. First open Visual Studio and create a New Project.

Create New Project

Create New Project(Click to zoom)

Pick Visual C++ and select Empty Project:

Empty Project

Empty Project

Make sure you don’t have any spaces in your path and your path is a valid one otherwise you can end up with a compile error called MSB3073: The command ” ” exited with code 1.

Now click OK and we are ready to create our main.cpp file which is our entry point for our program. Press CTR+SHIFT+A to add a new file and call it main.cpp.



We can write down the main function declaration and build and run the program by pressing F5 key:

int main(int argc, char **argv)
return 0;

If everything is ok, we are ready to use NuGet to set up FreeGLUT and GLEW:

NuGet Visual Studio

NuGet Visual Studio

A console window will appear waiting you, to write what  the packages you want to install in your project.

Now we are ready to use OpenGL and create a new window in our next tutorial.

You can also install them separately. For example  Install-Package freeglut and installs only FreeGLUT and Install-Package glew to install GLEW. If you want to install SDL you can write Install-Package SDL. It’s your choise. However in these tutorials we are using FreeGLUT. If you install them separately you have more control over libraries versions.


blog comments powered by Disqus