说明
gluOrtho2D(0.0, WINDOWWIDTH , WINDOWHEIGHT/2, 0.0);第三个参数取其一半,打点的Y坐标扩大了一倍.渲染直线的情况下,通过将第二参数和第三参数进行按比例尺放缩,实际上,可达到渲染图形缩放的效果。所以gluOrtho2D函数定义了屏幕坐标多少个单位像素表示投影矩阵的单位一
代码
#include <gl/glut.h>
#include <Windows.h>
#define WINDOWHEIGHT 480
#define WINDOWWIDTH 800
void myInit()
{
glClearColor(1.0,1.0,1.0,0.0);
glLineWidth(3.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//gluOrtho2D(0.0, WINDOWWIDTH, 0.0, WINDOWHEIGHT);
gluOrtho2D(0.0, WINDOWWIDTH , WINDOWHEIGHT/2, 0.0);
}
void myDisplay(void)
{
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
}
void myMouse(int button,int state,int x,int y)
{
if(state==GLU