GL Shading Language problem

Started by
1 comment, last by KumGame 17 years, 3 months ago
In GLSL, is that gl_TexCoord[0] means indexing the present texture coordinate that is working on? Also, for gl_TexCoord[0].st, what does .st means?
Advertisement
gl_TexCoord[0] means get the texture coordinate for the first texture unit (GL_TEXTURE0). When multi-texturing (more than one texture at time) you could enable multiple textures units, so you could have gl_TexCoord[1] for the second texture unit ...

example in the C++ you have:

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, num);
glTexCoord2f(8,5) ;

then you get the TexCoord in your GLSL:

gl_TexCoord[0].s ; // = 8
gl_TexCoord[0].t ; // = 5

By default only one texture unit is enable (if you glEnable(GL_TEXTURE_2D); ) which is GL_TEXTURE0
jma
gl_TexCoord[0] refers to the coordinates of the 0th texture unit.

.st is used to smear the vector. It means, you are aceesing/assigning only 2 (s & t) components of the vector depending on the usage of it vector.

This topic is closed to new replies.

Advertisement