Hi all,
I have an mesh object, and I want to texture it with an customer .rgb figure.
I loaded the figure with the following code:
glBindTexture( GL_TEXTURE_2D, texture );
image = read_texture("figure.rgb", &width, &height, &components);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, components, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,image);
Then while drawing the mesh object, I automatically compute the texture coordinates and draw the mesh as the following code:
glEnable( GL_TEXTURE_2D );
glActiveTexture(GL_TEXTURE0);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE,GL_NORMAL_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE,GL_NORMAL_MAP);
glEnable(GL_TEXTURE_GEN_S); //enable texture coordinate generation
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_TRIANGLES);
for( i = 0; i < current_gs-> street_light->ntri; i++)
{
for(j = 0; j < 3; j++)
{
//assign the normal of the vertices
//draw (x,y,z) of each vertices
}
}
glEnd();
However, the resulted figure is just black.
May I ask what did I do wrong? Is this the problem of my automatic texture coordinates generation? I tested this .rgb figure on a rectangle, it can shown correctly.
Any reply would be warmly welcomed.
Thank you very much.