2018年3月9日 星期五

week02畫茶壺

第一個茶壺圖
#include <stdio.h>
#include <GL/glut.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();


}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE);
    glutCreateWindow("Week02 Hello World Triangle");
    glutDisplayFunc(display);
    glutMainLoop();
}

 

第2步補上茶壺背景顏色
void display()
{
    glClearColor(225/255.0,180/255.0,20/255.0, 1);這邊選用土黃當背景。
    glClear(GL_COLOR_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();


}
第3改變茶壺本身顏色
void display()
{
    glClearColor(225/255.0,180/255.0,20/255.0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
    glColor3ub(180,19,233);選用紫色來當茶壺顏色

}

沒有留言:

張貼留言