首页 > 代码库 > 【openGL】指定着色模型

【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;}

运行结果如下所示:

技术分享

 

【openGL】指定着色模型