[osg-users] Using a custom StateAttribute

Lionel Lagarde lionel.lagarde at oktal-se.fr
Mon Oct 19 01:28:21 PDT 2015


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 at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151019/cdda60ab/attachment-0002.htm>


More information about the osg-users mailing list