ayuda en OpenGl por favor 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. |