添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
聪明的牛肉面  ·  Update error ...·  1 周前    · 
想出国的豆腐  ·  PostgreSQL Python: ...·  4 天前    · 
欢快的茶叶  ·  python json.update - ...·  4 天前    · 
会搭讪的大葱  ·  Changelog — Haystack ...·  3 天前    · 
爱笑的桔子  ·  How to update ...·  3 天前    · 
谦和的鸡蛋面  ·  'Property ...·  1 月前    · 
想表白的山羊  ·  HBase Tools | ...·  2 月前    · 

The GameWindow class contains cross-platform methods to create and render on an OpenGL window, handle input and load resources. More...

+ Inheritance diagram for OpenTK.GameWindow: Public Member Functions GameWindow ()  Constructs a new GameWindow with sensible default attributes. More...
GameWindow (int width, int height)  Constructs a new GameWindow with the specified attributes. More...
GameWindow (int width, int height, GraphicsMode mode)  Constructs a new GameWindow with the specified attributes. More...
GameWindow (int width, int height, GraphicsMode mode, string title)  Constructs a new GameWindow with the specified attributes. More...
GameWindow (int width, int height, GraphicsMode mode, string title, GameWindowFlags options)  Constructs a new GameWindow with the specified attributes. More...
GameWindow (int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device)  Constructs a new GameWindow with the specified attributes. More...
GameWindow (int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags)  Constructs a new GameWindow with the specified attributes. More...
GameWindow (int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext)  Constructs a new GameWindow with the specified attributes. More...
override void Dispose ()  Disposes of the GameWindow , releasing all resources consumed by it. More...
virtual void Exit ()  Closes the GameWindow . Equivalent to NativeWindow.Close method. More...
void MakeCurrent ()  Makes the GraphicsContext current on the calling thread. More...
void Run ()  Enters the game loop of the GameWindow using the maximum update rate. More...
void Run (double updateRate)  Enters the game loop of the GameWindow using the specified update rate. maximum possible render frequency. More...
void Run (double updates_per_second, double frames_per_second)  Enters the game loop of the GameWindow updating and rendering at the specified frequency. More...
void SwapBuffers ()  Swaps the front and back buffer, presenting the rendered scene to the user. More...
- Public Member Functions inherited from OpenTK.NativeWindow NativeWindow ()  Constructs a new NativeWindow with default attributes without enabling events. More...
NativeWindow (int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device)  Constructs a new centered NativeWindow with the specified attributes. More...
NativeWindow (int x, int y, int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device)  Constructs a new NativeWindow with the specified attributes. More...
void Close ()  Closes the NativeWindow . More...
Point PointToClient (Point point)  Transforms the specified point from screen to client coordinates. More...
Point PointToScreen (Point point)  Transforms the specified point from client to screen coordinates. More...
void ProcessEvents ()  Processes operating system events until the NativeWindow becomes idle. More...
Protected Member Functions override void OnClosing (System.ComponentModel.CancelEventArgs e)  Called when the NativeWindow is about to close. More...
virtual void OnLoad (EventArgs e)  Called after an OpenGL context has been established, but before entering the main loop. More...
virtual void OnUnload (EventArgs e)  Called after GameWindow.Exit was called, but before destroying the OpenGL context. More...
virtual void Dispose (bool manual)  Override to add custom cleanup logic. More...
virtual void OnRenderFrame ( FrameEventArgs e)  Called when the frame is rendered. More...
virtual void OnUpdateFrame ( FrameEventArgs e)  Called when the frame is updated. More...
virtual void OnWindowInfoChanged (EventArgs e)  Called when the WindowInfo for this GameWindow has changed. More...
override void OnResize (EventArgs e)  Called when this window is resized. More...
- Protected Member Functions inherited from OpenTK.NativeWindow void EnsureUndisposed ()  Ensures that this NativeWindow has not been disposed. More...
virtual void OnClosed (EventArgs e)  Called when the NativeWindow has closed. More...
virtual void OnClosing (CancelEventArgs e)  Called when the NativeWindow is about to close. More...
virtual void OnDisposed (EventArgs e)  Called when the NativeWindow is disposed. More...
virtual void OnFocusedChanged (EventArgs e)  Called when the OpenTK.INativeWindow.Focused property of the NativeWindow has changed. More...
virtual void OnIconChanged (EventArgs e)  Called when the OpenTK.INativeWindow.Icon property of the NativeWindow has changed. More...
virtual void OnKeyDown ( KeyboardKeyEventArgs e)  Occurs whenever a keybord key is pressed. More...
virtual void OnKeyPress ( KeyPressEventArgs e)  Called when a character is typed. More...
virtual void OnKeyUp ( KeyboardKeyEventArgs e)  Called when a keybord key is released. More...
virtual void OnMove (EventArgs e)  Called when the NativeWindow is moved. More...
virtual void OnMouseEnter (EventArgs e)  Called whenever the mouse cursor reenters the window Bounds . More...
virtual void OnMouseLeave (EventArgs e)  Called whenever the mouse cursor leaves the window Bounds . More...
virtual void OnTitleChanged (EventArgs e)  Called when the OpenTK.INativeWindow.Title property of the NativeWindow has changed. More...
virtual void OnVisibleChanged (EventArgs e)  Called when the OpenTK.INativeWindow.Visible property of the NativeWindow has changed. More...
virtual void OnWindowBorderChanged (EventArgs e)  Called when the WindowBorder of this NativeWindow has changed. More...
virtual void OnWindowStateChanged (EventArgs e)  Called when the WindowState of this NativeWindow has changed. More...
void ProcessEvents (bool retainEvents)  Processes operating system events until the NativeWindow becomes idle. More...
Properties IGraphicsContext Context [get] Returns the opengl IGraphicsContext associated with the current GameWindow . More...
bool IsExiting [get] Gets a value indicating whether the shutdown sequence has been initiated for this window, by calling GameWindow.Exit() or hitting the 'close' button. If this property is true, it is no longer safe to use any OpenTK.Input or OpenTK.Graphics.OpenGL functions or properties. More...
IList< JoystickDevice > Joysticks [get] Gets a readonly IList containing all available OpenTK.Input.JoystickDevices. More...
KeyboardDevice Keyboard [get] Gets the primary Keyboard device, or null if no Keyboard exists. More...
MouseDevice Mouse [get] Gets the primary Mouse device, or null if no Mouse exists. More...
double RenderFrequency [get] Gets a double representing the actual frequency of RenderFrame events, in hertz (i.e. fps or frames per second). More...
double RenderPeriod [get] Gets a double representing the period of RenderFrame events, in seconds. More...
double RenderTime [get, set] Gets a double representing the time spent in the RenderFrame function, in seconds. More...
double TargetRenderFrequency [get, set] Gets or sets a double representing the target render frequency, in hertz. More...
double TargetRenderPeriod [get, set] Gets or sets a double representing the target render period, in seconds. More...
double TargetUpdateFrequency [get, set] Gets or sets a double representing the target update frequency, in hertz. More...
double TargetUpdatePeriod [get, set] Gets or sets a double representing the target update period, in seconds. More...
double UpdateFrequency [get] Gets a double representing the frequency of UpdateFrame events, in hertz. More...
double UpdatePeriod [get] Gets a double representing the period of UpdateFrame events, in seconds. More...
double UpdateTime [get] Gets a double representing the time spent in the UpdateFrame function, in seconds. More...
VSyncMode VSync [get, set] Gets or sets the VSyncMode. More...
override WindowState WindowState [get, set] Gets or states the state of the NativeWindow . More...
- Properties inherited from OpenTK.NativeWindow Rectangle Bounds [get, set] Gets or sets a System.Drawing.Rectangle structure that contains the external bounds of this window, in screen coordinates. External bounds include the title bar, borders and drawing area of the window. More...
Rectangle ClientRectangle [get, set] Gets or sets a System.Drawing.Rectangle structure that contains the internal bounds of this window, in client coordinates. The internal bounds include the drawing area of the window, but exclude the titlebar and window borders. More...
Size ClientSize [get, set] Gets or sets a System.Drawing.Size structure that contains the internal size this window. More...
bool Exists [get] Gets a value indicating whether a render window exists. More...
bool Focused [get] Gets a System.Boolean that indicates whether this NativeWindow has input focus. More...
int Height [get, set] Gets or sets the external height of this window. More...
Icon Icon [get, set] Gets or sets the System.Drawing.Icon for this GameWindow . More...
IInputDriver InputDriver [get] This property is deprecated. More...
Point Location [get, set] Gets or sets a System.Drawing.Point structure that contains the location of this window on the desktop. More...
Size Size [get, set] Gets or sets a System.Drawing.Size structure that contains the external size of this window. More...
string Title [get, set] Gets or sets the NativeWindow title. More...
bool Visible [get, set] Gets or sets a System.Boolean that indicates whether this NativeWindow is visible. More...
int Width [get, set] Gets or sets the external width of this window. More...
WindowBorder WindowBorder [get, set] Gets or states the border of the NativeWindow . More...
IWindowInfo WindowInfo [get] Gets the OpenTK.Platform.IWindowInfo of this window. More...
virtual WindowState WindowState [get, set] Gets or states the state of the NativeWindow . More...
int X [get, set] Gets or sets the horizontal location of this window on the desktop. More...
int Y [get, set] Gets or sets the vertical location of this window on the desktop. More...
bool CursorVisible [get, set] Gets or sets a value indicating whether the mouse cursor is visible. More...
bool IsDisposed [get, set] Gets or sets a System.Boolean, which indicates whether this instance has been disposed. More...
- Properties inherited from OpenTK.INativeWindow Icon Icon [get, set] Gets or sets the System.Drawing.Icon of the window. More...
string Title [get, set] Gets or sets the title of the window. More...
bool Focused [get] Gets a System.Boolean that indicates whether this window has input focus. More...
bool Visible [get, set] Gets or sets a System.Boolean that indicates whether the window is visible. More...
bool Exists [get] Gets a System.Boolean that indicates whether the window has been created and has not been destroyed. More...
IWindowInfo WindowInfo [get] Gets the OpenTK.Platform.IWindowInfo for this window. More...
WindowState WindowState [get, set] Gets or sets the OpenTK.WindowState for this window. More...
WindowBorder WindowBorder [get, set] Gets or sets the OpenTK.WindowBorder for this window. More...
Rectangle Bounds [get, set] Gets or sets a System.Drawing.Rectangle structure the contains the external bounds of this window, in screen coordinates. External bounds include the title bar, borders and drawing area of the window. More...
Point Location [get, set] Gets or sets a System.Drawing.Point structure that contains the location of this window on the desktop. More...
Size Size [get, set] Gets or sets a System.Drawing.Size structure that contains the external size of this window. More...
int X [get, set] Gets or sets the horizontal location of this window on the desktop. More...
int Y [get, set] Gets or sets the vertical location of this window on the desktop. More...
int Width [get, set] Gets or sets the external width of this window. More...
int Height [get, set] Gets or sets the external height of this window. More...
Rectangle ClientRectangle [get, set] Gets or sets a System.Drawing.Rectangle structure that contains the internal bounds of this window, in client coordinates. The internal bounds include the drawing area of the window, but exclude the titlebar and window borders. More...
Size ClientSize [get, set] Gets or sets a System.Drawing.Size structure that contains the internal size this window. More...
OpenTK.Input.IInputDriver InputDriver [get] This property is deprecated and should not be used. More...
bool CursorVisible [get, set] Gets or sets a value, indicating whether the mouse cursor is visible. More...
Events EventHandler< EventArgs > Load = delegate { }  Occurs before the window is displayed for the first time. More...
EventHandler< FrameEventArgs > RenderFrame = delegate { }  Occurs when it is time to render a frame. More...
EventHandler< EventArgs > Unload = delegate { }  Occurs before the window is destroyed. More...
EventHandler< FrameEventArgs > UpdateFrame = delegate { }  Occurs when it is time to update a frame. More...
- Events inherited from OpenTK.NativeWindow EventHandler< EventArgs > Closed = delegate { }  Occurs after the window has closed. More...
EventHandler< CancelEventArgs > Closing = delegate { }  Occurs when the window is about to close. More...
EventHandler< EventArgs > Disposed = delegate { }  Occurs when the window is disposed. More...
EventHandler< EventArgs > FocusedChanged = delegate { }  Occurs when the Focused property of the window changes. More...
EventHandler< EventArgs > IconChanged = delegate { }  Occurs when the Icon property of the window changes. More...
EventHandler
< OpenTK.Input.KeyboardKeyEventArgs > KeyDown = delegate { }  Occurs whenever a keybord key is pressed. More...
EventHandler< KeyPressEventArgs > KeyPress = delegate { }  Occurs whenever a character is typed. More...
EventHandler
< OpenTK.Input.KeyboardKeyEventArgs > KeyUp = delegate { }  Occurs whenever a keyboard key is released. More...
EventHandler< EventArgs > Move = delegate { }  Occurs whenever the window is moved. More...
EventHandler< EventArgs > MouseEnter = delegate { }  Occurs whenever the mouse cursor enters the window Bounds . More...
EventHandler< EventArgs > MouseLeave = delegate { }  Occurs whenever the mouse cursor leaves the window Bounds . More...
EventHandler< EventArgs > Resize = delegate { }  Occurs whenever the window is resized. More...
EventHandler< EventArgs > TitleChanged = delegate { }  Occurs when the Title property of the window changes. More...
EventHandler< EventArgs > VisibleChanged = delegate { }  Occurs when the Visible property of the window changes. More...
EventHandler< EventArgs > WindowBorderChanged = delegate { }  Occurs when the WindowBorder property of the window changes. More...
EventHandler< EventArgs > WindowStateChanged = delegate { }  Occurs when the WindowState property of the window changes. More...
- Events inherited from OpenTK.INativeWindow EventHandler< EventArgs > Move Occurs whenever the window is moved. More...
EventHandler< EventArgs > Resize Occurs whenever the window is resized. More...
EventHandler< CancelEventArgs > Closing Occurs when the window is about to close. More...
EventHandler< EventArgs > Closed Occurs after the window has closed. More...
EventHandler< EventArgs > Disposed Occurs when the window is disposed. More...
EventHandler< EventArgs > IconChanged Occurs when the Icon property of the window changes. More...
EventHandler< EventArgs > TitleChanged Occurs when the Title property of the window changes. More...
EventHandler< EventArgs > VisibleChanged Occurs when the Visible property of the window changes. More...
EventHandler< EventArgs > FocusedChanged Occurs when the Focused property of the window changes. More...
EventHandler< EventArgs > WindowBorderChanged Occurs when the WindowBorder property of the window changes. More...
EventHandler< EventArgs > WindowStateChanged Occurs when the WindowState property of the window changes. More...
EventHandler
< OpenTK.Input.KeyboardKeyEventArgs > KeyDown Occurs whenever a keybord key is pressed. More...
EventHandler< KeyPressEventArgs > KeyPress Occurs whenever a character is typed. More...
EventHandler
< OpenTK.Input.KeyboardKeyEventArgs > KeyUp Occurs whenever a keyboard key is released. More...
EventHandler< EventArgs > MouseLeave Occurs whenever the mouse cursor leaves the window Bounds . More...
EventHandler< EventArgs > MouseEnter Occurs whenever the mouse cursor enters the window Bounds . More...
- Events inherited from OpenTK.Platform.IGameWindow EventHandler< EventArgs > Load Occurs before the window is displayed for the first time. More...
EventHandler< EventArgs > Unload Occurs before the window is destroyed. More...
EventHandler< FrameEventArgs > UpdateFrame Occurs when it is time to update a frame. More...
EventHandler< FrameEventArgs > RenderFrame Occurs when it is time to render a frame. More...

