Asia/Kolkata
ProjectsMay 29, 2025

Building Shaders in C++

image
A demonstration project for learning and experimenting with GPU shaders using OpenGL. This project provides simple examples to understand how to implement and use shaders in graphics programming. This project showcases various shader implementations using OpenGL, GLEW, and GLFW. Each example demonstrates different aspects of shader programming, starting with basic concepts like rendering a simple triangle. To build and run this project, you'll need:
  • C++17 compatible compiler
  • CMake (minimum 3.10)
  • OpenGL (3.3+)
  • GLEW (OpenGL Extension Wrangler Library)
  • GLFW3 (Graphics Library Framework)
It's recommended to use vcpkg or similar package managers:
  1. Clone the repository:
  1. Create and navigate to build directory:
  1. Generate build files with CMake:
  1. Build the project:
The project includes several examples, each demonstrating different shader techniques: A simple example showing a colored triangle rendered with basic vertex and fragment shaders. To run this example: This example demonstrates:
  • 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
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
  • Press ESC to close any example window
  • Window can be resized, and the viewport will adjust accordingly
To add a new example:
  1. Create a new .cpp file in the examples/ directory
  2. Add the example to CMakeLists.txt using the add_example() function
  3. If needed, add any shader files to the shaders/ directory

Recent projects

The Eden Project

The Eden Project

Avatar
What if music wasn't so inaccessible..
Run over a Deer

Run over a Deer

Avatar
A Silly little game based on the hit movie Over The Hedge
Just a Walkthrough

Just a Walkthrough

Avatar
Framework-agnostic onboarding walkthrough / product tour library with optional React provider & Tailwind/shadcn support.
Suvan GSgreeenboiGreenArcadeSuvan GSgreeenboiGreenArcadeSuvan GSgreeenboi
Suvan GSgreeenboiGreenArcadeSuvan GSgreeenboiGreenArcadeSuvan GSgreeenboi