how to change the control between two glut windows

Hi all,
i have two glut windows in my project and what I want to do now is to redraw the scene in the second window when the mouse move over the first window .
note: I’m using Trackball for rotating the scene in the first window.

any help will be appreciated

I found this valuable resource on many different glut examples at OpenGL API GLUT Sample Code & Tutorials. Under one of the headings, there is a set of C examples that are part of the GLUT distribution. The “sphere.c” example shows how to track when you have left one window and entered the other – it prints info to the console as you move the mouse between the two windows like:


enter/leave 1 = left
enter/leave 4 = entered
enter/leave 4 = left
enter/leave 1 = entered
enter/leave 1 = left
enter/leave 4 = entered
enter/leave 4 = left
enter/leave 1 = entered

This doesn’t solve your problem but may give some hints by looking at the code source “sphere.c”. The use of glutEntryFunc and glutGetWindowglutSetWindow(int win) along with setting a new callback to rotate the image might be the place to start.

Another example probably closer to what you are trying to accomplish is found at Lighthouse tutorials. As you press the arrow keys, each of the three views responds and dynamically traverses the scene. The GLUT source code can be downloaded at the bottom of its page, just look for the “download” link. They are using subwindows rather than two separate windows but I think still applies to your problem.

ps I found that my GPU was too fast and when I pressed the arrow keys things moved beyond what I could see. A easy fix was to replace glutIdleFunc with a glutTimerFun as follows


glutTimerFunc(renderSceneAll);
// replaced with
glutTimerFunc(10,renderSceneAll,0);
/////////////////////////////////////////////////

// and
void renderSceneAll() {
//replaced with
void renderSceneAll(int value) {
	glutTimerFunc(10,renderSceneAll,value);
////////////////////////////////////////////////

//and for ANSI-C you can't use \ in includes
#include <GL\glut.h>
#include <GL\gl.h>
#include <GL\glu.h>
// replaced with
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
////////////////////////////////////////////////