windows.zip,glut32.dll,data.zip
2.把data跟glut32.dll放進windows
3.然後到http://www.transmissionzero.co.uk/software/freeglut-devel/下載freeglut
把freeglut裡面的libfreeglut copy為libglut32
4.開codeblocks開啟專案選freeglut
把freeglut的路徑貼上
5.把開視窗的程式碼打好
(WEEK3重點)7.用glClear(GL_COLOR_BUFFER_BIT)做背景顏色
(WEEK3重點)8.用glBegin(GL_POLYGON)多邊型函式跟glClear配合做出一個有顏色的圖型.
#include <GL/glut.h>
void display()
{
glClearColor(1,1,1,1); //背景
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON); //多邊形
glColor3f(1 ,1 ,0 ); //顏色
glVertex2f(0,0);
glVertex2f(1,0);
glVertex2f(0,1);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1,0,0);
glVertex2f(0,0);
glColor3f(0,1,0);
glVertex2f(-1,0);
glColor3f(0,0,1);
glVertex2f(0,-1);
glEnd();
/*glColor3f(1,0,0);
glutSolidTeapot(0.5);
glColor3f(0,1,0);
glutSolidTeapot(0.4);
glColor3f(0,0,1);
glutSolidTeapot(0.3);*/
glFlush();
}
int main(int argc,char **argv) //主程式
{
glutInit(&argc,argv);
glutCreateWindow("02160792");
glutDisplayFunc(display); //呼叫函式
glutMainLoop();
}
沒有留言:
張貼留言