Hi All,

I'm currently working on multiple render target functionality, yesterday I
checking in ColorMaski, BlendFunci and BlendEquationi, and today I've moved
on to implementing glEnablei/glDisablei functionality.  I'm torn of what
naming convention to use and the granularity of the design - so I'd like
feedback from the community about what feels sensible.

Originally I was thinking that as glEnable/glDisable functionality in
imlemented via osg::StateSet::setMode(..) I'd add a StateSet::setModei()
and expand similar support in osg::State.  When I got into looking at how
much code I'd need to duplicate+tweak to make this all work I decided that
that much code for such a small chunk of functionality was totally
disproportionate.

When I come across issues like this I use this Complexity of implementation
vs Functionality Ratio as an indication of how well designed something is.
If it requires lots of Complexity for modest Functionality it screams out
that it's the wrong approach.  So I've taken a step back and am now
thinking about other ways I could tackle this feature.

My current favoured approach is to reuse the existing
StateSet/StateAttribute mechanism and have one or more subclass from
StateAttribute to wrap up the glEnablei and glDisablei functionality.  If I
am to follow the usual OpenGL->OSG naming convention it would seem sensible
to have two classes osg::Enablei and osg::Disablei that wrap up glEnablei
and glDisablei respectively.

An alternative approach would be to create an osg::Modei class that has an
Enabled/Disabled parameter.  The Modei name would be a nod to the previous
naming convention for handing glEnable/glDisable.  The name Modes I
originally adopted as the original OpenGL language around
glEnable/glDisable used to label them as modes - this was all decided back
in the late 90's.  This during the fixed function pipeline era of OpenGL
where you'd configure the OpenGL state machine by toggling different
"modes".

Since then a decade and half has passed and looking at modern docs for
OpenGL the glEnable/glDisable and glEnablei/glDisablei now discuss OpenGL
capability rather than modes.  I guess the new naming sits better modern
shader centric functionality.   Given this perhaps if one is to have a
single class then perhaps one should name it osg::Capability.

The usage mode for the new class/classes would be something like:

   stateset->setAttribute(new osg::Enablei(GL_BLEND, 0));
   stateset->setAttribubte(new osg::Disable(GL_SCISSOR_TEST,1));

OR

   stateset->setAttribute(new osg::Capabiltyi(GL_BLEND, 0, GL_TRUE));
   stateset->setAttribute(new osg::Capabiltyi(GL_SCISSOR_TEST, 0,
GL_FALSE);

It might still be better though for me to bite the bullet and do the hard
work refatoring the internals of osg::State/osg::StateSet to handle a new
osg::StateSet::setModei(..) method and associated set/gets.

Thoughts/Opinions/Suggestions?

Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to