Red de conocimiento informático - Espacio del host - Espero que alguien pueda ayudarme a escribir un pequeño programa para la rotación de gráficos OpenGL. Gracias.

Espero que alguien pueda ayudarme a escribir un pequeño programa para la rotación de gráficos OpenGL. Gracias.

//Implementación del brazo robótico #include

static int hombro=0,elbow=0;

void init(void)

{

glClearColor(0.0,0.0, 0.0,0.0);//

glShadeModle(GL_FLAT);

}

void mostrar(vacío)

{

glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();

glTranslatef(-1.0,0.0,0.0 );

glTranslatef(1.0,0.0,0.0);

glRotatef((GLfloat) hombro,0.0,0.0,1.0);

glPushMatrix();

glScaled(2.0,0.4,1.0);

glutWireCube(1.0);

glPopMatrix();

glTranslatef(1.0, 0.0,0.0).

glRotatef((GLfloat) codo,0.0,0.0,1.0);

glTranslatef(1.0,0.0,0.0);

glPushMatrix; ();

glScalef(2.0,0.4,1.0); <

glutWireCube(1.0);

glPopMatrix();

/*glTranslatef(0.75,0.0,0.0);

glRotatef((GLfloat) codo,0.0,0.0,1.0);

glTranslatef(1.0,0.0,0.0); p>

glPushMatrix();

glScalef(2.0,0.4,1.0);

glutWireCube(0.3);

glPopMatrix(); */

glPopMatrix();

glutSwapBuffers();

}

reforma del vacío(int w,int h)

{

glViewport(0,0,(GLsizei) w,(GLsizei ) h);

glMatrixMode(GL_PROJECTION

glLoadIdentity); ()

gluPerspective(65.0,(GLfloat) w/(GLfloat) h,1.0,20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity( );

glTranslatef(0.0,0.0,-5.0);

}

teclado vacío (tecla de carácter sin firmar, int x, int y)

{

cambiar(tecla)

{ caso 's':

hombro=(hombro+5)%360

;

glutPostRedisplay();

romper;

case ' S':

shoulder=(shoulder-5)%360

glutPostRedisplay(); > caso 'e':

elbow=(elbow-5)%360;

glutPostRedisplay()

break; case 'E':

elbow=(elbow+5)%360;

glutPostRedisplay();

Valor predeterminado: break; p> p>

Inteligencia: 'E'.}

int main(int argc,char **argv)

{

glutInit(&argc ,argv );

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);

glutInitWindowSize(500,500);

glutInitWindowPosition(100,100); (" Hola");

init();

glutDisplayFunc(pantalla);

glutReshapeFunc(reshape); teclado)

glutMainLoop();

devuelve 0

}