C# Класс SFML.Graphics.RenderWindow

Simple wrapper for Window that allows easy 2D rendering
Наследование: Window.Window, RenderTarget
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Clear ( ) : void

Clear the entire window with black color

Clear ( System.Color color ) : void

Clear the entire window with a single color

Close ( ) : void

Close (destroy) the window. The Window instance remains valid and you can call Create to recreate the window

Display ( ) : void

Display the window on screen

Draw ( Drawable drawable ) : void

Draw a drawable object to the render-target, with default render states

Draw ( Drawable drawable, RenderStates states ) : void

Draw a drawable object to the render-target

Draw ( Vertex vertices, PrimitiveType type ) : void

Draw primitives defined by an array of vertices, with default render states

Draw ( Vertex vertices, PrimitiveType type, RenderStates states ) : void

Draw primitives defined by an array of vertices

Draw ( Vertex vertices, uint start, uint count, PrimitiveType type ) : void

Draw primitives defined by a sub-array of vertices, with default render states

Draw ( Vertex vertices, uint start, uint count, PrimitiveType type, RenderStates states ) : void

Draw primitives defined by a sub-array of vertices

GetView ( ) : View

Return the current active view

GetViewport ( View view ) : IntRect

Get the viewport of a view applied to this target

HasFocus ( ) : bool

Check whether the window has the input focus

MapCoordsToPixel ( Vector2f point ) : Vector2i

Convert a point from world coordinates to target coordinates, using the current view This function is an overload of the mapCoordsToPixel function that implicitly uses the current view. It is equivalent to: target.MapCoordsToPixel(point, target.GetView());

MapCoordsToPixel ( Vector2f point, View view ) : Vector2i

Convert a point from world coordinates to target coordinates This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target -- if the view is translated by (140, 25). This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

MapPixelToCoords ( Vector2i point ) : Vector2f

Convert a point from target coordinates to world coordinates, using the current view This function is an overload of the MapPixelToCoords function that implicitly uses the current view. It is equivalent to: target.MapPixelToCoords(point, target.GetView());

MapPixelToCoords ( Vector2i point, View view ) : Vector2f

Convert a point from target coordinates to world coordinates This function finds the 2D position that matches the given pixel of the render-target. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25). For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor. This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

PopGLStates ( ) : void

Restore the previously saved OpenGL render states and matrices. See the description of PushGLStates to get a detailed description of these functions.

PushGLStates ( ) : void

Save the current OpenGL render states and matrices.

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with PopGLStates, it ensures that:

SFML's internal states are not messed up by your OpenGL code

Your OpenGL states are not modified by a call to a SFML function

More specifically, it must be used around code that calls Draw functions.

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the ResetGLStates function if you do so.

RenderWindow ( IntPtr handle ) : System

Create the window from an existing control with default creation settings

RenderWindow ( IntPtr handle, ContextSettings settings ) : System

Create the window from an existing control

RenderWindow ( VideoMode mode, string title ) : System

Create the window with default style and creation settings

RenderWindow ( VideoMode mode, string title, Styles style ) : System

Create the window with default creation settings

RenderWindow ( VideoMode mode, string title, Styles style, ContextSettings settings ) : System

Create the window

RequestFocus ( ) : void

Request the current window to be made the active foreground window

ResetGLStates ( ) : void

Reset the internal OpenGL states so that the target is ready for drawing.

This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use PushGLStates/PopGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent Draw() calls will work as expected.

SetActive ( bool active ) : bool

Activate of deactivate the window as the current target for rendering

SetFramerateLimit ( uint limit ) : void

Limit the framerate to a maximum fixed frequency

SetIcon ( uint width, uint height, byte pixels ) : void

Change the window's icon

SetJoystickThreshold ( float threshold ) : void

Change the joystick threshold, ie. the value below which no move event will be generated

SetKeyRepeatEnabled ( bool enable ) : void

Enable or disable automatic key-repeat. Automatic key-repeat is enabled by default

