老師的

我的

#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("05160133_week03 good goood!");
glutDisplayFunc(display);
glutMainLoop();
}
2.加背景顏色

#include <GL/glut.h>
void display()
{
glClearColor(1,1,0,1);//////////////
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0);//////////////////
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("05160133_week03 good goood!");
glutDisplayFunc(display);
glutMainLoop();
}
3.加入Mouse不需靠小畫家
左0 中1 右2 滑鼠對應其數字
把冰箱門打開 把冰箱門關起來
冷笑話~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include <GL/glut.h>
void display()
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
/*#include <stdio.h>
void mouse(int button,int state,int x,int y)
{
if(state==GLUT_DOWN)printf("glVertex2f(%f, %f);\n",(x-150)/150.0,-(y-150)/150.0);
}*/
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("05160133_week03 good goood!");
glutDisplayFunc(display);
/*glutMouseFunc(mouse);*/
///glutMotionFunc(motion);
glutMainLoop();
}
大象移到冰箱裡的步驟
冷笑話~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include <GL/glut.h>
/*float teapotX=0,teapotY=0;*/
void display()
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* glPushMatrix();
glTranslatef(teapotX,teapotY,0);
glutSolidTeapot(0.3);
glPopMatrix();*/
glutSwapBuffers();
}
#include <stdio.h>
void mouse(int button,int state,int x,int y)
{
if(state==GLUT_DOWN)printf("glVertex2f(%f, %f);\n",(x-150)/150.0,-(y-150)/150.0);
}
/*void motion(int x,int y)
{
teapotX=(x-150)/150.0;
teapotY=-(y-150)/150.0;
printf("%d %d\n",x,y);
glutPostRedisplay();
}*/
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("05160133_week03 good goood!");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutMainLoop();
}
5.
google 地圖
沒有留言:
張貼留言