add static function isVBOSupported to OpenGLBuffer to check for the GL_ARB_vertex_buffer_object extension
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
#include <Inventor/errors/SoDebugError.h>
|
||||
#include <Inventor/misc/SoContextHandler.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "GLBuffer.h"
|
||||
|
||||
using namespace Gui;
|
||||
@@ -63,6 +65,21 @@ OpenGLBuffer::~OpenGLBuffer()
|
||||
destroy();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief OpenGLBuffer::isVBOSupported returns if the OpenGL driver
|
||||
* supports the VBO extension.
|
||||
* When calling this function there must be a current OpenGL context.
|
||||
* \return
|
||||
*/
|
||||
bool OpenGLBuffer::isVBOSupported()
|
||||
{
|
||||
const GLubyte * str = glGetString(GL_EXTENSIONS);
|
||||
if (!str)
|
||||
return false;
|
||||
std::string ext = reinterpret_cast<const char*>(str);
|
||||
return (ext.find("GL_ARB_vertex_buffer_object") != std::string::npos);
|
||||
}
|
||||
|
||||
void OpenGLBuffer::setCurrentContext(uint32_t ctx)
|
||||
{
|
||||
currentContext = ctx;
|
||||
@@ -74,6 +91,9 @@ bool OpenGLBuffer::create()
|
||||
if (bufferId > 0)
|
||||
return true;
|
||||
|
||||
if (!cc_glglue_has_vertex_buffer_object(glue))
|
||||
return false;
|
||||
|
||||
cc_glglue_glGenBuffers(glue, 1, &bufferId);
|
||||
context = currentContext;
|
||||
return true;
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
OpenGLBuffer(GLenum type);
|
||||
~OpenGLBuffer();
|
||||
|
||||
static bool isVBOSupported();
|
||||
|
||||
void setCurrentContext(uint32_t ctx);
|
||||
bool create();
|
||||
bool isCreated() const;
|
||||
|
||||
@@ -106,8 +106,11 @@ bool MeshRenderer::Private::canRenderGLArray(SoGLRenderAction *action) const
|
||||
static bool init = false;
|
||||
static bool vboAvailable = false;
|
||||
if (!init) {
|
||||
std::string ext = (const char*)(glGetString(GL_EXTENSIONS));
|
||||
vboAvailable = (ext.find("GL_ARB_vertex_buffer_object") != std::string::npos);
|
||||
vboAvailable = Gui::OpenGLBuffer::isVBOSupported();
|
||||
if (!vboAvailable) {
|
||||
SoDebugError::postInfo("MeshRenderer",
|
||||
"GL_ARB_vertex_buffer_object extension not supported");
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
|
||||
@@ -483,7 +486,7 @@ void SoFCIndexedFaceSet::GLRender(SoGLRenderAction *action)
|
||||
|
||||
// get the VBO status of the viewer
|
||||
SbBool useVBO = true;
|
||||
//Gui::SoGLVBOActivatedElement::get(state, useVBO);
|
||||
Gui::SoGLVBOActivatedElement::get(state, useVBO);
|
||||
|
||||
// Check for a matching OpenGL context
|
||||
if (!render.canRenderGLArray(action))
|
||||
|
||||
Reference in New Issue
Block a user