Jump to content
  • Advertisement
Sign in to follow this  
TrueTom

OpenGL Linear interpolation behaviour

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

Hello, if I use texture interpolation (GL_LINEAR), does OpenGL interpolate even if there is no need to (Draw a 16x16 texture to a 16x16 rect)? (Cause it currently does and I wonder if it's my fault; the tex coords look good, but maybe due to some rounding errors) Regards, Thomas

Share this post


Link to post
Share on other sites
Advertisement
OpenGL does the interpolation, surely.
But if you want to draw exact quad, yo must specify exact texture coordinates.
Unfortunately, they are not 0 and 1.
Imagine, you texture width is W and height is H.
So, exact coordinates would be from 0.5/W to 1.0 - 0.5/W horizontally, and 0.5/H to 1.0 - 0.5/H vertically.

To read more about why is it so, look here:

http://download.nvidia.com/developer/NVTextureSuite/Atlas_Tools/Texture_Atlas_Whitepaper.pdf

page 12

Share this post


Link to post
Share on other sites
@blizzard999: Well, this seems obvious but is a problem if you need to interpolate some parts of a texture and some not...

@Jackis: Thank you very much, that helped me a lot. The solution is really that simple. Just add an offset of 0.5f to every coordinate and you're doing fine (using endpoint-exclusive rect required). You also have to do this with the destination coords and everything works fine. I also got rid of the recommended gltranslatef(0.375, 0.375, 0.0), doesn't work reliable.

Share this post


Link to post
Share on other sites
TrueTom:
You're welcome!
And about glTranslatef(0.375f, 0.375f, 0.f)
I works, but it doesn't affect texturing, this trick is helpful for drawing smth in exact window positions, but not for exact texturing, you're right!

Share this post


Link to post
Share on other sites
Sign in to follow this  

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