From e5685bc1aca78ea5f0ad05d6aaf6a52092bbdaa8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 11 Nov 2005 14:22:57 +0000 Subject: [PATCH] Added s/getMaxNumOfTextureUnits control to osgGA::StateSetManipulator, and set the default to 4. --- include/osgGA/StateSetManipulator | 4 ++++ src/osgGA/StateSetManipulator.cpp | 9 ++++++--- src/osgWrappers/osgGA/StateSetManipulator.cpp | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/osgGA/StateSetManipulator b/include/osgGA/StateSetManipulator index e7172ba75..22d5918ad 100644 --- a/include/osgGA/StateSetManipulator +++ b/include/osgGA/StateSetManipulator @@ -53,6 +53,9 @@ public: /** Get the keyboard and mouse usage of this manipulator.*/ virtual void getUsage(osg::ApplicationUsage& usage) const; + + void setMaximumNumOfTextureUnits(unsigned int i) { _maxNumOfTextureUnits = i; } + unsigned int getMaximumNumOfTextureUnits() const { return _maxNumOfTextureUnits; } protected: @@ -62,6 +65,7 @@ protected: bool _backface; bool _lighting; bool _texture; + unsigned int _maxNumOfTextureUnits; }; } diff --git a/src/osgGA/StateSetManipulator.cpp b/src/osgGA/StateSetManipulator.cpp index 2627a0079..dfbd242aa 100644 --- a/src/osgGA/StateSetManipulator.cpp +++ b/src/osgGA/StateSetManipulator.cpp @@ -16,7 +16,11 @@ using namespace osg; using namespace osgGA; -StateSetManipulator::StateSetManipulator(): _drawState(NULL) +StateSetManipulator::StateSetManipulator(): + _backface(false), + _lighting(false), + _texture(false), + _maxNumOfTextureUnits(4) { } @@ -83,10 +87,9 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa) // ( _drawState->getAttribute( osg::StateAttribute::TEXTURE ) ); // cout << tex->numTextureUnits() << endl; - unsigned int nunit = 8; // should actually use the _real_ num units here, but how? unsigned int mode = osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF; if ( _texture ) mode = osg::StateAttribute::INHERIT|osg::StateAttribute::ON; - for( unsigned int ii=0; iisetTextureMode( ii, GL_TEXTURE_1D, mode ); _drawState->setTextureMode( ii, GL_TEXTURE_2D, mode ); diff --git a/src/osgWrappers/osgGA/StateSetManipulator.cpp b/src/osgWrappers/osgGA/StateSetManipulator.cpp index 420beb9b5..a85a04191 100644 --- a/src/osgWrappers/osgGA/StateSetManipulator.cpp +++ b/src/osgWrappers/osgGA/StateSetManipulator.cpp @@ -34,6 +34,9 @@ BEGIN_OBJECT_REFLECTOR(osgGA::StateSetManipulator) I_Method2(bool, handle, IN, const osgGA::GUIEventAdapter &, ea, IN, osgGA::GUIActionAdapter &, us); I_Method1(void, accept, IN, osgGA::GUIEventHandlerVisitor &, x); I_Method1(void, getUsage, IN, osg::ApplicationUsage &, usage); + I_Method1(void, setMaximumNumOfTextureUnits, IN, unsigned int, i); + I_Method0(unsigned int, getMaximumNumOfTextureUnits); + I_Property(unsigned int, MaximumNumOfTextureUnits); I_Property(osg::StateSet *, StateSet); END_REFLECTOR