Setting Up OpenGL with GLUT in Visual Studio 2022 on Windows 10

Zerihun M.
4 min readAug 7, 2024

--

OpenGL is a powerful graphics library that enables developers to create 2D and 3D graphics. Setting it up with GLUT in Visual Studio 2022 on Windows 10 can be a bit tricky, but this step-by-step guide will walk you through the process smoothly.

Prerequisites

Before we begin, ensure you have the following installed on your system:

  • Visual Studio 2022: Download and install from the official website.
  • GLUT (OpenGL Utility Toolkit): Download the GLUT library.

Step 1: Install Visual Studio 2022

  1. Download Visual Studio 2022 from the Visual Studio website.
  2. Run the installer and select the “Desktop development with C++” workload.

3. Click “Install” and wait for the installation to complete.

Step 2: Download and Set Up GLUT

  1. Download GLUT: Go to the GLUT website and download glutdlls37beta.zip file.
  2. Extract the Files: Extract the downloaded ZIP file to a convenient location on your computer.
  3. File inside folder look like this:

Step 3: Copy GLUT Files

After downloading and extracting GLUT, you need to copy the files to the appropriate directories as instructed below:

1. Copy glut.h:

  • Navigate to the include folder in your GLUT download
  • Copy glut.h to:

Note: Please create a folder named “GL” inside the include folder if it does not already exist and copy glut.h to this folder.

2. Copy glut.lib:

  • Navigate to the lib folder in your GLUT download.
  • Copy glut.lib to:

3. Copy glut32.lib:

  • Navigate to the lib folder in your GLUT download.
  • Copy glut32.lib to:

4. Copy glut.dll and glut32.dll:

  • Navigate to the bin folder in your GLUT download.
  • Copy glut.dll and glut32.dll to

5. Copy glut32.dll:

  • From the same bin folder, copy glut32.dll to:

Step 4: Configure Visual Studio Project

  1. Create a New Project:
  • Open Visual Studio 2022.
  • Click on “Create a new project”.
  • Select “Empty Project” under the “C++” category.
  • Name your project and click “Create”.

2. Link the Libraries:

  • Under “Configuration Properties”, go to “Linker” > “Input”.
  • Add the following to the “Additional Dependencies” field:

Step 5: Add Source Code

  1. Add a New Source File:
  • Right-click on the “Source Files” folder in the Solution Explorer.
  • Select “Add” > “New Item…”.
  • Choose “C++ File (.cpp)” and name it main.cpp.
  1. Write Your OpenGL Code:(main.cpp)

Step 6: Build and Run

  1. Build the Project:
  • Go to “Build” > “Build Solution” or press Ctrl+Shift+B.
  • Ensure there are no errors in the Output window.

2. Run the Project:

  • Go to “Debug” > “Start Without Debugging” or press Ctrl+F5.
  • A window should appear displaying a simple triangle.

Troubleshooting

  • Linker Errors: Ensure the library paths are correctly set in the project properties.
  • Runtime Errors: Ensure the GLUT DLLs (glut32.dll) are setup properly in the system path

Conclusion

Congratulations! You’ve successfully set up OpenGL with GLUT in Visual Studio 2022 on Windows 10. This setup allows you to start developing powerful graphics applications using OpenGL. Click here to download the complete setup video, necessary OpenGL lib and complete source code.

Related Posts:

--

--

Zerihun M.

OpenGL expert sharing insights and tutorials on basic and advanced graphics programming and development techniques.