A simple C++14 library for managing OpenGL rendering using GLFW, GLAD, and stb_image.
Provides an easy-to-use Renderer class for window/context creation, shader management, buffer and texture handling, and drawing operations.
- Window and OpenGL context creation
- Shader compilation and management
- Vertex buffer and VAO management
- Texture loading and binding
- Drawing primitives and indexed geometry
- State management (depth test, blend mode)
- Error checking
- GLFW
- GLAD
- stb_image.h
- C++14 compatible compiler (tested with MSVC/Visual Studio 2022)
-
Add Source Files
- Copy
Renderer.handRenderer.cppinto your project. - In Visual Studio:
Project > Add Existing Item and select both files.
- Copy
-
Install Dependencies
- Use vcpkg or NuGet to install GLFW and GLAD:
vcpkg install glfw3 glad
- Download
stb_image.hand add it to your project directory.
- Use vcpkg or NuGet to install GLFW and GLAD:
-
Configure Project Properties
- Project > Properties:
- Add include directories for GLFW, GLAD, and stb_image.
- Add library directories for GLFW and GLAD.
- Link against
glfw3.libandopengl32.lib.
- Project > Properties:
-
Example Usage
#include "Renderer.h" int main() { ogl_lib::Renderer renderer; renderer.create_window(800, 600, "OpenGL Window"); renderer.initialize_opengl(); // Main loop while (true) { renderer.clear_screen(0.1f, 0.2f, 0.3f, 1.0f); // ... rendering code ... renderer.swap_buffers(); // Add window close logic as needed } renderer.shutdown_opengl(); return 0; } -
Shader and Resource Files
- Place your shader files and textures in accessible locations.
- Reference their paths when calling
load_shaderandload_texture.
See LICENSE for details.