OpenGL多视口

#include <gl/glew.h>
#include <gl/freeglut.h>
#include <iostream> int window_width = ;
int window_height = ;
float rtri = 0.0;
float rquad = 0.0;
void init();
void display();
void resize(int w, int h);
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowSize(, );
glutCreateWindow("OpenGL");
GLenum res = glewInit();
if (res != GLEW_OK)
{
std::cout << glewGetErrorString(res) << std::endl;
} init();
glutDisplayFunc(display);
glutReshapeFunc(resize);
glutMainLoop();
return EXIT_SUCCESS;
} void init()
{
glClearColor(0.0, 0.0, 0.0, 1.0);
} void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
for (int loop = ; loop < ; ++loop)
{
if ( == loop)
{
glViewport(, , window_width/, window_height/);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-, , -, );
}
if ( == loop)
{
glViewport(window_width/, , window_width, window_height/);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-, , -, );
}
if ( == loop)
{
glViewport(, window_height/, window_width/, window_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-, , -, );
}
if ( == loop)
{
glViewport(window_width/, window_height/, window_width, window_height) ;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-, , -, );
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_DEPTH_BUFFER_BIT);
if ( == loop)
{
glBegin(GL_QUADS);
glVertex2f(-, -);
glVertex2f(, -);
glVertex2f(, );
glVertex2f(-, );
glEnd();
}
if ( == loop)
{
glBegin(GL_QUADS);
glVertex2f(-, -);
glVertex2f(, -);
glVertex2f(, );
glVertex2f(-, );
glEnd();
}
if ( == loop)
{
glBegin(GL_QUADS);
glVertex2f(-, -);
glVertex2f(, -);
glVertex2f(, );
glVertex2f(-, );
glEnd();
}
if ( == loop)
{
glBegin(GL_QUADS);
glVertex2f(-, -);
glVertex2f(, -);
glVertex2f(, );
glVertex2f(-, );
glEnd();
}
}
glutSwapBuffers();
} void resize(int w, int h)
{
window_height = h;
window_width = w;
}

OpenGL多视口

上一篇:PostgreSQL Replication之第九章 与pgpool一起工作(6)


下一篇:CentOS配置VSFTP服务器