Open CASCADE Technology  6.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Protected Attributes
OpenGl_VertexBuffer Class Reference

Vertex Buffer Object - is a general storage object for vertex attributes (position, normal, color). Notice that you should use OpenGl_IndexBuffer specialization for array of indices. More...

#include <OpenGl_VertexBuffer.hxx>

Inheritance diagram for OpenGl_VertexBuffer:
Inheritance graph
[legend]

Public Member Functions

 OpenGl_VertexBuffer ()
 Create uninitialized VBO. More...
 
virtual ~OpenGl_VertexBuffer ()
 Destroy object. More...
 
virtual GLenum GetTarget () const
 
bool IsValid () const
 
GLuint GetComponentsNb () const
 
GLsizei GetElemsNb () const
 
GLenum GetDataType () const
 
bool Create (const Handle< OpenGl_Context > &theGlCtx)
 Creates VBO name (id) if not yet generated. Data should be initialized by another method. More...
 
virtual void Release (const OpenGl_Context *theGlCtx)
 Destroy object - will release GPU memory if any. More...
 
void Bind (const Handle< OpenGl_Context > &theGlCtx) const
 Bind this VBO. More...
 
void Unbind (const Handle< OpenGl_Context > &theGlCtx) const
 Unbind this VBO. More...
 
bool Init (const Handle< OpenGl_Context > &theGlCtx, const GLuint theComponentsNb, const GLsizei theElemsNb, const GLfloat *theData)
 Notice that VBO will be unbound after this call. More...
 
bool Init (const Handle< OpenGl_Context > &theGlCtx, const GLuint theComponentsNb, const GLsizei theElemsNb, const GLuint *theData)
 Notice that VBO will be unbound after this call. More...
 
bool Init (const Handle< OpenGl_Context > &theGlCtx, const GLuint theComponentsNb, const GLsizei theElemsNb, const GLubyte *theData)
 Notice that VBO will be unbound after this call. More...
 
bool SubData (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theElemFrom, const GLsizei theElemsNb, const GLfloat *theData)
 Notice that VBO will be unbound after this call. Function replaces portion of data within this VBO using glBufferSubData(). The VBO should be initialized before call. More...
 
bool SubData (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theElemFrom, const GLsizei theElemsNb, const GLuint *theData)
 Notice that VBO will be unbound after this call. Function replaces portion of data within this VBO using glBufferSubData(). The VBO should be initialized before call. More...
 
bool SubData (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theElemFrom, const GLsizei theElemsNb, const GLubyte *theData)
 Notice that VBO will be unbound after this call. Function replaces portion of data within this VBO using glBufferSubData(). The VBO should be initialized before call. More...
 
void BindVertexAttrib (const Handle< OpenGl_Context > &theGlCtx, const GLuint theAttribLoc) const
 Bind this VBO to active GLSL program. More...
 
void UnbindVertexAttrib (const Handle< OpenGl_Context > &theGlCtx, const GLuint theAttribLoc) const
 Unbind any VBO from active GLSL program. More...
 
void BindFixed (const Handle< OpenGl_Context > &theGlCtx, const GLenum theMode) const
 Bind this VBO as fixed pipeline attribute. More...
 
void UnbindFixed (const Handle< OpenGl_Context > &theGlCtx, const GLenum theMode) const
 Unbind this VBO as fixed pipeline attribute. More...
 
- Public Member Functions inherited from OpenGl_Resource
 OpenGl_Resource ()
 Empty constructor. More...
 
virtual ~OpenGl_Resource ()
 Destructor. Inheritors should call Clean (NULL) within it. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual void ShallowDump (Standard_OStream &) const
 
virtual const
Handle_Standard_Type & 
DynamicType () const
 Returns a type information object about this object. More...
 
