RenderWindow

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

class RenderWindow : Window , RenderTarget {
sfRenderWindow* sfPtr;
}

Constructors

this
this()

Default constructor.

this
this(VideoMode mode, immutable(T)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)

Construct a new window.

this
this(WindowHandle handle, ContextSettings settings = ContextSettings.init)

Construct the window from an existing control.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

capture
Image capture()

Copy the current contents of the window to an image

clear
void clear(Color color = Color.Black)

Clear the entire target with a single color.

close
void close()

Close the window and destroy all the attached resources.

create
void create(VideoMode mode, const(char)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)

Create (or recreate) the window.

create
void create(VideoMode mode, const(wchar)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)

Create (or recreate) the window.

create
void create(VideoMode mode, const(dchar)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)

Create (or recreate) the window.

create
void create(WindowHandle handle, ContextSettings settings = ContextSettings.init)

Create (or recreate) the window from an existing control.

display
void display()

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

draw
void draw(Drawable drawable, RenderStates states = RenderStates.init)

Draw a drawable object to the render target.

draw
void draw(const(Vertex)[] vertices, PrimitiveType type, RenderStates states = RenderStates.init)

Draw primitives defined by an array of vertices.

getDefaultView
View getDefaultView()

Get the default view of the render target.

getSettings
ContextSettings getSettings()

Get the settings of the OpenGL context of the window.

getSize
Vector2u getSize()

Return the size of the rendering region of the target.

getSystemHandle
WindowHandle getSystemHandle()

Get the OS-specific handle of the window.

isOpen
bool isOpen()

Tell whether or not the window is open.

pollEvent
bool pollEvent(ref Event event)

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

popGLStates
void popGLStates()

Restore the previously saved OpenGL render states and matrices.

pushGLStates
void pushGLStates()

Save the current OpenGL render states and matrices.

resetGLStates
void resetGLStates()

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

setActive
bool setActive(bool active)

Get the viewport of a view, applied to this render target.

setFramerateLimit
void setFramerateLimit(uint limit)

Limit the framerate to a maximum fixed frequency.

setIcon
void setIcon(uint width, uint height, const(ubyte[]) pixels)

Change the window's icon.

setJoystickThreshhold
void setJoystickThreshhold(float threshhold)

* Change the joystick threshold. * * The joystick threshold is the value below which no JoystickMoved event * will be generated. * * The threshold value is 0.1 by default. * * Params: * threshold = New threshold, in the range [0, 100]

setJoystickThreshold
void setJoystickThreshold(float threshold)

Change the joystick threshold.

setKeyRepeatEnabled
void setKeyRepeatEnabled(bool enabled)

Enable or disable automatic key-repeat.

setMouseCursorVisible
void setMouseCursorVisible(bool visible)

Show or hide the mouse cursor.

setTitle
void setTitle(const(char)[] newTitle)

Change the title of the window

setTitle
void setTitle(const(wchar)[] newTitle)

Change the title of the window

setTitle
void setTitle(const(dchar)[] newTitle)

Change the title of the window

setVerticalSyncEnabled
void setVerticalSyncEnabled(bool enabled)

Enable or disable vertical synchronization.

setVisible
void setVisible(bool visible)

Show or hide the window.

waitEvent
bool waitEvent(ref Event event)

Wait for an event and return it.

Properties

position
Vector2i position [@property setter]
Vector2i position [@property getter]

Change the position of the window on screen.

size
Vector2u size [@property setter]
Vector2u size [@property getter]

The size of the rendering region of the window.

view
View view [@property setter]
View view [@property getter]

Change the current active view.

Inherited Members

From Window

Style
enum Style

Choices for window style

~this
~this()

Destructor.

position
Vector2i position [@property setter]

Get's or set's the window's position. * 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).

size
Vector2u size [@property setter]

Get's or set's the window's size.

setActive
bool setActive(bool active)

Activate or deactivate the 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. *

requestFocus
void requestFocus()

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

hasFocus
bool hasFocus()

Check whether the window has the input focus *

setFramerateLimit
void setFramerateLimit(uint limit)

Limit the framerate to a maximum fixed frequency. * If a limit is set, the window will use a small delay after each call to display() to ensure that the current frame lasted long enough to match the framerate limit. SFML will try to match the given limit as much as it can, but since it internally uses dsfml.system.sleep, whose precision depends on the underlying OS, the results may be a little unprecise as well (for example, you can get 65 FPS when requesting 60). *

