1.使用範例檔
http://jsyeh.org/3dcg10 下載data,win32,glut32.dll檔案
打開範例檔,自由調整旁邊數值呈現不同的顏色圖形。
2.複習茶壺(改變顏色)
#include <GL/glut.h>
static void display(void)
{
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc,chat *argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}
3.畫三角形
#include <GL/glut.h>
static void display(void)
{
glBegin(GL_POLYGON);
glColor3f(1,0,0);
glVertex3f(0,0,0);
glColor3f(0,1,0);
glVertex3f(1,1,0);
glColor3f(0,1,0);
glVertex3f(-1,1,0);
glEnd();
//glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc,chat *argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}
沒有留言:
張貼留言