Standard_Boolean IsInstance (const Handle_Standard_Type &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const Handle_Standard_Type &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
virtual Handle_Standard_Transient This () const
 Returns a Handle which references this object. Must never be called to objects created in stack. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 

Static Public Attributes

static const GLuint NO_BUFFER = 0
 Helpful constants. More...
 

Protected Attributes

GLuint myBufferId
 VBO name (index) More...
 
GLuint myComponentsNb
 Number of components per generic vertex attribute, must be 1, 2, 3, or 4. More...
 
GLsizei myElemsNb
 Number of vertex attributes / number of vertices. More...
 
GLenum myDataType
 Data type (GL_FLOAT, GL_UNSIGNED_INT, GL_UNSIGNED_BYTE etc.) More...
 

Detailed Description

Vertex Buffer Object - is a general storage object for vertex attributes (position, normal, color). Notice that you should use OpenGl_IndexBuffer specialization for array of indices.

Constructor & Destructor Documentation

OpenGl_VertexBuffer::OpenGl_VertexBuffer ( )

Create uninitialized VBO.

virtual OpenGl_VertexBuffer::~OpenGl_VertexBuffer ( )
virtual

Destroy object.

Member Function Documentation

void OpenGl_VertexBuffer::Bind ( const Handle< OpenGl_Context > &  theGlCtx) const

Bind this VBO.

void OpenGl_VertexBuffer::BindFixed ( const Handle< OpenGl_Context > &  theGlCtx,
const GLenum  theMode 
) const

Bind this VBO as fixed pipeline attribute.

Parameters
theGlCtx- handle to bound GL context;
theMode- array mode (GL_VERTEX_ARRAY, GL_NORMAL_ARRAY, GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY).
void OpenGl_VertexBuffer::BindVertexAttrib ( const Handle< OpenGl_Context > &  theGlCtx,
const GLuint  theAttribLoc 
) const

Bind this VBO to active GLSL program.

bool OpenGl_VertexBuffer::Create ( const Handle< OpenGl_Context > &  theGlCtx)

Creates VBO name (id) if not yet generated. Data should be initialized by another method.

GLuint OpenGl_VertexBuffer::GetComponentsNb ( ) const
inline
Returns
the number of components per generic vertex attribute.
GLenum OpenGl_VertexBuffer::GetDataType ( ) const
inline
Returns
data type of each component in the array.
GLsizei OpenGl_VertexBuffer::GetElemsNb ( ) const
inline
Returns
number of vertex attributes / number of vertices.
virtual GLenum OpenGl_VertexBuffer::GetTarget ( ) const
virtual
bool OpenGl_VertexBuffer::Init ( const Handle< OpenGl_Context > &  theGlCtx,
const GLuint  theComponentsNb,
const GLsizei  theElemsNb,
const GLfloat *  theData 
)

Notice that VBO will be unbound after this call.

Parameters
theComponentsNb- specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
theElemsNb- elements count;
theData- pointer to GLfloat data (vertices/normals etc.).
bool OpenGl_VertexBuffer::Init ( const Handle< OpenGl_Context > &  theGlCtx,
const GLuint  theComponentsNb,
const GLsizei  theElemsNb,
const GLuint *  theData 
)

Notice that VBO will be unbound after this call.

Parameters
theComponentsNb- specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
theElemsNb- elements count;
theData- pointer to GLuint data (indices etc.).
bool OpenGl_VertexBuffer::Init ( const Handle< OpenGl_Context > &  theGlCtx,
const GLuint  theComponentsNb,
const GLsizei  theElemsNb,
const GLubyte *  theData 
)

Notice that VBO will be unbound after this call.

Parameters
theComponentsNb- specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
theElemsNb- elements count;
theData- pointer to GLubyte data (indices/colors etc.).
bool OpenGl_VertexBuffer::IsValid ( ) const
inline
Returns
true if current object was initialized
virtual void OpenGl_VertexBuffer::Release ( const OpenGl_Context theGlCtx)
virtual

Destroy object - will release GPU memory if any.

Implements OpenGl_Resource.

Reimplemented in OpenGl_TextureBufferArb.

bool OpenGl_VertexBuffer::SubData ( const Handle< OpenGl_Context > &  theGlCtx,
const GLsizei  theElemFrom,
const GLsizei  theElemsNb,
const GLfloat *  theData 
)

Notice that VBO will be unbound after this call. Function replaces portion of data within this VBO using glBufferSubData(). The VBO should be initialized before call.

Parameters
theElemFrom- element id from which replace buffer data (>=0);
theElemsNb- elements count (theElemFrom + theElemsNb <= GetElemsNb());
theData- pointer to GLfloat data.
bool OpenGl_VertexBuffer::SubData ( const Handle< OpenGl_Context > &  theGlCtx,
const GLsizei  theElemFrom,
const GLsizei  theElemsNb,
const GLuint *  theData 
)

Notice that VBO will be unbound after this call. Function replaces portion of data within this VBO using glBufferSubData(). The VBO should be initialized before call.

Parameters
theElemFromelement id from which replace buffer data (>=0);
theElemsNbelements count (theElemFrom + theElemsNb <= GetElemsNb());
theDatapointer to GLuint data.
bool OpenGl_VertexBuffer::SubData ( const Handle< OpenGl_Context > &  theGlCtx,
const GLsizei  theElemFrom,
const GLsizei  theElemsNb,
const GLubyte *  theData 
)

Notice that VBO will be unbound after this call. Function replaces portion of data within this VBO using glBufferSubData(). The VBO should be initialized before call.

Parameters
theElemFromelement id from which replace buffer data (>=0);
theElemsNbelements count (theElemFrom + theElemsNb <= GetElemsNb());
theDatapointer to GLubyte data.
void OpenGl_VertexBuffer::Unbind ( const Handle< OpenGl_Context > &  theGlCtx) const

Unbind this VBO.

void OpenGl_VertexBuffer::UnbindFixed ( const Handle< OpenGl_Context > &  theGlCtx,
const GLenum  theMode 
) const

Unbind this VBO as fixed pipeline attribute.

Parameters
theGlCtx- handle to bound GL context;
theMode- array mode.
void OpenGl_VertexBuffer::UnbindVertexAttrib ( const Handle< OpenGl_Context > &  theGlCtx,
const GLuint  theAttribLoc 
) const

Unbind any VBO from active GLSL program.

Field Documentation

GLuint OpenGl_VertexBuffer::myBufferId
protected

VBO name (index)

GLuint OpenGl_VertexBuffer::myComponentsNb
protected

Number of components per generic vertex attribute, must be 1, 2, 3, or 4.

GLenum OpenGl_VertexBuffer::myDataType
protected

Data type (GL_FLOAT, GL_UNSIGNED_INT, GL_UNSIGNED_BYTE etc.)

GLsizei OpenGl_VertexBuffer::myElemsNb
protected

Number of vertex attributes / number of vertices.

const GLuint OpenGl_VertexBuffer::NO_BUFFER = 0
static

Helpful constants.


The documentation for this class was generated from the following file: