RenderWindow

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

RenderWindow is the main class of the Graphics package.

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

RenderWindow is derived from Window, thus it inherits all its features: events, window management, OpenGL rendering, etc. See the documentation of Window for a more complete description of all these features, as well as code examples.

On top of that, RenderWindow adds more features related to 2D drawing with the graphics module (see its base class RenderTarget for more details).

Like Window, RenderWindow is still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular SFML drawing commands.

class RenderWindow : Window , RenderTarget {}

Constructors

this
this()
Undocumented in source.
this
this(VideoMode mode, immutable(T)[] title, Style style, const(ContextSettings) settings)
Undocumented in source.
this
this(WindowHandle handle, const(ContextSettings) settings)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

clear
void clear(Color color)

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, string title, Style style, const(ContextSettings) settings)

Create (or recreate) the window.

create
void create(VideoMode mode, wstring title, Style style, const(ContextSettings) settings)

Create (or recreate) the window.

create
void create(VideoMode mode, dstring title, Style style, const(ContextSettings) settings)

Create (or recreate) the window.

create
void create(WindowHandle handle, const(ContextSettings) settings)

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)

Draw a drawable object to the render target.

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

Draw primitives defined by an array of vertices.

getDefaultView
const(View) getDefaultView()

Get the default view of the render target.

getMousePosition
Vector2i getMousePosition()
Undocumented in source. Be warned that the author may not have intended to support it.
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.

getViewport
IntRect getViewport(const(View) view)

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

isOpen
bool isOpen()

Tell whether or not the window is open.

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point)

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

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point, const(View) view)

Convert a point from world coordinates to target coordinates.

mapPixelToCoords
Vector2f mapPixelToCoords(Vector2i point)

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

mapPixelToCoords
Vector2f mapPixelToCoords(Vector2i point, const(View) view)

Convert a point from target coordinates to world coordinates.

pollEvent
bool pollEvent(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.

setKeyRepeatEnabled
void setKeyRepeatEnabled(bool enabled)

Enable or disable automatic key-repeat.

setMouseCursorVisible
void setMouseCursorVisible(bool visible)

Show or hide the mouse cursor.

setMousePosition
void setMousePosition(Vector2i pos)
Undocumented in source. Be warned that the author may not have intended to support it.
setTitle
void setTitle(string newTitle)

Change the title of the window

setTitle
void setTitle(wstring newTitle)

Change the title of the window

setTitle
void setTitle(dstring 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(Event event)

Wait for an event and return it.

Properties

position
Vector2i position [@property setter]

Change the position of the window on screen.

position
Vector2i position [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
size
Vector2u size [@property setter]

The size of the rendering region of the window.

size
Vector2u size [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
view
const(View) view [@property setter]

Change the current active view.

view
const(View) view [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

windowPointer
void* windowPointer(Window window)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

sfPtr
sfRenderWindow* sfPtr;
Undocumented in source.

Inherited Members

From Window

Style
enum Style
Undocumented in source.
sfPtr
sfWindow* sfPtr;
Undocumented in source.
deleteWindowPtr
void deleteWindowPtr()
Undocumented in source. Be warned that the author may not have intended to support it.
~this
~this()
Undocumented in source.
position
Vector2i position [@property setter]

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

position
Vector2i position [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
size
Vector2u size [@property setter]

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

size
Vector2u size [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
setActive
bool setActive(bool active)

Activate or deactivate the window as the current target for OpenGL rendering.

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.

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(string newTitle)

Change the title of the window.

setTitle
void setTitle(wstring newTitle)

Change the title of the window.

setTitle
void setTitle(dstring newTitle)

Change the title of the window.

setVisible
void setVisible(bool visible)

Show or hide the window.

setVerticalSyncEnabled
void setVerticalSyncEnabled(bool enabled)

Enable or disable vertical synchronization.

getSettings
ContextSettings getSettings()

Get the settings of the OpenGL context of the window.

getSystemHandle
WindowHandle getSystemHandle()

Get the OS-specific handle of the window.

close
void close()

Close the window and destroy all the attached resources.

create
void create(VideoMode mode, string title, Style style, const(ContextSettings) settings)

Create (or recreate) the window.

create
void create(VideoMode mode, wstring title, Style style, const(ContextSettings) settings)

Create (or recreate) the window.

create
void create(VideoMode mode, dstring title, Style style, const(ContextSettings) settings)

Create (or recreate) the window.

create
void create(WindowHandle handle, const(ContextSettings) settings)

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

display
void display()

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

isOpen
bool isOpen()

Tell whether or not the window is open.

pollEvent
bool pollEvent(Event event)

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

waitEvent
bool waitEvent(Event event)

Wait for an event and return it.

getMousePosition
Vector2i getMousePosition()
Undocumented in source. Be warned that the author may not have intended to support it.
mouse_getPosition
Vector2i mouse_getPosition()
Undocumented in source. Be warned that the author may not have intended to support it.
setMousePosition
void setMousePosition(Vector2i pos)
Undocumented in source. Be warned that the author may not have intended to support it.
mouse_SetPosition
void mouse_SetPosition(Vector2i pos)
Undocumented in source. Be warned that the author may not have intended to support it.
getWindowPointer
void* getWindowPointer(Window window)
Undocumented in source. Be warned that the author may not have intended to support it.

From RenderTarget

view
const(View) view [@property setter]

Change the current active view.

view
const(View) view [@property getter]
Undocumented in source.
getDefaultView
const(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(const(View) view)

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

clear
void clear(Color color)

Clear the entire target with a single color.

draw
void draw(Drawable drawable, RenderStates states)

Draw a drawable object to the render target.

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

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, const(View) view)

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 current view.

mapCoordsToPixel
Vector2i mapCoordsToPixel(Vector2f point, const(View) view)

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.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan