GPU Shaders Demo
Overview
Prerequisites
- C++17 compatible compiler
- CMake (minimum 3.10)
- OpenGL (3.3+)
- GLEW (OpenGL Extension Wrangler Library)
- GLFW3 (Graphics Library Framework)
Installing dependencies
Ubuntu/Debian:
macOS:
Windows:
Building the Project
- Clone the repository:
- Create and navigate to build directory:
- Generate build files with CMake:
- Build the project:
Running Examples
Triangle Example
- Setting up an OpenGL context with GLFW
- Compiling and linking vertex and fragment shaders
- Creating and using vertex buffer objects (VBO) and vertex array objects (VAO)
- Drawing a basic shape with a solid color
Project Structure
gpu-shaders-demo/
├── CMakeLists.txt # Project configuration and build settings
├── examples/ # Contains individual example programs
│ └── triangle.cpp # Basic triangle rendering example
├── shaders/ # GLSL shader files (copied to build directory at compile time)
└── src/ # Main source code
└── main.cpp # Simple menu program listing available examples
Controls
- Press ESC to close any example window
- Window can be resized, and the viewport will adjust accordingly
Adding New Examples
- Create a new .cpp file in the examples/ directory
- Add the example to CMakeLists.txt using the add_example() function
- If needed, add any shader files to the shaders/ directory