Hi,

An attribute is identified by a type (enum Type) and a member (int). The StateAttribute getters and setters have the member parameter defaulted to 0.

I use some custom state attributes:
- I use the type as an attribute class (i.e. MATERIAL for BRDF related parameters...)
- I use the member of prevent conflicts with the OSG legacy attributes


On 18/10/2015 22:58, Jannik Heller wrote:
Hi,

How is one supposed to use a custom StateAttribute?

The docs say that:

"When extending the osg's StateAttribute's simply define your own Type value which 
is unique, using the StateAttribute::Type enum as a guide of what values to use"

As it is, returning a unique value simply isn't possible because the getType() 
function returns an enum:

         /** Return the Type identifier of the attribute's class type.*/
         virtual Type getType() const = 0;

Type is the enum defined here containing the default types, with no room for 
user types:


Code:

         enum Type
         {
             TEXTURE,

             POLYGONMODE,
      ....

             FRAME_BUFFER_OBJECT
         };




I suppose that you could choose some integer, static_cast it back to enum Type 
and then hope that will work. (it will most likely work if the enum has a large 
enough bit size, but it's technically undefined behaviour, so I can't imagine 
that's how Robert intended it to be used).

To me it seems the feature advertised in docs of creating your own 
StateAttributes simply isn't possible, just because of this one function 
returning enum instead of int, which would be an easy fix. Am I missing 
something here?

Cheers,
Jannik

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65369#65369





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


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

Reply via email to