Hello All…
I am quit new to GLSL and trying to map a single texture through shaders…but all i get is a Black Screen in front of me…i googled a lot and compared my program to others…but no luck…!!!
my vertex shader
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
here is the fragment shader…
uniform sampler2D sand;
void main()
{
gl_FragColor = texture2D(sand,gl_TexCoord[0].st);
//gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
noe intresting thing is that both shaders are compiled and linked with no errors and when I try to give simple color in fragment shader it works…(line 2)
this is my init() function…
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
textures[0]=loadTexture("sand.jpg");
multiTex.abCreate();
multiTex.abCompileAndLink();
multiTex.abSetUniformTexture("sand",textures[0]);
here is render function…
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,textures[0]);
multiTex.abSetUniformTexture("sand",textures[0]);
multiTex.abUseProgram();
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0); glVertex3f(-10.0,-10.0,0.0);
glTexCoord2f(1.0,0.0); glVertex3f(10.0,-10.0,0.0);
glTexCoord2f(1.0,1.0); glVertex3f(10.0,10.0,0.0);
glTexCoord2f(0.0,1.0); glVertex3f(-10.0,10.0,0.0);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers();
it is the function in which i am setting my uniform variable…
glUseProgram(programID);
GLint parameterLocation = glGetUniformLocation(programID, name);
glUniform1i(parameterLocation, unit);
glUseProgram(0);
also texture is working without shaders…
plz help guys it is so frustating…!!!