Combining Lazarus LCL and OpenGL

I recently moved a large program from Delphi to Lazarus. Most errors are sorted, and I am completely impressed with Lazarus / FPC. But there is one mistake that I cannot understand.

My application has an OpenGL main window and several additional forms. I originally developed these forms using Delphi VCL, and now I have translated them to Lazarus LCL.

Edit: The OpenGL window is not currently an LCL form. It is implemented using Win32 calls and has its own message loop.

All forms are considered children of the main OpenGL window according to this line of code:

Form.ParentWindow := OpenGLWindow.h_wnd; 

Unfortunately, when the forms belong to the OpenGL window, they simply disappear. Of course, the OpenGL window is updated at a frame rate of 30 frames per second, and this causes a problem with the screen buffer. Forms are rendering, and then displayed on top of the OpenGL window.

The problem is resolved if the forms do not belong to the main window. Unfortunately, changing ownership is pretty damaging for end users (menus get lost behind the program, etc.).

So, I wonder where to start with such a problem? Do I have to ensure that the forms have their own screen buffers for rendering inside, or is this the wrong idea?

To clarify some things: I am using Win32 LCL version, not QT or something like that. In addition, I tried setting the forms to two buffers to make sure this helps, but it doesn’t.

+4
source share
1 answer

Try using the OpenGlControl that comes with Lazarus. Install the package from the components folder. These components work like Tpaint, but are opengl contexts. Drop it in any form, and this form will be an opengl context, but also a form that can be moved, resized, etc. See the samples that come with the component.

/ BlueIcaro

+1
source

Source: https://habr.com/ru/post/1486153/


All Articles