2020年3月10日 星期二

Week02

複習上週OpenGL:
劃出茶壺:











程式碼:
#include <GL/glut.h>
void display()
{
    glColor3ub(100,100,255);//調整顏色
    glutWireTeapot(0.3);
    glutSwapBuffers();
}

int main(int argc,char**argv)
{
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
  glutCreateWindow("week02 Yes!!!");

  glutDisplayFunc(display);

  glutMainLoop();
}


畫一個點or線or面:












程式碼:
#include <GL/glut.h>
void display()
{
    glBegin(GL_QUADS);//調整形狀
        glColor3f(1,0,0); glVertex2f(1,0);//顏色與點的位置
        glColor3f(0,1,0); glVertex2f(0,1);
        glColor3f(0,0,1); glVertex2f(-1,0);
        glColor3f(1,1,1); glVertex2f(0,-1);
    glEnd();
    glutSwapBuffers();
}

int main(int argc,char**argv)
{
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
  glutCreateWindow("week02 Yes!!!");

  glutDisplayFunc(display);

  glutMainLoop();
}

沒有留言:

張貼留言