Dears,
I have a question on texture mapping using OpenGL. I have tried to texture map a photo onto a sphere hoping that it could have a more realistic metalic looking.
I mapped each texture to each sphere but there is something looking not smooth just like the first shown picture below.
I hope to have the result like the second picture shown below but I cannot figure out where the problem is. The texture mapping code list here:
//Part of the code: To generate the texture
QPixmap pixmap(materialFileName);
glGenTextures(1, &ID);
glBindTexture(GL_TEXTURE_2D, ID);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
QImage tx = this->convertToGLFormat(pixmap.toImage());
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, tx.width(), tx.height(), GL_RGBA, GL_UNSIGNED_BYTE, tx.bits());
//Not continue from above
//Part of the code: To bind the texture
glEnable(GL_TEXTURE_2D); //enable texture mapping
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); //Preset the texture mapping mode
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glBindTexture (GL_TEXTURE_2D, _it->front()->getTextureId());
drawSomething(); //The place to draw the sphere
glDisable(GL_TEXTURE_GEN_S);//disable texture generate
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D); //disable texture mapping
Can anyone help and explain?