Struct sfml::graphics::RenderWindow [] [src]

pub struct RenderWindow { /* fields omitted */ }

Window that can serve as a target for 2D drawing.

RenderWindow is the main type of the graphics module. It defines an OS window that can be painted using the other classes of the graphics module.

Methods

impl RenderWindow
[src]

Construct a new render window

This function creates the render window with the size and pixel depth defined in mode. An optional style can be passed to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...). If style contains FULLSCREEN, then mode must be a valid video mode.

The fourth parameter is a pointer to a structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc.

Arguments

  • mode - Video mode to use (defines the width, height and depth of the rendering area of the render window)
  • title - Title of the render window
  • style - Window style
  • settings - Additional settings for the underlying OpenGL context

Return Some(RenderWindow) or None

Change a render window's icon pixels must be an array of width x height pixels in 32-bits RGBA format.

Arguments

  • width - Icon's width, in pixels
  • height - Icon's height, in pixels
  • pixels - Vector of pixels

Return an iterator over all the event currently in the events queue.

Pop the event on top of event queue, if any, and return it

This function is not blocking: if there's no pending event then it will return false and leave \a event unmodified. Note that more than one event may be present in the event queue, thus you should always call this function in a loop to make sure that you process every pending event.

Return Some(event) if an event was returned, or None if the event queue was empty

Wait for an event and return it

This function is blocking: if there's no pending event then it will wait until an event is received. After this function returns (and no error occured), the event object is always valid and filled properly. This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread sleep as long as no new event is received.

Return Some(event) or None if an error has occured

Close a render window and destroy all the attached resources

After calling this method, the Window object remains valid. All other functions such as poll_event or display will still work (i.e. you don't have to test is_open every time), and will have no effect on closed windows.

Tell whether or not a window is opened

This function returns whether or not the window exists. Note that a hidden window (set_visible(false)) will return true.

Display on screen what has been rendered to the window so far

This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.

Limit the framerate to a maximum fixed frequency

If a limit is set, the window will use a small delay after each call to RenderWindow::display to ensure that the current frame lasted long enough to match the framerate limit.

Arguments

  • limit - Framerate limit, in frames per seconds (use 0 to disable limit)

Get the settings of the OpenGL context of a window

Note that these settings may be different from what was passed to the RenderWindow::create function, if one or more settings were not supported. In this case, SFML chose the closest match.

Return a structure containing the OpenGL context settings

Change the title of a window

Arguments

  • title - New title

Show or hide a window

Arguments

  • visible - true to show the window, false to hide it

Show or hide the mouse cursor

Arguments

  • visible - true to false to hide

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.

Enable or disable vertical synchronization

Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor. This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

Arguments

  • enabled - true to enable v-sync, false to deactivate

Enable or disable automatic key-repeat

If key repeat is enabled, you will receive repeated KeyPress events while keeping a key pressed. If it is disabled, you will only get a single event when the key is pressed.

Key repeat is enabled by default.

Arguments

  • enabled - true to enable, false to disable

Activate or deactivate a render window as the current target for OpenGL rendering

A window is active only on the current thread, if you want to make it active on another thread you have to deactivate it on the previous thread first if it was active. Only one window can be active on a thread at a time, thus the window previously active (if any) automatically gets deactivated.

Arguments

  • active - true to activate, false to deactivate

Return true if operation was successful, false otherwise

Change the joystick threshold

The joystick threshold is the value below which no JoyMoved event will be generated.

Arguments

  • threshold - New threshold, in the range [0, 100]

Get the position of a window

Return the position in pixels

Change the position of a window on screen

This function only works for top-level windows (i.e. it will be ignored for windows created from the handle of a child window/control).

Arguments

  • position - New position of the window, in pixels

Change the size of the rendering region of a window

Arguments

  • size - New size, in pixels

Change the size of the rendering region of a window

Arguments

  • size_x - New size x, in pixels
  • size_y - New size x, in pixels

Returns the current position of the mouse relative to the window.

Set the current position of the mouse relatively to a render window

This function sets the current position of the mouse cursor relative to the given render window

Arguments

  • position - the positon to set

Returns the current position of a touch in window coordinates.

Check whether the window has the input focus.

At any given time, only one window may have the input focus to receive input events such as keystrokes or most mouse events.

Request the current window to be made the active foreground window.

At any given time, only one window may have the input focus to receive input events such as keystrokes or mouse events. If a window requests focus, it only hints to the operating system, that it would like to be focused. The operating system is free to deny the request. This is not to be confused with set_active().

Trait Implementations

impl Raw for RenderWindow
[src]

The raw representation of this type.

Acquires the raw representation of this type through &self.

impl RenderTarget for RenderWindow
[src]

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 and that your OpenGL states are not modified by a call to a SFML function

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.

Restore the previously saved OpenGL render states and matrices

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 push_gl_states/pop_gl_states. It makes sure that all OpenGL states needed by SFML are set, so that subsequent draw() calls will work as expected.

Change the current active view of a render window

Arguments

  • view - The new view

Get the current active view of a render window

Return the current active view

Get the default view of a render window

Return the default view of the render window

Convert a point from window coordinates to world coordinates

This function finds the 2D position that matches the given pixel of the render-window. 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 window, this assertion is not true anymore, ie. a point located at (10, 50) in your render-window may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25).

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 map_pixel_to_coords_current_view function if you want to use the current view of the render-window.

Arguments

  • point - Pixel to convert
  • view - The view to use for converting the point

Return the converted point, in "world" units

Convert a point from window coordinates to world coordinates

This function finds the 2D position that matches the given pixel of the render-window. 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 window, this assertion is not true anymore, ie. a point located at (10, 50) in your render-window may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25).

This function is typically used to find which point (or object) is located below the mouse cursor.

This version uses the current view for calculations, see the map_pixel_to_coords function if you want to use a custom view.

Arguments

  • point - Pixel to convert

Return the converted point, in "world" units

Convert a point from world coordinates to window coordinates

This function finds the pixel of the render-window 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 window, 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-window -- if the view is translated by (140, 25).

This version uses a custom view for calculations, see map_coords_to_pixel_current_view if you want to use the current view of the render-window.

Arguments

  • point - Point to convert
  • view - The view to use for converting the point

Convert a point from world coordinates to window coordinates

This function finds the pixel of the render-window 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 window, 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-window -- if the view is translated by (140, 25).

This version uses the current view for calculations, see map_coords_to_pixel if you want to use a custom view.

Arguments

  • point - Point to convert

Get the viewport of a view applied to this target

Arguments

  • view - Target view

Return the viewport rectangle, expressed in pixels in the current target

Get the size of the rendering region of a window

The size doesn't include the titlebar and borders of the window.

Return the size in pixels

Draw a drawable object to the render target

Arguments

  • object - Object to draw

Draw a drawable object to the render-target with a RenderStates

Arguments

  • object - Object to draw
  • renderStates - The renderStates to associate to the object

Draw a Text with a RenderStates

Draw a Shape with a RenderStates

Draw a sprite with a RenderStates

Draw a CircleShape with a RenderStates

Draw a RectangleShape with a RenderStates

Draw a ConvexShape with a RenderStates

Draw a VertexArray with a RenderStates

draw primitives

Clear window with the given color

impl Drop for RenderWindow
[src]

A method called when the value goes out of scope. Read more