Skip to content
acdemiralpPublic

About

Header-only C++17 wrapper for OpenGL 4.6 Core Profile.

Topics

Resources

Stars

162 stars

Watchers

14 watching

Forks

Latest commit

 

History

106 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GL

Complete C++17 wrapper for OpenGL 4.6 Core Profile.


Dependencies

  • OpenGL
  • GLEW
  • CUDA (optional, for interoperation support)

Building

  • Follow the cmake build process for locating the dependencies.
  • Toggle CUDA_INTEROP_SUPPORT for CUDA interoperation support. Note that the build will ask for the location of Cuda upon enabling this option.

Getting Started

Creating and uploading data to buffers:

#include <gl/all.hpp>

void buffer_example()
{
  gl::buffer buffer;
  
  std::vector<float> vertices(32);
  buffer.set_data(sizeof(float) * vertices.size(), vertices.data());
}

Creating and uploading data to textures:

#include <gl/all.hpp>

void texture_example()
{
  gl::texture_1d texture_1d;
  texture_1d.set_min_filter(GL_LINEAR);
  texture_1d.set_mag_filter(GL_LINEAR);
  texture_1d.set_wrap_s    (GL_CLAMP );
  
  std::array<float, 32> scalars;
  texture_1d.set_storage   (0, GL_RGBA, sizeof(float) * scalars.size());
  texture_1d.set_sub_image (0, 0, scalars.size(), GL_RGBA, GL_FLOAT, scalars.data());
}

Creating shaders and attaching them to programs:

#include <gl/all.hpp>

void shader_program_example()
{
  gl::shader vert_shader(GL_VERTEX_SHADER);
  vert_shader.load_source("vert_example.glsl");

  gl::shader frag_shader(GL_FRAGMENT_SHADER);
  frag_shader.load_source("frag_example.glsl");

  gl::program program;
  program.attach_shader(vert_shader);
  program.attach_shader(frag_shader);
  program.link();
  program.use();
  program.set_uniform(program.uniform_location("example_uniform"), 42);
  program.unuse();
}

Extensions

For adding GLM support to type-inferring uniform variable setters of the shader program, simply #include <gl/auxiliary/glm_uniforms.hpp>.

About

Header-only C++17 wrapper for OpenGL 4.6 Core Profile.

Topics

Resources

Stars

162 stars

Watchers

14 watching

Forks

Releases

Packages

Contributors

Languages