Archived

This topic is now archived and is closed to further replies.

FERNANDO-BRASIL

problem with Win32API an OpenGL

Recommended Posts

Hi!! I''m trying to construct a program like 3D Studio Max (just a little program.. An Example), and I''m having some problems with it... Well.. I''m using WIN32API to create Menus, Toolbars, Status Bars and etc... Until the menu, the application runs correctly, but when I put a Toolbar or a Status Bar on my Form, the OpenGL, draw things over this components when I do a call to SwapBuffers... How Do I do to solve this problem?? Isn''t there a way to inform OpenGl just to draw in a specific region of the screen? Thank you very mutch guys!

Share this post


Link to post
Share on other sites
Hi Elber Kain!!

I tryed putting glViewPort on my code and i still getting the problem.. I don''t know if I used it correct.

What you wanted to tell me with it:
"it should be part of your perspective call anyhow, just send it different params"? I didn''t understand, maybe because I''m from another country, and my english is not god.

thank you again!

Share this post


Link to post
Share on other sites
vincoof    514
You have to use a GUI Toolkit, like MFC, to encapsulate your OpenGL context in the window.
If you use plainly NeHe''s method, then the OpenGL context will appropriate the whole window drawing region, which obviously will draw over anything else already present.

Although I would not recommend using MFC (since it is history with Visual.Net) you should take a look at NeHe''s MFC tutorial. Maybe he has something interesting there.

Share this post


Link to post
Share on other sites
t0ne    124
You don''t have to use a GUI toolkit !
What''s happening is that your toolbars are occupying some of the client area of your window and what you need to do is correctly calculate the size of your client area.
In response to a WM_SIZE message, you should calculate the space occupied by any toolbars/statusbars etc (use GetWindowRect or GetClientRect api''s) and subtract them from the height and width of the client area. Then pass this new size to glViewport API.

You would also need to do this if you were using MFC too.

HTH,
t0ne.


Slightly shrimpy smell == unsafe breadbin

Share this post


Link to post
Share on other sites
Thank you t0ne!!! I finally did it!!

BUt i didn''t use GetWindowRect nor GetClientRect. Instead of this, I created a new window and resized it to the blank space of the principal form, then linked it to HDC and HGLRC.

But now, I would like to know What method is better? Using GetWIndowRect or Creatting a new Window??

thanks again guys!

Share this post


Link to post
Share on other sites
t0ne    124
Your toolbars and status bars are child windows in their own right and using GetWindowRect and calculating the area is fairly painless. However, creating a seperate window (almost like creating an OpenGL control) is a simple alternative and should work fine.
Don''t forget to use a NULL brush for the background HBRUSH in your WNDCLASS structure to avoid un-necessary erase backgound messages in your containing window (as it won''t be visible).

cheers,
t0ne.

Slightly shrimpy smell == unsafe breadbin

Share this post


Link to post
Share on other sites