Skip to content

Repository files navigation

OpenGL_Lib

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.

Features

  • 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

Requirements

Setup (Visual Studio)

  1. Add Source Files

    • Copy Renderer.h and Renderer.cpp into your project.
    • In Visual Studio:
      Project > Add Existing Item and select both files.
  2. Install Dependencies

    • Use vcpkg or NuGet to install GLFW and GLAD:
      vcpkg install glfw3 glad
    • Download stb_image.h and add it to your project directory.
  3. Configure Project Properties

    • Project > Properties:
      • Add include directories for GLFW, GLAD, and stb_image.
      • Add library directories for GLFW and GLAD.
      • Link against glfw3.lib and opengl32.lib.
  4. 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;
     }
    
    
  5. Shader and Resource Files

  • Place your shader files and textures in accessible locations.
  • Reference their paths when calling load_shader and load_texture.

License

See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages