View Full Version : different textures ...

05-10-2004, 06:18 AM
.. i want to used two different textures in my fragment shader .. seems to be no problem with texture2D() .. but it doesn't work ..
i'm loading my textures and bind them .. i thought i have to use the texturename in my fragment shader as sampler2d value .. but looks like it isn't the right way ..

GLuint a = 0;
GLuint b = 0;

char nameA[256] = "bla"
char nameB[256] = "blubb"

Image ta, tb;

imgLoadImage( ta, nameA);
imgLoadImage( tb, nameB);

glGenTextures( 1, &a);
glTexParameteri( ...
.. and all the other texture stuff ...

glGenTextures( 1, &b);
.. same as a ..

and now i want to use them both in my shader ..

loc = glGetUniformLocationARB(*shaderProgam, "baseImage");
glUniform2fvARB( loc, 1, &a);

loc = glGetUniformLocationARB(*shaderProgam, "shadowMap");
glUniform2fvARB( loc, 1, &b);

.. but this doesn't work .. perhaps i didn't really understood the meaning of an texture unit .. ist it similar to the texture name or discribes it a part of an multitexture???

05-10-2004, 06:27 AM
You don't pass the texture object to the GL, you pass the texture unit to the GL:

unsigned int tex;

//Texture generation
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexData2D(GL_TEXTURE_2D, ...);

glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, tex);
glUniform1i(glGetUniformLocation("my_texture"), i);