RenderWindow
Object Hierarchy:
Description:
[ Compact ]
[ CCode ( cprefix = "sfRenderWindow_" , free_function = "sfRenderWindow_destroy" ) ]
public class RenderWindow
Window that can serve as a target for 2D drawing.
sf.RenderWindow is the main class of the Graphics module.
It defines an OS window that can be painted using the other classes of the graphics module.
sf.RenderWindow is derived from sf.Window, thus it inherits all its features: events, window management, OpenGL rendering, etc. See the
documentation of sf.Window for a more complete description of all these features, as well as code examples.
On top of that, sf.RenderWindow adds more features related to 2D drawing with the graphics module (see its base class sf.RenderTarget for
more details). Here is a typical rendering and event loop with a sf.RenderWindow:
using sf;
void main()
{
var window = new RenderWindow(VideoMode(200, 200), "SFML works!");
var circle = new CircleShape();
circle.setFillColor(Color.Green);
circle.setRadius(100);
while (window.isOpen())
{
Event event;
while (window.pollEvent(out event))
{
if (event.type == EventType.Closed)
window.close();
}
window.clear();
window.draw(circle);
window.display();
}
}
Content:
Properties:
Creation methods:
Methods:
- public Image capture ()
- public void clear (Color color = Black)
Clear the entire target with a single color.
- public void close ()
Close the window and destroy all the attached resources.
- public void display ()
- public void draw (Shape drawable, RenderStates? state = null)
- public void drawPrimitives (Vertex vertices, size_t vertexCount, PrimitiveType type, RenderStates? states = null)
- public void drawVertexBuffer (VertexBuffer object, RenderStates? states = null)
- public void drawVertexBufferRange (VertexBuffer object, size_t firstVertex, size_t vertexCount, RenderStates? states = null)
- public unowned View getDefaultView ()
Get the default view of the render target.
- public Vector2i getPosition ()
Get the position of the window.
- public ContextSettings getSettings ()
Get the settings of the OpenGL context of the window.
- public Vector2u getSize ()
Return the size of the rendering region of the target.
- public WindowHandle getSystemHandle ()
- public unowned string getTitle ()
return the title of the window.
- public unowned View getView ()
Get the view currently in use in the render target.
- public IntRect getViewport (View view)
- public bool hasFocus ()
- public bool isOpen ()
Tell whether or not the window is open.
- public Vector2i mapCoordsToPixel (Vector2f point, View view)
- public Vector2f mapPixelToCoords (Vector2i point, View view)
- public bool pollEvent (out Event event)
- public void popGLStates ()
- public void pushGLStates ()
- public void requestFocus ()
- public void resetGLStates ()
- public bool setActive (bool active)
Activate or deactivate the render target for rendering.
- public void setFramerateLimit (uint limit)
- public void setIcon (uint width, uint height, uint8[] pixels)
Change the window's icon.
- public void setJoystickThreshold (float threshold)
- public void setKeyRepeatEnabled (bool enabled)
- public void setMouseCursor (Cursor cursor)
- public void setMouseCursorGrabbed (bool grabbed)
- public void setMouseCursorVisible (bool show)
- public void setPosition (Vector2i position)
Change the position of the window on screen.
- public void setSize (Vector2u size)
Change the size of the rendering region of the window.
- public void setTitle (string title)
Change the title of the window.
- public void setUnicodeTitle (uint32[] title)
- public void setVerticalSyncEnabled (bool enabled)
- public void setView (View view)
Change the current active view.
- public void setVisible (bool visible)
Show or hide the window.
- public bool waitEvent (out Event event)