OGLplus (0.52.0) a C++ wrapper for OpenGL

Bound objects

Bound objects make the usage of objects that can be bound to a OpenGL binding point or "target" easier. This includes objects like Buffer, Texture, Renderbuffer or Framebuffer which have a target to which individual instances can be bound and operated on through the binding point. Generally Bound<Object> classes re-implement those functions of Object which have a target parameter of the Object::Target type. These re-implemented functions have all the other parameters of the original member functions, but lack the target parameter and supply it to the original function call automatically.

For example to setup a texture object one might need to do the following:

// create the texture
Texture tex;
// the binding point we'll be using to setup the texture
Texture::Target tex_tgt = Texture::Target::_2D;
tex.Bind(tex_tgt);
{
Texture::Image2D(tex_tgt, ...);
Texture::GenerateMipmap(tex_tgt);
Texture::MinFilter(tex_tgt, TextureMinFilter::Linear);
Texture::MagFilter(tex_tgt, TextureMagFilter::Linear);
Texture::WrapS(tex_tgt, TextureWrap::Repeat);
Texture::WrapT(tex_tgt, TextureWrap::Repeat);
Texture::SwizzleG(tex_tgt, TextureSwizzle::Red);
Texture::SwizzleB(tex_tgt, TextureSwizzle::Red);
}

The Bound template class instantiated through the Bind function allows to do things more conveniently:

Context gl;
// create the texture
Texture tex;
// start a block where the texture will be set-up
{
// make a wrapper for the texture bound to TEXTURE_2D
gl.Bind(Texture::Target::_2D, tex)
.Image2D(...)
.GenerateMipmap()
.SwizzleB(TextureSwizzle::Red);
}

The source code for the specializations of the Bound template class is not included automatically by including oglplus/all.hpp. In order to be able to use Bound objects it is necessary to include the appropriate header:

#include <oglplus/bound/texture.hpp> // Bound<Texture>
#include <oglplus/bound/buffer.hpp> // Bound<Buffer>
#include <oglplus/bound/framebuffer.hpp> // Bound<Framebuffer>
#include <oglplus/bound/renderbuffer.hpp> // Bound<Renderbuffer>

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).