How to force Firemonkey to use a DirectX 9 context in Delphi XE3?
Asked Answered
T

1

9

The main TForm3D window of Firemonkey application in Delphi X3 has a Context:TContext3D which gives me access to the current device used.
In my case with Windows7 64, it always shows a TDX10Context object from FMX.Context.DX10.pas.

I have not visibility to create new instance from TDX9Context class from FMX.Context.DX9.pas just to see the ancestor TCustomDX9Context.

I found the TContextManager class that collect the registerd 3D contexts in a strict private TList :( , this is the only class that can call the constructor...

{ Don't call contructor directly from TContext - only using TContextManager class }
constructor CreateFromWindow(const AParent: TFmxHandle; const AWidth, AHeight: Integer;`

They call TContextManager to get a context when creating new forms, then a readonly property TContextManager.DefaultContextClass is used.

There is no way I can find access to contexts other than DefaultContextClass.

Tye answered 19/12, 2012 at 4:42 Comment(4)
From a comment on your G+ post: GlobalUseDX10 := False;Wittol
Yes! :) That was unexpectedly easy and magical! it works! This line of code must be before application.initialize!Tye
I'm a newbie here, I don't know if should answer my own question? :-/Tye
Yes, if you find a good answer please post it to your own question. It might be helpful to others in the future.Wittol
C
3

For the record:

Put the following line in your project file:

GlobalUseDX10 := False;  <<-- add this.
Application.Initialize;  <<-- just before this line.
Cheatham answered 19/12, 2012 at 4:42 Comment(3)
Thanks, The trick works perfectly. We should also thanks g+ user: Sergionn Rad.Tye
note there are other useful GlobalUseXX too in FMX.Types unitGaffe
btw, documentation of Delphi 11 says "Warning: GlobalUseDX10 is deprecated. Please use GlobalUseDX." but GlobalUseDX says that if "false" it will use GDI instead (not DX9)Gaffe

© 2022 - 2024 — McMap. All rights reserved.