From 0900857333845d5eedd6f0e894dbbd9f3042fc76 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 25 Aug 2006 08:48:16 +0000 Subject: [PATCH] From Farshid Lashkari, "I was experiencing hard crashes of my application when using PBO's on machines that don't support PBO's. I think osg incorrectly checks if PBO's are supported. I added a new method to the BufferObject::Extensions class which returns if the "GL_ARB_pixel_buffer_object" string is supported. This fixes the problem on my end. Machines without PBO support will continue to work and machines with PBO support will still be able to use it." --- include/osg/BufferObject | 3 +++ src/osg/BufferObject.cpp | 3 ++- src/osg/Texture.cpp | 4 ++-- src/osg/TextureRectangle.cpp | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/osg/BufferObject b/include/osg/BufferObject index f541c3cca..c000b1667 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -106,6 +106,7 @@ class OSG_EXPORT BufferObject : public Object }; inline bool isBufferObjectSupported(unsigned int contextID) const { return getExtensions(contextID,true)->isBufferObjectSupported(); } + inline bool isPBOSupported(unsigned int contextID) const { return getExtensions(contextID,true)->isPBOSupported(); } inline GLuint& buffer(unsigned int contextID) const { return _bufferObjectList[contextID]; } @@ -153,6 +154,7 @@ class OSG_EXPORT BufferObject : public Object void setupGLExtenions(unsigned int contextID); bool isBufferObjectSupported() const { return _glGenBuffers!=0; } + bool isPBOSupported() const { return _isPBOSupported; } void glGenBuffers (GLsizei n, GLuint *buffers) const; void glBindBuffer (GLenum target, GLuint buffer) const; @@ -192,6 +194,7 @@ class OSG_EXPORT BufferObject : public Object GetBufferParameterivProc _glGetBufferParameteriv; GetBufferPointervProc _glGetBufferPointerv; + bool _isPBOSupported; }; /** Function to call to get the extension of a specified context. diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index 5aa7a132b..aa4429558 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -182,7 +182,7 @@ void BufferObject::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._glGetBufferParameteriv) _glGetBufferPointerv = rhs._glGetBufferPointerv; } -void BufferObject::Extensions::setupGLExtenions(unsigned int) +void BufferObject::Extensions::setupGLExtenions(unsigned int contextID) { _glGenBuffers = ((GenBuffersProc)osg::getGLExtensionFuncPtr("glGenBuffers","glGenBuffersARB")); _glBindBuffer = ((BindBufferProc)osg::getGLExtensionFuncPtr("glBindBuffer","glBindBufferARB")); @@ -195,6 +195,7 @@ void BufferObject::Extensions::setupGLExtenions(unsigned int) _glUnmapBuffer = ((UnmapBufferProc)osg::getGLExtensionFuncPtr("glUnmapBuffer","glUnmapBufferARB")); _glGetBufferParameteriv = ((GetBufferParameterivProc)osg::getGLExtensionFuncPtr("glGetBufferParameteriv","glGetBufferParameterivARB")); _glGetBufferPointerv = ((GetBufferPointervProc)osg::getGLExtensionFuncPtr("glGetBufferPointerv","glGetBufferPointervARB")); + _isPBOSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_pixel_buffer_object"); } void BufferObject::Extensions::glGenBuffers(GLsizei n, GLuint *buffers) const diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 63a36113b..72808cbcd 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -897,7 +897,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima unsigned char* dataPlusOffset = 0; const PixelBufferObject* pbo = image->getPixelBufferObject(); - if (pbo && pbo->isBufferObjectSupported(contextID) && !needImageRescale) + if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale) { pbo->compileBuffer(state); pbo->bindBuffer(contextID); @@ -1149,7 +1149,7 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* unsigned char* dataPlusOffset=0; const PixelBufferObject* pbo = image->getPixelBufferObject(); - if (pbo && pbo->isBufferObjectSupported(contextID) && !needImageRescale) + if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale) { pbo->compileBuffer(state); pbo->bindBuffer(contextID); diff --git a/src/osg/TextureRectangle.cpp b/src/osg/TextureRectangle.cpp index b934f5216..25a51871d 100644 --- a/src/osg/TextureRectangle.cpp +++ b/src/osg/TextureRectangle.cpp @@ -283,7 +283,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st unsigned char* dataPlusOffset = 0; const PixelBufferObject* pbo = image->getPixelBufferObject(); - if (pbo && pbo->isBufferObjectSupported(contextID)) + if (pbo && pbo->isPBOSupported(contextID)) { pbo->compileBuffer(state); pbo->bindBuffer(contextID); @@ -350,7 +350,7 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& unsigned char* dataPlusOffset = 0; const PixelBufferObject* pbo = image->getPixelBufferObject(); - if (pbo && pbo->isBufferObjectSupported(contextID)) + if (pbo && pbo->isPBOSupported(contextID)) { pbo->compileBuffer(state); pbo->bindBuffer(contextID);