Castle Game Engine: CastleControl: Class TCastleControlCustom

# Class TCastleControlCustom
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleControl ## Declaration `type TCastleControlCustom = class(TCustomOpenGLControl)` ## Description OpenGL control, with extensions for "Castle Game Engine", including Controls list for TUIControl instances. Use a descendant TCastleControl to have a ready TCastleControl.SceneManager for 3D world. This extends TOpenGLControl, adding various features: Controls list where you can easily add TUIControl instances (like TCastleOnScreenMenu, TCastleButton and more). We will pass events to these controls, draw them etc. Continously called DoUpdate method, that allows to handle TUIControl.Update. This is something different than LCL "idle" event, as it's guaranteed to be run continously, even when your application is clogged with events (like when using TWalkCamera.MouseLook). Automatically calls GLInformationInitialize when OpenGL context is initialized. This will initialize GLVersion, GLUVersion, GLFeatures. FPS (frames per second) counter inside Fps. Tracks pressed keys Pressed and mouse buttons MousePressed and mouse position MousePosition. ## Hierarchy TCustomOpenGLControl TCastleControlCustom ## Overview ### Methods
| `procedure DestroyHandle; override;`
| `procedure DoExit; override;`
| `procedure Resize; override;`
| `procedure KeyDown(var Key: Word; Shift: TShiftState); 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: TUIControlList;`
| `function MakeCurrent(SaveOldToStack: boolean = false): boolean; override;`
| `procedure Invalidate; override;`
| `procedure Paint; override;`
| `procedure ReleaseAllKeysAndMouse;`
| `function SaveScreenBuffer: TColorBuffer;`
| `function SaveScreen: TRGBImage;`
| `function Rect: TRectangle;`
### Properties
| `property GLInitialized: boolean read FGLInitialized;`
| `property Pressed: TKeysPressed read FPressed;`
| `property MousePressed: CastleKeysMouse.TMouseButtons read FMousePressed;`
| `property MousePosition: TVector2Single read FMousePosition write SetMousePosition;`
| `property Fps: TFramesPerSecond read FFps;`
| `property Align;`
| `property Anchors;`
| `property AutoResizeViewport;`
| `property BorderSpacing;`
| `property Enabled;`
| `property OpenGLMajorVersion;`
| `property OpenGLMinorVersion;`
| `property MultiSampling;`
| `property AlphaBits;`
| `property DepthBits;`
| `property StencilBits;`
| `property AUXBuffers;`
| `property OnChangeBounds;`
| `property OnConstrainedResize;`
| `property OnDblClick;`
| `property OnDragDrop;`
| `property OnDragOver;`
| `property OnEnter;`
| `property OnExit;`
| `property OnMakeCurrent;`
| `property OnClick;`
| `property OnKeyDown;`
| `property OnKeyPress;`
| `property OnKeyUp;`
| `property OnMouseDown;`
| `property OnMouseMove;`
| `property OnMouseUp;`
| `property OnMouseWheel;`
| `property OnMouseWheelDown;`
| `property OnMouseWheelUp;`
| `property OnMouseEnter;`
| `property OnMouseLeave;`
| `property OnPaint;`
| `property OnShowHint;`
| `property PopupMenu;`
| `property ShowHint;`
| `property Visible;`
| `property OnOpen: TNotifyEvent read FOnOpen write FOnOpen ;`
| `property OnClose: TNotifyEvent read FOnClose write FOnClose ;`
| `property OnBeforeRender: TNotifyEvent read FOnBeforeRender write FOnBeforeRender;`
| `property OnRender: TNotifyEvent read FOnRender write FOnRender ;`
| `property OnResize: TNotifyEvent read FOnResize write FOnResize ;`
| `property OnPress: TControlInputPressReleaseEvent read FOnPress write FOnPress ;`
| `property OnRelease: TControlInputPressReleaseEvent read FOnRelease write FOnRelease ;`
| `property OnMotion: TControlInputMotionEvent read FOnMotion write FOnMotion ;`
| `property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate ;`
| `property TabOrder;`
| `property TabStop default true;`
| `property Container: TContainer read FContainer;`
## Description ### Methods
| `procedure DestroyHandle; override;`
| `procedure DoExit; override;`
| `procedure Resize; override;`
| `procedure KeyDown(var Key: Word; Shift: TShiftState); 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: TUIControlList;`
| `function MakeCurrent(SaveOldToStack: boolean = false): boolean; override;`
| `procedure Invalidate; override;`
| `procedure Paint; override;`
| `procedure ReleaseAllKeysAndMouse;`
| `function SaveScreenBuffer: TColorBuffer;`
Color buffer where we draw, and from which it makes sense to grab pixels. Use with SaveScreen_NoFlush.
| `function SaveScreen: TRGBImage;`
Capture the current control contents to an image. These functions take care of flushing any pending redraw operations and capturing the screen contents correctly.
| `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;`
| `property Pressed: TKeysPressed read FPressed;`
| `property MousePressed: CastleKeysMouse.TMouseButtons read FMousePressed;`
| `property MousePosition: TVector2Single read FMousePosition write SetMousePosition;`
Current mouse position. See TTouch.Position for a documentation how this is expressed.
| `property Fps: TFramesPerSecond read FFps;`
| `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, as not every widgetset has them. property RedBits; property GreenBits; property BlueBits; - Don't publish, as we have our own event for this. property OnResize;
| `property Anchors;`
| `property AutoResizeViewport;`
Don't use, engine handles this completely.
| `property BorderSpacing;`
| `property Enabled;`
| `property OpenGLMajorVersion;`
| `property OpenGLMinorVersion;`
| `property MultiSampling;`
| `property AlphaBits;`
| `property DepthBits;`
| `property StencilBits;`
| `property AUXBuffers;`
| `property OnChangeBounds;`
| `property OnConstrainedResize;`
| `property OnDblClick;`
| `property OnDragDrop;`
| `property OnDragOver;`
| `property OnEnter;`
| `property OnExit;`
| `property OnMakeCurrent;`
Don't use, engine handles this completely.
| `property OnClick;`
Deprecated, use OnPress instead.
| `property OnKeyDown;`
Deprecated, use OnPress instead.
| `property OnKeyPress;`
Deprecated, use OnPress instead.
| `property OnKeyUp;`
Deprecated, use OnRelease instead.
| `property OnMouseDown;`
Deprecated, use OnPress instead.
| `property OnMouseMove;`
Deprecated, use OnMotion instead.
| `property OnMouseUp;`
Deprecated, use OnRelease instead.
| `property OnMouseWheel;`
Deprecated, use OnPress instead.
| `property OnMouseWheelDown;`
Deprecated, use OnPress instead.
| `property OnMouseWheelUp;`
Deprecated, use OnPress instead.
| `property OnMouseEnter;`
| `property OnMouseLeave;`
| `property OnPaint;`
Deprecated, use OnRender instead.
| `property OnShowHint;`
| `property PopupMenu;`
| `property ShowHint;`
| `property Visible;`
| `property OnOpen: TNotifyEvent read FOnOpen write FOnOpen ;`
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), but sometimes it may be handy (e.g. TGLImage requires OpenGL context). You usually will also want to implement OnClose callback that releases stuff created here. Even when you really need to initialize some OpenGL resource (like TGLImage), instead of using this callback it's usually better to derive new classes from TUIControl class or it's descendants, and override their GLContextOpen / GLContextClose methods to react to context being open/closed. Using such TUIControl 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.
| `property OnClose: TNotifyEvent read FOnClose write FOnClose ;`
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.
| `property OnBeforeRender: TNotifyEvent read FOnBeforeRender write FOnBeforeRender;`
Event always called right before OnRender. These two events, `OnBeforeRender` and OnRender, will be always called sequentially as a pair. The only difference between these two events is that time spent in `OnBeforeRender` is NOT counted as "frame time" by Fps.FrameTime. This is useful when you have something that needs to be done from time to time right before OnRender and that is very time-consuming. It such cases it is not desirable to put such time-consuming task inside OnRender because this would cause a sudden big change in Fps.FrameTime value. So you can avoid this by putting this in `OnBeforeRender`.
| `property OnRender: TNotifyEvent read FOnRender write FOnRender ;`
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 `OnRender` is not ignored. It means that in a short time next `OnRender` will be called.
| `property OnResize: TNotifyEvent read FOnResize write FOnResize ;`
Called when the control size (`Width`, `Height`) changes. It's also guaranteed to be called right after the OnOpen event. Our OpenGL context is already "current" when this event is called (MakeCurrent is done right before), like for other events. This is a good place to set OpenGL viewport and projection matrix. In the usual case, the SceneManager takes care of setting appropriate OpenGL projection, so you don't need to do anything here.
| `property OnPress: TControlInputPressReleaseEvent read FOnPress write FOnPress ;`
Called when user presses a key or mouse button or moves mouse wheel.
| `property OnRelease: TControlInputPressReleaseEvent read FOnRelease write FOnRelease ;`
Called when user releases a pressed key or mouse button. It's called right after `Pressed[Key]` changed from true to false. 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 `OnRelease` callback. The idea is that a character is released when the key that initially caused the press of this character is also released. 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.)
| `property OnMotion: TControlInputMotionEvent read FOnMotion write FOnMotion ;`
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.
| `property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate ;`
Continously occuring event. This event is called at least as regularly as redraw, so it is continously called even when your game is overwhelmed by messages (like mouse moves) and redraws.
| `property TabOrder;`
| `property TabStop default true;`
| `property Container: TContainer read FContainer;`
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:09