OpenGL レンダリング パラメータのオーバーライド
iOS プラットフォームや Android プラットフォームでは、グラフィカル アプリケーションのパフォーマンスを向上させるために、OpenGL レンダリング パラメータをオーバーライドすることができます。
たとえば、3D モデルを使用しない場合は、深度バッファを無効にできます。同様に、塗りつぶされたパスなどのベクタ キャンバス図形を使用しない場合は、ステンシル バッファを無効にするのが安全です。見栄えよりもパフォーマンスの高さを重視する場合は、24 ビットや 32 ビットではなく 16 ビットの色深度を使用するとよいでしょう。
OpenGL パラメータをオーバーライドするには、次のステップに従います:
Delphi:
- お使いのユニットの uses リストに FMX.Platform.pas を追加します。
-
レンダリング セットアップ手続きを次のように記述します。
procedure RenderingSetupCallback(const Sender, Context: TObject; var ColorBits, DepthBits: Integer; var Stencil: Boolean; var Multisamples: Integer); begin // Override OpenGL rendering setup to use custom values. ColorBits := 16; // default is 24 DepthBits := 0; // default is 24 Stencil := False; // default is True Multisamples := 0; // default depends on TForm.Quality or TForm3D.Multisample end;
-
登録手続きを次のように記述します。
procedure RegisterRenderingSetup; var SetupService: IFMXRenderingSetupService; begin if TPlatformServices.Current.SupportsPlatformService(IFMXRenderingSetupService, IInterface(SetupService)) then SetupService.Subscribe(RenderingSetupCallback); // There is also SetupService.Unsubscribe, which removes the hook. end;
- ユニットの
initialization
セクションでRegisterRenderingSetup
を呼び出します。
C++:
- レンダリング プロシージャと登録プロシージャを記述する:
class TCppRenderingSetupCallback : public TCppInterfacedObject<TRenderingSetupCallback> { public: void __fastcall Invoke(System::TObject* const Sender, System::TObject* const Context, int &ColorBits, int &DepthBits, bool &Stencil, int &Multisamples) { // Override OpenGL rendering setup to use custom values. ColorBits = 16; // default is 24 DepthBits = 0; // default is 24 Stencil = false; // default is true Multisamples = 0; // default depends on TForm.Quality or TForm3D.Multisample } }; void RegisterRenderingSetup() { _di_IFMXRenderingSetupService SetupService; if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXRenderingSetupService), &SetupService)) { SetupService->Subscribe(new TCppRenderingSetupCallback()); } }
- 関数
RegisterRenderingSetup()
は、Application->Initialize
の前に、FMXmain
で呼び出される必要があります。 次のようになります:extern "C" int FMXmain() { RegisterRenderingSetup(); try { Application->Initialize(); Application->CreateForm(__classid(TForm8), &Form8); Application->Run();
関連項目