Discussion:
How do I create/update uniform struct?
Wyatt Earp
2009-09-03 15:51:55 UTC
Permalink
I want to use a struct in my glsl shader.

osg::StateSet::getOrCreateUniform allows for the specification of
Uniform::Type, but I don't see an enumeration for struct. How would I
create/set the uniform struct?

WE
Wyatt Earp
2009-09-03 16:40:40 UTC
Permalink
I want to use a struct in my glsl shader.

osg::StateSet:: getOrCreateUniform allows for the specification of
Uniform::Type, but I don't see an enumeration for struct. How would I
create/set the uniform struct?

WE
Wyatt Earp
2009-09-03 16:43:33 UTC
Permalink
I want to use a struct in my glsl shader.

osg::StateSet::getOrCreateUniform allows for the specification of
Uniform::Type, but I don't see an enumeration for struct. How would I
create/set the uniform struct?

WE
Wyatt B. S. Earp
2009-09-03 18:22:10 UTC
Permalink
Sorry for the multiple posts.
Wyatt

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=17029#17029
Robert Osfield
2009-09-04 08:46:36 UTC
Permalink
Hi Wyatt,

I don't know where to start as I don't understand your point of
confusion. The best thing you can do is go look at the
include/osg/Unform header, and the examples that use uniforms, just do
a search through the OSG sources for osg::Uniform to see how it's
used.

Robert.
Post by Wyatt Earp
I want to use a struct in my glsl shader.
osg::StateSet::getOrCreateUniform allows for the specification of
Uniform::Type, but I don't see an enumeration for struct.  How would I
create/set the uniform struct?
WE
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Ralph Kern
2009-09-04 14:47:59 UTC
Permalink
Wyatt Earp schrieb:
How would I
Post by Wyatt Earp
create/set the uniform struct?
You don't create/set the whole struct at once, but the individual
members of the struct. OpenGL recognizes struct members by the typical
dot notation "<name of struct>.<name of member>".

regards Ralph
Wyatt Earp
2009-09-04 14:56:37 UTC
Permalink
This is what I was getting at...

So if I have a struct in my app

struct MyStruct
{
float fMember;
int iMember;
} _myStruct;

And in my shader

struct MyStruct
{
float fMember;
int iMember;
} myStruct;


Then in my osg code I would do this...

stateset->getOrCreateUniform("myStruct.fMember",osg::Uniform::FLOAT)->set(myStruct.fMember);
stateset->getOrCreateUniform("myStruct.iMember",osg::Uniform::INT)->set(_myStruct.iMember);

And then to access the updated data, just use the struct as usual?

something = somethinelse * myStruct.fMember;

Wyatt
Post by Wyatt Earp
How would I
Post by Wyatt Earp
create/set the uniform struct?
You don't create/set the whole struct at once, but the individual
members of the struct. OpenGL recognizes struct members by the typical
dot notation "<name of struct>.<name of member>".
regards Ralph
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Loading...