lClearColor(1.0,1.0,1.0,0.1);//仅仅设置清屏颜色,并不实际执行操作,是一个状态值
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//把颜色缓存清为glClearColor()设置的颜色,颜色缓存指的是整个屏幕,不是指的视口,是一个动作
glViewport(0, 0, 100, 100);
glBegin(GL_LINES);
glColor3f(0.0, 0.0, 1.0);
glVertex3d(-500.0, -500.0, 0.0);
glVertex3d(500, 500, 0);
glEnd();
glViewport(200, 0,100, 100);
glMatrixMode(GL_MODELVIEW);//第二设置视口的时候,不能设置glClear(GL_COLOR_BUFFER_BIT),不则会把上一个视口的颜色清掉
glLoadIdentity();
glBegin(GL_LINES);
glColor3f(0.0, 1.0, 1.0);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(500, 500, 0);
glEnd();
SwapBuffers(pDC->m_hDC);
glFlush();
glClearColor(1.0,1.0,1.0,0.1);//必需放在glClear(GL_COLOR_BUFFER_BIT)前,否则glClera()用默认的黑色
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, 100, 100);
glBegin(GL_LINES);
glColor3f(0.0, 0.0, 1.0);
glVertex3d(-500.0, -500.0, 0.0);
glVertex3d(500, 500, 0);
glEnd();
glViewport(200, 0,100, 100);
glEnable(GL_SCISSOR_TEST); //打开剪切测试,其它的一切操作,如清屏都在这个范围内进行
glScissor(200, 0, 100, 100);
glClearColor(1.0, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST); //打开深度测试,默认关闭
glClearDepth(1.0); //清空颜色设置在glClear(GL_DEPTH_BUFFER_BIT)前,否则用默认颜色。
glClear(GL_DEPTH_BUFFER_BIT);
glDepthFunc(GL_GREATER); //深度测试函数
glBegin(GL_LINES);
glColor3f(0.0, 1.0, 1.0);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(500, 500, 0);
glEnd();
SwapBuffers(pDC->m_hDC);
glFlush();