PDA

View Full Version : Z-order: keeping an openGL window on top



clintCJM
10-03-2006, 11:01 AM
I have 2 openGL windows, among many other windows, in my C++ application.

These 2 openGL windows, we'll call BIG, and SMALL. I've positioned SMALL window over the BIG window. I'd like the SMALL window to NEVER hide behind the BIG window. NEVER. NEVER. NEVER. Of course, anytime I put the cursor in the BIG window, for example to rotate the model in the BIG window, the SMALL window hides behind the big window.

Is there any way to prevent this from happening, so that SMALL ALWAYS stays in front of BIG, even when BIG is the active window.

Thanks.

Trahern
10-03-2006, 11:15 AM
this is an OS specific question and it really isnt related to OpenGL at all..

edit: I see you are using win32 api.. so you can at least post this post into OpenGL under Windows section .. however you would probably receive the best answers in some forum directly related to win32 programming ( or by using google ;) )
Try function SetWindowPos ..it can change z-order of the windows

clintCJM
10-03-2006, 11:29 AM
Yeah. I've been fiddling with SetWindowPos, but the moment the BIG window becomes active (like by clicking around inside it), the SMALL window goes behind the BIG window, and thus becomes hidden. I'll try your suggestion of posting to a windows forum. Thanks for your help.

clintCJM
10-03-2006, 02:22 PM
I found the solution, for anyone interested. To make the SMALL window, (which is located over the BIG window), I call ptrSmallWnd->BringWindowToTop() from the BIG window's DrawScene(). Thus, each time the BIG window is done drawing itself, the SMALL window moves to the top of the Z order, so it's visible again.

zeoverlord
10-03-2006, 02:33 PM
So why don't you merge the two windows, you can render the smaller window within the bigger one, it's a much nicer solution.
NeHe (http://nehe.gamedev.net/) lesson 42 deals with multiple viewports.

rgpc
10-03-2006, 02:56 PM
Create the smaller window as a child of the "BIG" window.

clintCJM
10-04-2006, 06:30 AM
rgpc, thanks for the suggestion. would making the SMALL window a child of the BIG window keep the SMALL window from getting pushed under the BIG window, in the Z order?

clintCJM
10-04-2006, 06:31 AM
zeoverlord, I'm going to look into the multiple viewports idea. thanks. Having not done that before, I figured it was trickier than simply creating 2 separate windows (BIG and SMALL), and placing one on top of the other.

gstrickler
10-04-2006, 07:56 AM
Just create the small window with the WS_POPOP style, and it will float above all the other non-popup windows. WS_POPUP is often used for modal windows so they stay on top, but you can use the style for non-modal windows too.

clintCJM
10-04-2006, 08:08 AM
gstrickler, I tried making the window style WS_POPUP, but alas, the SMALL window still hides behind the BIG window, each time the BIG window is clicked. Darn.

gstrickler
10-04-2006, 11:19 AM
http://i12.tinypic.com/2i1cbw7.jpg
Here is a view of my app. I use the MDI (multiple document interface) for the app, and all the gl windows are children of the main frame. The task windows are modeless dialogs, and will always float above the MDI frame and its child windows. Windows are windows, and gl contexts are attached to the windows, so attaching a gl context to a dialog window (just don't include any controls) should not be hard. Notice that the front most gl window is the active view (the title bar is blue) and the task window in front is not.

Building an app with all this window management stuff is not for the faint of heart.

Hope this helps a little.

mabraham
10-05-2006, 07:54 AM
Create the small window as a WS_POPUP, as suggested by other people, and make sure to specify the large window as the owner (parent) of the small window. I'm sure that'll achieve what you want. If all else fails, you can try to set the window extended style to WS_EX_TOPMOST...

If you use CreateWindowEx, the parent owner window is the 9th parameter.