How to setup OpenGL1.4 environment in Firemonkey App?

In older days I would create a TForm, place a TMyPanel on it (with overriden WM_PAINT message) and pass its Handle to a bunch of WGL functions that find a compatible pixelformat and create rendering context. Just like NeHe tutorials did it.

Now there comes FireMonkey application. How to get OpenGL 1.4 rendering context there that is working on Win and iOS?

EDIT: Been trying to make it to work by passing TForm.Handle (which is NativeUInt). Good news - no errors from OpenGL end, but bad news - no output on TForm either.. I'm obviously missing some critical piece here, does anyone has a working OpenGL in FireMonkey application?


Firemonkey provides an abstraction layer.

So on Windows your using DirectX and on OSX and iOS your using OpenGL/Quartz. On windows it's also possible for things to fall back to GDI+

Given this one must take into account that the rendering destination may not always be OpenGL, and it may not always be the same even on the same platform.

TCanvas in part of this abstraction layer.

There are 3 current implementations of TCanvas , your application may be using any of these.

  • FMX.Canvas.D2D.pas - Direct2d
  • FMX.Canvas.GDIP.pas - GDI+
  • FMX.Canvas.Mac.pas - Mac
  • The platform implementation details are typically hidden in private sections are are not accessible.

    You also have TPlatform in FMX.Platform.pas which hides the implementation details and publishes a single API (limited in scope) that is designed to work on all platforms.

    If you use FMX.Platform.Win.pas you can get the windows handle for a given TFmxHandle

    If you use FMX.Platform.Mac.pas you can get the IObjectiveC for a given TFmxHandle

    However on IOS there is no equivalent function in FMX_Platform_iOS.pas


    After some investigations I have managed to create OpenGL context in FireMonkey on Windows platform. I don't have access to iOS yet, but I'm sure something can be done there as well.

    To the solution: add FMX.Platform.Win to uses clause (might need to wrap it into IFDEF 's for iOS). Now we can use FmxHandleToHWND(Form1.Handle) to get valid HWND . Thats it. On MacOS the same is done by adding FMX.Platform.Win and through H_WND := FmxHandleToObjC(AHandle); call.

    链接地址: http://www.djcxy.com/p/55630.html

    上一篇: 我可以存储多少数据

    下一篇: 如何在Firemonkey应用程序中设置OpenGL1.4环境?