Castle Game Engine: CastleWindowModes: Class TGLMode

# Class TGLMode
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleWindowModes ## Declaration `type TGLMode = class(TObject)` ## Description Enter / exit modal box on a TCastleWindowBase. Saves/restores the state of TCastleWindowBase properties (see TWindowState) and various OpenGL state. ## Hierarchy TObject TGLMode ## Overview ### Methods
| `constructor Create(AWindow: TCastleWindowBase; AttribsToPush: TGLbitfield; APushPopMessagesTheme: boolean);`
| `constructor CreateReset(AWindow: TCastleWindowBase; AttribsToPush: TGLbitfield; APushPopMessagesTheme: boolean; NewDraw, NewResize, NewCloseQuery: TWindowFunc);`
| `destructor Destroy; override;`
### Properties
| `property FakeMouseDown: boolean read FFakeMouseDown write FFakeMouseDown default false;`
| `property RestoreProjectionMatrix: boolean read FRestoreProjectionMatrix write FRestoreProjectionMatrix default true;`
| `property RestoreModelviewMatrix: boolean read FRestoreModelviewMatrix write FRestoreModelviewMatrix default true;`
| `property RestoreTextureMatrix: boolean read FRestoreTextureMatrix write FRestoreTextureMatrix default true;`
## Description ### Methods
| `constructor Create(AWindow: TCastleWindowBase; AttribsToPush: TGLbitfield; APushPopMessagesTheme: boolean);`
Constructor saves open TCastleWindowBase 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: TWindowState OpenGL attributes specified in AttribsToPush OpenGL matrix mode OpenGL matrices (saved without using OpenGL stack) OpenGL PIXEL_STORE_* state MessagesTheme (only if APushPopMessagesTheme) OpenGL context connected to this window is also made current during constructor and destructor. Also, TCastleWindowBase.PostRedisplay 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 TCastleWindowBase.EventRelease with original callbacks. This way, if user releases some keys/mouse inside modal box, your original TCastleWindowBase 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 TCastleWindowBase.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 TCastleWindowBase.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: TCastleWindowBase; AttribsToPush: TGLbitfield; APushPopMessagesTheme: boolean; NewDraw, NewResize, NewCloseQuery: TWindowFunc);`
Save OpenGL and TCastleWindowBase state, and then change this to a standard state. Destructor will restore saved state. This is a shortcut for Create followed by TWindowState.SetStandardState, see there for explanation of parameters.
| `destructor Destroy; override;`
### Properties
| `property FakeMouseDown: boolean read FFakeMouseDown write FFakeMouseDown default false;`
| `property RestoreProjectionMatrix: boolean read FRestoreProjectionMatrix write FRestoreProjectionMatrix default true;`
| `property RestoreModelviewMatrix: boolean read FRestoreModelviewMatrix write FRestoreModelviewMatrix default true;`
| `property RestoreTextureMatrix: boolean read FRestoreTextureMatrix write FRestoreTextureMatrix default true;`
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:15