Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TGLMode
Unit
CastleWindowModes
Declaration
type TGLMode = class(TObject)
Description
Enter / exit modal state on a TCastleWindowCustom. Saves/restores the state of TCastleWindowCustom.
Hierarchy
Overview
Methods
Properties
 |
property FakeMouseDown: boolean
read FFakeMouseDown write FFakeMouseDown default false; |
Description
Methods
 |
constructor Create(AWindow: TCastleWindowCustom); |
Constructor saves open TCastleWindowCustom and OpenGL state. Destructor will restore them.
Some gory details (that you will usually not care about... the point is: everything works sensibly of the box) :
We save/restore window state.
OpenGL context connected to this window is also made current during constructor and destructor. Also, TCastleWindowCustom.Invalidate is called (since new callbacks, as well as original callbacks, probably want to redraw window contents.)
All pressed keys and mouse butons are saved and faked to be released, by calling TCastleWindowCustom.EventRelease with original callbacks. This way, if user releases some keys/mouse inside modal box, your original TCastleWindowCustom callbacks will not miss this fact. This way e.g. user scripts in VRML/X3D worlds that observe keys work fine.
If FakeMouseDown then at destruction (after restoring original callbacks) we will also notify your original callbacks that user pressed these buttons (by sending TCastleWindowCustom.EventMouseDown). Note that FakeMouseDown feature turned out to be usually more troublesome than usefull — too often some unwanted MouseDown event was caused by this mechanism. That's because if original callbacks do something in MouseDown (like e.g. activate some click) then you don't want to generate fake MouseDown by TGLMode.Destroy. So the default value of FakeMouseDown is False . But this means that original callbacks have to be careful and never assume that when some button is pressed (because it's included in MousePressed, or has EventRelease generated for it) then for sure there occurred some MouseDown for it.
At destructor, we notify original callbacks about size changes by sending TCastleWindowCustom.EventResize. This way your original callbacks know about size changes, and can set OpenGL projection etc.
We call ZeroNextSecondsPassed at the end, when closing our mode, see TFramesPerSecond.ZeroNextSecondsPassed for comments why this is needed.
This also performs important optimization to avoid closing / reinitializing window TCastleWindowCustom.Controls OpenGL resources, see TUIControl.DisableContextOpenClose.
|
 |
constructor CreateReset(AWindow: TCastleWindowCustom; NewRender, NewResize, NewCloseQuery: TContainerEvent); |
Save TCastleWindowCustom state, and then change it to a standard state. Destructor will restore saved state.
For most properties, we simply reset them to some sensible default values. For some important properties, we take their value explicitly by parameter.
Window properties resetted:
If you're looking for a suitable callback to pass as NewCloseQuery (new TCastleWindowCustom.OnCloseQuery), @NoClose may be suitable: it's an empty callback, thus using it disables the possibility to close the window by window manager (usually using "close" button in some window corner or Alt+F4).
|
 |
destructor Destroy; override; |
|
Properties
 |
property FakeMouseDown: boolean
read FFakeMouseDown write FFakeMouseDown default false; |
|
Generated by PasDoc 0.14.0.
|