This simple C++ program utilizes GLFW and GLAD to create an OpenGL window and render a colored triangle. The triangle is defined by vertex and fragment shaders, and the program provides a basic structure for setting up OpenGL, compiling shaders, and rendering graphics.
-
Make sure you have GLFW and GLAD installed.
-
Compile the program using your preferred C++ compiler. For example, using g++:
g++ -o main main.cpp -lglfw -ldl
-
Run the executable:
./main
- Press
ESC
to close the window.
- The program initializes GLFW and sets up an OpenGL 3.3 Core Profile window.
- Vertex and fragment shaders define the geometry and color of the triangle.
- Vertex data and buffers are created, and shaders are compiled and linked into a shader program.
- The main rendering loop clears the screen, uses the shader program, and draws the triangle.
- Cleanup is performed at the end of the program.
Feel free to modify and extend this code to experiment with OpenGL graphics programming.