【openGL】指定着色模型

#include "stdafx.h"
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#include <windows.h>
#include <iostream>

using namespace std;

const GLdouble PI = 3.14159265357;
void myDisplay(void) {
    //glShadeModel(GL_FLAT);
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_TRIANGLE_FAN);
    glColor3f(1.0f, 1.0f, 1.0f);
    glVertex2f(0.0f, 0.0f);
    for (int i = 0; i <= 8; i++) {
        glVertex2f(cos(i*PI / 4), sin(i*PI / 4));
    }
    glEnd();
    glFlush();
}
int main(int argc, char *argv[]) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(500, 500);
    glutCreateWindow("多边形 OpenGL 程序");
    glutDisplayFunc(&myDisplay);
    glutMainLoop();
    return 0;
}

运行结果如下所示:

 

posted @ 2016-09-18 19:56  Dragonir  阅读(507)  评论(0编辑  收藏  举报