OpenGL Texture Coordinates & Wrapping
by Brett Fattori · in Torque Game Engine · 01/02/2004 (6:13 am) · 4 replies
I was working with some code, last night, that I pulled from another application. In the application (which is more of a simple demonstration of a concept in OpenGL) the texture coordinates seem to wrap. Thus, since texture coordinates go from 0.0 to 1.0, if it were to supply 0.0, 2.5, then it would be the same as 0.0, 0.5. It works properly in the demonstration.
I translated it to the TGE and that doesn't seem to hold true anymore. The texture coordinates seem to clamp. So, if you supply 0.0, 2.5, what you get is actually 0.0, 1.0. And when it goes to 2.6, you get 1.0 also. Thus, the texture appears to "smear" at the border, rather than wrap.
Am I seeing the right behavior? Is the TGE made to do this by default? How do I get around it?
I tried using
- Brett
PS: By the way Melv... Thanks for the fxRenderObject. Really saved me from balding myself prematurely!
I translated it to the TGE and that doesn't seem to hold true anymore. The texture coordinates seem to clamp. So, if you supply 0.0, 2.5, what you get is actually 0.0, 1.0. And when it goes to 2.6, you get 1.0 also. Thus, the texture appears to "smear" at the border, rather than wrap.
Am I seeing the right behavior? Is the TGE made to do this by default? How do I get around it?
I tried using
mFmod([my algorithm], 1.0)but I'm getting strange artifacts. Anyone have any ideas about what I'm missing? I'm still learning OpenGL, so forgive me if this is obvious.
- Brett
PS: By the way Melv... Thanks for the fxRenderObject. Really saved me from balding myself prematurely!
#2
You can select the texture-lookup behavior with...
You don't need to keep settings this as it is kept with the texture state.
TRUE means that your texture coordindates are clamped at 1.0f and FALSE stops this.
In OpenGL, this equates to a call, seperate for each texture axis S/T and is...
Misc Ref
MSDN Ref
Hope this helps,
- Melv.
01/02/2004 (7:15 am)
Brett,You can select the texture-lookup behavior with...
mTextureHandle.setClamp(false);
You don't need to keep settings this as it is kept with the texture state.
TRUE means that your texture coordindates are clamped at 1.0f and FALSE stops this.
In OpenGL, this equates to a call, seperate for each texture axis S/T and is...
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (GL_CLAMP/GL_CLAMP_TO_EDGE_EXT) or GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (GL_CLAMP/GL_CLAMP_TO_EDGE_EXT) or GL_REPEAT);
Misc Ref
MSDN Ref
Hope this helps,
- Melv.
#3
- Brett
01/02/2004 (7:22 am)
Thanks Melv... as per usual, you are DA man! I'll report back on my findings once this boring day at work is done and I can go home. :-P- Brett
Torque Owner Brett Fattori