重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
说明
在南乐等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站设计、做网站 网站设计制作定制设计,公司网站建设,企业网站建设,品牌网站建设,成都全网营销推广,外贸营销网站建设,南乐网站建设费用合理。
gluOrtho2D(0.0, WINDOWWIDTH , WINDOWHEIGHT/2, 0.0);第三个参数取其一半,打点的Y坐标扩大了一倍.渲染直线的情况下,通过将第二参数和第三参数进行按比例尺放缩,实际上,可达到渲染图形缩放的效果。所以gluOrtho2D函数定义了屏幕坐标多少个单位像素表示投影矩阵的单位一
代码
#include
#include
#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==GLUT_DOWN)
{
glPointSize(10);
glBegin(GL_POINTS);
glColor3f(1.0f, 0.0f, 0.0f);
//glVertex2f(x, WINDOWHEIGHT-y);
glVertex2f(x, y);
glEnd();
glFlush();
}
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
glutInitWindowSize(WINDOWWIDTH, WINDOWHEIGHT);
glutInitWindowPosition(100,150);
glutCreateWindow("OpenGL 窗口1");
glutDisplayFunc(&myDisplay);
glutMouseFunc(&myMouse);
myInit();
glutMainLoop();
return 0;
}
代码2
#include
#include
#define WINDOWHEIGHT 480
#define WINDOWWIDTH 800
void myInit(int scale)
{
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, WINDOWWIDTH/scale , WINDOWHEIGHT/scale, 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)
{
static int scale = 2;
if(state==GLUT_DOWN)
{
myInit(scale);
scale = scale + 2;
glLineWidth(10);
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(10, 10);
glVertex2f(20, 20);
glEnd();
glFlush();
}
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
glutInitWindowSize(WINDOWWIDTH, WINDOWHEIGHT);
glutInitWindowPosition(100,150);
glutCreateWindow("OpenGL 窗口1");
glutDisplayFunc(&myDisplay);
glutMouseFunc(&myMouse);
glutMainLoop();
return 0;
}