作業一:
到網址:jsyeh.org/3dcg10 下載[data] [win32] [glut32.dll]解壓縮後開啟shapes
右邊點選右鍵可更改圖案










右邊可調整點的位置和顏色

作業二:
程式碼
#include<GL/glut.h> //標頭檔
void display()
{
glBegin(GL_POLYGON);
glColor3f(1,1,0);//顏色
glVertex3f(0.0,0.0,0.0);
glVertex3f(1.0,0.0,0.0);
glVertex3f(1.0,1.0,0.0);
glEnd();
//glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc, argv); //引入程式
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH); //雙視窗
glutCreateWindow("hello 3D"); //視窗名稱
glutDisplayFunc(display); //展示
glutMainLoop();
}
作業三:
用小畫家幫忙查作標
作業四:
利用mosue點座標 印出程式碼
程式碼:
#include <Gl/glut.h>
#include <stdio.h>
void mouse(int button, int state, int x, int y)
{
if(state==GLUT_DOWN)
printf("glVertex3f((%d-150)/150.0 ,-(%d-150)/150.0, 0.0);\n", x, y);
}
void display()
{
glClearColor(152/255.0, 100/255.0, 222/255.0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3ub(192, 215, 107);
glVertex3f((95-100)/100.0,-(49-100)/100.0, 0.0);
glVertex3f((17-100)/100.0,-(106-100)/100.0, 0.0);
glVertex3f((93-100)/100.0,-(165-100)/100.0, 0.0);
glVertex3f((174-100)/100.0,-(103-100)/100.0, 0.0);
glEnd();
glBegin(GL_POLYGON);
glVertex3f((38-150)/150.0 ,-(22-150)/150.0, 0.0);
glVertex3f((41-150)/150.0 ,-(57-150)/150.0, 0.0);
glVertex3f((110-150)/150.0 ,-(63-150)/150.0, 0.0);
glVertex3f((114-150)/150.0 ,-(27-150)/150.0, 0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("hello");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}



沒有留言:
張貼留言