Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes
omni::visual::VBO Struct Reference

A small Vertex Buffer Object class. More...

#include <VBO.h>

Public Member Functions

 VBO ()
 
 ~VBO ()
 Destructor. Frees VBO if necessary. More...
 
void gen ()
 Generate a new VBO and get the associated ID. More...
 
void freeAndGen ()
 Free the existing buffer generates a new one. More...
 
template<typename BUF >
void bufferStaticArray (BUF const &_buf)
 Copy static vertex array onto GPU. More...
 
template<typename BUF >
void bufferStaticElementArray (BUF const &_buf)
 Copy static index array onto GPU. More...
 
void free ()
 Free VBO via glDeleteBuffers. More...
 
GLuint id () const
 Return buffer id. More...
 

Private Attributes

GLuint id_ = 0
 

Detailed Description

A small Vertex Buffer Object class.

Constructor & Destructor Documentation

omni::visual::VBO::VBO ( )
29  {
30  gen();
31  }
void gen()
Generate a new VBO and get the associated ID.
Definition: VBO.cpp:38
omni::visual::VBO::~VBO ( )

Destructor. Frees VBO if necessary.

34  {
35  free();
36  }
void free()
Free VBO via glDeleteBuffers.
Definition: VBO.cpp:56

Member Function Documentation

template<typename BUF >
void omni::visual::VBO::bufferStaticArray ( BUF const &  _buf)
inline

Copy static vertex array onto GPU.

44  {
45  withCurrentContext([&](QOpenGLFunctions& _) {
46  _.glBindBuffer(GL_ARRAY_BUFFER, id());
47  {
48  _.glBufferData(GL_ARRAY_BUFFER,
49  _buf.size() * sizeof(typename BUF::value_type),
50  _buf.data(),
51  GL_STATIC_DRAW);
52  }
53  _.glBindBuffer(GL_ARRAY_BUFFER, 0);
54  });
55  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
template<typename BUF >
void omni::visual::VBO::bufferStaticElementArray ( BUF const &  _buf)
inline

Copy static index array onto GPU.

59  {
60  withCurrentContext([&](QOpenGLFunctions& _) {
61  _.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id());
62  {
63  _.glBufferData(GL_ELEMENT_ARRAY_BUFFER,
64  _buf.size() * sizeof(typename BUF::value_type),
65  _buf.data(),
66  GL_STATIC_DRAW);
67  }
68  _.glBindBuffer(GL_ARRAY_BUFFER, 0);
69  });
70  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
void omni::visual::VBO::free ( )

Free VBO via glDeleteBuffers.

57  {
58  withCurrentContext([this](QOpenGLFunctions& _)
59  {
60  if (id_)
61  _.glDeleteBuffers(1,&id_);
62  });
63  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
GLuint id_
Definition: VBO.h:79
void omni::visual::VBO::freeAndGen ( )

Free the existing buffer generates a new one.

48  {
49  withCurrentContext([this](QOpenGLFunctions& _)
50  {
51  if (id_) free();
52  _.glGenBuffers(1,&id_);
53  });
54  }
void free()
Free VBO via glDeleteBuffers.
Definition: VBO.cpp:56
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
GLuint id_
Definition: VBO.h:79
void omni::visual::VBO::gen ( )

Generate a new VBO and get the associated ID.

39  {
40  withCurrentContext([this](QOpenGLFunctions& _)
41  {
42  if (!id_)
43  _.glGenBuffers(1, &id_);
44  });
45  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
GLuint id_
Definition: VBO.h:79
GLuint omni::visual::VBO::id ( ) const

Return buffer id.

66  {
67  return id_;
68  }
GLuint id_
Definition: VBO.h:79

Field Documentation

GLuint omni::visual::VBO::id_ = 0
private

The documentation for this struct was generated from the following files: