+ {\r
+ glutSetWindow(nWindow);\r
+ printf("main window resize\n");\r
+ if (glutGet(GLUT_WINDOW_WIDTH)<400)\r
+ glutReshapeWindow(600,300);\r
+ else\r
+ glutReshapeWindow(300,300);\r
+ }\r
+\r
+ break;\r
+\r
+\r
+ case 'm':\r
+ case 'M':\r
+ if (nChildWindow!=-1 && cChar=='m') /* Capital M always moves the main window*/\r
+ {\r
+ glutSetWindow(nChildWindow);\r
+ /* The window position you request is relative to the top-left\r
+ * corner of the client area of the parent window.\r
+ */\r
+ if (!bChildPosDone)\r
+ glutPositionWindow(glutGet(GLUT_WINDOW_X)+50,glutGet(GLUT_WINDOW_Y)+50);\r
+ else\r
+ glutPositionWindow(glutGet(GLUT_WINDOW_X)-50,glutGet(GLUT_WINDOW_Y)-50);\r
+ bChildPosDone = !bChildPosDone;\r
+ }\r
+ else\r
+ {\r
+ glutSetWindow(nWindow);\r
+ printf("main window position\n");\r
+ /* The window position you request is the outer top-left of the window,\r
+ * the client area is at a different position if the window has borders\r
+ * and/or a title bar.\r
+ */\r
+ if (glutGet(GLUT_WINDOW_X)<400)\r
+ glutPositionWindow(600,300);\r
+ else\r
+ glutPositionWindow(300,300);\r
+ }\r
+\r
+ break;\r
+\r
+\r
+ case 'd':\r
+ case 'D':\r
+ if (nChildWindow!=-1 && cChar=='d') /* Capital D always moves+resizes the main window*/\r
+ {\r
+ glutSetWindow(nChildWindow);\r
+ if (!bChildPosDone)\r
+ glutPositionWindow(glutGet(GLUT_WINDOW_X)+50,glutGet(GLUT_WINDOW_Y)+50);\r
+ else\r
+ glutPositionWindow(glutGet(GLUT_WINDOW_X)-50,glutGet(GLUT_WINDOW_Y)-50);\r
+ bChildPosDone = !bChildPosDone;\r
+ if (!bChildSizeDone)\r
+ glutReshapeWindow(glutGet(GLUT_WINDOW_WIDTH)+50,glutGet(GLUT_WINDOW_HEIGHT)+50);\r
+ else\r
+ glutReshapeWindow(glutGet(GLUT_WINDOW_WIDTH)-50,glutGet(GLUT_WINDOW_HEIGHT)-50);\r
+ bChildSizeDone = !bChildSizeDone;\r
+ }\r
+ else\r
+ {\r
+ if (glutGet(GLUT_WINDOW_X)<400)\r
+ glutPositionWindow(600,300);\r
+ else\r
+ glutPositionWindow(300,300);\r
+ if (glutGet(GLUT_WINDOW_WIDTH)<400)\r
+ glutReshapeWindow(600,300);\r
+ else\r
+ glutReshapeWindow(300,300);\r
+ }\r
+ break;\r
+\r
+\r
+ case 'c':\r
+ case 'C':\r
+ if (nChildWindow==-1)\r
+ {\r
+ int width = glutGet(GLUT_WINDOW_WIDTH);\r
+ int height = glutGet(GLUT_WINDOW_HEIGHT);\r
+\r
+ /* open child window */\r
+ printf("open child window\n");\r
+\r
+ nChildWindow = glutCreateSubWindow(nWindow,(int)(width*.35),(int)(height*.35),(int)(width*.3),(int)(height*.3));\r
+ glutKeyboardFunc( SampleKeyboard );\r
+ glutDisplayFunc( Redisplay );\r
+ glutReshapeFunc( Reshape );\r
+ glutPositionFunc( Position );\r
+ glutWindowStatusFunc( WindowStatus );\r
+ }\r