glTexGen problem

I need to generate texture coordinates(using glTexGen) for a plane which is centered around the origin, that is it goes from -Width/2 to Width/2 in the x direction and from -Height/2 to Hgith/2 in the y direction. I don’t really know how to set up my s and t vectors to avoid getting negative texture coordinates.
Using this…

float sVec= {1/Width, 0, 0, 0};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, sVec);
(and the same for t)

… will not work properly as half the coordinates become negative.
Maybe I’m just being stupid here, but how do I generate texture coordinates for objects with vertices with both negative and positive coordinates?

Try …

float sVec[]= {1/Width, 0, 0, 0.5};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);   
glTexGenfv(GL_S, GL_OBJECT_PLANE, sVec);

You will have been getting coordinates between -0.5 and +0.5 with your code, so use the 0.5 in the “w” (as above) to always adjust the generated coordinates back into the 0.0 to 1.0 range.

[This message has been edited by Rog (edited 07-31-2003).]

Thanks alot. It seems to work now.