Skip to main content
gamedev.net
🔒 Locked

Linear interpolation behaviour

Started by TrueTom Sep 7, 2005 at 6:44 AM 3 replies 800+ views
Original Post
TrueTom
TrueTom
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
blizzard999
blizzard999
Dont use GL_LINEAR if there is no need to use interpolation
Jackis
Jackis
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
TrueTom
TrueTom
@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.
Jackis
Jackis
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.