setIcon
void setIcon(uint width, uint height, const(ubyte[]) pixels)

Change the window's icon. * pixels must be an array of width x height pixels in 32-bits RGBA format. * The OS default icon is used by default. *

setJoystickThreshold
void setJoystickThreshold(float threshold)

Change the joystick threshold. * The joystick threshold is the value below which no JoystickMoved event will be generated. * The threshold value is 0.1 by default. *

setJoystickThreshhold
void setJoystickThreshhold(float threshhold)

Change the joystick threshold. * The joystick threshold is the value below which no JoystickMoved event will be generated. * The threshold value is 0.1 by default. *

setKeyRepeatEnabled
void setKeyRepeatEnabled(bool enabled)

Enable or disable automatic key-repeat. * If key repeat is enabled, you will receive repeated KeyPressed 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. *

setMouseCursorVisible
void setMouseCursorVisible(bool visible)

Show or hide the mouse cursor. * The mouse cursor is visible by default. *

setTitle
void setTitle(const(char)[] newTitle)
void setTitle(const(wchar)[] newTitle)
void setTitle(const(dchar)[] newTitle)

Change the title of the window. *

setVisible
void setVisible(bool visible)

Show or hide the window. * The window is shown by default. *

setVerticalSyncEnabled
void setVerticalSyncEnabled(bool enabled)

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). * Vertical synchronization is disabled by default. *

getSettings
ContextSettings getSettings()

Get the settings of the OpenGL context of the window. * Note that these settings may be different from what was passed to the constructor or the create() function, if one or more settings were not supported. In this case, SFML chose the closest match. *

getSystemHandle
WindowHandle getSystemHandle()

Get the OS-specific handle of the window. * The type of the returned handle is sf::WindowHandle, which is a typedef to the handle type defined by the OS. You shouldn't need to use this function, unless you have very specific stuff to implement that SFML doesn't support, or implement a temporary workaround until a bug is fixed. *

close
void close()

Close the window and destroy all the attached resources. * After calling this function, the Window instance remains valid and you can call create() to recreate the window. All other functions such as pollEvent() or display() will still work (i.e. you don't have to test isOpen() every time), and will have no effect on closed windows.

create
void create(VideoMode mode, const(char)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)
void create(VideoMode mode, const(wchar)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)
void create(VideoMode mode, const(dchar)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init)
void create(WindowHandle handle, ContextSettings settings = ContextSettings.init)

Create (or recreate) the window. * If the window was already created, it closes it first. If style contains Style.Fullscreen, then mode must be a valid video mode. * The fourth parameter is an optional structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc.

display
void display()

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.

isOpen
bool isOpen()

Tell whether or not the window is open. * This function returns whether or not the window exists. Note that a hidden window (setVisible(false)) is open (therefore this function would return true). *

pollEvent
bool pollEvent(ref Event event)

Pop the event on top of the 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 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. *

waitEvent
bool waitEvent(ref Event event)

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. *

From RenderTarget

view
View view [@property setter]
View view [@property getter]

The current active view.

getDefaultView
View getDefaultView()

Get the default view of the render target.

getSize
Vector2u getSize()

Return the size of the rendering region of the target.

getViewport
IntRect getViewport(View view)

Get the viewport of a view, applied to this render target.

clear
void clear(Color color = Color.Black)

Clear the entire target with a single color.

draw
void draw(Drawable drawable, RenderStates states = RenderStates.init)

Draw a drawable object to the render target.

draw
void draw(const(Vertex)[] vertices, PrimitiveType type, RenderStates states = RenderStates.init)

Draw primitives defined by an array of vertices.

mapPixelToCoords
Vector2f mapPixelToCoords(Vector2i point)

Convert a point fom target coordinates to world coordinates, using the current view.

mapPixelToCoords
Vector2f mapPixelToCoords(Vector2i point, View theView)

Convert a point from target coordinates to world coordinates.

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point)

Convert a point from target coordinates to world coordinates, using the curtheView.view.

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point, View theView)

Convert a point from world coordinates to target coordinates.

popGLStates
void popGLStates()

Restore the previously saved OpenGL render states and matrices.

pushGLStates
void pushGLStates()

Save the current OpenGL render states and matrices.

resetGLStates
void resetGLStates()

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

Meta