wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 13 people, some anonymous, worked to edit and improve it over time.
This article has been viewed 42,823 times.
Learn more...
This guide will help you get over the first challenge of using OpenGL, GLFW, GLEW, and GLM: Installing and setting them up, and creating your first project with GLFW-GLEW-GLM Template in Visual Studio 2022. It will assume your platform is Windows 10 or 11. During Visual Studio installation, check the Desktop development with C++ workload box, also click "Language pack" and check "English" box. It is addressing the beginner. He can set up GLFW-GLEW-GLM in project with Visual Studio by 3 ways: 1st targeting x32 platform, 2nd targeting x64 platform, and 3rd set up GLFW-GLEW-GLM source compiled by CMake and Visual Studio. Visual Studio 2022 is by default x64, however works interchangeably with x34.
Steps
Configuring Visual Studio
-
1Highlight step or sub-step. Highlight step or sub-step you expect to do and then do it. See as example picture above.
-
2Download Visual Studio 2022. If you have not done so, you can download it from https://www.visualstudio.com/downloads.
- Check the Desktop development with C++ workload box as you download. If necessary scroll down the page (see below image).
- Click "Language pack" and check "English" box.
- During installation, in "Personalize your Visual Studio experience" wizard, in "Development settings" menu, click "General" > click "Visual C++" > hit Start Visual Studio.
Downloading GLFWx32, GLEWbin, and GLM
-
1Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
- If folders GL and GLP exist it's okay.
- If they do not, right click in empty area > select New > Folder > type GL > hit ↵ Enter. By same way create folder GLP.
-
2Download GLFW. Right click on the following address and select Open Link in New Window https://www.glfw.org/download.html.
- Click 32-bit Windows binaries. You will get "glfw-3.3.8.bin.WIN32" or the latest version.
- Click the download folder "glfw-3.3.7.bin.WIN32" > right click > select copy.
- Navigate to C: > GL > right click > select paste.
- Click on "glfw-3.3.8.bin.WIN32" > right click > select Rename > type GLFWx32 > hit ↵ Enter.
- Now in "GL" folder, you have folder GLFWx32.
-
3Download GLEWbin. Right click on the following link and select Open Link in New Window http://glew.sourceforge.net/. Below Downloads, find Binaries and click Windows 32-bit and 64-bit.
- Click the downloaded folder glew-2.1.0 (or latest version) > right click > select Copy.
- Navigate to C: > GL > right click > select Paste.
- (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
- Rename glew-2.1.0 to GLEWbin
- If folder glew-2.1.0-win32 is downloaded, double click it for get glew-2.1.0.
-
4Download GLM. Right click on the following address and select Open Link in New Window glm OpenGL mathematics library. In the upper left corner click Download GLM 0.9.9.7 or latest version (see picture above).
- Click downloaded folder "glm" > right click > Copy.
- Navigate to C:\GL > right click > Paste.
- (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
- When copying is finished, rename glm to GLM
Creating Project targeting x32 Platform
-
1Create empty project.
-
If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
- In Configure your new project wizard, for "Project name", type (or copy and paste): GLFWx32-GLEWx32-GLM-0
- In "Location" delete everything, copy C:\GLP\ and paste.
- Check "Place solution and project in the same directory" > click Create.
- Wait until Visual Studio instance appears.
- If it is open. Click File > New > Project… > Empty Project > Next. The rest as above.
-
If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
-
2Add your Source file to the project.
- In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
- Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
Setting up GLFWx32, GLEWx32, and GLM in the Project
-
1Configure "Property Pages". Go to "Solution Explorer" > right click on the name of your project GLFWx32-GLEWx32-GLM-0 > select "Properties" (the last one). In "GLFWx32-GLEWx32-GLM-0 Property Pages" wizard,
-
1. Main menu. In Configuration: select Active(Debug) > Platform: Win32 or x86 > click Configuration Manager.
- "Configuration Manager" wizard
- "Active solution platform:" select x86 or Win32
- "Platform" Win32 or x86 is automatically selected
- Click Close.
- "Configuration Manager" wizard
-
2. Additional Include Directories. In GLFWx32-GLEWx32-GLM-0 Property Pages window double click C/C++ > click General > Additional Include Directories > down arrow at the end of the field > click <Edit...>.
- 1. Copy C:\GL\GLFWx32\include and paste in Additional Include Directories wizard's upper-most text field.
- 2. Copy C:\GL\GLEWbin\include and paste in Additional Include Directories wizard's upper-most text field.
- 3. Copy C:\GL\GLM and paste in Additional Include Directories wizard's upper-most text field.
- In Additional Include Directories wizard click OK.
-
3. Additional Library Directories. In "GLFWx32-GLEWx32-GLM-0 Property Pages" wizard, double click Linker > click General > Additional Library Directories > down arrow at the end of the field > click <Edit... >.
- 1. Copy C:\GL\GLFWx32\lib-vc2022 > click Additional Library Directories wizard's first icon > Paste.
- 2. Copy C:\GL\GLEWbin\lib\Release\Win32 > click again Additional Library Directories wizard's first icon > Paste.
- Click OK in Additional Library Directories wizard.
-
4. Additional Dependencies. In "Linker" drop down menu, click Input > Additional Dependencies > down arrow at the end of the field > click <Edit...>.
- Copy opengl32.lib; glfw3.lib; glfw3dll.lib; glew32.lib and paste on the top-most text box of the Additional Dependencies wizard.
- In "Additional Dependencies" wizard click OK.
- 5. System. In Linker dropdown menu click System > SubSystem > down arrow at the end of the field > select Console (/SUBSYSTEM:CONSOLE) > click Apply and then OK.
-
1. Main menu. In Configuration: select Active(Debug) > Platform: Win32 or x86 > click Configuration Manager.
-
2Add dll file path (address) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit ↵ Enter. "System Properties" wizard is thrown.
- Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
- Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
- Copy C:\GL\GLEWbin\bin\Release\Win32 > click New > Paste.
- Click OK in all 3 wizards.
- Close Visual Studio > in thrown wizard "Save changes to the following items?" click Save.
- Restart your PC > open Visual Studio. In "Open recent" list, click "GLFWx32-GLEWx32-GLM-0.sln", the first one. Now your project is open ready for test.
Testing and Correcting Project GLFWx32-GLEWx32-GLM-0
-
1Test your project. Right click on following address and select Open Link in New Window tutorial01.cpp. Copy the code and paste in Main.cpp code area > in main menu select x86 > hit Ctrl+F5. Two windows should appear. One black and other blue.
- If only the black window (the console) appears with message: "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorial.", set up is okay, but function glfwCreateWindow did not work.
-
2Correct errors if any. Files are missing. Copy GLFWx32-GLEWx32-GLM-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 3, step 2, and add it now.
- In "Error List" if you see error about
- file with extension .h go to previous Part, step 1, Additional Include Directories and follow instructions. Also check whether folders GLFWx32, GLEWbin, and GLM exist in C:\GL.
- file with extension .lib go to previous Part, step 1, Additional Library Directories, and follow instructions. Also to Additional Dependencies.
- "entry point must be defined" go to previous Part 3, step 1, System, and follow instructions.
- Thrown wizard about system or file .dll, go to previous part steps 2 and 3, and follow instructions.
- For other errors, if you can not correct them, close Visual Studio > delete project folder GLFWx32-GLEWx32-GLM-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 3. Good programming.
- In "Error List" if you see error about
Creating project with Template targeting x32 Platform
-
1Create Template. Go to Visual Studio main menu and, while GLFWx32-GLEWx32-GLM-0 is open, click Project > Export Template....
- On Export template Wizard check Project Template, if it's not checked > click Next >.
- On "Export Template Wizard" (Select Template Options), Template name should be GLFWx32-GLEWx32-GLM-0 > click Finish. The Template has been created. Delete thrown window with template's address.
-
2Create your project.
- In Visual Studio main menu click File > New > Project....
- In Create a new project wizard, in the list of templates, select GLFWx32-GLEWx32-GLM-0 (if necessary scroll dow the list of templates) > click Next.
- In the Configure your new project wizard, "Project name" should be GLFWx32-GLEWx32-GLM-01.
- Location should be C:\GLP.
- Be sure Place solution and project in the same directory is checked. Click Create, and wait till project be created.
- In Visual Studio's GUI main menu, select x86 > hit Ctrl+F5.
- TIP. Remember, when you create project with this template, in Visual Studio GUI main menu select x86.
Downloading GLFWx64, GLEWbin, and GLM
-
1Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
- If folders GL and GLP exist it's okay.
- If they do not, right click in empty area > select New > Folder > type GL > hit ↵ Enter. By same way create folder GLP.
-
2Download GLFW 64 bits. Right click on following address and select Open Link in New Window https://www.glfw.org/download.html.
- Click 64-bit Windows binaries. You get "glfw-3.3.8.bin.WIN64" or latest version.
- Click folder > right click > Copy.
- Navigate C:\GL > right click > Paste.
- When copying is finished, rename folder "glfw-3.3.8.bin.WIN64" to GLFWx64
-
3Download GLEWbin. If you don't already have downloaded it, right click on the following link and select Open Link in New Window http://glew.sourceforge.net/. Below Downloads, find Binaries and click Windows 32-bit and 64-bit.
- Click the downloaded folder glew-2.1.0 (or latest version) > right click > select Copy.
- Navigate to C: > GL > right click > select Paste.
- (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
- Rename glew-2.1.0 to GLEWbin
- If folder glew-2.1.0-win32 is downloaded, double click it for get glew-2.1.0.
-
4Download GLM. If you already have downloaded it it's okay. If not, right click on the following address and select Open Link in New Window glm OpenGL mathematics library. In the upper left corner click Download GLM 0.9.9.7 or latest version (see picture above).
- Click downloaded folder "glm" > right click > Copy.
- Navigate to C:\GL > right click > Paste.
- (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
- Rename glm to GLM
Creating Project to target x64 Platform
-
1Create empty project.
-
If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
- In Configure your new project wizard, for "Project name", type (or copy and paste): GLFWx64-GLEWx64-GLM-0
- In "Location" delete everything, copy C:\GLP\ and paste.
- Check "Place solution and project in the same directory" > click Create.
- Wait until Visual Studio instance appears.
- If it is open. Click File > New > Project… > Empty Project > Next. The rest as above.
-
If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
-
2Add your Source file to the project.
- In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
- Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
Setting up GLFWx64, GLEWx64, and GLM in the Project
-
1Configure "Property Pages". Go to "Solution Explorer" > right click on the name of your project GLFWx64-GLEWx64-GLM-0 > select "Properties" (the last one). In "GLFWx64-GLEWx64-GLM-0 Property Pages" wizard,
-
1. Main menu. In Configuration entry select Active(Debug) > in Platform: entry, select "x64" > Click {{macButton|Configuration manager...}. In Configuration Manager wizard,
- Active solution platform: select "x64"
- Platform entry, "x64" is automatically selected.
- Click Close
-
2. Additional Include Directories. In GLFWx64-GLEWx64-GLM-0 Property Pages window double click C/C++ > click General > Additional Include Directories > down arrow at the end of the field > click <Edit...>.
- 1. Copy C:\GL\GLFWx64\include > in Additional Include Directories wizard click first icon > Paste.
- 2. Copy C:\GL\GLEWbin\include and paste as before.
- 3. Copy C:\GL\GLM and paste as before.
- In Additional Include Directories wizard click OK.
-
3. Additional Library Directories. In "GLFWx64-GLEWx64-GLM-0 Property Pages" wizard, double click Linker > click General > Additional Library Directories > down arrow at the end of the field > click <Edit... >.
- 1. Copy C:\GL\GLFWx64\lib-vc2022 and paste in Additional Library Directories wizard's upper-most text field.
- 2. Copy C:\GL\GLEWbin\lib\Release\x64 and paste in Additional Library Directories wizard's upper-most text field.
- Click OK in Additional Library Directories wizard.
- In Additional Library Directories wizard click OK.
-
4. Additional Dependencies. In "Linker" drop down menu, click Input > Additional Dependencies > down arrow at the end of the field > click <Edit...>.
- Copy opengl32.lib; glfw3.lib; glfw3dll.lib; glew32.lib and paste on the top-most text box of the Additional Dependencies wizard.
- In "Additional Dependencies" wizard click OK.
- 5. System. In Linker dropdown menu click System > SubSystem > down arrow at the end of the field > select Console (/SUBSYSTEM:CONSOLE) > click Apply and then OK.
-
1. Main menu. In Configuration entry select Active(Debug) > in Platform: entry, select "x64" > Click {{macButton|Configuration manager...}. In Configuration Manager wizard,
-
2Add dll file path (address) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit ↵ Enter. "System Properties" wizard is thrown.
- Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
- Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
- Copy C:\GL\GLEWbin\bin\Release\x64 > click New > Paste.
- Click OK in all 3 wizards.
- Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
- Restart your PC > open Visual Studio. In "Open recent" list, click "GLFWx64-GLEWx64-GLM-0.sln", the first one. Now your project is open ready for test.
- TIP: Even if in Property Pages main settings it is Platform: x64, click Configuration manager..., and in Active solution platform: select x64.
Testing and Correcting project GLFWx64-GLEWx64-GLM-0
-
1Test your project. Right click on following address and select Open Link in New Window tutorial01.cpp. Copy the code and paste in Main.cpp code area > in main menu select x64 > hit Ctrl+F5. Two windows should appear. One black and other blue.
- If only the black window (the console) appears with message: "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorial.", set up is okay, but function glfwCreateWindow did not work.
-
2Correct errors if any. Files are missing. Copy GLFWx64-GLEWx64-GLM-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 7, step 5, and add it now.
- In "Error List" if you see error about
- file with extension .h go to previous Part, step 1, sub step 2. Additional Include Directories and follow instructions. Also check whether folders GLFWx64, GLEWbin, and GLM exist in C:\GL.
- file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories, and follow instructions. Also to sub step 4. Additional Dependencies.
- "entry point must be defined" go to previous Part, step 1, sub step 5. System, and follow instructions.
- Thrown wizard about System or file .dll, go to previous Part, step 2 and 3, and follow instructions.
- For other errors, if you can not correct them, close Visual Studio > delete project folder GLFWx64-GLEWx64-GLM-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 7.
- In "Error List" if you see error about
Creating Project with GLFWx64-GLEWx64-GLM-0 Template
-
1Create Template. Go to Visual Studio main menu and, while GLFWx64-GLEWx64-GLM-0 is open, click Project > Export Template....
- On Export template Wizard check Project Template, if it's not checked > click Next >.
- On "Export Template Wizard" (Select Template Options), Template name should be GLFWx64-GLEWx64-GLM-0 > click Finish. The Template has been created. Delete thrown window with template's address.
-
2Create your project. Go to Visual Studio main menu,
- Click File > New > Project....
- In Create a new project wizard, in the list of templates, select GLFWx64-GLEWx64-GLM-0 (if necessary scroll dow the list of templates) > click Next.
- In the Configure your new project wizard, "Project name" should be GLFWx64-GLEWx64-GLM-01.
- Location should be C:\GLP.
- Be sure Place solution and project in the same directory is checked. Click Create, and wait till project be created.
- In Visual Studio's GUI main menu, select x64 > hit Ctrl+F5.
- TIP. When you create project with this template, remember in Visual Studio GUI's main menu select x64.
Installing CMake
-
1Compiling a library from the source code guarantees that the resulting library is perfectly tailored for your CPU/OS, a luxury pre-compiled binaries don't always provide. It is also important that binaries you get target x64 platform.
-
2Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
- If folders GL and GLP exist it's okay.
- If they do not, right click in empty area > select New > Folder > type GL > hit ↵ Enter. By same way create folder GLP.
-
3Download CMake. Right-click on following address and select Open Link in New Window https://cmake.org/download/. Scroll down the page and find "Latest Release (3.26.0)", (or latest). In second "Platform" list, find (see image above) "Windows x64 ZIP" and click the beside entry cmake-3.26.0-windows-x86_64.zip (or latest) > in opening wizard select Save file.
-
4Copy and unzip the zip folder.
- If the downloaded folder doesn't contain line with stripes (unzipped folder) click it > right click > Copy.
- If downloaded folder's icon contains vertical line with stripes (zipped folder), double click it for get unzipped folder, (or alternatively, click folder > right click > in drop-down menu select Extract all).
- When unzipping (extracting files) is finished, click unzip folder cmake-3.26.0-windows-x86_64.zip (or latest) > right click > Copy.
- Go to drive (directory) C: > GL > right click > Paste.
- (Alternatively click folder "cmake-3.26.0-windows-x86_64" and drag into folder "GL").
- When copying is finished click folder "cmake-3.26.0-windows-x86_64" > right click > select "Rename" > type CMake > hit ↵ Enter > double click it > double click folder bin > inside you should see CMake's logo next to file name cmake-gui > double click this file. If wizard "Windows protect your PC" appears, click More information > Run anyway. Now on your screen you have CMake GUI.
- Each time you need CMake, navigate to C:\ > GL > double click folder CMake > double click "bin" > double click file cmake-gui (the one with CMake's logo).
Downloading Source GLFW, Source GLEW, and Source GLM
-
1Download GLFW source. Right-click on following address and select Open Link in New Window https://www.glfw.org/download.html. Select "Source package".
- In downloading window click folder "glfw-3.3.7" (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 (or copy and paste) GLFWsrc > hit ↵ Enter.
-
2Download GLEW source. Right-click on following address and select Open Link in New Window http://glew.sourceforge.net/. Beside Source click ZIP, be aware of the TGZ.
- In downloading window click folder "glew-2.1.0" (or latest) > right click > Copy.
- Navigate to C:\ > GL. Right click > Paste. When copying is finished, rename to GLEWsrc > hit ↵ Enter. Now in folder GL you have folders GLFWsrc and GLEWsrc, perhaps among others.
-
3Download GLM. If you already have downloaded it it's okay. If not, right click on the following address and select Open Link in New Window glm OpenGL mathematics library. In the upper left corner click Download GLM 0.9.9.7 or latest version (see picture above).
- Click downloaded folder "glm" > right click > Copy.
- Navigate to C:\GL > right click > Paste.
- (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
- Rename glm to GLM
Building source GLFW, source GLEW, and source GLM
-
1Build GLFW by CMake and Visual Studio. Go to CMake GUI.
- Copy (Be careful do not copy any blank space)C:/GL/GLFWsrc and paste in first text field.
- Copy (Be careful do not copy any blank space)C:/GL/GLFWsrc/build and paste in second text field ("Where to build the binaries:").
- Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > in wizard "Specify the generator for this project" click Finish.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- If, instead, wizard "Error" is thrown, click OK > click "File" > click "Delete Cache" > in thrown wizard "Delete Cache", click Yes.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- Build your solution.
- Copy C:\GL\GLFWsrc\build and paste in File Explorer Address Bar > hit ↵ Enter > double click "GLFW.sln", or "GLFW", 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: 32 succeeded, 0 failed, 0 up-to-date, 2 skipped" ==========
- Number of "succeeded" and/or skipped" may changes in glfw versions.
- Copy C:\GL\GLFWsrc\build\src\Debug and paste in File Explorer Address Bar > hit ↵ Enter. Inside you should see file glfw3.lib.
- Close this instance of Visual Studio.
-
2Build GLEW by CMake and Visual Studio. Go again to CMake GUI.
- Copy (Be careful do not copy any blank space)C:/GL/GLEWsrc/build/cmake and paste in first text field.
- Copy (Be careful do not copy any blank space)C:/GL/GLEWsrc/build and paste in second text field ("Where to build the binaries:").
- Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > in wizard "Specify the generator for this project" click Finish.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- If, instead, wizard "Error" is thrown, click OK > click "File" > click "Delete Cache" > in thrown wizard "Delete Cache", click Yes.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- Build your solution.
- Copy C:\GL\GLEWsrc\build and paste in File Explorer Address Bar > hit ↵ Enter > double click "glew.sln", or "glew", 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: 6 succeeded, 0 failed, 0 up-to-date, 2 skipped" ==========
- Number of "succeeded" and/or "skipped" may changes in glew versions.
- Copy C:\GL\GLEWsrc\build\lib\Debug and paste in File Explorer Address Bar > hit ↵ Enter. Inside you should see file glew32d.lib among other files.
- Close this instance of Visual Studio.
-
3Build GLM by CMake and Visual Studio. Go once more to CMake GUI.
- Copy (Be careful do not copy any blank space)C:/GL/GLM and paste in first text field.
- Copy (Be careful do not copy any blank space)C:/GL/GLM/build and paste in second text field ("Where to build the binaries:").
- Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > in wizard "Specify the generator for this project" click Finish.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- If, instead, wizard "Error" is thrown, click OK > click "File" > click "Delete Cache" > in thrown wizard "Delete Cache", click Yes.
- When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
- Build your solution.
- Copy C:\GL\GLM\build and paste in File Explorer Address Bar > hit ↵ Enter > double click the file "ALL_BUILD.vcxproj" or the file (not the folder) "glm" or "glm.sln". An instance of Visual Studio appears. Wait until in main menu Build entry appears. Click it > click "Build Solution".
- Wait till you read the last line in "Output" window: ========== Build: 165 succeeded, 0 failed, 0 up-to-date, X skipped" ==========
- Number of "succeeded" and/or "skipped" may changes in GLM versions.
- If number of succeeded is less than 165, close Visual Studio instance > delete CMake GUI > go to C: > GL > double click "CMake" > double click "bin" > double click file "cmake-gui". New CMake GUI appears. Follow present step.
- If now you see ========== Build: 0 succeeded, 0 failed, 165 up-to-date, 2 skipped ==========, or ========== Build: 3 succeeded, 0 failed, 162 up-to-date, 2 skipped ==========, it's okay.
- Copy C:\GL\GLM\build\glm\Debug and paste in File Explorer Address Bar > hit ↵ Enter. Inside you should see file glm_static.lib among other files.
- Close this instance of Visual Studio.
- Close CMake GUI.
Creating Project GLFWsrc-GLEWsrc-GLMsrc-0
-
1Create empty project.
-
If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
- In Configure your new project wizard, for "Project name", type (or copy and paste): GLFWsrc-GLEWsrc-GLMsrc-0
- In "Location" delete everything, copy C:\GLP\ and paste.
- Check "Place solution and project in the same directory" > click Create.
- Wait until Visual Studio instance appears.
- If it is open. Click File > New > Project… > Empty Project > Next. The rest as above.
-
If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
-
2Add your Source file to the project.
- In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
- Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
Setting up built GLFW, built GLEW and built GLM
-
1Configure project's Properties. In Solution Explorer wizard, right click Project's name that is GLFWsrc-GLEWsrc-GLMsrc-0 > select Properties (the last one). In GLFWsrc-GLEWsrc-GLMsrc-0 Property Pages wizard, .
-
1. Main menu. In "Configuration:" select "Active(Debug)" > 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....
- 1. Copy C:\GL\GLFWsrc\include > in "Additional Include Directories" wizard click first icon > paste in the uppermost text field.
- 2. Copy C:\GL\GLEWsrc\include > click again first icon > paste.
- 3. Copy C:\GL\GLM > click once more first icon > paste.
- In "Additional Include Directories" wizard 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....
- 1. Copy C:\GL\GLFWsrc\build\src\Debug > in Additional Library Directories" wizard click first icon > paste in upper-most text field.
- 2. Copy C:\GL\GLEWsrc\build\lib\Debug > click again first icon > paste.
- 3. Copy C:\GL\GLM\build\glm\Debug > click once more first icon > paste.
- In "Additional Library Directories" wizard 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; glfw3.lib; glew32d.lib; glm_static.lib > paste in "Additional Dependencies" wizard's upper-most text box.
- In "Additional Dependencies" wizard click OK.
- 5. System. 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. Main menu. In "Configuration:" select "Active(Debug)" > Platform entry select x64 > click Configuration Manager....
-
2Add dll files paths (addresses) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit ↵ Enter. "System Properties" wizard is thrown.
- Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
- In the "System Variables" section, double click the "Path" (or "PATH") Variable. "Edit environment variable" wizard is thrown.
- Copy C:\GL\GLM\build\glm\Debug > click New > Paste.
- Copy C:\GL\GLEWsrc\build\bin\Debug > click New > Paste.
- Click OK in all 3 wizards.
- Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
- Restart your PC > open Visual Studio. In "Open recent" list, click "C:\GLP\GLFWsrc-GLEWsrc-GLMsrc-0", the first one. Now your project is open ready for test.
Testing and Correcting project GLFWsrc-GLEWsrc-GLMsrc-0
-
1Test your project. Right click on following address and select Open Link in New Window tutorial01.cpp. Copy the code and paste in Main.cpp code area > in main menu select x64 > hit Ctrl+F5. Two windows should appear. One black and other blue.
- If only the black window (the console) appears with message: "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorial.", set up is okay, but function glfwCreateWindow did not work.
-
2Correct errors if any. Files are missing. Copy GLFWsrc-GLEWsrc-GLMsrc-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 14, step 2, and add it now.
- In "Error List" if you see error about
- file with extension .h go to previous Part, step 1, sub step 2. Additional Include Directories and follow instructions. Also check whether folders GLFWsrc, GLEWsrc, and GLM exist in C:\GL.
- file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories, and follow instructions. Also to sub step 4. Additional Dependencies.
- "entry point must be defined" go to previous Part, step 1, sub step 5. System, and follow instructions.
- Thrown wizard about System or file .dll, go to previous Part, step 2 and 3, and follow instructions.
- For other errors, if you can not correct them, close Visual Studio > delete project folder GLFWsrc-GLEWsrc-GLMsrc-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 14. Good job.
- In "Error List" if you see error about
Creating Project with GLFWsrc-GLEWsrc-GLMsrc Template
-
1Create Template. Go to Visual Studio main menu and, while GLFWsrc-GLEWsrc-GLMsrc-0 is open, click Project > Export Template....
- On Export template Wizard check Project Template, if it's not checked > click Next >.
- On "Export Template Wizard" (Select Template Options), Template name should be GLFWsrc-GLEWsrc-GLMsrc-0 > click Finish. The Template has been created. Delete thrown window with template's address.
-
2Create your project. Go to Visual Studio main menu,
- Click File > New > Project....
- In Create a new project wizard, in the list of templates, select GLFWsrc-GLEWsrc-GLMsrc-0 (if necessary scroll dow the list of templates) > click Next.
- In the Configure your new project wizard, "Project name" should be GLFWsrc-GLEWsrc-GLMsrc-01.
- Location should be C:\GLP.
- Be sure Place solution and project in the same directory is checked. Click Create, and wait till project be created.
- In Visual Studio GUI's main menu select x64 (next to Debug) > hit Ctrl+F5. Good job
- TIP: Remember, in every project you create with this template, select x64 (next to Debug) in Visual Studio's GUI.