Jump to content
  • Advertisement

Archived

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

kevbogsp

glHint() not working

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

I am having a problem when texturing. I apply a texture map to a polygon, but it appears that the quad has been split into two triangles (the texture map is applied unevenly across the quad). I read that I could use glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) to fix the problem, but this did not work. Am I using this incorrectly or is there another fix to my problem? Kevin P.S. I am working in Linux.

Share this post


Link to post
Share on other sites
Advertisement
glHint is not guaranteed to do anything. It is merely a suggestion to the driver, which may or may not ignore it. The quality is also dependent on the hardware and the driver settings.

Share this post


Link to post
Share on other sites
What 3D hardware are you using ? Pretty much every 3D chip in existance will totally ignore GL_PERSPECTIVE_CORRECTION_HINT. They will always apply the correction by default (as a sidenote: it''s not even possible to disable that feature, even if you wanted to. That''s why eg. projective textures need special treatment).

So either you are using a software rasterizer (probably Mesa, if you''re under Linux), or your error comes from somewhere else. In the former case, the renderer is free to ignore the hint, as BB mentioned.

Share this post


Link to post
Share on other sites
Isn''t it true that quads are actually rendered as two triangles? If your coordinates dont correctly map to a quad, then it wont work - are you using typical ( 0.0f | 1.0f ) coordinates or are they skewed at all?

Share this post


Link to post
Share on other sites
On some hardware, you need to enable texture filtering (rather than GL_NEAREST) for it to get the perspective of textures right on quads. And I''ve found that with environment mapping, it''s always a bit off.

Share this post


Link to post
Share on other sites
I have tried using the glTexCoord4f() suggested in the website given, but the code still does not work. Does anyone know how to calculate q?

My code is fairly huge, but here is the quad I am building. A camera sits at (0,0,0) looking down the z-axis. I am building a quad with:

glBegin(GL_QUADS);
glTexCoord2f(1, 0);
glVertex3d(-.15,-.3, -1.2);
glTexCoord2f(0, 0);
glVertex3d(.15,-.3, -1.2);
glTexCoord2f(0,1);
glVertex3d(.3,.3, -1.2);
glTexCoord2f(1, 1);
glVertex3d(-.3,.3, -1.2);
glEnd();

Thanks so far for all the help.

Share this post


Link to post
Share on other sites
You''ll NEVER ever get a correct result with that.....

It has nothing to do with perspective-correction!!!!!!!

The reason is the barycentric texture-space which is defined by the API for a triangle.....

If you create a quad with vertices that don''t form a perfect rectangle or tex-coords that don''t form a perfect rectangle in texture-space, you''ll get ''incorrect'' results along the diagonal line seperating the two triangles....it''s because of u,v-interpolation.

BUT there is a way to fix this....using homogenous texture-coords which have a third coordinate, that is used like the 4th component of point during transformation....


I think the DXSDK has some samples regarding homogenous texcoords.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!