Jump to content
  • Advertisement


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


glTexGen problem

This topic is 5587 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,all In the blue book,it said: " If the texture generation function is GL_OBJECT_LINEAR, the function g = p1 * xo + p2 * yo + p3 * zo + p4 * wo is used, where g is the value computed for the coordinate named in coord, p1, p2, p3, and p4 are the four values supplied in params, and xo, yo, zo, and wo are the object coordinates of the vertex. This function can be used to texture-map terrain using sea level as a reference plane (defined by p1, p2, p3, and p4). The altitude of a terrain vertex is computed by the GL_OBJECT_LINEAR coordinate generation function as its distance from sea level; that altitude is used to index the texture image to map white snow onto peaks and green grass onto foothills, for example. " But how to use it?I tried many times but failed. Thank you.

Share this post

Link to post
Share on other sites
To use OBJECT_LINEAR, call :
GLfloat eq[4]={0,0,1.f,0}; /* set your equation here */
glTexGenfv(GL_S, GL_OBJECT_PLANE, eq);

You may also do something equivalent with the T texture coordinate (if your texture is 2D).

Then you don''t need to call glTexCoord before glVertex. That''s the call of glVertex that will provoke texture coordinate computation.

Share this post

Link to post
Share on other sites
To simplify

g = p1 * xo + p2 * yo + p3 * zo + p4 * wo

can also be writen as

g = p1 * xo + p2 * yo + p3 * zo + p4

becouse wo will always be 1 if you don''t specify it yourself (glVertex4f(...))

Another thing to note is that you may experience a (small) performance hit when using automatic texture generation. Depends on where your bottlenecks are.

You should never let your fears become the boundaries of your dreams.

Share this post

Link to post
Share on other sites

  • 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!