The Vish Visualization Shell 0.3
Vish
Public Types | Public Member Functions | Public Attributes | List of all members
Wizt::BufferID Class Reference

Base class for OpenGL buffer id's. More...

#include <ocean/GLvish/BufferID.hpp>

Inheritance diagram for Wizt::BufferID:
Wizt::BufferArray Wizt::GLMapMemory Wizt::IndexBufferObject Wizt::TextureBuffer Wizt::TypedBufferArrayBase< Type > Wizt::TypedTextureBuffer< Type > Wizt::GLUniformBuffer Wizt::IndexBuffer< Type > Wizt::TypedTextureBuffer< Type > Wizt::TypedBufferArray< Type > Wizt::TypedTextureBuffer< Type > Wizt::IndexBuffer< Type > Wizt::TypedVertexBufferArray< Type > Wizt::ColorArray< Type > Wizt::SecondaryColorArray< Type > Wizt::TexCoordArray< Type > Wizt::TypedNormalArray< Type > Wizt::TypedVertexArray< Type > Wizt::VertexAttribArray< Type > Wizt::TypedColorArray< Type > Wizt::TypedSecondaryColorArray< Type > Wizt::TypedTexCoordArray< Type > Wizt::TypedVertexAttribArray< Type >

Public Types

enum  type
 Possible types of buffer ID's. More...
 

Public Member Functions

bool bindBuffer () const
 const version of bind(), does not create a buffer ID.
 
bool bindBufferWithPossibleCreation ()
 Non-const version of bind().
 
 BufferID (const type bufferType) noexcept
 The constructor does not yet create openGL buffers yet.
 
GLuint createId () noexcept
 If no valid ID yet, call glCreateBuffers().
 
GLuint getId () const noexcept
 Get an Id without attempting to generate it.
 
bool isbound () const throw ()
 Verification function: buffer is bound?
 
bool isIndexBuffer () const
 Check whether this is an index buffer.
 
bool isVertexArray () const
 Check whether this is a vertex array.
 
GLuint makeId ()
 On first access, OpenGL buffers will be generated. This function must be called from within a valid OpenGL context.
 
GLuint operator() ()
 On first access, OpenGL buffers will be generated. This function must be called from within a valid OpenGL context.
 
 ~BufferID () noexcept
 Deletion of created OpenGL buffers. Note that this might be problematic here if called outside a valid OpenGL context.
 

Public Attributes

const type target
 The target type of this buffer ID.
 

Detailed Description

Base class for OpenGL buffer id's.

Member Enumeration Documentation

◆ type

Possible types of buffer ID's.

See also
http://www.opengl.org/wiki/Buffer_Object

Constructor & Destructor Documentation

◆ BufferID()

Wizt::BufferID::BufferID ( const type  bufferType)
inlinenoexcept

The constructor does not yet create openGL buffers yet.

It is just a placeholder for deferred construction. Buffers are created by the () access operator. As such, a BufferID object can be created outside of an OpenGL context, but the access operator must be called within a valid one.

◆ ~BufferID()

Wizt::BufferID::~BufferID ( )
noexcept

Deletion of created OpenGL buffers. Note that this might be problematic here if called outside a valid OpenGL context.

Todo:
Need to investigate when OpenGL buffers may be deleted. Might need an explicit cleanup function.

Member Function Documentation

◆ bindBuffer()

bool Wizt::BufferID::bindBuffer ( ) const

const version of bind(), does not create a buffer ID.

Calls glBindBuffer(), but does not create ID.

References Wizt::RequireGLContext().

Referenced by Wizt::TypedBufferArray< Type >::activate(), Wizt::TypedBufferArray< Type >::deactivate(), Wizt::IndexBuffer< Type >::draw(), Wizt::BufferArray::load_subset(), and Wizt::BufferArray::load_untyped().

◆ bindBufferWithPossibleCreation()

bool Wizt::BufferID::bindBufferWithPossibleCreation ( )

Non-const version of bind().

Calls glBindBuffer(), creating a buffer ID if required.

References bindBufferWithPossibleCreation(), and target.

Referenced by bindBufferWithPossibleCreation().

◆ createId()

GLuint Wizt::BufferID::createId ( )
noexcept

◆ getId()

GLuint Wizt::BufferID::getId ( ) const
noexcept

Get an Id without attempting to generate it.

This function is safe to be called from a non-OpenGL context.

Referenced by Wizt::GLMapMemory::setSubData().