OpenGL scene overlaps windows controls c++ winapi
I'm trying to create simple button on top of openGL scene, but I have one serious problem.
I am using double buffer and when I want to draw the button, it is covered by the openGL scene.
The whole openGL window is in fullscreen mode (WS_POPUP) and when I use WS_CLIPSIBLINGS and WS_CLIPCHILDREN window style for the parent window,
the area of the button is filled with Visual Studio background. But when I minimize that window and maximize again, the button is drawn but it has no text on it.
FPS in the scene also dramatically drop when I just create the button. I have no idea what can I do to fix that.
Any help would be appreciated. Thank You in advance!
I'm not sure if that is actually supposed or intended to work, or how the WS_POPUP window fullscreen mode internally works, but I imagine it to be quite messy and only a hack to turn ownership of entire rendering device/screen over in order to get most performance. I don't know (and don't really want to know) the internal workings of those particular parts of the WINAPI so I personally would not try that to begin with.
Either way, if you want GUI inside a fullscreen GL application you are probably way better off using an existing GUI library specifically designed for drawing GUI stuff via OpenGL(R), either using GL drawing functions or drawing offscreen and uploading to a texture.
Here are a few libraries I know of:
- Ant tweak bar
- You could use the SGUI offscreen canvas and upload the data to a GL texture
- A few years ago, I managed to get QT to draw to an offscreen memory buffer that can also be upload to a GL texture
If you insist on using the WINAPI controlls, there might be some way to get them to draw offscreen and then upload that to a texture.
Actually my idea was to create editbox as a text input window, the button was just for testing purposes.
I want to keep the visual interface of the windows controls and mainly the funcionality as copying text, pasting text,
mooving carret possition using arrow keys on keyboard and so on.
Either way, thank you for your advices, I will try one of them.
Drawing the controls to a texture sound like a great soloution, we will see what impact will it have on performance
Tags for this Thread