Jump to content
  • Advertisement
Sign in to follow this  
rotalever

sending data to vertex shader

This topic is 4236 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

In my vertex shader I need the current x,z position of my player for many vertices. What would the best way to send the playerposition to the shader?

Share this post


Link to post
Share on other sites
Advertisement
Hmm, but how to get the data for "vec2 uniform" onto the graphiccard?
I thought using something like glColor..() can work?
And yeah it's constant for all vertices, but changes with each frame.

Share this post


Link to post
Share on other sites

GLhandleARB prgmShdr;

...

GLuint eyePos = glGetUniformLocationARB( prgmShdr, "eyePos" );

...

glUniform3fARB( eyePos, 0.0f, 0.0f, 0.0f );


if you have vec2 uniform eyePos in your shader. if its not called eyePos, change "eyePos" to the variable name.

Share this post


Link to post
Share on other sites
What does the line
GLuint eyePos = glGetUniformLocationARB( prgmShdr, "eyePos" );
do exactly?
I have the coordinates in the main program as two floats. Could I pass them directly with this glUniform3fARB ? Hmm..., I dont understand you code... :-(

Share this post


Link to post
Share on other sites
Aah, I think I've guessed, what it means.
glGetUniformLocationARB() gives me something to store data for the shader, glUniform3fARB( eyePos, 0.0f, 0.0f, 0.0f ); will store the information. And I can change the 0.0fs to the values I need... Thanks!

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!