sending data to vertex shader

Started by
4 comments, last by rotalever 17 years, 4 months ago
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?
Advertisement
If it's constant for all vertices, a vec2 uniform should work ok.

Previously "Krohm"

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.
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.
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... :-(
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!

This topic is closed to new replies.

Advertisement