2016年3月7日 星期一

BOZC Week03

课堂作业:


1.打开CODEBLOCKS




2.创建OPENGL档案


3.资料夹路径设置为->桌面的freeglut资料夹

4.在main.cpp中写下code

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

    glutDisplayFunc(display);
    glutMainLoop();
}

5.结束build and run



PS


vertex:顶点

glColor3f(x,y,z) 设置颜色

glvertex2f(x,y) 设置顶点坐标

网站上图片使用小画家可以取色 (RGU) and 查坐标

操作过程如下:













沒有留言:

張貼留言