From 46ce4c3df382101b43a074cfa1c26c0367d68ee3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 7 Feb 2005 17:28:03 +0000 Subject: [PATCH] Added the full set of buffer object methods --- include/osg/Drawable | 31 +++++++++++-- src/osg/Drawable.cpp | 107 ++++++++++++++++++++++++++++--------------- 2 files changed, 95 insertions(+), 43 deletions(-) diff --git a/include/osg/Drawable b/include/osg/Drawable index 2457edfe8..3c544d0e5 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -604,11 +604,19 @@ class SG_EXPORT Drawable : public Object void glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const; void glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const; + void glGenBuffers (GLsizei n, GLuint *buffers) const; void glBindBuffer (GLenum target, GLuint buffer) const; void glBufferData (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) const; void glBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data) const; void glDeleteBuffers (GLsizei n, const GLuint *buffers) const; + GLboolean glIsBuffer (GLuint buffer) const; + void glGetBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data) const; + GLvoid* glMapBuffer (GLenum target, GLenum access) const; + GLboolean glUnmapBuffer (GLenum target) const; + void glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params) const; + void glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params) const; + void glGenOcclusionQueries( GLsizei n, GLuint *ids ) const; void glDeleteOcclusionQueries( GLsizei n, const GLuint *ids ) const; @@ -641,11 +649,18 @@ class SG_EXPORT Drawable : public Object typedef void (APIENTRY * MultiTexCoord1fProc) (GLenum target,GLfloat coord); typedef void (APIENTRY * MultiTexCoordfvProc) (GLenum target,const GLfloat* coord); + typedef void (APIENTRY * GenBuffersProc) (GLsizei n, GLuint *buffers); typedef void (APIENTRY * BindBufferProc) (GLenum target, GLuint buffer); typedef void (APIENTRY * BufferDataProc) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); typedef void (APIENTRY * BufferSubDataProc) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); typedef void (APIENTRY * DeleteBuffersProc) (GLsizei n, const GLuint *buffers); + typedef GLboolean (APIENTRY * IsBufferProc) (GLuint buffer); + typedef void (APIENTRY * GetBufferSubDataProc) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); + typedef GLvoid* (APIENTRY * MapBufferProc) (GLenum target, GLenum access); + typedef GLboolean (APIENTRY * UnmapBufferProc) (GLenum target); + typedef void (APIENTRY * GetBufferParameterivProc) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRY * GetBufferPointervProc) (GLenum target, GLenum pname, GLvoid* *params); typedef void (APIENTRY * GenOcclusionQueriesProc) ( GLsizei n, GLuint *ids ); typedef void (APIENTRY * DeleteOcclusionQueriesProc) ( GLsizei n, const GLuint *ids ); @@ -691,11 +706,17 @@ class SG_EXPORT Drawable : public Object MultiTexCoordfvProc _glMultiTexCoord3fv; MultiTexCoordfvProc _glMultiTexCoord4fv; - GenBuffersProc _glGenBuffers; - BindBufferProc _glBindBuffer; - BufferDataProc _glBufferData; - BufferSubDataProc _glBufferSubData; - DeleteBuffersProc _glDeleteBuffers; + GenBuffersProc _glGenBuffers; + BindBufferProc _glBindBuffer; + BufferDataProc _glBufferData; + BufferSubDataProc _glBufferSubData; + DeleteBuffersProc _glDeleteBuffers; + IsBufferProc _glIsBuffer; + GetBufferSubDataProc _glGetBufferSubData; + MapBufferProc _glMapBuffer; + UnmapBufferProc _glUnmapBuffer; + GetBufferParameterivProc _glGetBufferParameteriv; + GetBufferPointervProc _glGetBufferPointerv; GenOcclusionQueriesProc _glGenOcclusionQueries; DeleteOcclusionQueriesProc _glDeleteOcclusionQueries; diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index 924faab09..68401f4be 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -690,6 +690,12 @@ void Drawable::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._glBufferData) _glBufferData = 0; if (!rhs._glBufferSubData) _glBufferSubData = 0; if (!rhs._glDeleteBuffers) _glDeleteBuffers = 0; + if (!rhs._glIsBuffer) _glIsBuffer = 0; + if (!rhs._glGetBufferSubData) _glGetBufferSubData = 0; + if (!rhs._glMapBuffer) _glMapBuffer = 0; + if (!rhs._glUnmapBuffer) _glUnmapBuffer = 0; + if (!rhs._glGetBufferParameteriv) _glGetBufferParameteriv = 0; + if (!rhs._glGetBufferPointerv) _glGetBufferPointerv = 0; if (!rhs._glGenOcclusionQueries) _glGenOcclusionQueries = 0; if (!rhs._glDeleteOcclusionQueries) _glDeleteOcclusionQueries = 0; @@ -739,6 +745,12 @@ void Drawable::Extensions::setupGLExtenions() _glBufferData = ((BufferDataProc)osg::getGLExtensionFuncPtr("glBufferData","glBufferDataARB")); _glBufferSubData = ((BufferSubDataProc)osg::getGLExtensionFuncPtr("glBufferSubData","glBufferSubDataARB")); _glDeleteBuffers = ((DeleteBuffersProc)osg::getGLExtensionFuncPtr("glDeleteBuffers","glDeleteBuffersARB")); + _glIsBuffer = ((IsBufferProc)osg::getGLExtensionFuncPtr("glIsBuffer","glIsBufferARB")); + _glGetBufferSubData = ((GetBufferSubDataProc)osg::getGLExtensionFuncPtr("glGetBufferSubData","glGetBufferSubDataARB")); + _glMapBuffer = ((MapBufferProc)osg::getGLExtensionFuncPtr("glMapBuffer","glMapBufferARB")); + _glUnmapBuffer = ((UnmapBufferProc)osg::getGLExtensionFuncPtr("glUnmapBuffer","glUnmapBufferARB")); + _glGetBufferParameteriv = ((GetBufferParameterivProc)osg::getGLExtensionFuncPtr("glGetBufferParameteriv","glGetBufferParameterivARB")); + _glGetBufferPointerv = ((GetBufferPointervProc)osg::getGLExtensionFuncPtr("glGetBufferPointerv","glGetBufferPointervARB")); _glGenOcclusionQueries = ((GenOcclusionQueriesProc)osg::getGLExtensionFuncPtr("glGenOcclusionQueries","glGenOcclusionQueriesNV")); _glDeleteOcclusionQueries = ((DeleteOcclusionQueriesProc)osg::getGLExtensionFuncPtr("glDeleteOcclusionQueries","glDeleteOcclusionQueriesNV")); @@ -928,64 +940,83 @@ void Drawable::Extensions::glVertexAttrib4Nubv(unsigned int index, const GLubyte void Drawable::Extensions::glGenBuffers(GLsizei n, GLuint *buffers) const { - if (_glGenBuffers) - { - _glGenBuffers(n, buffers); - } - else - { - notify(WARN)<<"Error: glGenBuffers not supported by OpenGL driver"<