Giter VIP home page Giter VIP logo

libglw's Introduction

libglw - OpenGL C++11 wrapper

libglw is a C++11 wrapper for OpenGL and OpenGL Shader Language. It provides classes for most OpenGL objects and some function wrapped in a C++11 style.

Features

OpenGL Buffers

libglw provides classes for VBO (gl::ArrayBuffer<Struct>) and EBO (gl::ElementBuffer<Integer>). Those two classes work like vectors : you reserve space (internally allocate more space than size in capacity), you map then unmap it.

struct Vertex
{
    glm::vec2 pos;
    glm::vec4 color;
};
gl::ArrayBuffer<Vertex> buffer;
buffer.reserve(6); // 6 vertices
buffer.reserve_relative(3); // add 3 vertices, these now 9 vertices
Vertex* v = buffer.map();
// change v map
buffer.unmap();
buffer.draw(GL_TRIANGLES);

You can easily attach a VAO (gl::VertexArray) and add attributs (gl::ArrayBuffer<Struct>::Attrib<index>) to the ArrayBuffer.

GLSL Shaders

GLSL Shader loading are splitted in two classes gl::sl::Shader<ShaderType> and gl::sl::Program. Shader uses to load and compile the shader, Program links attached shaders and become the shaders owner to use.

Any errors from compile and link throw exceptions you can catch. TRY_GLSL and CATCH_GLSL are provided to capture gl::sl exceptions and displays errors to error console (std::cerr).

You can use stream operator to aply a shader :

gl::sl::Program prog;
TRY_GLSL
prog << gl::sl::Shader<gl::sl::Vertex>(vert, false) << gl::sl::Shader<gl::sl::Fragment>(frag, false) << gl::sl::link;
CATCH_GLSL
prog.use();

Uniforms GLM compatible

Uniforms are packed into two classes to transmit to gl::sl::Program. You can set referenced value (gl::UniformRef<ValueType>) or static and r-value (gl::UniformStatic<ValueType>).

program << gl::sl::use
        << gl::UniformRef<glm::mat4>("modelmat", modelmat);
        << gl::UniformStatic<float>("opacity", 0.5f);

Textures, Renderbuffers and Framebuffers

Texture, Renderbuffer and Framebuffer provide several functionalities following OpenGL ones. You can set format, sampler and size of a texture for example, and attach Texture and Renderbuffer to Framebuffer. Check out GLClass.h for more informations.

Dependencies

libglw needs some libraries to work.

glwapp - Demo

A demo is available to test the library. Using SDL2 for Window and events handling, it displays a turning RGB colored triangle.

Release notes

Version 0.0.1

It all starts one day...

  • Add buffers, shader loading, texture, framebuffers and renderbuffers
  • Add functional: Clear and Enable.
  • Add demo
  • Cmake support

TODO

  • Linux portage (very soon)
  • Doxygen documentation
  • OpenGL versions compatibilities

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.