Archived

This topic is now archived and is closed to further replies.

How to specify depend on the height?

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

Hi. I know that there is a function in OpenGl to set color of a vertex depend on the height.For example,the heightest is red,or the lowest is darkblue. Somebody knows,please help me. Thank you.

Share this post


Link to post
Share on other sites
hi there,
I assume u want the color to be dependant on the Y axis (?)...
if so, just specify the color as dependant on the Y value of the vertic u draw:

glColor3f((GLfloat)y/MAX, (GLfloat)green, (GLfloat)blue);
// y is the Y value of the vertex to draw
// MAX is the top value that Y can get (to keep it bellow 1.0)

just showed the red portion, but u can apply it to any value....

this is just an idea, so you can use any kind of math play there, just try to keep the value below 1.0.

good luck.

Share this post


Link to post
Share on other sites