This example contains a basic OpenGL project that uses GLAD for loading OpenGL functions (version 3.3) and GLFW for window management and user input. The code renders a simple triangle in an OpenGL window in a Windows environment. The demo only uses Visual Studio Code as the IDE.
g++ -g -std=c++11 -I./include -L./lib ./src/*.cpp ./src/glad.c -lglfw3dll -o ./program.exeExplanation:
g++: The compiler being used.-g: Option to generate debugging information.-std=c++11: Specifies the C++11 standard.-I./include: Includes theincludefolder for header files.-L./lib: Adds thelibfolder where the libraries are located../src/*.cpp ./src/glad.c: Specifies the source files to be compiled.-lglfw3dll: Links theglfw3dlldynamic library.-o ./program.exe: Specifies the output file, in this case,program.exe.
This command should be run in the root directory of your project.
The following file structure is organized to ensure the project works correctly:
- The
.vscodefolder containstasks.jsonfor automating build tasks (optional). - The
includefolder holds the necessary header files for GLAD, GLFW, and KHR. - The
libfolder stores the compiled GLFW libraries. - The
srcfolder contains the source files (main.cppandglad.c) for the project. - glfw3.dll is placed in the root directory for dynamic linking during runtime.
This structure is essential for the correct functioning of the files, ensuring that the libraries and source files are organized and accessible during compilation and execution.
- GLAD Web Service: A web-based tool for generating OpenGL loaders, customizable by API version and extensions.
- GLFW Download Page: Official download page for GLFW, a library used to manage windows and input in OpenGL applications.
The necessary dependencies are also located in./assets/dependencies
