From bd7762a73e975c8f3d35636900d9e83469da8328 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 13 Nov 2002 11:09:55 +0000 Subject: [PATCH] Added State::computeSecondaryColorSupported() & computeFogCoordSupported(). Updated NEWS. --- NEWS | 52 +++++++++++++++++++++++++++++------------------ include/osg/State | 17 ++++++++++++++-- src/osg/State.cpp | 20 ++++++++++++++++++ 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index 81874ea0d..cf2af3eb9 100644 --- a/NEWS +++ b/NEWS @@ -4,38 +4,50 @@ OSG News (most significant items from ChangeLog) 11th November 2002 - OpenSceneGraph-0.9.2.tar.gz - >>> New shape primitive support, and new AC3D and GEO loaders, + >>> New AC3D and GEO loaders, new Shape primitives, improved OpenFlight support. . - Geometry has been extended to all per primtive bindings and + From Geoff Michel, AC3D .wc and Carbon Graphics GEO .geo loaders. + + Support for multi-texturing added to OpenFlight loader. + + LOD has been revamped to allow independent min and max ranges for + each LOD child, bringing it inline with the OpenFlight style LOD + representation. + + Switch has been revamped to allow independent switching on or off of + each Switch child, bringing it inline with the OpenFlight style Switch + representation. + + New osg::Shape geometry primitives added which allow the specification + of geometry in a form that can accelerate collision detection, and as + a way of specifying the geometry to tessellate. Shapes include + Sphere, Oriented Box, Cone, Cylinder, Grid, TriangleMesh, ConvexHull + and CompositeShape which allows the storage of a hierarchy of shapes. + + Geometry has been extended to all per primitive bindings and per primitive set bindings of attributes, and indexing of attributes with the same or different index lists for each attribute list. From Macro Jez, new cubemap helper classes. - New osg::Shape geometry primitives added which allow the specification - of geometry in a form that can accelerate collision detection, and as - a way of specifiying the geometry to tesselate. Shapes include - Shere, Orintatble Box, Cone, Cylinder, Grid, TriangleMesh, ConvexHull - and CompositeShape which allows the storage of a heirachy of shapes. - - From Geoff Michel, AC3D .wc and Carbon Graphics GEO .geo loaders. - Support added for handling different extensions on different graphics contexts. Draw and Sort callbacks added to osg::RenderStage. - Support for multitexturing added to OpenFlight loader. - - LOD has been revamped to allow independat min and max ranges for - each LOD child, bringing it inline with the OpenFlight style LOD - representation. - - Switch has been revamped to allow independat switching on or off of - each Switch child, bringing it inline with the OpenFlight style Switch - representation. - Added PolygonStipple class. + + Further refinement of class names and method calls: + Renamed classes : + + Primitive -> PrimitiveSet + + Renamed methods : + + Geometry::addPrimitive(..) -> addPrimitiveSet(..) + Drawable::drawImmediateMode(..) -> drawImplementation(..) const + Drawable::DrawCallback::drawImmediateMode(..) -> drawImplementation(..) const + 30th August 2002 - OpenSceneGraph-0.9.1.tar.gz diff --git a/include/osg/State b/include/osg/State index 8eef4b040..f727225c9 100644 --- a/include/osg/State +++ b/include/osg/State @@ -326,6 +326,9 @@ class SG_EXPORT State : public Referenced _colorArray._dirty = true; } + + inline bool isSecondaryColorSupported() const { return _isSecondColorSupportResolved?_isSecondColorSupported:computeSecondaryColorSupported(); } + /** wrapper around glEnableClientState(GL_SECONDARY_COLOR_ARRAY);glSecondayColorPointer(..); * note, only updates values that change.*/ void setSecondaryColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); @@ -338,7 +341,7 @@ class SG_EXPORT State : public Referenced { _secondaryColorArray._enabled = false; _secondaryColorArray._dirty = false; - glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + if (isSecondaryColorSupported()) glDisableClientState(GL_SECONDARY_COLOR_ARRAY); } } @@ -383,6 +386,8 @@ class SG_EXPORT State : public Referenced } + inline bool isFogCoordSupported() const { return _isFogCoordSupportResolved?_isFogCoordSupported:computeFogCoordSupported(); } + /** wrapper around glEnableClientState(GL_FOG_COORDINATE_ARRAY);glFogCoordPointer(..); * note, only updates values that change.*/ void setFogCoordPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); @@ -395,7 +400,7 @@ class SG_EXPORT State : public Referenced { _fogArray._enabled = false; _fogArray._dirty = false; - glDisableClientState(GL_FOG_COORDINATE_ARRAY); + if (isFogCoordSupported()) glDisableClientState(GL_FOG_COORDINATE_ARRAY); } } @@ -692,6 +697,14 @@ class SG_EXPORT State : public Referenced bool getLastAppliedMode(const ModeMap& modeMap,StateAttribute::GLMode mode) const; const StateAttribute* getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type) const; + + mutable bool _isSecondColorSupportResolved; + mutable bool _isSecondColorSupported; + bool computeSecondaryColorSupported() const; + + mutable bool _isFogCoordSupportResolved; + mutable bool _isFogCoordSupported; + bool computeFogCoordSupported() const; }; inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index b6a920df9..9ea6bfc93 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -16,6 +16,12 @@ State::State() _currentActiveTextureUnit=0; _currentClientActiveTextureUnit=0; + + _isSecondColorSupportResolved = false; + _isSecondColorSupported = false; + + _isFogCoordSupportResolved = false; + _isFogCoordSupported = false; } State::~State() @@ -512,3 +518,17 @@ void State::setSecondaryColorPointer( GLint size, GLenum type, _secondaryColorArray._dirty = false; } } + +bool State::computeSecondaryColorSupported() const +{ + _isSecondColorSupportResolved = true; + _isSecondColorSupported = osg::isGLExtensionSupported("GL_EXT_secondary_color");; + return _isSecondColorSupported; +} + +bool State::computeFogCoordSupported() const +{ + _isFogCoordSupportResolved = true; + _isFogCoordSupported = osg::isGLExtensionSupported("GL_EXT_fog_coord"); + return _isFogCoordSupported; +}