OpenGL绘制框架

#include <windows.h>    // Windows的头文件

#include <gl\gl.h> // OpenGL32库的头文件
#include <gl\glu.h> // GLu32库的头文件
#include <gl\glaux.h> // GLaux库的头文件
#include <gl\glut.h> // Glut库头文件

#pragma comment( lib, "opengl32.lib") // OpenGL32连接库
#pragma comment( lib, "glu32.lib") // GLu32连接库
#pragma comment( lib, "glaux.lib") // GLaux连接库
#pragma comment( lib, "glut.lib") // Glut链接库

void myInit()
{
glClearColor(1.0,1.0,1.0,0.0); //设置背景颜色为亮白
glColor3f(0.0f,0.0f,0.0f); //设置绘图颜色为黑色
glPointSize(4.0); //设置点的大小为4*4像素
glMatrixMode(GL_PROJECTION); //设置合适的矩阵
glLoadIdentity();
gluOrtho2D(0.0,640,0.0,480.0);

}

void myDisplay()
{
glClear(GL_COLOR_BUFFER_BIT); //清屏
glBegin(GL_POINTS);
glVertex2i(100,50); //画一些点
glVertex2i(100,130);
glVertex2i(150,130);
glVertex2i(320,240);
glEnd();
glFlush(); //送所有输出到显示设备
}

void main(int argc, char **argv)
{
glutInit(&argc,argv); //初始化工具包
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//设置显示模式
glutInitWindowSize(640,480); //设置窗口大小
glutInitWindowPosition(100,150); //设置窗口在屏幕上的位置
glutCreateWindow("my first attempt"); //打开屏幕窗口

//注册回调函数
glutDisplayFunc(myDisplay);

myInit();
glutMainLoop(); //进入循环
}
原文地址:https://www.cnblogs.com/tiandsp/p/2328325.html