synchronized openGL windows

I have two openGL windows: Model Window, and Axes Window. These are both 3D windows. The Model window contains a model, and the Axes window simply contains an X,Y and Z axes to show the orientation of the model. When I rotate the model in the Model window, I want the axes in the Axes window to SIMULTANEOUSLY rotate, so that it always shows the correct orientation. (I say "simultaneouly’, but of course it’s ok if the axes is actually rotating a split instant AFTER the model is rotated. The point is that, to the user’s eye, it looks simultaneous).

FYI, I don’t want to put the axes INSIDE the model window. I’ve got to have 2 separate windows.

I already have code written in the model window to handle the zooming, rotating, etc. Just need to sync up this Axes window.

The real issue is how to tell the Axes window that it’s time to redraw. This is the part that I don’t know how to do. Each time the user rotates the model in the Model Window, the Axes window needs to be told “Hey, redraw yourself”. The axes window DOES have the latest rotational information. I accomplish this by saving the rotational data in memory that the Axes window has access to. Thus, the Axes window KNOWS exactly how to draw the axes. It just needs to be told to redraw the axes each time the user rotates the model in the Model window.

FYI, these 2 openGL windows are 2 separate window objects in my application. Neither is a child or parent of the other.

Thanks very much.

well, you could use a global (ugh) variable.
Window 1 sets the variable a true if it was false each time it updates anything on the model.
Window 2 sets the variable to false if it was true, and also redraws the axis.
Easy sync :smiley:

My 2 cents,

Toni

Thanks. That should work. The thing I don’t know how to do is to call Window 2’s DrawScene( ) each time something in Window 1 changes. I’ve tried using PostMessage(…), but this doesn’t keep up.

PostMessage(…), but this doesn’t keep up
Simplest solution would be to use SendMessage instead - this function will make window 1 wait until window 2 has finished processing your message.

Thanks BIGTIME, k_szczech. Thanks, also, Toni.

Ultimately, the solution was to call SendMessage(…) for the Axes Window, to force a redraw with the latest rotations applied. I called this from the Model Window, in the OnMouseMove(). OnMouseMove() gets called each time the user rotates the model in the Model Window. Voila. It works. I had previously tried using PostMessage(…), but this didn’t work.

The working code looks like this:

void C3ModelWnd::OnMouseMove(UINT nFlags, CPoint point)


//store the Model window’s latest rotations in variables that the Axes window has access too
m_dRotationInX = m_dModelAngleX;
m_dRotationInY = m_dModelAngleY;
m_dRotationInZ = m_dModelAngleZ;

//send a message to the Axes window, that it’s time to redraw (using the above rotations in m_dRotationInX, m_dRotationInY and m_dRotationInZ)
m_wndAxes->SendMessage(WM_USER_NEWDATA, WM_AXES_REDRAW);


}