Detailed Description

The GameWindow class contains cross-platform methods to create and render on an OpenGL window, handle input and load resources.

GameWindow contains several events you can hook or override to add your custom logic:

OnLoad: Occurs after creating the OpenGL context, but before entering the main loop. Override to load resources. OnUnload: Occurs after exiting the main loop, but before deleting the OpenGL context. Override to unload resources. OnResize: Occurs whenever GameWindow is resized. You should update the OpenGL Viewport and Projection Matrix here. OnUpdateFrame: Occurs at the specified logic update rate. Override to add your game logic. OnRenderFrame: Occurs at the specified frame render rate. Override to add your rendering code.

Call the Run() method to start the application's main loop. Run(double, double) takes two parameters that specify the logic update rate, and the render update rate.

Constructor & Destructor Documentation

widthThe width of the GameWindow in pixels. heightThe height of the GameWindow in pixels. modeThe OpenTK.Graphics.GraphicsMode of the GameWindow . widthThe width of the GameWindow in pixels. heightThe height of the GameWindow in pixels. modeThe OpenTK.Graphics.GraphicsMode of the GameWindow . titleThe title of the GameWindow . widthThe width of the GameWindow in pixels. heightThe height of the GameWindow in pixels. modeThe OpenTK.Graphics.GraphicsMode of the GameWindow . titleThe title of the GameWindow . options GameWindow options regarding window appearance and behavior. widthThe width of the GameWindow in pixels. heightThe height of the GameWindow in pixels. modeThe OpenTK.Graphics.GraphicsMode of the GameWindow . titleThe title of the GameWindow . options GameWindow options regarding window appearance and behavior. deviceThe OpenTK.Graphics.DisplayDevice to construct the GameWindow in. widthThe width of the GameWindow in pixels. heightThe height of the GameWindow in pixels. modeThe OpenTK.Graphics.GraphicsMode of the GameWindow . titleThe title of the GameWindow . options GameWindow options regarding window appearance and behavior. deviceThe OpenTK.Graphics.DisplayDevice to construct the GameWindow in. majorThe major version for the OpenGL GraphicsContext. minorThe minor version for the OpenGL GraphicsContext. flagsThe GraphicsContextFlags version for the OpenGL GraphicsContext. widthThe width of the GameWindow in pixels. heightThe height of the GameWindow in pixels. modeThe OpenTK.Graphics.GraphicsMode of the GameWindow . titleThe title of the GameWindow . options GameWindow options regarding window appearance and behavior. deviceThe OpenTK.Graphics.DisplayDevice to construct the GameWindow in. majorThe major version for the OpenGL GraphicsContext. minorThe minor version for the OpenGL GraphicsContext. flagsThe GraphicsContextFlags version for the OpenGL GraphicsContext. sharedContextAn IGraphicsContext to share resources with.

