#include<GL/glut.h>
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.8,0.8,0);
glRotatef(rot,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void idle()
{
rot++;
display();
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("00160760");
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}
#include<GL/glut.h>
float rot=0;
void myCar()
{
glPushMatrix();
glScalef(1,0.2,0.5);
glColor3f(1,1,0);
glutSolidCube(1);
glColor3f(1,0,0);
glutWireCube(1);
glPopMatrix();
}
void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(-20,1,0,0);
glRotatef(rot,0,1,0);
myCar();
glPopMatrix();
glutSwapBuffers();
}
void idle()
{
rot++;
display();
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("00160760");
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}
#include<GL/glut.h>
float rot=0;
void myBox()
{
glPushMatrix();
glScalef(1,0.2,0.5);
glColor3ub(78,69,62);
glutSolidCube(1);
glColor3f(1,0,0);
glutWireCube(1);
glPopMatrix();
}
void myBot()
{
for(int i=-10;i<10;i++)
{
glPushMatrix();
glTranslatef(0,-0.2*i,0);
glRotatef(i*rot,0,0,1);
myBox();
glPopMatrix();
}
}
void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(-20,1,0,0);
glRotatef(rot,0,1,0);
myBot();
glPopMatrix();
glutSwapBuffers();
}
void idle()
{
rot+=0.1;
display();
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("00160760");
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}
沒有留言:
張貼留言