How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio
Many programmers prefer OpenGL for graphics. If you are one of them, you are strongly advised by its producer, to use a window toolkit (such as freeGLUT) and an OpenGL loading libraries (such as GLEW). This guide will help you get over the...
Method 1 of 7:
Downloading freeGLUT and GLEW
- Highlight what you expect to do. Highlight step or sub-step or part of it and then do it. For example see picture above.
- Create a new folder called GL. In directory (disk) C:, right click > select New > Folder > type GL > hit ↵ Enter.
- Download the application GLEW. Right-click on following link and select Open Link in New Window http://glew.sourceforge.net. Below the Downloads heading, click Windows 32-bit and 64-bit.
- In downloading window click folder glew-2.1.0 > right click > select Copy.
- Navigate to C: > GL. Right click > select Paste. Click on name glew-2.1.0 and rename it to glew.
- If folder glew-2.1.0-win32 is downloaded, double click it to get glew-2.1.0.
- Download the freeglut 3.0.0 MSVC Package. In following link right click and select Open Link in New Window https://www.transmissionzero.co.uk/software/freeglut-devel/. In section freeglut 3.0.0 MSVC Package click Download freeglut 3.0.0 for MSVC.
- In downloading window right click folder freeglut
- Navigate to C: > GL. Right click > select Paste.
- Now in folder GL you have two folders: freeglut and glew.
Method 2 of 7:
Creating a Visual Studio Project
- Create an empty project.
- With Visual Studio 2017
- In V.S. main menu, click File. Then go to New > Project…
- In the left part of the new project window, click Visual C++ if it is not clicked.
- In the center of the screen click Empty Project.
- Below that, find the Name text box, type Project-0.
- Next to Location text box, click Browse... and navigate to C: > GL.
- Click Select a folder. The Location in New Project window is C:GL.
- Make sure the Create directory for solution box is not checked.
- Click OK.
- With Visual Studio 2019
- If it's not opened. Open it > Click Create a new project > Empty Project > Next.
- In Configure your new project wizard for "Project name" type: Project-0.
- Next to "Location" text field click .... Navigate to C: > GL > click Select folder. Now "Location" is C:GL.
- Check "Place solution and project in the same directory" > click Create.
- Wait till Visual Studio 2019 instance appears.
- If it's opened. Click File > New > Project… > Create a new project > Empty Project > Next. The rest as above.
- With Visual Studio 2017
- Add your source file to the Project.
- In the solution explorer window, right click the Source Files folder (the last one) > click Add > New Item….
- In the Add New Item - Project-0 window, click C++ File (.cpp) (the first one) from the middle of the window. In the Name text box, type Main.cpp.
- The Location is C:GLProject-0.
- Click the Add button. The file will open in the main text editor but leave the file blank for now.
Method 3 of 7:
Installing freeGLUT and GLEW on a Project
- Configure "Additional Include Directories"
- In Solution Explorer, right click on the name of your project, that is Project-0, and select Properties. Leave default settings: Configuration: Active(Debug), and Platform: Active(Win32).
- Open the C/C++ drop-down menu. Click General > Additional Include Directories > click the down arrow at the right of the field > click in the drop down menu.
- Add freeglutinclude folder: Copy C:GLfreeglutinclude > in Additional Include Directories wizard, click first icon > paste.
- Add glewinclude folder: Copy C:GLglewinclude > click again first icon > paste > on Additional Include Directories wizard click OK .
- In Solution Explorer, right click on the name of your project, that is Project-0, and select Properties. Leave default settings: Configuration: Active(Debug), and Platform: Active(Win32).
- Configure linker "Additional Library Directories"
- Open the Linker drop-down menu, and click General. Click Additional Library Directories entry > down arrow at the right of the field > in the drop-down menu.
- Add the freeglutlib folder: Copy C:GLfreeglutlib > in Additional Library Directories wizard click first icon > paste.
- Add the glewlibReleaseWin32 folder: Copy C:GLglewlibReleaseWin32 > click first icon > paste > in Additional Library Directories wizard click OK.
- Open the Linker drop-down menu, and click General. Click Additional Library Directories entry > down arrow at the right of the field > in the drop-down menu.
- Configure linker "Additional Dependencies"
- In the Linker drop-down menu, click Input > click the Additional Dependencies entry > the down arrow at the right of the field > click in the drop-down menu.
- Copy freeglut.lib; glew32.lib; opengl32.lib and paste on the top-most text box of the Additional Dependencies wizard > click OK in the Additional Dependencies wizard.
- In the Linker drop-down menu, click Input > click the Additional Dependencies entry > the down arrow at the right of the field > click in the drop-down menu.
- Set linker "SubSystem" to "Console"
- In the Linker drop-down menu, click System > SubSystem. Click the down arrow and select Console(/SUBSYSTEM:CONSOLE) from the dropdown menu. Click Apply, then OK on the Project Property Pages window.
- Copy freeglut.dll file and paste to Project-0 folder.
- Navigate to C: > GL > freeglut > bin. Inside bin folder click freeglut.dll file > right-click > Copy.
- Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
- The freeglut.dll file should now be in your project directory along with your Main.cpp file and a few other files created by Visual Studio.
- Copy glew32.dll file and paste to Project folder
- Navigate to C: > GL > glew > bin > Release > Win32. Click glew32.dll > right-click > Copy.
- Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
- The glew32.dll file should now be in Project-0 folder along with Main.cpp, freeglut.dll, and 4 other files created by Visual Studio.
- Test your project. Right click on following link and select Open Link in New Window badprog. Scroll down the page and find section Testing the setup (see image above). Copy code and paste in Main.cpp code area > hit Ctrl + F5. You should see two windows: one black (the console) and other with white square in black background. If you do not see that, do bellow step.
- Correct any errors. In "Error List" if you see error about
- file with extension .h go to part (Method) 3, step 1, "Configure the "Additional Include Directories"" and follow instructions.
- file with extension .lib go to part (Method) 3, step 2, "Configure the linker "Additional Library Directories"", and follow instructions. Also to step 3, "Configure the linker "Additional Library Directories"".
- "entry point must be defined" go to step 4, Set linker "SubSystem" to "CONSOLE" and follow instructions.
- file .dll go to step 5, "Copy freeglut.dll file and paste to Project-0 folder" and follow instructions.
- For other errors, if you cannot correct them, close Visual Studio > delete project folder Projetc-0 which lives in C:GL > open Visual Studio > repeat set up from part Method 2. Good job.
Method 4 of 7:
Creating a Project with OpenGL-freeGLUT-GLEW Template
- Create template. Go to Visual Studio main menu and, while Project-0 is open, click Project > Export Template.... On Export template Wizard check Project Template, if it's not checked. Click Next >. On Select Template Options, in Template name text box type: OpenGL-freeGLUT-GLEW. Click Finish. The Template has been created.
- Create project.
- With V.S. 2017. Click File > New > Project....
- On the New Project window, click template: OpenGL-freeGLUT-GLEW.
- In Name text field, type: Project-1. Be sure Create directory for solution is unchecked. Click OK.
- With V.S. 2019. Click File > New > Project....
- In Create a new project wizard scroll down the list of templates and select OpenGL-freeGLUT-GLEW > click Next.
- In Configure your new project wizard, in "Project name" text field type Project-1.
- Location should be C:GL. If it's not, click ... at the end of the field > navigate C:GL > Folder should be GL > click Select a folder. Now Location is C:GL.
- Be sure Place solution and project in the same directory is checked. Click Create.
- In the Solution Explorer, double click Source Files > double click ++Main.cpp. Its code appears in the code area. Run it. If code does not appear, right click ++Main.cpp > click Exclude From Project. Now create new Main.cpp.
- With V.S. 2017. Click File > New > Project....
- Add freeglut.dll file to new project-folder
- Navigate to C: > GL > Project-0 > click file freeglut.dll > right click > click Copy.
- Navigate to C: > GL > Project-1 > click on empty area > right click > click Paste.
- Now file freeglut.dll is in folder Project-1 among Main.cpp and other 4 files.
- Add glew32.dll file to new project-folder
- Navigate to C: > GL > Project-0 > click file glew32.dll > right click > click Copy.
- Navigate to C: > GL > Project-1 > click on empty area > right click > click Paste.
- Now the file glew32.dll is in the folder Project-1 among freeglut.dll, Main.cpp and other 4 files.
- Test your project as above. Good job!
Method 5 of 7:
Create project to target x64 platform
- Create empty project as above with name Project-2, and add Main.cpp file.
- SDLproject's Properties settings. Go to "Solution Explorer" > right click on the name of your project that is Project-2 > select "Properties". In Platform: entry, choose x64 > Click Configuration manager...
- In Active solution platform: select x64
- In Platform entry select x64
- Click Close
- Additional Include Directories. As with targeting x86 platform, see above Method 3, step 1.
- Additional Library Directories. Open the "Linker" drop-down menu, and click "General". Click "Additional Library Directories" entry > down arrow at the end of the field > "Edit" in the drop-down menu.
- Copy this C:GLfreeglutlibx64 > in Additional Library Directories click first icon > paste.
- Copy this C:GLglewlibReleasex64 > click first icon > paste > click OK.
- Additional Dependencies. As with targeting x86 platform, see above Method 3, step 3.
- Subsystem. As with targeting x86 platform, see above Method 3, step 4.
- Copy dll files and paste into Project-2.
- Copy freeglut.dll file and paste into Project-2. In Windows's "File Explorer" navigate to
- C:GLfreeglutbinx64. In "x64" folder click "freeglut.dll" file > right-click > "Copy".
- C: > GL > Project-2. Right-click on empty area in "Project-2" folder, and select "Paste".
- Copy glew32.dll file and paste into Project-2. In Windows's "File Explorer" navigate to
- C: > GL > glew > bin > Release > x64. In "x64" folder click "glew32.dll" file > right-click > "Copy".
- C: > GL > Project-2. Right-click on empty area in "Project-2" folder, and select "Paste".
- Copy freeglut.dll file and paste into Project-2. In Windows's "File Explorer" navigate to
- Test your project and correct errors if any. As with targeting x86 platform, see above, Method 3 steps 7 and 8.
- Tip: Even if in Property Pages main settings it is Platform: x64, click Configuration manager... and in Active solution platform: select x64.
- Create template. As in Method 4.
- Tip: In every project you create with it, select x64 (next to Debug) in Visual Studio's GUI.
Method 6 of 7:
Setting up Built FreeGLUT and Built GLEW
- In directory C, create folder GL. If folder with this name exists, close Visual Studio > in File Explorer > directory C > right click GL folder > select Delete > again right click > select New > Folder > type: GL > hit ↵ Enter.
- Install CMake. Right-click on following link and select Open Link in New Window Use CMake to Get Binaries from Source Code. Follow Method 1 Installing CMake.
- Download FreeGLUT source. Right-click on following address and select Open Link in New Window https://sourceforge.net/projects/freeglut/. Click Download
- In downloading window click zip folder freeglut-3.2.1 (or latest version) > right click > select Copy.
- In File Explorer navigate to C: > GL > right click > select Paste. Click twice on folder's name > delete name > type: freeglut > hit ↵ Enter.
- Download GLEW source. Right-click on following address and select Open Link in New Window http://glew.sourceforge.net/. Beside Source click ZIP.
- In download in window click folder glew-2.1.0 (or latest) > right click > Copy.
- Navigate to C: > GL. Right click > Paste. Click twice on folder's name and rename glew > hit ↵ Enter. Now in folder GL you have folders glew and freeglut.
- Build FreeGLUT by CMake and Visual Studio. Go to CMake GUI.
- Copy C:/GL/freeglut and paste in first text field.
- Copy C:/GL/freeglut/build and paste in second text field.
- Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > select Visual Studio 16 2019 > click Finish.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- Build your solution.
- Navigate to C: > GL > freeglut > build. Double click "freeglut.sln", or "freeglut", or "ALL_BUILD.vcxproj". An instance of Visual Studio appears. Wait until in main menu Build entry appears. Click it > "Build Solution".
- Wait till you read the last line in "Output" window: ========== Build: XX succeeded, 0 failed, 0 up-to-date, 1 skipped" ==========
- Number XX of "succeeded" changes in freeglut versions. Today (11-Feb-2020) is 28.
- Navigate to C:GLfreeglutbuildlibDebug. Inside you should see file freeglutd.lib among other two files.
- Build GLEW by CMake and Visual Studio. Follow above step but
- In first text field paste C:/GL/glew/build/cmake
- In second paste C:/GL/glew/build
- Navigate to C: > GL > glew > build. Double click "glew.sln", or "glew", or "ALL_BUILD.vcxproj".
- In V.S. Output wizard, number of succeeded today (31-1-2020) is 6, may change in later version though.
- Navigate to C: > GL > glew > build > lib > Debug. Inside you should see file glew32d.lib among two other files.
- Set up built FreeGLUT and built GLEW in project.
- Create empty project and add source file according to Method 2.
- Configure project's Properties. In Solution Explorer wizard, right click Project's name that is Project-0 > select Properties.
- (1) Project-0 Property Pages main menu. In Platform entry select x64 > click Configuration Manager....
- In Active solution platform: select x64.
- In Platform entry, x64 is automatically selected.
- Click Close.
- (2) Additional Include Directories. Click C/C++ > General > In beside menu select the first one, Additional Include Directories > click the down arrow at the end of the field > click Edit... > first icon > three dots ...
- Navigate to C: > GL > freeglut > include > click include > click Select a folder.
- Click again first icon > three dots > navigate to C: > GL > glew > include > click include > click Select a folder > click OK.
- (3) Additional Library Directories. Double click Linker > click General > Additional Library Directories > click the down arrow at the end of the field > click Edit... > first icon.
- Copy C:GLfreeglutbuildlibDebug and paste in upper-most text field.
- Click again first icon > copy C:GLglewbuildlibDebug and paste in upper-most text field > click OK.
- (4) Additional Dependencies. In Linker drop-down menu select Input > in beside menu select the first one, Additional Dependencies > click the down arrow at the end of the field > Edit... > copy opengl32.lib; freeglutd.lib; glew32d.lib and paste in Additional Dependencies wizard's upper-most text box > click OK.
- (5) Set System to SubSystem CONSOLE. In Linker drop-down menu select System > in beside menu select the first one, SubSystem > click the down arrow at the end of the field > select Console (/SUBSYSTEM:CONSOLE). Click Apply and OK.
- (1) Project-0 Property Pages main menu. In Platform entry select x64 > click Configuration Manager....
- Copy files freeglutd.dll and glew32d.dll, and paste into Project-0 folder.
- Navigate to C:GLfreeglutbuildbinDebug. Click freeglutd.dll > right-click > Copy.
- Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
- Navigate to C:GLglewbuildbinDebug. Click glew32d.dll > right-click > Copy.
- Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
- Files freeglutd.dll and glew32d.dll should now be in Project-0 folder along with Main.cpp, and 4 other files created by Visual Studio.
- Test your project and correct errors if any. As above Method 3, steps 7 and 8.
- Create Template. As above Method 4 but in Visual Studio GUI, main menu select x64. Remember copy and paste dll files.
Method 7 of 7:
Choosing Set Up
- In this tutorial you learn 3 was to set up FreeGLUT and GLEW in Project with Visual Studio.
- Set up binaries x86 (32 bits). It's the easiest. You should start learning set up from here.
- Set up binaries x64 (64 bits). It targets x64 platform. Choose it only when you have specific reason for doing so.
- Compile FreeGLUT source, GLEW source, and set up them in project. Targets x64 too.The most difficult. The best though.
4.2 ★ | 5 Vote
You should read it
- How to Set Up SDL with Visual Studio
- How to Create an Executable File from Eclipse
- Secure personal data on Windows XP
- How to Set Up an OpenGL SDL GLEW Template Project in Visual Studio
- How to Set Up OpenGL GLFW GLEW GLM on a Project with Visual Studio
- How to Restore Deleted Files in Windows XP
- How to Set Up OpenGL‐GLFW‐GLAD on a Project with Visual Studio
- How to Zip Folder on Windows
- Hide the Windows folder in a professional way
- How to Open an MPP File on PC or Mac
- How to Make a New Folder on a Computer
- How to Set Up SFML in a Project on Visual Studio
Maybe you are interested
How to use Auto Clicker Assist to automatically click the mouse
Instructions to fix double click error on computer mouse - Click once becomes twice
PowerToys will soon support creating app spaces and launching with just one click
Turn Windows 11 interface into Windows 10 with just one click
Fix right-click issue on Windows 10
Do not click on strange links or your phone will be hijacked