Class TCastleControl
Unit
Declaration
type TCastleControl = class(TCustomOpenGLControl)
Description
Control to render everything (3D or 2D) with Castle Game Engine.
See https://castle-engine.io/control_on_form for a documentation how to use this.
You can use this with TCastleView, following https://castle-engine.io/control_on_form instructions. In this case, all user interface creation and event handling should be inside some state.
You can also add any user-interface controls to the Controls property. User-interface controls are any TCastleUserInterface descendants, like TCastleImageControl or TCastleButton or TCastleViewport. Use events like OnPress to react to events. Use event OnUpdate to do something continuously.
By default, the control is filled with simple color from Container.BackgroundColor.
This control is an alternative to rendering things using TCastleWindow. Note that you cannot use both TCastleControl
and TCastleWindow within the same application.
Hierarchy
- TObject
- TPersistent
- TComponent
- TLCLComponent
- TControl
- TWinControl
- TCustomOpenGLControl
- TCastleControl
Overview
Fields
![]() |
class var MainControl: TCastleControl deprecated 'this should no longer be useful, if you change views using MyControl.Container.View := .. or MyControl.Container.PushView(...)'; |
Methods
![]() |
procedure DestroyHandle; override; |
![]() |
procedure DoExit; override; |
![]() |
procedure Resize; override; |
![]() |
procedure KeyDown(var Key: Word; Shift: TShiftState); override; |
![]() |
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override; |
![]() |
procedure KeyUp(var Key: Word; Shift: TShiftState); override; |
![]() |
procedure MouseDown(Button: Controls.TMouseButton; Shift:TShiftState; X,Y:Integer); override; |
![]() |
procedure MouseUp(Button: Controls.TMouseButton; Shift:TShiftState; X,Y:Integer); override; |
![]() |
procedure MouseMove(Shift: TShiftState; NewX, NewY: Integer); override; |
![]() |
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override; |
![]() |
procedure DoUpdate; virtual; |
![]() |
constructor Create(AOwner: TComponent); override; |
![]() |
destructor Destroy; override; |
![]() |
function Controls: TInternalChildrenControls; |
![]() |
function MakeCurrent(SaveOldToStack: boolean = false): boolean; override; |
![]() |
procedure Invalidate; override; |
![]() |
procedure Paint; override; |
![]() |
function Pressed: TKeysPressed; |
![]() |
function MousePressed: TCastleMouseButtons; |
![]() |
procedure ReleaseAllKeysAndMouse; |
![]() |
function Fps: TFramesPerSecond; |
![]() |
procedure SaveScreen(const URL: string); overload; |
![]() |
function SaveScreen: TRGBImage; overload; |
![]() |
function SaveScreen(const SaveRect: TRectangle): TRGBImage; overload; |
![]() |
function SaveScreenBuffer: TColorBuffer; |
![]() |
function Rect: TRectangle; |
![]() |
function DesignedComponent(const ComponentName: String): TComponent; deprecated 'use Container.DesignedComponent'; |
Properties
![]() |
property GLInitialized: boolean read FGLInitialized; |
![]() |
property MousePosition: TVector2 read FMousePosition write SetMousePosition; |
![]() |
property Align; |
![]() |
property Anchors; |
![]() |
property BorderSpacing; |
![]() |
property Enabled; |
![]() |
property OpenGLMajorVersion; |
![]() |
property OpenGLMinorVersion; |
![]() |
property MultiSampling; |
![]() |
property AlphaBits; |
![]() |
property DepthBits; |
![]() |
property StencilBits default DefaultStencilBits; |
![]() |
property AUXBuffers; |
![]() |
property Options; |
![]() |
property OnChangeBounds; |
![]() |
property OnConstrainedResize; |
![]() |
property OnDblClick; |
![]() |
property OnDragDrop; |
![]() |
property OnDragOver; |
![]() |
property OnEnter; |
![]() |
property OnExit; |
![]() |
property OnMouseEnter; |
![]() |
property OnMouseLeave; |
![]() |
property OnShowHint; |
![]() |
property PopupMenu; |
![]() |
property ShowHint; |
![]() |
property Visible; |
![]() |
property TabOrder; |
![]() |
property TabStop default true; |
![]() |
property AutoFocus: Boolean read FAutoFocus write FAutoFocus default false; |
![]() |
property Container: TCastleControlContainer read FContainer; |
![]() |
property OnOpen: TNotifyEvent read FOnOpen write FOnOpen; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method GLContextOpen; or use ApplicationProperties.OnGLContextOpen'; |
![]() |
property OnClose: TNotifyEvent read FOnClose write FOnClose; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method GLContextClose; or use ApplicationProperties.OnGLContextClose'; |
![]() |
property OnBeforeRender: TNotifyEvent read FOnBeforeRender write FOnBeforeRender; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method BeforeRender; or use virtual Render or OnRender event'; |
![]() |
property OnRender: TNotifyEvent read FOnRender write FOnRender; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Render or OnRender event'; |
![]() |
property OnResize: TNotifyEvent read FOnResize write FOnResize; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Resize'; |
![]() |
property OnPress: TControlInputPressReleaseEvent read FOnPress write FOnPress; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Press or OnPress event'; |
![]() |
property OnRelease: TControlInputPressReleaseEvent read FOnRelease write FOnRelease; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Release or OnRelease event'; |
![]() |
property OnMotion: TControlInputMotionEvent read FOnMotion write FOnMotion; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Motion or OnMotion event'; |
![]() |
property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Update or OnUpdate event'; |
![]() |
property AutoRedisplay: boolean read FAutoRedisplay write SetAutoRedisplay
default true; |
![]() |
property DesignUrl: String read GetDesignUrl write SetDesignUrl stored false; deprecated 'use Container.DesignUrl'; |
Description
Fields
![]() |
class var MainControl: TCastleControl deprecated 'this should no longer be useful, if you change views using MyControl.Container.View := .. or MyControl.Container.PushView(...)'; |
Warning: this symbol is deprecated: this should no longer be useful, if you change views using MyControl.Container.View := .. or MyControl.Container.PushView(...) Central control. This is only important now if you use deprecated way of setting TCastleView, using class properties/methods TUIState.Current, TUIState.Push. If instead you use new way of setting TCastleView, using container properties/methods TCastleContainer.Current, TCastleContainer.Push, then this value isn't useful. This means that in new applications, you probably have no need to set this value. |
Methods
![]() |
procedure DestroyHandle; override; |
This item has no description. |
![]() |
procedure DoExit; override; |
This item has no description. |
![]() |
procedure Resize; override; |
This item has no description. |
![]() |
procedure KeyDown(var Key: Word; Shift: TShiftState); override; |
This item has no description. |
![]() |
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override; |
This item has no description. |
![]() |
procedure KeyUp(var Key: Word; Shift: TShiftState); override; |
This item has no description. |
![]() |
procedure MouseDown(Button: Controls.TMouseButton; Shift:TShiftState; X,Y:Integer); override; |
This item has no description. |
![]() |
procedure MouseUp(Button: Controls.TMouseButton; Shift:TShiftState; X,Y:Integer); override; |
This item has no description. |
![]() |
procedure MouseMove(Shift: TShiftState; NewX, NewY: Integer); override; |
This item has no description. |
![]() |
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override; |
This item has no description. |
![]() |
procedure DoUpdate; virtual; |
This item has no description. |
![]() |
constructor Create(AOwner: TComponent); override; |
This item has no description. |
![]() |
destructor Destroy; override; |
This item has no description. |
![]() |
function Controls: TInternalChildrenControls; |
List of user-interface controls currently active. You can add your TCastleUserInterface instances (like TCastleViewport, TCastleButton and much more) to this list. We will pass events to these controls, draw them etc. See TCastleContainer.Controls for details. |
![]() |
function MakeCurrent(SaveOldToStack: boolean = false): boolean; override; |
This item has no description. |
![]() |
procedure Invalidate; override; |
This item has no description. |
![]() |
procedure Paint; override; |
This item has no description. |
![]() |
function Pressed: TKeysPressed; |
Keys currently pressed. |
![]() |
function MousePressed: TCastleMouseButtons; |
Mouse buttons currently pressed. See TCastleContainer.MousePressed for details. |
![]() |
procedure ReleaseAllKeysAndMouse; |
This item has no description. |
![]() |
function Fps: TFramesPerSecond; |
Application speed. |
![]() |
procedure SaveScreen(const URL: string); overload; |
Capture the current control contents to an image. |
![]() |
function SaveScreen: TRGBImage; overload; |
This item has no description. |
![]() |
function SaveScreen(const SaveRect: TRectangle): TRGBImage; overload; |
This item has no description. |
![]() |
function SaveScreenBuffer: TColorBuffer; |
Color buffer where we draw, and from which it makes sense to grab pixels. Use only if you save the screen using low-level SaveScreen_NoFlush function. Usually, you should save the screen using the simpler SaveScreen method, and then the |
![]() |
function Rect: TRectangle; |
Rectangle representing the inside of this container. Always (Left,Bottom) are zero, and (Width,Height) correspond to container sizes. |
Properties
![]() |
property GLInitialized: boolean read FGLInitialized; |
This item has no description. |
![]() |
property MousePosition: TVector2 read FMousePosition write SetMousePosition; |
Current mouse position. See TTouch.Position for a documentation how this is expressed. |
![]() |
property Align; |
Be cafeful about comments in the published section. They are picked up and shown automatically by Lazarus Object Inspector, and it has it's own logic, much much dumber than what PasDoc sees. There seems no way to hide comment there. We publish most, but not all, stuff from inherited TCustomOpenGLControl. Exceptions: - Don't publish these, as not every widgetset has them: property RedBits; property GreenBits; property BlueBits; - Don't publish these, as we have our own events for this: property OnResize; property OnClick; property OnKeyDown; property OnKeyPress; property OnKeyUp; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnMouseWheel; property OnMouseWheelDown; property OnMouseWheelUp; property OnPaint; - Don't use, engine handles this completely: property OnMakeCurrent; property AutoResizeViewport; |
![]() |
property Anchors; |
This item has no description. |
![]() |
property BorderSpacing; |
This item has no description. |
![]() |
property Enabled; |
This item has no description. |
![]() |
property OpenGLMajorVersion; |
This item has no description. |
![]() |
property OpenGLMinorVersion; |
This item has no description. |
![]() |
property MultiSampling; |
This item has no description. |
![]() |
property AlphaBits; |
This item has no description. |
![]() |
property DepthBits; |
This item has no description. |
![]() |
property StencilBits default DefaultStencilBits; |
This item has no description. |
![]() |
property AUXBuffers; |
This item has no description. |
![]() |
property Options; |
This item has no description. |
![]() |
property OnChangeBounds; |
This item has no description. |
![]() |
property OnConstrainedResize; |
This item has no description. |
![]() |
property OnDblClick; |
This item has no description. |
![]() |
property OnDragDrop; |
This item has no description. |
![]() |
property OnDragOver; |
This item has no description. |
![]() |
property OnEnter; |
This item has no description. |
![]() |
property OnExit; |
This item has no description. |
![]() |
property OnMouseEnter; |
This item has no description. |
![]() |
property OnMouseLeave; |
This item has no description. |
![]() |
property OnShowHint; |
This item has no description. |
![]() |
property PopupMenu; |
This item has no description. |
![]() |
property ShowHint; |
This item has no description. |
![]() |
property Visible; |
This item has no description. |
![]() |
property TabOrder; |
This item has no description. |
![]() |
property TabStop default true; |
This item has no description. |
![]() |
property AutoFocus: Boolean read FAutoFocus write FAutoFocus default false; |
Automatically make this control focused (receiving key input) when user clicks on it. If this is |
![]() |
property Container: TCastleControlContainer read FContainer; |
Access Castle Game Engine container properties and events, not specific for Lazarus LCL. |
![]() |
property OnOpen: TNotifyEvent read FOnOpen write FOnOpen; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method GLContextOpen; or use ApplicationProperties.OnGLContextOpen'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method GLContextOpen; or use ApplicationProperties.OnGLContextOpen Event called when the OpenGL context is created. You can initialize things that require OpenGL context now. Often you do not need to use this callback (engine components will automatically create/release OpenGL resource when necessary). You usually will also want to implement OnClose callback that should release stuff you create here. Often, instead of using this callback, it's cleaner to derive new classes from TCastleUserInterface class or it's descendants, and override their GLContextOpen / GLContextClose methods to react to context being open/closed. Using such TCastleUserInterface classes is usually easier, as you add/remove them from controls whenever you want (e.g. you add them in ApplicationInitialize), and underneath they create/release/create again the OpenGL resources when necessary. Note that we automatically initialize necessary Castle Game Engine resources when context is created (GLVersion, GLFeatures and more). Instead of this, use TCastleUserInterface and TCastleView virtual method TCastleUserInterface.GLContextOpen. Or use ApplicationProperties.OnGLContextOpen to know when GL context is created. |
![]() |
property OnClose: TNotifyEvent read FOnClose write FOnClose; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method GLContextClose; or use ApplicationProperties.OnGLContextClose'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method GLContextClose; or use ApplicationProperties.OnGLContextClose Event called when the context is closed, right before the OpenGL context is destroyed. This is your last chance to release OpenGL resources, like textures, shaders, display lists etc. This is a counterpart to OnOpen event. Instead of this, use TCastleUserInterface and TCastleView virtual method TCastleUserInterface.GLContextClose. Or use ApplicationProperties.OnGLContextClose. |
![]() |
property OnBeforeRender: TNotifyEvent read FOnBeforeRender write FOnBeforeRender; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method BeforeRender; or use virtual Render or OnRender event'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method BeforeRender; or use virtual Render or OnRender event
Event always called right before OnRender. These two events, The only difference between these two events is that time spent in Instead of this, use TCastleUserInterface and TCastleView virtual method BeforeRender. Or just use virtual Render or OnRender event. |
![]() |
property OnRender: TNotifyEvent read FOnRender write FOnRender; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Render or OnRender event'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method Render or OnRender event Render window contents here. Called when window contents must be redrawn, e.g. after creating a window, after resizing a window, after uncovering the window etc. You can also request yourself a redraw of the window by the Invalidate method, which will cause this event to be called at nearest good time. Note that calling Invalidate while in EventRender ( When you have some controls on the Controls list, the Instead of this, use TCastleUserInterface and TCastleView virtual method Render and |
![]() |
property OnResize: TNotifyEvent read FOnResize write FOnResize; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Resize'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method Resize
Called when the control size ( Instead of this, use TCastleUserInterface and TCastleView virtual method Resize. |
![]() |
property OnPress: TControlInputPressReleaseEvent read FOnPress write FOnPress; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Press or OnPress event'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method Press or OnPress event Called when user presses a key or mouse button or moves mouse wheel. Instead of this, use TCastleUserInterface and TCastleView virtual method Press and |
![]() |
property OnRelease: TControlInputPressReleaseEvent read FOnRelease write FOnRelease; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Release or OnRelease event'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method Release or OnRelease event Called when user releases a pressed key or mouse button. It's called right after The TInputPressRelease structure, passed as a parameter to this event, contains the exact information what was released. Note that reporting characters for "key release" messages is not perfect, as various key combinations (sometimes more than one?) may lead to generating given character. We have some intelligent algorithm for this, used to make Characters table and to detect this C for This solves in a determined way problems like "what happens if I press Shift, then X, then release Shift, then release X". (will "X" be correctly released as pressed and then released? yes. will small "x" be reported as released at the end? no, as it was never pressed.) Instead of this, use TCastleUserInterface and TCastleView virtual method Release and |
![]() |
property OnMotion: TControlInputMotionEvent read FOnMotion write FOnMotion; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Motion or OnMotion event'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method Motion or OnMotion event Mouse or a finger on touch device moved. For a mouse, remember you always have the currently pressed mouse buttons in MousePressed. When this is called, the MousePosition property records the previous mouse position, while callback parameter NewMousePosition gives the new mouse position. Instead of this, use TCastleUserInterface and TCastleView virtual method Motion and |
![]() |
property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate; deprecated 'instead of this, use TCastleUserInterface and TCastleView virtual method Update or OnUpdate event'; |
Warning: this symbol is deprecated: instead of this, use TCastleUserInterface and TCastleView virtual method Update or OnUpdate event Continuously occuring event. This event is called roughly as regularly as redraw, and you should use this to update your game state. Note that this is different than LCL "idle" event, as it's guaranteed to be run continuously, even when your application is clogged with events (like when using TCastleWalkNavigation.MouseLook). Instead of this, use TCastleUserInterface and TCastleView virtual method Update and |
![]() |
property AutoRedisplay: boolean read FAutoRedisplay write SetAutoRedisplay
default true; |
Should we automatically redraw the window all the time, without the need for an Invalidate call. If If your game may have a still screen (nothing animates), then this approach is a little unoptimal, as we use CPU and GPU for drawing, when it's not needed. In such case, you can set this property to |
![]() |
property DesignUrl: String read GetDesignUrl write SetDesignUrl stored false; deprecated 'use Container.DesignUrl'; |
Warning: this symbol is deprecated: use Container.DesignUrl Load and show the design (.castle-user-interface file). You can reference the loaded components by name using DesignedComponent. If you have more complicated control flow, we recommend to leave this property empty, and split your management into a number of states (TCastleView) instead. In this case, load design using TCastleView.DesignUrl. This property makes it however easy to use .castle-user-interface in simple cases, when TCastleControl just shows one UI. The design loaded here is visible also at design-time, when editing the form in Lazarus/Delphi. Though we have to way to edit it now in Lazarus/Delphi (you have to use CGE editor to edit the design), so it is just a preview in this case. |
Generated by PasDoc 0.16.0-snapshot.