Closes the GameWindow . Equivalent to NativeWindow.Close method.

Override if you are not using GameWindow.Run() .

If you override this method, place a call to base.Exit(), to ensure proper OpenTK shutdown.

Called after an OpenGL context has been established, but before entering the main loop.

Parameters
eNot used.

You will typically wish to update your viewport whenever the window is resized. See the OpenTK.Graphics.OpenGL.GL.Viewport(int, int, int, int) method.

Reimplemented from OpenTK.NativeWindow .

Called after GameWindow.Exit was called, but before destroying the OpenGL context.

Parameters
eNot used.

Enters the game loop of the GameWindow using the maximum update rate.

See Also
Run(double)

Implements OpenTK.Platform.IGameWindow .

Enters the game loop of the GameWindow using the specified update rate. maximum possible render frequency.

Implements OpenTK.Platform.IGameWindow .

Enters the game loop of the GameWindow updating and rendering at the specified frequency.

When overriding the default game loop you should call ProcessEvents() to ensure that your GameWindow responds to operating system events.

Once ProcessEvents() returns, it is time to call update and render the next frame.

Parameters
updates_per_secondThe frequency of UpdateFrame events. frames_per_secondThe frequency of RenderFrame events.

Gets or sets a double representing the target render frequency, in hertz.

A value of 0.0 indicates that RenderFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).

Values lower than 1.0Hz are clamped to 1.0Hz. Values higher than 200.0Hz are clamped to 200.0Hz.

Gets or sets a double representing the target render period, in seconds.

A value of 0.0 indicates that RenderFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).

Values lower than 0.005 seconds (200Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0.

Gets or sets a double representing the target update frequency, in hertz.

A value of 0.0 indicates that UpdateFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).

Values lower than 1.0Hz are clamped to 1.0Hz. Values higher than 200.0Hz are clamped to 200.0Hz.

Gets or sets a double representing the target update period, in seconds.

A value of 0.0 indicates that UpdateFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).

Values lower than 0.005 seconds (200Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0.