resizer demo now uses timer to display window information
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1479 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
6badc4e20a
commit
9db85cd9b3
@ -50,7 +50,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
|
|||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'R':
|
case 'R':
|
||||||
if (nChildWindow!=-1)
|
if (nChildWindow!=-1 && cChar=='r') /* Capital R always resizes the main window*/
|
||||||
{
|
{
|
||||||
glutSetWindow(nChildWindow);
|
glutSetWindow(nChildWindow);
|
||||||
printf("child window resize\n");
|
printf("child window resize\n");
|
||||||
@ -62,6 +62,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
glutSetWindow(nWindow);
|
||||||
printf("main window resize\n");
|
printf("main window resize\n");
|
||||||
if (nWidth<400)
|
if (nWidth<400)
|
||||||
glutReshapeWindow(600,300);
|
glutReshapeWindow(600,300);
|
||||||
@ -74,10 +75,9 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
|
|||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
case 'M':
|
case 'M':
|
||||||
if (nChildWindow!=-1)
|
if (nChildWindow!=-1 && cChar=='m') /* Capital M always moves the main window*/
|
||||||
{
|
{
|
||||||
glutSetWindow(nChildWindow);
|
glutSetWindow(nChildWindow);
|
||||||
|
|
||||||
/* The window position you request is relative to the top-left
|
/* The window position you request is relative to the top-left
|
||||||
* corner of the client area of the parent window.
|
* corner of the client area of the parent window.
|
||||||
*/
|
*/
|
||||||
@ -89,8 +89,8 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
glutSetWindow(nWindow);
|
||||||
printf("main window position\n");
|
printf("main window position\n");
|
||||||
|
|
||||||
/* The window position you request is the outer top-left of the window,
|
/* The window position you request is the outer top-left of the window,
|
||||||
* the client area is at a different position if the window has borders
|
* the client area is at a different position if the window has borders
|
||||||
* and/or a title bar.
|
* and/or a title bar.
|
||||||
@ -174,8 +174,28 @@ void Redisplay(void)
|
|||||||
{
|
{
|
||||||
int win = glutGetWindow();
|
int win = glutGetWindow();
|
||||||
|
|
||||||
if (nLoopMain++%20==0)
|
if (win==nWindow)
|
||||||
{
|
{
|
||||||
|
glClearColor(.2f,0.f,0.f,0.f);
|
||||||
|
glColor3f(1,1,1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* child window */
|
||||||
|
glClearColor(.0f,.2f,0.f,0.f);
|
||||||
|
glColor3f(.5,.5,.5);
|
||||||
|
glutPostWindowRedisplay(nWindow);
|
||||||
|
}
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
DrawQuad();
|
||||||
|
|
||||||
|
glutSwapBuffers();
|
||||||
|
glutPostWindowRedisplay(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer(int unused)
|
||||||
|
{
|
||||||
|
int win = glutGetWindow();
|
||||||
int border, caption;
|
int border, caption;
|
||||||
|
|
||||||
nPosX = glutGet(GLUT_WINDOW_X);
|
nPosX = glutGet(GLUT_WINDOW_X);
|
||||||
@ -205,25 +225,9 @@ void Redisplay(void)
|
|||||||
printf("child window %dx%d, top-left of client at: (%d,%d), relative to parent\n",
|
printf("child window %dx%d, top-left of client at: (%d,%d), relative to parent\n",
|
||||||
nWidth, nHeight,
|
nWidth, nHeight,
|
||||||
nPosX ,nPosY);
|
nPosX ,nPosY);
|
||||||
}
|
|
||||||
|
|
||||||
if (win==nWindow)
|
/* (re)set the timer callback and ask glut to call it in 1 second */
|
||||||
{
|
glutTimerFunc(300, Timer, 0);
|
||||||
glClearColor(.2f,0.f,0.f,0.f);
|
|
||||||
glColor3f(1,1,1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* child window */
|
|
||||||
glClearColor(.0f,.2f,0.f,0.f);
|
|
||||||
glColor3f(.5,.5,.5);
|
|
||||||
glutPostWindowRedisplay(nWindow);
|
|
||||||
}
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
DrawQuad();
|
|
||||||
|
|
||||||
glutSwapBuffers();
|
|
||||||
glutPostWindowRedisplay(win);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -254,6 +258,8 @@ int main(int argc, char* argv[])
|
|||||||
glutReshapeFunc( Reshape );
|
glutReshapeFunc( Reshape );
|
||||||
glutPositionFunc( Position );
|
glutPositionFunc( Position );
|
||||||
|
|
||||||
|
glutTimerFunc(300, Timer, 0);
|
||||||
|
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
printf("glutMainLoop returned\n");
|
printf("glutMainLoop returned\n");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user