Restructred the enabling of vertex array object support to allow one to set enable the default via osg::State.
Added OSG_VERTEX_BUFFER_HINT env var to osg::DisplaySettings with VERTEX_BUFFER_OBJECT/VBO, VERTEX_ARRAY_OBJECT/VAO and NO_PREFERENCE to allow one to foce on VBO or VAO usage. Restructred BufferObject assigned in osg::Geometry Added
This commit is contained in:
@@ -299,15 +299,15 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
int getNvOptimusEnablement() const;
|
||||
|
||||
|
||||
enum GeometryImplementation
|
||||
enum VertexBufferHint
|
||||
{
|
||||
OLD_GEOMETRY_IMPLEMENTATION,
|
||||
NEW_GEOMETRY_IMPLEMENTATION,
|
||||
NO_PREFERENCE,
|
||||
VERTEX_BUFFER_OBJECT,
|
||||
VERTEX_ARRAY_OBJECT
|
||||
};
|
||||
|
||||
void setGeometryImplementation(GeometryImplementation gi) { _geometryImplementation = gi; }
|
||||
GeometryImplementation getGeometryImplementation() const { return _geometryImplementation; }
|
||||
void setVertexBufferHint(VertexBufferHint gi) { _vertexBufferHint = gi; }
|
||||
VertexBufferHint getVertexBufferHint() const { return _vertexBufferHint; }
|
||||
|
||||
|
||||
void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
|
||||
@@ -399,7 +399,7 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
SwapMethod _swapMethod;
|
||||
unsigned int _syncSwapBuffers;
|
||||
|
||||
GeometryImplementation _geometryImplementation;
|
||||
VertexBufferHint _vertexBufferHint;
|
||||
|
||||
bool _keystoneHint;
|
||||
FileNames _keystoneFileNames;
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
#endif
|
||||
|
||||
|
||||
#define INLINE_DRAWABLE_DRAW
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
||||
@@ -256,7 +258,11 @@ class OSG_EXPORT Drawable : public Node
|
||||
* \c virtual). Subclasses should override
|
||||
* \c drawImplementation() instead.
|
||||
*/
|
||||
#ifdef INLINE_DRAWABLE_DRAW
|
||||
inline void draw(RenderInfo& renderInfo) const;
|
||||
#else
|
||||
void draw(RenderInfo& renderInfo) const;
|
||||
#endif
|
||||
|
||||
inline void drawInner(RenderInfo& renderInfo) const
|
||||
{
|
||||
@@ -491,12 +497,11 @@ class OSG_EXPORT Drawable : public Node
|
||||
ref_ptr<DrawCallback> _drawCallback;
|
||||
};
|
||||
|
||||
#if 1
|
||||
#ifdef INLINE_DRAWABLE_DRAW
|
||||
inline void Drawable::draw(RenderInfo& renderInfo) const
|
||||
{
|
||||
State& state = *renderInfo.getState();
|
||||
bool useVertexArrayObject = _useVertexBufferObjects && state.useVertexArrayObject();
|
||||
|
||||
bool useVertexArrayObject = state.useVertexArrayObject(_useVertexArrayObject);
|
||||
if (useVertexArrayObject)
|
||||
{
|
||||
unsigned int contextID = renderInfo.getContextID();
|
||||
@@ -560,46 +565,6 @@ inline void Drawable::draw(RenderInfo& renderInfo) const
|
||||
drawInner(renderInfo);
|
||||
}
|
||||
}
|
||||
#else
|
||||
inline void Drawable::draw(RenderInfo& renderInfo) const
|
||||
{
|
||||
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
if (_useDisplayList && !(_supportsVertexBufferObjects && _useVertexBufferObjects && renderInfo.getState()->isVertexBufferObjectSupported()))
|
||||
{
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
unsigned int contextID = renderInfo.getContextID();
|
||||
|
||||
// get the globj for the current contextID.
|
||||
GLuint& globj = _globjList[contextID];
|
||||
|
||||
if( globj == 0 )
|
||||
{
|
||||
// compile the display list
|
||||
globj = generateDisplayList(contextID, getGLObjectSizeHint());
|
||||
glNewList( globj, GL_COMPILE );
|
||||
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImplementation(renderInfo,this);
|
||||
else
|
||||
drawImplementation(renderInfo);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
// call the display list
|
||||
glCallList( globj);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// draw object as nature intended..
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImplementation(renderInfo,this);
|
||||
else
|
||||
drawImplementation(renderInfo);
|
||||
}
|
||||
#endif
|
||||
|
||||
class AttributeFunctorArrayVisitor : public ArrayVisitor
|
||||
|
||||
@@ -716,10 +716,11 @@ class OSG_EXPORT State : public Referenced
|
||||
|
||||
|
||||
inline bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupported; }
|
||||
inline bool useVertexBufferObject(bool useVBO) const { return _forceVertexBufferObject || (_isVertexBufferObjectSupported && useVBO); }
|
||||
|
||||
inline bool isVertexArrayObjectSupported() const { return _isVertexArrayObjectSupported; }
|
||||
inline bool useVertexArrayObject(bool useVAO) const { return _forceVertexArrayObject || (_isVertexArrayObjectSupported && useVAO); }
|
||||
|
||||
inline bool useVertexArrayObject() const { return _useVertexArrayObject; }
|
||||
|
||||
inline void setLastAppliedProgramObject(const Program::PerContextProgram* program)
|
||||
{
|
||||
@@ -1306,8 +1307,8 @@ class OSG_EXPORT State : public Referenced
|
||||
bool _isFogCoordSupported;
|
||||
bool _isVertexBufferObjectSupported;
|
||||
bool _isVertexArrayObjectSupported;
|
||||
|
||||
bool _useVertexArrayObject;
|
||||
bool _forceVertexBufferObject;
|
||||
bool _forceVertexArrayObject;
|
||||
|
||||
typedef void (GL_APIENTRY * ActiveTextureProc) (GLenum texture);
|
||||
typedef void (GL_APIENTRY * FogCoordPointerProc) (GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
|
||||
@@ -161,6 +161,8 @@ public:
|
||||
void setRequiresSetArrays(bool flag) { _requiresSetArrays = flag; }
|
||||
bool getRequiresSetArrays() const { return _requiresSetArrays; }
|
||||
|
||||
void dirty();
|
||||
|
||||
void release();
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user