The code to draw a table is below. I want the same figure to be displayed in multiple viewports with in a window.
#include "stdafx.h"
#include <windows.h>
#include <GL/glut.h>
static float x = 0.0, z = 0.0;
void init(void){
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
}
void reshape(int w, int h){
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-20.0, 20.0, -20.0, 20.0, -10.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void table(){
glTranslatef(x,-2.5,z);
glScalef(1.0,3.0,1.0);
glutWireCube(1.0);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glLoadIdentity();
gluLookAt(6.0, 1.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0);
glPushMatrix();
glScalef(8.0, 1.0, 8.0);
glutWireCube(2.0);
glPopMatrix();
glPushMatrix();
x = -6.0; z = -6.0;
table();
glPopMatrix();
glPushMatrix();
x = 6.0; z = -6.0;
table();
glPopMatrix();
glPushMatrix();
x = -6; z = 6.0;
table();
glPopMatrix();
glPushMatrix();
x = 6; z = 6.0;
table();
glPopMatrix();
glPopMatrix();
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}