An open API service indexing awesome lists of open source software.

https://github.com/acdemiralp/gl

Header-only C++17 wrapper for OpenGL 4.6 Core Profile.
https://github.com/acdemiralp/gl

cpp11 opengl wrapper

Last synced: 17 days ago
JSON representation

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

Awesome Lists containing this project

README

        

#### 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:

```cpp
#include

void buffer_example()
{
gl::buffer buffer;

std::vector vertices(32);
buffer.set_data(sizeof(float) * vertices.size(), vertices.data());
}
```

Creating and uploading data to textures:

```cpp
#include

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 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:
```cpp
#include

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 `.