Jump to content
  • Advertisement
Sign in to follow this  
ThePixelPony

Modify GLSL Struct Uniform

This topic is 1041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this struct:

 

struct Test {
vec2 value1;
vec3 value2;
float value3;
}

 

uniform Test test0;

 

`glUniform2f` can be used to modify a vec2 type uniform. Which function allows one to set the value of a struct?

Share this post


Link to post
Share on other sites
Advertisement
You set structs as buffers. The easiest would be to set the structs members with primitive functions, like glsetuniform2f("test0.value1", data). I think that works.

Share this post


Link to post
Share on other sites

Which function allows one to set the value of a struct?

It will be the same glUniform1/2/3/4/fv(). You just need correct locations of struct items.

In your case there will be 3 uniforms, named "test0.value1", "test0.value2" and "test0.value3". You can query locations for those names with glGetUniformLocation().

To be perfectly sure about names - list active uniforms.

First ask uniforms count with glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &uniform_cnt), then loop from 0 till <uniform_cnt, calling glGetActiveUniform() for every index.

Edited by vstrakh

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!