/* Demo to demonstrate the properties of vectors in 2-dimensional space */ #include #include #include #include #include #include #include "tw.h" #define GAP 25 /* gap between subwindows */ int leftWinWidth=400; int leftWinHeight=400; int rightWinWidth=400; int rightWinHeight=400; void parentDisplay(void) { twDisplayInit(); glFlush(); glutSwapBuffers(); } GLfloat aspectRatio(int w, int h) { return ((GLfloat) w) / ((GLfloat) h); } void leftDisplay(void) { twDisplayInit(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90,aspectRatio(leftWinWidth,leftWinHeight),2,6); // gluPerspective(90,1.94,0.7,4.2); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,4, 0,0,0, 0,1,0); twSetMessages(TW_ALL_MESSAGES); //twCamera(); twColorName(TW_MAGENTA); glutWireCube(1); glFlush(); glutSwapBuffers(); } void rightDisplay(void) { twDisplayInit(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(2*atan(2.0/22.0),aspectRatio(rightWinWidth,rightWinHeight),20,24); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,0, 0,0,-22, 0,1,0); twColorName(TW_YELLOW); glutWireCube(1); glFlush(); glutSwapBuffers(); } int parentWin, leftWin, rightWin; int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(leftWinWidth+rightWinWidth+GAP*3, leftWinHeight+GAP*2); //parent window parentWin = glutCreateWindow(argv[0]); glutDisplayFunc(leftDisplay); twBoundingBox(-1,1,-1,1,-1,1); // keeps twMainInit quiet twMainInit(); glutMainLoop(); return 0; }