Problem with multiple viewports with animation

I want to 2 Viewports on the screen. In first one, i have some animation and i am calling gluttimerFunc for this. In other viewport i have some text displayed which updates continuously with by calling gluttimerfunc. Now when I resize the window, i need to get updated height and width of a viewport from my reshape function. I have the separate modules of the program working fine. but i am not able to integrate it to see the animation with both the viewports.

I want to 2 Viewports on the screen. In first one, i have some animation and i am calling gluttimerFunc for this. In other viewport i have some text displayed which updates continuously with by calling gluttimerfunc. Now when I resize the window, i need to get updated height and width of a viewport from my reshape function. I have the separate modules of the program working fine. but i am not able to integrate it to see the animation with both the viewports.

Don't execute drawing commands outside of the display function. If you want animation, have a timer call glutPostRedisplay().

If both viewports are part of the same window, you have to redraw everything. glutSwapBuffers() applies to the entire window, not a region, and it leaves the contents of the back buffer undefined (so you have to call glClear() before drawing anything).

You can use glutCreateSubWindow() to create a separate subwindow with its own buffers, context etc. Note that you have to register display/reshape functions for the subwindow separately. Also, you need to use glutSetWindow() to ensure that functions such as glutPostRedisplay() affect the correct window (display/reshape callbacks already have the correct window active when they are called).

The OpenGL viewport specifies a transformation between clip coordinates and window coordinates. It doesn't establish a clipping rectangle. While geometry will be clipped to the frustum, rasterisation can extend beyond it (e.g. wide lines and points, and bitmaps can extend outside the viewport). Use glScissor() to set a clip rectangle.

Don't execute drawing commands outside of the display function. If you want animation, have a timer call glutPostRedisplay().

If both viewports are part of the same window, you have to redraw everything. glutSwapBuffers() applies to the entire window, not a region, and it leaves the contents of the back buffer undefined (so you have to call glClear() before drawing anything).

You can use glutCreateSubWindow() to create a separate subwindow with its own buffers, context etc. Note that you have to register display/reshape functions for the subwindow separately. Also, you need to use glutSetWindow() to ensure that functions such as glutPostRedisplay() affect the correct window (display/reshape callbacks already have the correct window active when they are called).

The OpenGL viewport specifies a transformation between clip coordinates and window coordinates. It doesn't establish a clipping rectangle. While geometry will be clipped to the frustum, rasterisation can extend beyond it (e.g. wide lines and points, and bitmaps can extend outside the viewport). Use glScissor() to set a clip rectangle.

This is a very good explanation.
Took me years to learn the stuff you've listed.

Don't execute drawing commands outside of the display function. If you want animation, have a timer call glutPostRedisplay().

If both viewports are part of the same window, you have to redraw everything. glutSwapBuffers() applies to the entire window, not a region, and it leaves the contents of the back buffer undefined (so you have to call glClear() before drawing anything).

You can use glutCreateSubWindow() to create a separate subwindow with its own buffers, context etc. Note that you have to register display/reshape functions for the subwindow separately. Also, you need to use glutSetWindow() to ensure that functions such as glutPostRedisplay() affect the correct window (display/reshape callbacks already have the correct window active when they are called).

The OpenGL viewport specifies a transformation between clip coordinates and window coordinates. It doesn't establish a clipping rectangle. While geometry will be clipped to the frustum, rasterisation can extend beyond it (e.g. wide lines and points, and bitmaps can extend outside the viewport). Use glScissor() to set a clip rectangle.

Thanks a lot.. Animation part of it done now.
I have rendering code in display and timer calling postRedisplay. Now I am stuck up with multiple viewports part.
I dont want to create subwindow as you have mentioned.

In Reshapefunction, i am saving width and height retrieved in global variables. Now i am using these variables to set viewport in my display call like this: