I am working through some beginner OpenGL tutorials, and the current one teaches how to apply a texture to a simple rectangle. The tutorial states tells me to set the texture parameters GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T to GL_CLAMP_TO_EDGE, however I am uncertain as to what this actually does. I am aware it is something to do with how textures larger/smaller than the space they are being mapped onto are handled, but I'm not sure what behavior this actually causes. What does GL_CLAMP_TO_EDGE do, and how is this different from GL_CLAMP, GL_CLAMP_TO_BORDER, GL_REPEAT? Thanks very much in advance, and bonus helpfulness if you can provide images for an idiot like me.
Answer
Well S and T just mean U and V (or X and Y if you prefer), or in GLSL:
vec4.xyzw == vec4.rgba == vec4.strq
The GL_REPEAT mode has textures repeat when you go past (0,0) to (1,1) range
The GL_CLAMP_TO_EDGE mode has textures stop at the last pixel when you fall off the edge.
The GL_CLAMP and GL_CLAMP_TO_BORDER are depreciated because all texture borders must be 0 pixels, so the modes don't make sense anymore. (somewhere around GL3 I believe)
There are more modes so make sure to read the docs. (Examples: GL_MIRRORED_REPEAT, GL_MIRROR_CLAMP_TO_EDGE)
There are some good examples on http://www.flipcode.com/archives/Advanced_OpenGL_Texture_Mapping.shtml, here is a preview:
Wrap S : GL_CLAMP / Wrap T : GL_CLAMP
Wrap S : GL_CLAMP / Wrap T : GL_REPEAT
Wrap S : GL_REPEAT / Wrap T : GL_CLAMP
Wrap S : GL_REPEAT / Wrap T : GL_REPEAT
No comments:
Post a Comment