How to Set Up OpenGL‐GLFW‐GLAD on a Project with 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 GLFW) and an OpenGL loading libraries (such as GLAD). This guide will help you get over the...
Method 1 of 7:
Downloading GLFW and GLAD
- Highlight what you expect to do. For example see picture above.
- Create folder GL. In directory (disk) C:, right click > select New > Folder > type GL > hit ↵ Enter.
- In folder GL create folder with name glad.
- Download GLFW. Right click on following address and select Open Link in New Window https://www.glfw.org/download.html, click 32-bit Windows binaries. You get "glfw-3.3.bin.WIN32" or latest version.
- Click it > right click > select Copy.
- Navigate to C: > GL > right click > select paste.
- Click on "glfw-3.3.bin.WIN32" and rename to glfw.
- Now in "GL" folder you have two folders: glad and glfw.
- Download GLAD. Right click on following address and select Open Link in New Window https://glad.dav1d.de/. In Language leave C/C++. In API/gl entry, select the latest version (today is 4.6). In Specification leave OpenGL. In Profile select Core. Scroll down the page and click GENERATE.
- In the "Glad" window, click "glad.zip", (see picture above).
- After download, in downloading window you have two zip folders: include and src.
- Click folder include > right click > Copy.
- Navigate to C: > GL > glad. In glad folder right click > select Paste.
- (Alternatively click folder include and drag into folder glad, at C:GLglad).
- Go back to downloading window > click folder src > right click > Copy.
- Navigate to C: > GL > glad. In glad folder right click > select Paste.
- (Alternatively click folder src and drag into folder glad, at C:GLglad).
- Now in folder glad you have two (unzipped) folders: include and src.
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. Folder's name should be 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 "Project name" text field type: Project-0. Next to "Location" text field click ....
- Navigate to C: > GL. Folder's name should be 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… > 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 entry (the last one).
- Click Add > New Item… In the Add New Item - Project-0 wizard, click C++ File (.cpp) (the first one) from the middle of the window. In the Name text box leave Source.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 GLFW and GLAD in the Project
- Add file glad.c. Go to Visual Studio > Solution Explorer > right click Source Files > click Add > Existing Item ... .
- Navigate to C: > GL > glad > src > glad.c > click glad.c. "File name" should be glad.c. Click Add.
- Configure Project-0 Property Pages. In Solution Explorer, right click on the name of your project, that is Project-0, and select Properties. Select Configuration: Active(Debug), Platform: Active(Win32).
- (1) Additional Include Directories. Open C/C++ drop-down menu. Click General > Additional Include Directories. > the down arrow at the right of the field > click in the drop down menu.
- Copy C:GLglfwinclude > in Additional Include Directories wizard click first icon > paste.
- Copy C:GLgladinclude > in Additional Include Directories wizard click first icon > paste.
- On Additional Include Directories wizard click OK.
- Copy C:GLglfwinclude > in Additional Include Directories wizard click first icon > paste.
- (2) 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 > click in the drop-down menu.
- In "Additional Library Directories" wizard click first icon > ....
- Navigate to C: > GL > glfw > lib-vc2019 or the latest. In the "Select Directory" window, the "Folder" should be "lib-vc2019" or the latest. Click Select folder.
- In "Additional Library Directories," click OK.
- (3) Additional Dependencies. In Linker drop down menu click "Input". Click Additional Dependencies entry > the down arrow at the right of the field > in the drop-down menu.
- Copy opengl32.lib; glfw3.lib; glfw3dll.lib and paste on the top-most text box of the Additional Dependencies wizard. Click OK in the Additional Dependencies wizard.
- (4) Set Linker "SubSystem" to "Console". In the Linker drop-down menu, click System > SubSystem > click the down arrow at the end of the field > select Console(/SUBSYSTEM:CONSOLE) from the dropdown menu > click Apply, then OK on the Project Property Pages wizard.
- (1) Additional Include Directories. Open C/C++ drop-down menu. Click General > Additional Include Directories. > the down arrow at the right of the field > click in the drop down menu.
- Test your project. Right click on following address and select Open Link in New Window https://learnopengl.com/code_viewer_gh.php?code=src/1.getting_started/2.1.hello_triangle/hello_triangle.cpp Copy the code. Go to Visual Studio and paste in Source.cpp code area > hit Ctr+F5, and wait... Two windows should appear: One black and other with name "LearnOpenGL" and inside an orange triangle.
- If only the black window (the console) appears with message: "Failed to create GLFW window", set up is okay, function glfwCreateWindow did not work.
- 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 glad.c go to step 5, and follow instructions.
- For other errors, if you cannot correct them, close Visual Studio > delete project folder Project-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 an OpenGL-GLFW-GLAD 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-GLFW-GLAD. 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-GLFW-GLAD.
- In Name text field, type: Project-1.
- Location should be C:GL. If it's not, click Browse > navigate C:GL > Folder's name should be GL > click Select a folder.
- 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-GLFW-GLAD > 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 ... > navigate C:GL > Folder's name should be GL > click Select a folder.
- Be sure Place solution and project in the same directory is checked. Click Create.
- Type or paste a new code in Source.cpp. Run the program. Good job.
- With V.S. 2017. Click File > New > Project....
Method 5 of 7:
Creating Project to target x64 Platform
- Download GLFW. 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.bin.WIN64" or latest version. The rest as above but with following step.
- Project's Property Pages main settings. Go to "Solution Explorer" > right click on the name of your project > select "Properties". In Platform: entry, choose x64 > Click Configuration manager...
- In Active solution platform: select x64
- In Platform entry, x64 is automatically selected.
- Click Close
- 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 above.
- TIP: In every project you create with it, select x64 (next to Debug) in Visual Studio's GUI.
Method 6 of 7:
Setting up GLFW built by CMake, and GLAD
- Build GLFW by CMake and Visual Studio, and set up in project. Right click on following link and select Open Link in New Window Use CMake to Get Binaries from Source Code. Follow it, but ...
- Before Method 3 (Testing Binaries), download GLAD according to present article's Method 1, step 4.
- In Method 3 (Testing Binaries), after step 2, add glad.c file: Go to Visual Studio > Solution Explorer > right click Source Files > click Add > Existing Item ....
- Navigate to C: > GL > glad > src > glad.c > click glad.c. "File name" should be glad.c. Click Add.
- In Solution Explorer, below Source Files you should see two files: glad.c and Main.cpp.
- In same Method (3), in step 3 Configure project's Properties, sub-step (2) Additional Include Directories, after configuring C:GLglfwinclude, copy C:GLgladinclude and, in Additional Include Directories wizard, click first icon > paste > click OK.
- Test your project and correct errors if any. In present article follow Method 3, steps 3 and 4.
- Create template. As above.
- TIP: In every project you create with it, select x64 (next to Debug) in Visual Studio's GUI.
Method 7 of 7:
Choosing Set Up
- In this tutorial you learn 3 was to set up GLFW and GLAD 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 GLFW source, and set up, together with GLAD, in project. Targets x64 too.The most difficult. The best though.
3.8 ★ | 38 Vote
You should read it
- 10 tips to work more effectively with PowerPoint
- How to Create an Executable File from Eclipse
- 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 Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio
- How to Open an MPP File on PC or Mac
- How to Set Up SFML in a Project on Visual Studio
- Toshiba will be the main supplier for Project Ara
- How to Set Up SDL with Visual Studio
- How to Add JARs to Project Build Paths in Eclipse (Java)
- Latest Project XL code and how to enter Project XL code
- How to Play Sounds for Calendar Notifications on a Mac
Maybe you are interested
5 popular Auto Click software for computers today
Latest Roblox Clicker Simulator Codes 12/2024
How to use GS Auto Clicker, automatically click mouse on computer
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