SetMouseCursorGrabbed ( bool grabbed ) : void

Grab or release the mouse cursor

If set, grabs the mouse cursor inside this window's client area so it may no longer be moved outside its bounds. Note that grabbing is only active while the window has focus and calling this function for fullscreen windows won't have any effect (fullscreen windows always grab the cursor).

SetMouseCursorVisible ( bool visible ) : void

Show or hide the mouse cursor

SetTitle ( string title ) : void

Change the title of the window

SetVerticalSyncEnabled ( bool enable ) : void

Enable / disable vertical synchronization

SetView ( View view ) : void

Change the current active view

SetVisible ( bool visible ) : void

Show or hide the window

ToString ( ) : string

Provide a string describing the object

Защищенные методы

Метод Описание
Destroy ( bool disposing ) : void

Handle the destruction of the object

InternalGetMousePosition ( ) : Vector2i

Internal function to get the mouse position relative to the window. This function is protected because it is called by another class, it is not meant to be called by users.

InternalGetTouchPosition ( uint Finger ) : Vector2i

Internal function to get the touch position relative to the window. This function is protected because it is called by another class of another module, it is not meant to be called by users.

InternalSetMousePosition ( Vector2i position ) : void

Internal function to set the mouse position relative to the window. This function is protected because it is called by another class, it is not meant to be called by users.

PollEvent ( Event &eventToFill ) : bool

Internal function to get the next event

WaitEvent ( Event &eventToFill ) : bool

Internal function to get the next event (blocking)

Приватные методы

Метод Описание
Capture ( ) : Image
Initialize ( ) : void

Do common initializations

sfMouse_getPositionRenderWindow ( IntPtr CPointer ) : Vector2i
sfMouse_setPositionRenderWindow ( Vector2i position, IntPtr CPointer ) : void
sfRenderWindow_capture ( IntPtr CPointer ) : IntPtr
sfRenderWindow_clear ( IntPtr CPointer, System.Color ClearColor ) : void
sfRenderWindow_close ( IntPtr CPointer ) : void
sfRenderWindow_create ( VideoMode Mode, string Title, Styles Style, ContextSettings &Params ) : IntPtr
sfRenderWindow_createFromHandle ( IntPtr Handle, ContextSettings &Params ) : IntPtr
sfRenderWindow_createUnicode ( VideoMode Mode, IntPtr Title, Styles Style, ContextSettings &Params ) : IntPtr
sfRenderWindow_destroy ( IntPtr CPointer ) : void
sfRenderWindow_display ( IntPtr CPointer ) : void
sfRenderWindow_drawPrimitives ( IntPtr CPointer, Vertex vertexPtr, uint vertexCount, PrimitiveType type, RenderStates &renderStates ) : void
sfRenderWindow_getDefaultView ( IntPtr CPointer ) : IntPtr
sfRenderWindow_getFrameTime ( IntPtr CPointer ) : uint
sfRenderWindow_getPosition ( IntPtr CPointer ) : Vector2i
sfRenderWindow_getSettings ( IntPtr CPointer ) : ContextSettings
sfRenderWindow_getSize ( IntPtr CPointer ) : Vector2u
sfRenderWindow_getSystemHandle ( IntPtr CPointer ) : IntPtr
sfRenderWindow_getView ( IntPtr CPointer ) : IntPtr
sfRenderWindow_getViewport ( IntPtr CPointer, IntPtr TargetView ) : IntRect
sfRenderWindow_hasFocus ( IntPtr CPointer ) : bool
sfRenderWindow_isOpen ( IntPtr CPointer ) : bool
sfRenderWindow_mapCoordsToPixel ( IntPtr CPointer, Vector2f point, IntPtr View ) : Vector2i
sfRenderWindow_mapPixelToCoords ( IntPtr CPointer, Vector2i point, IntPtr View ) : Vector2f
sfRenderWindow_pollEvent ( IntPtr CPointer, Event &Evt ) : bool
sfRenderWindow_popGLStates ( IntPtr CPointer ) : void
sfRenderWindow_pushGLStates ( IntPtr CPointer ) : void
sfRenderWindow_requestFocus ( IntPtr CPointer ) : void
sfRenderWindow_resetGLStates ( IntPtr CPointer ) : void
sfRenderWindow_restoreGLStates ( IntPtr CPointer ) : bool
sfRenderWindow_saveGLStates ( IntPtr CPointer ) : bool
sfRenderWindow_setActive ( IntPtr CPointer, bool Active ) : bool
sfRenderWindow_setFramerateLimit ( IntPtr CPointer, uint Limit ) : void
sfRenderWindow_setIcon ( IntPtr CPointer, uint Width, uint Height, byte Pixels ) : void
sfRenderWindow_setJoystickThreshold ( IntPtr CPointer, float Threshold ) : void
sfRenderWindow_setKeyRepeatEnabled ( IntPtr CPointer, bool Enable ) : void
sfRenderWindow_setMouseCursorGrabbed ( IntPtr CPointer, bool grabbed ) : void
sfRenderWindow_setMouseCursorVisible ( IntPtr CPointer, bool visible ) : void
sfRenderWindow_setPosition ( IntPtr CPointer, Vector2i position ) : void
sfRenderWindow_setSize ( IntPtr CPointer, Vector2u size ) : void
sfRenderWindow_setTitle ( IntPtr CPointer, string title ) : void
sfRenderWindow_setUnicodeTitle ( IntPtr CPointer, IntPtr title ) : void
sfRenderWindow_setVerticalSyncEnabled ( IntPtr CPointer, bool Enable ) : void
sfRenderWindow_setView ( IntPtr CPointer, IntPtr View ) : void
sfRenderWindow_setVisible ( IntPtr CPointer, bool visible ) : void
sfRenderWindow_waitEvent ( IntPtr CPointer, Event &Evt ) : bool
sfTouch_getPositionRenderWindow ( uint Finger, IntPtr RelativeTo ) : Vector2i

Описание методов

Clear() публичный Метод

Clear the entire window with black color
public Clear ( ) : void
Результат void

Clear() публичный Метод

Clear the entire window with a single color
public Clear ( System.Color color ) : void
color System.Color Color to use to clear the window
Результат void

Close() публичный Метод

Close (destroy) the window. The Window instance remains valid and you can call Create to recreate the window
public Close ( ) : void
Результат void

Destroy() защищенный Метод

Handle the destruction of the object
protected Destroy ( bool disposing ) : void
disposing bool Is the GC disposing the object, or is it an explicit call ?
Результат void

Display() публичный Метод

Display the window on screen
public Display ( ) : void
Результат void

Draw() публичный Метод

Draw a drawable object to the render-target, with default render states
public Draw ( Drawable drawable ) : void
drawable Drawable Object to draw
Результат void

Draw() публичный Метод

Draw a drawable object to the render-target
public Draw ( Drawable drawable, RenderStates states ) : void
drawable Drawable Object to draw
states RenderStates Render states to use for drawing
Результат void

Draw() публичный Метод

Draw primitives defined by an array of vertices, with default render states
public Draw ( Vertex vertices, PrimitiveType type ) : void
vertices Vertex Pointer to the vertices
type PrimitiveType Type of primitives to draw
Результат void

Draw() публичный Метод

Draw primitives defined by an array of vertices
public Draw ( Vertex vertices, PrimitiveType type, RenderStates states ) : void
vertices Vertex Pointer to the vertices
type PrimitiveType Type of primitives to draw
states RenderStates Render states to use for drawing
Результат void

Draw() публичный Метод

Draw primitives defined by a sub-array of vertices, with default render states
public Draw ( Vertex vertices, uint start, uint count, PrimitiveType type ) : void
vertices Vertex Array of vertices to draw
start uint Index of the first vertex to draw in the array
count uint Number of vertices to draw
type PrimitiveType Type of primitives to draw
Результат void

Draw() публичный Метод

