A cross-platform OpenGL application demonstrating modern OpenGL rendering techniques with interactive 3D graphics and GUI controls.
opengl.mp4
OpenGLThingy is an educational OpenGL application that renders animated 3D cubes with the following features:
- 3D Cube Rendering: Displays textured 3D cubes with proper depth testing and perspective projection
- Interactive GUI: Uses ImGui for real-time parameter adjustment including:
- Object positioning controls
- Color animation speed adjustment
- Shader parameter tweaking
- Animated Graphics: Dynamic color cycling and transformations
- Modern OpenGL: Uses OpenGL 3.3+ with vertex buffer objects, shaders, and modern rendering pipeline
- Cross-Platform: Runs on both Windows and Linux systems
The application serves as a practical example of:
- OpenGL context creation and management
- Vertex/Index buffer usage
- Shader compilation and uniform management
- Texture loading and binding
- 3D mathematics with GLM
- ImGui integration for debugging interfaces
The project includes pre-built libraries in the Dependencies/
folder:
- GLFW 3.x - Window management and input handling
- GLEW - OpenGL extension loading
- OpenGL 3.3+ - Graphics API (provided by graphics drivers)
- Visual Studio 2019/2022 - C++ compiler (or compatible toolchain)
Install development packages via your distribution's package manager:
sudo apt-get update
sudo apt-get install libglfw3-dev libglew-dev libgl1-mesa-dev build-essential cmake
sudo dnf install glfw-devel glew-devel mesa-libGL-devel gcc-c++ cmake
sudo pacman -S glfw-x11 glew mesa cmake gcc
For 32-bit builds, enable multiarch and install 32-bit packages:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libglfw3-dev:i386 libglew-dev:i386 libgl1-mesa-dev:i386
build.bat
chmod +x build.sh
./build.sh
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build .
mkdir build-win64
cd build-win64
cmake .. -A x64
cmake --build . --config Debug
mkdir build-linux32
cd build-linux32
cmake .. -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_C_FLAGS="-m32"
cmake --build .
After building, the executable will be in the build/
directory:
- Windows:
build/Debug/OpenGLThingy.exe
- Linux:
build/OpenGLThingy
The application automatically copies required resources (shaders, textures) to the build directory.
- CMake Build System: Provides consistent builds across different platforms and toolchains
- Platform Abstractions: Code uses conditional compilation for platform-specific features (memory allocation, debug breaks)
- Dependency Management: Windows uses bundled libraries while Linux uses system packages for better integration
- Vertex Array Objects: Efficiently manage vertex attribute state
- Buffer Objects: Store vertex and index data on GPU for performance
- Shader Programs: Use GLSL for programmable rendering pipeline
- Uniform Buffers: Pass transformation matrices and parameters to shaders
The project demonstrates:
- 3D Graphics Fundamentals: Model-view-projection transformations, texture mapping, depth testing
- Real-Time Rendering: Game loop with update/render cycle
- GUI Integration: Immediate mode GUI for parameter adjustment and debugging
- Resource Management: Proper OpenGL object lifecycle management
- Abstraction Layers: Wrapper classes for OpenGL objects (Shader, Texture, VertexArray, etc.)
- RAII Pattern: Automatic resource cleanup using destructors
- Modular Design: Separate classes for different rendering concerns
- Test Framework: Extensible testing system for different rendering scenarios
OpenGLThingy/
├── CMakeLists.txt # Cross-platform build configuration
├── build.sh/build.bat # Platform-specific build scripts
├── src/ # Source code
│ ├── main.cpp # Application entry point
│ ├── Application.cpp/h # Main application class and GLFW management
│ ├── Renderer.cpp/h # OpenGL rendering abstraction
│ ├── Shader.cpp/h # GLSL shader compilation and management
│ ├── Texture.cpp/h # Texture loading and binding
│ ├── Cube.cpp/h # Cube geometry and rendering
│ ├── VertexArray.cpp/h # Vertex array object wrapper
│ ├── VertexBuffer.cpp/h # Vertex buffer object wrapper
│ ├── IndexBuffer.cpp/h # Index buffer object wrapper
│ ├── tests/ # Test framework for rendering scenarios
│ └── vendor/ # Third-party libraries
│ ├── imgui/ # Dear ImGui for GUI
│ ├── glm/ # OpenGL Mathematics library
│ └── stb_image/ # Image loading library
├── res/ # Resources (shaders, textures)
│ ├── shaders/ # GLSL shader files
│ └── textures/ # Texture image files
└── Dependencies/ # Windows pre-built libraries
├── GLFW/ # GLFW library
└── GLEW/ # GLEW library
- Open the project folder in Visual Studio 2019/2022
- Visual Studio automatically detects CMakeLists.txt
- Build using CMake configuration
- CLion: Full CMake support with debugging
- Qt Creator: CMake project support
- VS Code: With CMake Tools extension
- Command Line: Use provided build scripts or manual CMake commands
# Verify required packages are installed
dpkg -l | grep -E "(libglfw|libglew|libgl1-mesa)"
# Install missing development tools
sudo apt-get install build-essential cmake
# Check library linking
ldd build/OpenGLThingy
- Ensure Visual Studio 2019+ with C++ tools is installed
- Verify CMake is in PATH:
cmake --version
- The Dependencies folder contains x64 libraries only
- For 32-bit builds, obtain 32-bit versions of GLFW and GLEW
- "Failed to initialize GLFW": Update graphics drivers
- Shader compilation errors: Check
res/shaders/
directory exists - Texture loading failures: Verify
res/textures/
contains required files - Black screen: Ensure OpenGL 3.3+ support in graphics drivers
- Windows 32-bit: Only 64-bit libraries are included in Dependencies folder
- Need to obtain and add 32-bit versions of GLFW and GLEW for full 32-bit Windows support
- macOS: Not currently supported
- Would require additional CMake configuration and dependency management
- ARM64: No specific support for ARM-based systems (Apple Silicon, ARM Linux)
- Fixed Pipeline Elements: Some legacy OpenGL patterns could be modernized
- Limited Texture Formats: Currently only supports basic image formats via stb_image
- No HDR Support: Limited to standard dynamic range rendering
- Fixed Cube Geometry: Hardcoded cube vertices, could benefit from mesh loading system
- Error Handling: Limited error recovery in some OpenGL operations
- Resource Management: Some OpenGL resources could benefit from more robust RAII wrappers
- Memory Allocation: Mixed use of
_malloca()
vsmalloc()
could be standardized - Configuration: Hardcoded constants that could be moved to config files
- Dependency Bundling: Large Dependencies folder increases repository size
- Package Management: Could benefit from modern C++ package managers (vcpkg, Conan)
- Build Caching: No ccache or similar build acceleration
- Static Analysis: No integrated linting or static analysis tools
-
Add Windows 32-bit library support
- Download and organize 32-bit GLFW/GLEW libraries
- Update CMake configuration for proper library selection
-
Improve error handling
- Add more comprehensive OpenGL error checking
- Better graceful failure modes for missing resources
-
Enhanced GUI
- Add more ImGui controls for shader parameters
- Performance metrics display (FPS, frame time)
- Scene graph visualization
-
Resource management
- Implement proper asset loading system
- Add resource hot-reloading for development
-
Cross-platform packaging
- Windows installer/portable builds
- Linux AppImage or Flatpak packages
- macOS app bundle support
-
Graphics improvements
- Normal mapping and advanced lighting
- Shadow mapping implementation
- Post-processing effects pipeline
-
Code modernization
- Migrate to C++20 features where beneficial
- Improve const-correctness throughout codebase
- Add comprehensive unit testing
-
Build system enhancements
- Integration with vcpkg or Conan for dependency management
- Automated CI/CD pipeline for multiple platforms
- Code coverage reporting
-
Advanced rendering features
- Physically-based rendering (PBR)
- Deferred rendering pipeline
- Compute shader integration
-
Platform expansion
- WebGL/WebAssembly port for browser deployment
- Mobile platform support (Android/iOS)
- Console platform investigation
-
Educational features
- Interactive shader editor
- Step-by-step rendering pipeline visualization
- Performance profiling tools
- CPU-GPU synchronization: Some blocking OpenGL calls could be optimized
- Memory allocations: Frequent small allocations in render loop
- Shader compilation: Done at runtime, could be pre-compiled for production
- Batched rendering: Group similar objects to reduce draw calls
- Instanced rendering: For multiple similar objects
- GPU profiling: Add timing queries for bottleneck identification
- Multi-threading: Separate render and update threads
Do whatever you want with it, it's not like i own anything in this :)