2020年3月11日 星期三

02

刪掉原先的程式碼
打上新的程式碼

#include <GL/glut.h>
void display()
{
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week02");
    glutDisplayFunc(display);
    glutMainLoop();
}



改顏色

#include <GL/glut.h>
void display()
{
    glColor3f(1,0,0);       ←***新增這行***
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week02");
    glutDisplayFunc(display);
    glutMainLoop();
}





點線面

#include <GL/glut.h>
void display()
{
    glBegin(GL_POLYGON);
        glColor3f(1,0,0);glVertex2f(1,0);
        glColor3f(0,1,0);glVertex2f(-1,1);
        glColor3f(0,0,1);glVertex2f(-1,-1);
    glEnd();
    glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week02");
    glutDisplayFunc(display);
    glutMainLoop();
}



















沒有留言:

張貼留言