一.
3.執行檔案
二.
1.前往http://www.transmissionzero.co.uk/software/freeglut-devel/,下載
freeglut 2.8.1 MinGW Package
2.Code Blocks 新增 GLUT 專案
3.複製 libfreeglut 改名為 libglut32
4.打上程式碼
#include <GL/glut.h>
void display();
int main (int argc,char *argv[])
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
glutMainLoop();
}
void display()
{
glColor3f(1,0,0);
glutSolidTeapot(0.5);
glColor3f(0,1,0);
glutSolidTeapot(0.4);
glColor3f(0,0,1);
glutSolidTeapot(0.3);
glFlush();
}
void display();
int main (int argc,char *argv[])
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
glutMainLoop();
}
void display()
{
glColor3f(1,0,0);
glutSolidTeapot(0.5);
glColor3f(0,1,0);
glutSolidTeapot(0.4);
glColor3f(0,0,1);
glutSolidTeapot(0.3);
glFlush();
}
5.執行程式
第二堂
1.接第一堂 二.5
在display加上程式碼,改變背景顏色
glClearColor(0.7, 0, 0.6, 1);
glClear(GL_COLOR_BUFFER_BIT);
2.執行程式
3.修改程式,看看效果
#include <GL/glut.h>
void display();
int main (int argc,char *argv[])
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
glutMainLoop();
}
void display()
{
glClearColor(0.7, 0, 0.6, 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();
glFlush();
}
沒有留言:
張貼留言