從網址下載: sorce , date , win32 ,glut32.dll ( jsyeh.org/3dcg10 )
解壓縮win32
把 data 打開,將裡面的資料夾複製到上面解壓縮後的window32資料夾
再將 glut32.dll 移至window32資料夾
執行Shapes
右鍵可選擇
LINES
TRIANGLES
LINES_LOOP
TRIANGLES_FAN
TRIANGLES_STRIP
QUADS
QUADS_STRIP
POLYGON
課堂作業2
寫個三角形
code:
#include <GL/glut.h>
void display()
{
glClearColor(10, 0.5, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(1, 0, 0); glVertex3f(-1.0, 0.0, 0.0);
glColor3f(0, 1, 0); glVertex3f(1.0, -1.0, 0.0);
glColor3f(0, 0, 1); glVertex3f(1.0, 1.0, 0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMainLoop();
}
課堂作業3
小畫家幫你查color,座標
code:
#include <GL/glut.h>
void display()
{
glClearColor(10, 0.5, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(1, 0, 0);
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();
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMainLoop();
}
課堂作業4
用mouse點座標,印出程式碼
code:
#include <GL/glut.h>
#include <stdio.h>
void mouse(int botton, 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(10, 0.5, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(1, 0, 0);
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);
glColor3f(1, 0, 0);
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();
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}














沒有留言:
張貼留言