// aaaa.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "gl/glut.h"
void init(void)
{glClearColor(1.0,1.0,1.0,0.0);
//窗口的背景颜色设置为白色
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,200.0,0.0,150.0);
}
void lineSegment(void)
{
glClear(GL_COLOR_BUFFER_BIT); //赋值的窗口显示.
glColor3f(1.0,0.0,0.0); //设置直线的颜色红色
glBegin(GL_LINES);
glVertex2i(180,15); //Specify line-segment geometry.
glVertex2i(10,145);
glEnd();
glFlush(); //Process all OpenGL routines as quickly as possible.
}
void main(int argc,char* argv)
{
glutInit(&argc,&argv); //I初始化 GLUT.
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //设置显示模式:单个缓存和使用RGB模型
glutInitWindowPosition(50,100); //设置窗口的顶部和左边位置
glutInitWindowSize(400,300); //设置窗口的高度和宽度
glutCreateWindow("An Example OpenGL Program"); //创建显示窗口
init(); //调用初始化过程
glutDisplayFunc(lineSegment); //图形的定义传递给我window.
glutMainLoop(); //显示所有的图形并等待
}