well,
as you see, the texture is distoreted when i translate the sphere around.
the thing is, in another test, trying to solve this, i tried making the sphere rotate, and the texture it self stayed stationary while the spere was clearly rotating (you could see the edges of the faces of the sphere as they when aroung the edge of the sphere).
can someone please help me?
if anybody is interested:
void Widget::initializeGL(){
GLfloat pos[] = { 0.0, 0.0, 0.0, 1.0};
GLfloat spec[] = { 1.0, 1.0, 1.0, 0.0};
GLfloat diff[] = { 1.0, 1.0, 1.0, 0.0};
GLfloat amb[] = { 1.0, 1.0, 1.0, 0.0};
GLfloat shine[] = { 50.0 };
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glClearColor(0.0,0.0,0.0,0.0);
glEnable(GL_DEPTH_TEST);
// glEnable(GL_LIGHTING);
// glEnable(GL_LIGHT0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_NORMALIZE);
glDepthFunc(GL_LEQUAL);
buff = QImage();
if(buff.load("earth.png") == NULL){
QMessageBox::critical(this, "Error", "Cannot load texture image");
}
im = QImage();
im = convertToGLFormat(buff);
sun = gluNewQuadric();
glGenTextures(1, &text[0]);
glBindTexture(GL_TEXTURE_2D, text[0]);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, im.width(), im.height(), GL_RGBA, GL_UNSIGNED_BYTE, im.bits());
gluQuadricDrawStyle(sun, GLU_FILL);
gluQuadricTexture(sun, GL_TRUE);
}
void Widget::resizeGL(int w, int h){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(0.0,0.0,0.0,0.0,0.0,0.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,w,h);
}
void Widget::paintGL(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, text[0]);
gluQuadricNormals(sun, GL_FLAT);
gluQuadricOrientation(sun, GLU_OUTSIDE);
gluSphere(sun, 0.5, 32.0, 20.0);
glPopMatrix();
renderText(10,10,"Moshe");
//glRotatef(rot++, 0.5, 0.5, 0.0); // That constant rotation i was talking about
update();
}