Open GL - minimizo y las rotaciones desaparecen

 
Vista:

minimizo y las rotaciones desaparecen

Publicado por jose godoy (3 intervenciones) el 06/03/2007 14:59:09
hola, por favor ayudenme:
para este codigo:

SI LES DA FLOJERA LEER EL CODIGO, LO UNICO IMPORTANTE, Y DONDE ESTA EL ERROR, ES EN LA FUNCION void reshape(), ASI QUE LEAN ESA SOLAMENTE

#include <conio.h>
#include <GL/glut.h>
#include <stdio.h>

void keyboard(unsigned char key, int x, int y) {
switch (key) {
case 'h':
printf("help\n\n");
printf("c - Toggle culling\n");
printf("q/escape - Quit\n\n");
break;
case 'c':
if (glIsEnabled(GL_CULL_FACE))
glDisable(GL_CULL_FACE);
else
glEnable(GL_CULL_FACE);
break;
case '4':
glRotatef(1.0,1.,0.,0.);
break;
case '2':
glRotatef(1.0,0.,1.,0.);
break;
case '1':
glRotatef(1.0,0.,0.,1.);
break;

case 'q':
case 27:
exit(0);
break;
}
glutPostRedisplay();

}

void reshape(int width, int height) {
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(height==0){height=1;}
if(width==0){width=1;}
gluPerspective(60.0, (GLfloat)height / (GLfloat)width, 1.0, 128.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 1.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);


}


void display(void) {
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glutWireTorus(0.25,0.75, 28, 28);
glColor3f(0.0,0.0,1.0) ;
glutWireCube(.60) ;

glutSwapBuffers();

}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(512, 512);
glutInitWindowPosition(20, 20);
glutCreateWindow("tecnunLogo");
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
//---------------------------------------------------------------------------

como comentario al ejecutar el codigo:
-al presionar c se activa o desactiva el GL_CULL_FACE
-al presionar 4 , 1 y 2 se rota la figura(un toroide con un cubo dentro de el) en torno a los ejes
-al presionar q se sale del programa

el error sucede cuando ejecuto el programa y roto la figura, luego minimizo, maximizo o reescalo la figura vuelve a estar como en el principio y pierde todas sus transformaciones.
En cambio si roto en torno a los ejes y solo muevo la ventana o la oculta(es decir, sin maximizar, minimizar o escalar) las transformaciones de la figura se mantiene.
POR FAVOR AYUDENME

GRACIASSS.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:minimizo y las rotaciones desaparecen

Publicado por Rick.Salvadoreño (8 intervenciones) el 05/05/2007 01:30:33
Hola.

Si, el problema esta en tú ReshapeFunc.

Eliminale esto:

gluLookAt(0.0, 1.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

Ah, y por cierto, el cambio del ViewPort:
glViewport(0, 0, width, height);

va despues de las comprobaciones de h == 0 y w == 0

Si lo haces al reves, no tiene sentido...

Lo que sucede es
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

minimizo y las rotaciones desaparecen

Publicado por Eduardo Márquez (1 intervención) el 25/02/2012 23:39:31
glutReshapeFunc(reshape);

cambia por

//glutReshapeFunc(reshape);

casi al ultimo y se soluciona ;)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar