views:

295

answers:

2

Currently it is floating on top of my rendered window, i dont think thats good for few reasons: 1) i waste rendering time for rendering stuff that isnt visible. 2) it must be rendered every frame again when i wouldnt be updating the whole statusbar every frame anyways.

So how i could create a window where it leaves space for my statusbar and none of my OpenGL stuff could be rendered in that area?

At this moment i just adjust my viewports in a way that creates empty space for statusbar, but it causes some problems in my current way of doing things. i would have to make my code look much more messier to make it work.

A: 

One way may be to make your "rendered window" and "statusbar" both children of a containing window, and to add some code for the WM_SIZE message for that containing window to position the children so they don't overlap.

Brian Nixon
yes, how? example? tutorials? anything!
Newbie
+2  A: 

http://www.gamedev.net/community/forums/topic.asp?topic_id=291682

Edit: Its not a simple question to answer. If you don't know what a child window is under Win32 then you may be in a much better position. However asking someone to give you a full explanation of the windows windowing system is no mean feat.

Here is an overview:

Basically you need to create a child window which can be done using CreateWindow to create a window with the WS_CHILD style and with its hWndParent parameter set to the window handle you want the new window to be a child of.

When you created the window you will have, necessarily, create a window procedure When you call DispatchMessage from your message pump (The Loop that does a Get/PeekMessage and then dispatches the messages is the message pump). Inside the window procedure you can then switch on the message type and handle each message sent to your window.

From here you can handle things like setup. Your initial window will have either a WM_CREATE or a WM_INITDIALOG (Depending on what type of window you create). It is from there that you need to create the child windows (Don't forget to call ShowWindow to make them visible!!). From this point you can then set up the DirectX device to be attached to the child window handle (HWND).

Furthermore if you want to be able to re-size the window then you ALSO need to take into account the WM_SIZE mesage. However I'd strongly recommend trying to get the rest working before even beginning to look into this as it gets very complicated as you will need to destroy and re-create your DirectX device so that it is the right size.

Anyway thats just a simple overview. I hope it helps!

Goz
oh crap, i forgot to say i am using OpenGL not DirectX. does this change anything? this all seems pretty complicated, is there some easy way of doing this in Visual studio?
Newbie
There is no easy way of doing it in Visual Studio and no it really doesn't make much difference whether you are using GL rather than DX. You may want to take a look at QT as that has an OpenGL renderer "widget" as one of its primary types :)
Goz
Actualyl I should say there is no easy way of doing it without a paid for version of Visual Studio ... but then many would argue with me on how easy or difficult MFC is ...
Goz