PDA

View Full Version : glTexGen



05-07-2001, 05:23 AM
Hello,
I cant figure out the syntax of glTexGen.. Does it create texture coordinates for any object? and where do i place it? lets say i have:
glBegin(GL_TRIANGLES);
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(1.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, 1.0);
glEnd();

and I want to apply a texture to this object.
Where do i place the glTexGen function? will it work ok? cause its too much work to do the texture mapping by urself.

Deiussum
05-07-2001, 06:28 AM
To use texcoord generation you would do something like this in your init function.




glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);


Note, you can use different formulas for the texture generation depending on what you specify for the last parameter of glTexGeni. You can also modify those formulas somewhat using the glTexGen*v version and specifying a object or eye plane to get used in the calculation. You can find the formulas in MSDN and also in the OpenGL 1.2.1 specification document.

It may be more convenient to use texgen for some things, but there are a lot of things where you are really better off doing the texture coordinates yourself. (i.e. you can't always get the results you want from texgen.)