https://blog.csdn.net/smilife_/article/details/89010423
#include <windows.h>
#include <stdio.h>
#include <GL/freeglut.h>
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(300, 300);
glutInitWindowPosition(100, 100);
glutCreateWindow("OpenGL Version");
const GLubyte* name = glGetString(GL_VENDOR);
const GLubyte* biaoshifu = glGetString(GL_RENDERER);
const GLubyte* OpenGLVersion = glGetString(GL_VERSION);
const GLubyte* gluVersion = gluGetString(GLU_VERSION);
printf("OpenGL实现厂商的名字:%s\n", name);
printf("渲染器标识符:%s\n", biaoshifu);
printf("OOpenGL实现的版本号:%s\n", OpenGLVersion);
printf("OGLU工具库版本:%s\n", gluVersion);
system("pause");
return 0;
}
#include <windows.h>
#include <GL/freeglut.h>
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0, 0);
static float sc = 1.0;
glRectf(-0.5f*sc, -0.5f*sc, 0.5f*sc, 0.5f*sc);
sc = sc *1.01;
glFlush();
}
void timerProc(int id)
{
myDisplay();
glutTimerFunc(33, timerProc, 1);//需要在函数中再调用一次,才能保证循环
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("第一个OpenGL程序");
glutDisplayFunc(&myDisplay);
glutTimerFunc(33, timerProc, 1);
glutMainLoop();
return 0;
}