#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/Vertex.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Window.h>
#include <SFML/System/Vector2.h>
Go to the source code of this file.
Functions | |
CSFML_GRAPHICS_API sfRenderWindow * | sfRenderWindow_create (sfVideoMode mode, const char *title, sfUint32 style, const sfContextSettings *settings) |
Construct a new render window. | |
CSFML_GRAPHICS_API sfRenderWindow * | sfRenderWindow_createUnicode (sfVideoMode mode, const sfUint32 *title, sfUint32 style, const sfContextSettings *settings) |
Construct a new render window (with a UTF-32 title) | |
CSFML_GRAPHICS_API sfRenderWindow * | sfRenderWindow_createFromHandle (sfWindowHandle handle, const sfContextSettings *settings) |
Construct a render window from an existing control. | |
CSFML_GRAPHICS_API void | sfRenderWindow_destroy (sfRenderWindow *renderWindow) |
Destroy an existing render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_close (sfRenderWindow *renderWindow) |
Close a render window (but doesn't destroy the internal data) | |
CSFML_GRAPHICS_API sfBool | sfRenderWindow_isOpen (const sfRenderWindow *renderWindow) |
Tell whether or not a render window is opened. | |
CSFML_GRAPHICS_API sfContextSettings | sfRenderWindow_getSettings (const sfRenderWindow *renderWindow) |
Get the creation settings of a render window. | |
CSFML_GRAPHICS_API sfBool | sfRenderWindow_pollEvent (sfRenderWindow *renderWindow, sfEvent *event) |
Get the event on top of event queue of a render window, if any, and pop it. | |
CSFML_GRAPHICS_API sfBool | sfRenderWindow_waitEvent (sfRenderWindow *renderWindow, sfEvent *event) |
Wait for an event and return it. | |
CSFML_GRAPHICS_API sfVector2i | sfRenderWindow_getPosition (const sfRenderWindow *renderWindow) |
Get the position of a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setPosition (sfRenderWindow *renderWindow, sfVector2i position) |
Change the position of a render window on screen. | |
CSFML_GRAPHICS_API sfVector2u | sfRenderWindow_getSize (const sfRenderWindow *renderWindow) |
Get the size of the rendering region of a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setSize (sfRenderWindow *renderWindow, sfVector2u size) |
Change the size of the rendering region of a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setTitle (sfRenderWindow *renderWindow, const char *title) |
Change the title of a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setUnicodeTitle (sfRenderWindow *renderWindow, const sfUint32 *title) |
Change the title of a render window (with a UTF-32 string) | |
CSFML_GRAPHICS_API void | sfRenderWindow_setIcon (sfRenderWindow *renderWindow, unsigned int width, unsigned int height, const sfUint8 *pixels) |
Change a render window's icon. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setVisible (sfRenderWindow *renderWindow, sfBool visible) |
Show or hide a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setMouseCursorVisible (sfRenderWindow *renderWindow, sfBool show) |
Show or hide the mouse cursor on a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setVerticalSyncEnabled (sfRenderWindow *renderWindow, sfBool enabled) |
Enable / disable vertical synchronization on a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setKeyRepeatEnabled (sfRenderWindow *renderWindow, sfBool enabled) |
Enable or disable automatic key-repeat for keydown events. | |
CSFML_GRAPHICS_API sfBool | sfRenderWindow_setActive (sfRenderWindow *renderWindow, sfBool active) |
Activate or deactivate a render window as the current target for rendering. | |
CSFML_GRAPHICS_API void | sfRenderWindow_display (sfRenderWindow *renderWindow) |
Display a render window on screen. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setFramerateLimit (sfRenderWindow *renderWindow, unsigned int limit) |
Limit the framerate to a maximum fixed frequency for a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setJoystickThreshold (sfRenderWindow *renderWindow, float threshold) |
Change the joystick threshold, ie. | |
CSFML_GRAPHICS_API sfWindowHandle | sfRenderWindow_getSystemHandle (const sfRenderWindow *renderWindow) |
Retrieve the OS-specific handle of a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_clear (sfRenderWindow *renderWindow, sfColor color) |
Clear a render window with the given color. | |
CSFML_GRAPHICS_API void | sfRenderWindow_setView (sfRenderWindow *renderWindow, const sfView *view) |
Change the current active view of a render window. | |
CSFML_GRAPHICS_API const sfView * | sfRenderWindow_getView (const sfRenderWindow *renderWindow) |
Get the current active view of a render window. | |
CSFML_GRAPHICS_API const sfView * | sfRenderWindow_getDefaultView (const sfRenderWindow *renderWindow) |
Get the default view of a render window. | |
CSFML_GRAPHICS_API sfIntRect | sfRenderWindow_getViewport (const sfRenderWindow *renderWindow, const sfView *view) |
Get the viewport of a view applied to this target. | |
CSFML_GRAPHICS_API sfVector2f | sfRenderWindow_mapPixelToCoords (const sfRenderWindow *renderWindow, sfVector2i point, const sfView *view) |
Convert a point from window coordinates to world coordinates. | |
CSFML_GRAPHICS_API sfVector2i | sfRenderWindow_mapCoordsToPixel (const sfRenderWindow *renderWindow, sfVector2f point, const sfView *view) |
Convert a point from world coordinates to window coordinates. | |
CSFML_GRAPHICS_API void | sfRenderWindow_drawSprite (sfRenderWindow *renderWindow, const sfSprite *object, const sfRenderStates *states) |
Draw a drawable object to the render-target. | |
CSFML_GRAPHICS_API void | sfRenderWindow_drawText (sfRenderWindow *renderWindow, const sfText *object, const sfRenderStates *states) |
CSFML_GRAPHICS_API void | sfRenderWindow_drawShape (sfRenderWindow *renderWindow, const sfShape *object, const sfRenderStates *states) |
CSFML_GRAPHICS_API void | sfRenderWindow_drawCircleShape (sfRenderWindow *renderWindow, const sfCircleShape *object, const sfRenderStates *states) |
CSFML_GRAPHICS_API void | sfRenderWindow_drawConvexShape (sfRenderWindow *renderWindow, const sfConvexShape *object, const sfRenderStates *states) |
CSFML_GRAPHICS_API void | sfRenderWindow_drawRectangleShape (sfRenderWindow *renderWindow, const sfRectangleShape *object, const sfRenderStates *states) |
CSFML_GRAPHICS_API void | sfRenderWindow_drawVertexArray (sfRenderWindow *renderWindow, const sfVertexArray *object, const sfRenderStates *states) |
CSFML_GRAPHICS_API void | sfRenderWindow_drawPrimitives (sfRenderWindow *renderWindow, const sfVertex *vertices, unsigned int vertexCount, sfPrimitiveType type, const sfRenderStates *states) |
Draw primitives defined by an array of vertices to a render window. | |
CSFML_GRAPHICS_API void | sfRenderWindow_pushGLStates (sfRenderWindow *renderWindow) |
Save the current OpenGL render states and matrices. | |
CSFML_GRAPHICS_API void | sfRenderWindow_popGLStates (sfRenderWindow *renderWindow) |
Restore the previously saved OpenGL render states and matrices. | |
CSFML_GRAPHICS_API void | sfRenderWindow_resetGLStates (sfRenderWindow *renderWindow) |
Reset the internal OpenGL states so that the target is ready for drawing. | |
CSFML_GRAPHICS_API sfImage * | sfRenderWindow_capture (const sfRenderWindow *renderWindow) |
Copy the current contents of a render window to an image. | |
CSFML_GRAPHICS_API sfVector2i | sfMouse_getPositionRenderWindow (const sfRenderWindow *relativeTo) |
Get the current position of the mouse relatively to a render-window. | |
CSFML_GRAPHICS_API void | sfMouse_setPositionRenderWindow (sfVector2i position, const sfRenderWindow *relativeTo) |
Set the current position of the mouse relatively to a render-window. | |
CSFML_GRAPHICS_API sfVector2i sfMouse_getPositionRenderWindow | ( | const sfRenderWindow * | relativeTo | ) |
Get the current position of the mouse relatively to a render-window.
This function returns the current position of the mouse cursor relative to the given render-window, or desktop if NULL is passed.
relativeTo | Reference window |
CSFML_GRAPHICS_API void sfMouse_setPositionRenderWindow | ( | sfVector2i | position, |
const sfRenderWindow * | relativeTo | ||
) |
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, or desktop if NULL is passed.
position | New position of the mouse |
relativeTo | Reference window |
CSFML_GRAPHICS_API sfImage* sfRenderWindow_capture | ( | const sfRenderWindow * | renderWindow | ) |
Copy the current contents of a render window to an image.
This is a slow operation, whose main purpose is to make screenshots of the application. If you want to update an image with the contents of the window and then use it for drawing, you should rather use a sfTexture and its update(sfWindow*) function. You can also draw things directly to a texture with the sfRenderWindow class.
renderWindow | Render window object |
CSFML_GRAPHICS_API void sfRenderWindow_clear | ( | sfRenderWindow * | renderWindow, |
sfColor | color | ||
) |
Clear a render window with the given color.
renderWindow | Render window object |
color | Fill color |
CSFML_GRAPHICS_API void sfRenderWindow_close | ( | sfRenderWindow * | renderWindow | ) |
Close a render window (but doesn't destroy the internal data)
renderWindow | Render window to close |
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create | ( | sfVideoMode | mode, |
const char * | title, | ||
sfUint32 | style, | ||
const sfContextSettings * | settings | ||
) |
Construct a new render window.
mode | Video mode to use |
title | Title of the window |
style | Window style |
settings | Creation settings (pass NULL to use default values) |
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createFromHandle | ( | sfWindowHandle | handle, |
const sfContextSettings * | settings | ||
) |
Construct a render window from an existing control.
handle | Platform-specific handle of the control |
settings | Creation settings (pass NULL to use default values) |
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createUnicode | ( | sfVideoMode | mode, |
const sfUint32 * | title, | ||
sfUint32 | style, | ||
const sfContextSettings * | settings | ||
) |
Construct a new render window (with a UTF-32 title)
mode | Video mode to use |
title | Title of the window (UTF-32) |
style | Window style |
settings | Creation settings (pass NULL to use default values) |
CSFML_GRAPHICS_API void sfRenderWindow_destroy | ( | sfRenderWindow * | renderWindow | ) |
Destroy an existing render window.
renderWindow | Render window to destroy |
CSFML_GRAPHICS_API void sfRenderWindow_display | ( | sfRenderWindow * | renderWindow | ) |
Display a render window on screen.
renderWindow | Render window object |
CSFML_GRAPHICS_API void sfRenderWindow_drawCircleShape | ( | sfRenderWindow * | renderWindow, |
const sfCircleShape * | object, | ||
const sfRenderStates * | states | ||
) |
CSFML_GRAPHICS_API void sfRenderWindow_drawConvexShape | ( | sfRenderWindow * | renderWindow, |
const sfConvexShape * | object, | ||
const sfRenderStates * | states | ||
) |
CSFML_GRAPHICS_API void sfRenderWindow_drawPrimitives | ( | sfRenderWindow * | renderWindow, |
const sfVertex * | vertices, | ||
unsigned int | vertexCount, | ||
sfPrimitiveType | type, | ||
const sfRenderStates * | states | ||
) |
Draw primitives defined by an array of vertices to a render window.
renderWindow | render window object |
vertices | Pointer to the vertices |
vertexCount | Number of vertices in the array |
type | Type of primitives to draw |
states | Render states to use for drawing (NULL to use the default states) |
CSFML_GRAPHICS_API void sfRenderWindow_drawRectangleShape | ( | sfRenderWindow * | renderWindow, |
const sfRectangleShape * | object, | ||
const sfRenderStates * | states | ||
) |
CSFML_GRAPHICS_API void sfRenderWindow_drawShape | ( | sfRenderWindow * | renderWindow, |
const sfShape * | object, | ||
const sfRenderStates * | states | ||
) |
CSFML_GRAPHICS_API void sfRenderWindow_drawSprite | ( | sfRenderWindow * | renderWindow, |
const sfSprite * | object, | ||
const sfRenderStates * | states | ||
) |
Draw a drawable object to the render-target.
renderWindow | render window object |
object | Object to draw |
states | Render states to use for drawing (NULL to use the default states) |
CSFML_GRAPHICS_API void sfRenderWindow_drawText | ( | sfRenderWindow * | renderWindow, |
const sfText * | object, | ||
const sfRenderStates * | states | ||
) |
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexArray | ( | sfRenderWindow * | renderWindow, |
const sfVertexArray * | object, | ||
const sfRenderStates * | states | ||
) |
CSFML_GRAPHICS_API const sfView* sfRenderWindow_getDefaultView | ( | const sfRenderWindow * | renderWindow | ) |
Get the default view of a render window.
renderWindow | Render window object |
CSFML_GRAPHICS_API sfVector2i sfRenderWindow_getPosition | ( | const sfRenderWindow * | renderWindow | ) |
Get the position of a render window.
renderWindow | Render window object |
CSFML_GRAPHICS_API sfContextSettings sfRenderWindow_getSettings | ( | const sfRenderWindow * | renderWindow | ) |
Get the creation settings of a render window.
renderWindow | Render window object |
CSFML_GRAPHICS_API sfVector2u sfRenderWindow_getSize | ( | const sfRenderWindow * | renderWindow | ) |
Get the size of the rendering region of a render window.
renderWindow | Render window object |
CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getSystemHandle | ( | const sfRenderWindow * | renderWindow | ) |
Retrieve the OS-specific handle of a render window.
renderWindow | Render window object |
CSFML_GRAPHICS_API const sfView* sfRenderWindow_getView | ( | const sfRenderWindow * | renderWindow | ) |
Get the current active view of a render window.
renderWindow | Render window object |
CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getViewport | ( | const sfRenderWindow * | renderWindow, |
const sfView * | view | ||
) |
Get the viewport of a view applied to this target.
renderWindow | Render window object |
view | Target view |
CSFML_GRAPHICS_API sfBool sfRenderWindow_isOpen | ( | const sfRenderWindow * | renderWindow | ) |
Tell whether or not a render window is opened.
renderWindow | Render window object |
CSFML_GRAPHICS_API sfVector2i sfRenderWindow_mapCoordsToPixel | ( | const sfRenderWindow * | renderWindow, |
sfVector2f | point, | ||
const sfView * | view | ||
) |
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 the other overload of the function if you want to use the current view of the render-window.
renderWindow | Render window object |
point | Point to convert |
view | The view to use for converting the point |
CSFML_GRAPHICS_API sfVector2f sfRenderWindow_mapPixelToCoords | ( | const sfRenderWindow * | renderWindow, |
sfVector2i | point, | ||
const sfView * | view | ||
) |
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 other overload of the function if you want to use the current view of the render-window.
renderWindow | Render window object |
point | Pixel to convert |
view | The view to use for converting the point |
CSFML_GRAPHICS_API sfBool sfRenderWindow_pollEvent | ( | sfRenderWindow * | renderWindow, |
sfEvent * | event | ||
) |
Get the event on top of event queue of a render window, if any, and pop it.
renderWindow | Render window object |
event | Event to fill, if any |
CSFML_GRAPHICS_API void sfRenderWindow_popGLStates | ( | sfRenderWindow * | renderWindow | ) |
Restore the previously saved OpenGL render states and matrices.
See the description of pushGLStates to get a detailed description of these functions.
renderWindow | render window object |
CSFML_GRAPHICS_API void sfRenderWindow_pushGLStates | ( | sfRenderWindow * | renderWindow | ) |
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:
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 | render window object |
CSFML_GRAPHICS_API void sfRenderWindow_resetGLStates | ( | sfRenderWindow * | renderWindow | ) |
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 sfRenderWindow_draw*() calls will work as expected.
renderWindow | render window object |
CSFML_GRAPHICS_API sfBool sfRenderWindow_setActive | ( | sfRenderWindow * | renderWindow, |
sfBool | active | ||
) |
Activate or deactivate a render window as the current target for rendering.
renderWindow | Render window object |
active | sfTrue to activate, sfFalse to deactivate |
CSFML_GRAPHICS_API void sfRenderWindow_setFramerateLimit | ( | sfRenderWindow * | renderWindow, |
unsigned int | limit | ||
) |
Limit the framerate to a maximum fixed frequency for a render window.
renderWindow | Render window object |
limit | Framerate limit, in frames per seconds (use 0 to disable limit) |
CSFML_GRAPHICS_API void sfRenderWindow_setIcon | ( | sfRenderWindow * | renderWindow, |
unsigned int | width, | ||
unsigned int | height, | ||
const sfUint8 * | pixels | ||
) |
Change a render window's icon.
renderWindow | Render window object |
width | Icon's width, in pixels |
height | Icon's height, in pixels |
pixels | Pointer to the pixels in memory, format must be RGBA 32 bits |
CSFML_GRAPHICS_API void sfRenderWindow_setJoystickThreshold | ( | sfRenderWindow * | renderWindow, |
float | threshold | ||
) |
Change the joystick threshold, ie.
the value below which no move event will be generated
renderWindow | Render window object |
threshold | New threshold, in range [0, 100] |
CSFML_GRAPHICS_API void sfRenderWindow_setKeyRepeatEnabled | ( | sfRenderWindow * | renderWindow, |
sfBool | enabled | ||
) |
Enable or disable automatic key-repeat for keydown events.
Automatic key-repeat is enabled by default
renderWindow | Render window object |
enabled | sfTrue to enable, sfFalse to disable |
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible | ( | sfRenderWindow * | renderWindow, |
sfBool | show | ||
) |
Show or hide the mouse cursor on a render window.
renderWindow | Render window object |
show | sfTrue to show, sfFalse to hide |
CSFML_GRAPHICS_API void sfRenderWindow_setPosition | ( | sfRenderWindow * | renderWindow, |
sfVector2i | position | ||
) |
Change the position of a render window on screen.
Only works for top-level windows
renderWindow | Render window object |
position | New position, in pixels |
CSFML_GRAPHICS_API void sfRenderWindow_setSize | ( | sfRenderWindow * | renderWindow, |
sfVector2u | size | ||
) |
Change the size of the rendering region of a render window.
renderWindow | Render window object |
size | New size, in pixels |
CSFML_GRAPHICS_API void sfRenderWindow_setTitle | ( | sfRenderWindow * | renderWindow, |
const char * | title | ||
) |
Change the title of a render window.
renderWindow | Render window object |
title | New title |
CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle | ( | sfRenderWindow * | renderWindow, |
const sfUint32 * | title | ||
) |
Change the title of a render window (with a UTF-32 string)
renderWindow | Render window object |
title | New title |
CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled | ( | sfRenderWindow * | renderWindow, |
sfBool | enabled | ||
) |
Enable / disable vertical synchronization on a render window.
renderWindow | Render window object |
enabled | sfTrue to enable v-sync, sfFalse to deactivate |
CSFML_GRAPHICS_API void sfRenderWindow_setView | ( | sfRenderWindow * | renderWindow, |
const sfView * | view | ||
) |
Change the current active view of a render window.
renderWindow | Render window object |
view | Pointer to the new view |
CSFML_GRAPHICS_API void sfRenderWindow_setVisible | ( | sfRenderWindow * | renderWindow, |
sfBool | visible | ||
) |
Show or hide a render window.
renderWindow | Render window object |
visible | sfTrue to show the window, sfFalse to hide it |
CSFML_GRAPHICS_API sfBool sfRenderWindow_waitEvent | ( | sfRenderWindow * | renderWindow, |
sfEvent * | event | ||
) |
Wait for an event and return it.
renderWindow | Render window object |
event | Event to fill |