Open CASCADE Technology
7.2.0
|
Compatibility layer for old OpenGL without VBO. Make sure to pass pointer from GetDataOffset() instead of NULL. Method GetDataOffset() returns pointer to real data in this class (while base class OpenGl_VertexBuffer always return NULL). More...
#include <OpenGl_VertexBufferCompat.hxx>
Public Member Functions | |
OpenGl_VertexBufferCompat () | |
Create uninitialized VBO. More... | |
virtual | ~OpenGl_VertexBufferCompat () |
Destroy object. More... | |
bool | Create (const Handle< OpenGl_Context > &theGlCtx) override |
Creates VBO name (id) if not yet generated. Data should be initialized by another method. More... | |
virtual void | Release (OpenGl_Context *theGlCtx) override |
Destroy object - will release memory if any. More... | |
virtual void | Bind (const Handle< OpenGl_Context > &theGlCtx) const override |
Bind this VBO. More... | |
virtual void | Unbind (const Handle< OpenGl_Context > &theGlCtx) const override |
Unbind this VBO. More... | |
Public Member Functions inherited from OpenGl_VertexBuffer | |
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 |
GLubyte * | GetDataOffset () const |
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 GLushort *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 GLushort *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 | BindAttribute (const Handle< OpenGl_Context > &theCtx, const Graphic3d_TypeOfAttribute theMode) const |
Bind this VBO and enable specified attribute in OpenGl_Context::ActiveProgram() or FFP. More... | |
void | UnbindAttribute (const Handle< OpenGl_Context > &theCtx, const Graphic3d_TypeOfAttribute theMode) const |
Unbind this VBO and disable specified attribute in OpenGl_Context::ActiveProgram() or FFP. More... | |
bool | init (const Handle< OpenGl_Context > &theGlCtx, const GLuint theComponentsNb, const GLsizei theElemsNb, const void *theData, const GLenum theDataType) |
Initialize buffer with new data. More... | |
virtual bool | HasColorAttribute () const |
virtual bool | HasNormalAttribute () const |
virtual void | BindAllAttributes (const Handle< OpenGl_Context > &theGlCtx) const |
Bind all vertex attributes to active program OpenGl_Context::ActiveProgram() or for FFP. Default implementation does nothing. More... | |
virtual void | BindPositionAttribute (const Handle< OpenGl_Context > &theGlCtx) const |
Bind vertex position attribute only. Default implementation does nothing. More... | |
virtual void | UnbindAllAttributes (const Handle< OpenGl_Context > &theGlCtx) const |
Unbind all vertex attributes. Default implementation does nothing. 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_Transient & | operator= (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 const opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. More... | |
Standard_Boolean | IsInstance (const opencascade::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 opencascade::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... | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
void | IncrementRefCounter () const |
Increments the reference counter of this object. More... | |
Standard_Integer | DecrementRefCounter () const |
Decrements the reference counter of this object; returns the decremented value. More... | |
advanced methods | |
Handle< NCollection_Buffer > | myData |
buffer data More... | |
bool | initLink (const Handle< NCollection_Buffer > &theData, const GLuint theComponentsNb, const GLsizei theElemsNb, const GLenum theDataType) |
Initialize buffer with existing data. Data will NOT be copied by this method! More... | |
virtual bool | init (const Handle< OpenGl_Context > &theGlCtx, const GLuint theComponentsNb, const GLsizei theElemsNb, const void *theData, const GLenum theDataType, const GLsizei theStride) override |
Initialize buffer with new data (data will be copied). More... | |
virtual bool | subData (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theElemFrom, const GLsizei theElemsNb, const void *theData, const GLenum theDataType) override |
Update part of the buffer with new data. More... | |
Additional Inherited Members | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. More... | |
Static Public Member Functions inherited from OpenGl_VertexBuffer | |
static size_t | sizeOfGlType (const GLenum theType) |
static void | bindAttribute (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_TypeOfAttribute theMode, const GLint theNbComp, const GLenum theDataType, const GLsizei theStride, const GLvoid *theOffset) |
Setup array pointer - either for active GLSL program OpenGl_Context::ActiveProgram() or for FFP using bindFixed() when no program bound. More... | |
static void | unbindAttribute (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_TypeOfAttribute theMode) |
Disable GLSL array pointer - either for active GLSL program OpenGl_Context::ActiveProgram() or for FFP using unbindFixed() when no program bound. More... | |
Static Public Member Functions inherited from Standard_Transient | |
static const char * | get_type_name () |
Returns a type descriptor about this object. More... | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. More... | |
Static Public Attributes inherited from OpenGl_VertexBuffer | |
static const GLuint | NO_BUFFER = 0 |
Helpful constants. More... | |
Protected Attributes inherited from OpenGl_VertexBuffer | |
GLubyte * | myOffset |
offset to data More... | |
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... | |
Compatibility layer for old OpenGL without VBO. Make sure to pass pointer from GetDataOffset() instead of NULL. Method GetDataOffset() returns pointer to real data in this class (while base class OpenGl_VertexBuffer always return NULL).
Methods Bind()/Unbind() do nothing (do not affect OpenGL state) and ::GetTarget() is never used. For this reason there is no analog for OpenGl_IndexBuffer. Just pass GetDataOffset() to glDrawElements() directly as last argument.
Class overrides methods init() and subData() to copy data into own memory buffer. Extra method initLink() might be used to pass existing buffer through handle without copying the data.
Method Create() creates dummy identifier for this object which should NOT be passed to OpenGL functions.
OpenGl_VertexBufferCompat::OpenGl_VertexBufferCompat | ( | ) |
Create uninitialized VBO.
|
virtual |
Destroy object.
|
overridevirtual |
Bind this VBO.
Reimplemented from OpenGl_VertexBuffer.
|
overridevirtual |
Creates VBO name (id) if not yet generated. Data should be initialized by another method.
Reimplemented from OpenGl_VertexBuffer.
|
overridevirtual |
Initialize buffer with new data (data will be copied).
Reimplemented from OpenGl_VertexBuffer.
bool OpenGl_VertexBufferCompat::initLink | ( | const Handle< NCollection_Buffer > & | theData, |
const GLuint | theComponentsNb, | ||
const GLsizei | theElemsNb, | ||
const GLenum | theDataType | ||
) |
Initialize buffer with existing data. Data will NOT be copied by this method!
|
overridevirtual |
Destroy object - will release memory if any.
Reimplemented from OpenGl_VertexBuffer.
|
overridevirtual |
Update part of the buffer with new data.
Reimplemented from OpenGl_VertexBuffer.
|
overridevirtual |
Unbind this VBO.
Reimplemented from OpenGl_VertexBuffer.
|
protected |
buffer data