Draw primitives defined by a sub-array of vertices
public Draw ( Vertex vertices, uint start, uint count, PrimitiveType type, RenderStates states ) : void
vertices Vertex Pointer to the vertices
start uint Index of the first vertex to use in the array
count uint Number of vertices to draw
type PrimitiveType Type of primitives to draw
states RenderStates Render states to use for drawing
Результат void

GetView() публичный Метод

Return the current active view
public GetView ( ) : View
Результат View

GetViewport() публичный Метод

Get the viewport of a view applied to this target
public GetViewport ( View view ) : IntRect
view View Target view
Результат IntRect

HasFocus() публичный Метод

Check whether the window has the input focus
public HasFocus ( ) : bool
Результат bool

InternalGetMousePosition() защищенный Метод

Internal function to get the mouse position relative to the window. This function is protected because it is called by another class, it is not meant to be called by users.
protected InternalGetMousePosition ( ) : Vector2i
Результат Vector2i

InternalGetTouchPosition() защищенный Метод

Internal function to get the touch position relative to the window. This function is protected because it is called by another class of another module, it is not meant to be called by users.
protected InternalGetTouchPosition ( uint Finger ) : Vector2i
Finger uint Finger index
Результат Vector2i

InternalSetMousePosition() защищенный Метод

Internal function to set the mouse position relative to the window. This function is protected because it is called by another class, it is not meant to be called by users.
protected InternalSetMousePosition ( Vector2i position ) : void
position Vector2i Relative mouse position
Результат void

MapCoordsToPixel() публичный Метод

Convert a point from world coordinates to target coordinates, using the current view This function is an overload of the mapCoordsToPixel function that implicitly uses the current view. It is equivalent to: target.MapCoordsToPixel(point, target.GetView());
public MapCoordsToPixel ( Vector2f point ) : Vector2i
point Vector2f Point to convert
Результат Vector2i

MapCoordsToPixel() публичный Метод

Convert a point from world coordinates to target coordinates This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target -- if the view is translated by (140, 25). This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.
public MapCoordsToPixel ( Vector2f point, View view ) : Vector2i
point Vector2f Point to convert
view View The view to use for converting the point
Результат Vector2i

MapPixelToCoords() публичный Метод

Convert a point from target coordinates to world coordinates, using the current view This function is an overload of the MapPixelToCoords function that implicitly uses the current view. It is equivalent to: target.MapPixelToCoords(point, target.GetView());
public MapPixelToCoords ( Vector2i point ) : Vector2f
point Vector2i Pixel to convert
Результат Vector2f

MapPixelToCoords() публичный Метод

Convert a point from target coordinates to world coordinates This function finds the 2D position that matches the given pixel of the render-target. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25). For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor. This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.
public MapPixelToCoords ( Vector2i point, View view ) : Vector2f
point Vector2i Pixel to convert
view View The view to use for converting the point
Результат Vector2f

PollEvent() защищенный Метод

Internal function to get the next event
protected PollEvent ( Event &eventToFill ) : bool
eventToFill SFML.Window.Event Variable to fill with the raw pointer to the event structure
Результат bool

PopGLStates() публичный Метод

Restore the previously saved OpenGL render states and matrices. See the description of PushGLStates to get a detailed description of these functions.
public PopGLStates ( ) : void
Результат void

PushGLStates() публичный Метод

Save the current OpenGL render states and matrices.

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with PopGLStates, it ensures that:

SFML's internal states are not messed up by your OpenGL code

Your OpenGL states are not modified by a call to a SFML function

More specifically, it must be used around code that calls Draw functions.

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the ResetGLStates function if you do so.

public PushGLStates ( ) : void
Результат void

RenderWindow() публичный Метод

Create the window from an existing control with default creation settings
public RenderWindow ( IntPtr handle ) : System
handle System.IntPtr Platform-specific handle of the control
Результат System

RenderWindow() публичный Метод

Create the window from an existing control
public RenderWindow ( IntPtr handle, ContextSettings settings ) : System
handle System.IntPtr Platform-specific handle of the control
settings SFML.Window.ContextSettings Creation parameters
Результат System

RenderWindow() публичный Метод

Create the window with default style and creation settings
public RenderWindow ( VideoMode mode, string title ) : System
mode SFML.Window.VideoMode Video mode to use
title string Title of the window
Результат System

RenderWindow() публичный Метод

Create the window with default creation settings
public RenderWindow ( VideoMode mode, string title, Styles style ) : System
mode SFML.Window.VideoMode Video mode to use
title string Title of the window
style Styles Window style (Resize | Close by default)
Результат System

RenderWindow() публичный Метод

Create the window
public RenderWindow ( VideoMode mode, string title, Styles style, ContextSettings settings ) : System
mode SFML.Window.VideoMode Video mode to use
title string Title of the window
style Styles Window style (Resize | Close by default)
settings SFML.Window.ContextSettings Creation parameters
Результат System

RequestFocus() публичный Метод

Request the current window to be made the active foreground window
public RequestFocus ( ) : void
Результат void

ResetGLStates() публичный Метод

Reset the internal OpenGL states so that the target is ready for drawing.
This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use PushGLStates/PopGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent Draw() calls will work as expected.
public ResetGLStates ( ) : void
Результат void

SetActive() публичный Метод

Activate of deactivate the window as the current target for rendering
public SetActive ( bool active ) : bool
active bool True to activate, false to deactivate (true by default)
Результат bool

SetFramerateLimit() публичный Метод

Limit the framerate to a maximum fixed frequency
public SetFramerateLimit ( uint limit ) : void
limit uint Framerate limit, in frames per seconds (use 0 to disable limit)
Результат void

SetIcon() публичный Метод

Change the window's icon
public SetIcon ( uint width, uint height, byte pixels ) : void
width uint Icon's width, in pixels
height uint Icon's height, in pixels
pixels byte Array of pixels, format must be RGBA 32 bits
Результат void

SetJoystickThreshold() публичный Метод

Change the joystick threshold, ie. the value below which no move event will be generated
public SetJoystickThreshold ( float threshold ) : void
threshold float New threshold, in range [0, 100]
Результат void

SetKeyRepeatEnabled() публичный Метод

Enable or disable automatic key-repeat. Automatic key-repeat is enabled by default
public SetKeyRepeatEnabled ( bool enable ) : void
enable bool True to enable, false to disable
Результат void

SetMouseCursorGrabbed() публичный Метод

Grab or release the mouse cursor
If set, grabs the mouse cursor inside this window's client area so it may no longer be moved outside its bounds. Note that grabbing is only active while the window has focus and calling this function for fullscreen windows won't have any effect (fullscreen windows always grab the cursor).
public SetMouseCursorGrabbed ( bool grabbed ) : void
grabbed bool True to grab, false to release
Результат void

SetMouseCursorVisible() публичный Метод

Show or hide the mouse cursor
public SetMouseCursorVisible ( bool visible ) : void
visible bool True to show, false to hide
Результат void

SetTitle() публичный Метод

Change the title of the window
public SetTitle ( string title ) : void
title string New title
Результат void

SetVerticalSyncEnabled() публичный Метод

Enable / disable vertical synchronization
public SetVerticalSyncEnabled ( bool enable ) : void
enable bool True to enable v-sync, false to deactivate
Результат void

SetView() публичный Метод

Change the current active view
public SetView ( View view ) : void
view View New view
Результат void

SetVisible() публичный Метод

Show or hide the window
public SetVisible ( bool visible ) : void
visible bool True to show the window, false to hide it
Результат void

ToString() публичный Метод

Provide a string describing the object
public ToString ( ) : string
Результат string

WaitEvent() защищенный Метод

Internal function to get the next event (blocking)
protected WaitEvent ( Event &eventToFill ) : bool
eventToFill SFML.Window.Event Variable to fill with the raw pointer to the event structure
Результат bool