机器人的胳膊
#include<GL/>
static int shoulder=0,elbow=0;
void init(void){
glClearColor(,,,); glShade机器人的胳膊
#include<GL/>
static int shoulder=0,elbow=0;
void init(void){
glClearColor(,,,); glShadeModel(GL_FLAT);
}
void display(void){
glClear(GL_COLOR_BUFFER_BIT); glPushMatrix();
glTranslatef(-,,); glRotatef((GLfloat) shoulder,,,);
glTranslatef(,,); glPushMatrix();
glScalef(,,);
glutWireCube();
glPopMatrix();
glTranslatef(,,); glRotatef((GLfloat) elbow,,,);
glTranslatef(,,); glPushMatrix();
glScalef(,,);
glutWireCube();
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void reshape(int w,int h){ glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION); glLoadIdentity();
gluPerspective(,(GLfloat)w/(GLfloat)h,,);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
glTranslatef(,,-); }
void keyboard(unsigned char key,int x,int y){
switch(key)
{
case 's':
shoulder=(shoulder +5)%360;
glutPostRedisplay();
break;
case 'S':
shoulder=(shoulder - 5)%360;
glutPostRedisplay()
机器人的胳膊 来自淘豆网www.taodocs.com转载请标明出处.