|
33 | 33 | #include <CSFML/Graphics/PrimitiveType.h> |
34 | 34 | #include <CSFML/Graphics/Rect.h> |
35 | 35 | #include <CSFML/Graphics/RenderStates.h> |
| 36 | +#include <CSFML/Graphics/StencilMode.h> |
36 | 37 | #include <CSFML/Graphics/Types.h> |
37 | 38 | #include <CSFML/Graphics/Vertex.h> |
| 39 | +#include <CSFML/System/Time.h> |
38 | 40 | #include <CSFML/System/Vector2.h> |
39 | 41 | #include <CSFML/Window/Event.h> |
40 | 42 | #include <CSFML/Window/VideoMode.h> |
@@ -122,26 +124,47 @@ CSFML_GRAPHICS_API bool sfRenderWindow_isOpen(const sfRenderWindow* renderWindow |
122 | 124 | CSFML_GRAPHICS_API sfContextSettings sfRenderWindow_getSettings(const sfRenderWindow* renderWindow); |
123 | 125 |
|
124 | 126 | //////////////////////////////////////////////////////////// |
125 | | -/// \brief Get the event on top of event queue of a render window, if any, and pop it |
| 127 | +/// \brief Pop the event on top of event queue, if any, and return it |
| 128 | +/// |
| 129 | +/// This function is not blocking: if there's no pending event then |
| 130 | +/// it will return false and leave \a event unmodified. |
| 131 | +/// Note that more than one event may be present in the event queue, |
| 132 | +/// thus you should always call this function in a loop |
| 133 | +/// to make sure that you process every pending event. |
126 | 134 | /// |
127 | 135 | /// \param renderWindow Render window object |
128 | 136 | /// \param event Event to fill, if any |
129 | 137 | /// |
130 | | -/// \return true if an event was returned, false if event queue was empty |
| 138 | +/// \return true if an event was returned, or false if the event queue was empty |
131 | 139 | /// |
132 | 140 | //////////////////////////////////////////////////////////// |
133 | 141 | CSFML_GRAPHICS_API bool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event); |
134 | 142 |
|
135 | 143 | //////////////////////////////////////////////////////////// |
136 | 144 | /// \brief Wait for an event and return it |
137 | 145 | /// |
| 146 | +/// This function is blocking: if there's no pending event then |
| 147 | +/// it will wait until an event is received or until the provided |
| 148 | +/// timeout elapses. Only if an error or a timeout occurs the |
| 149 | +/// function returns `false`. |
| 150 | +/// This function is typically used when you have a thread that is |
| 151 | +/// dedicated to events handling: you want to make this thread sleep |
| 152 | +/// as long as no new event is received. |
| 153 | +/// \code |
| 154 | +/// while (sfRenderWindow_waitEvent(renderWindow, timeout, &event)) |
| 155 | +/// { |
| 156 | +/// // process event... |
| 157 | +/// } |
| 158 | +/// \endcode |
| 159 | +/// |
138 | 160 | /// \param renderWindow Render window object |
139 | | -/// \param event Event to fill |
| 161 | +/// \param timeout Maximum time to wait (`sfTime_Zero` for infinite) |
| 162 | +/// \param event Event to fill, if any |
140 | 163 | /// |
141 | | -/// \return false if an error occurred |
| 164 | +/// \return true if an event was returned, false if event queue was empty or function timed out |
142 | 165 | /// |
143 | 166 | //////////////////////////////////////////////////////////// |
144 | | -CSFML_GRAPHICS_API bool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfEvent* event); |
| 167 | +CSFML_GRAPHICS_API bool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfTime timeout, sfEvent* event); |
145 | 168 |
|
146 | 169 | //////////////////////////////////////////////////////////// |
147 | 170 | /// \brief Get the position of a render window |
@@ -377,6 +400,31 @@ CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getNativeHandle(const sfRenderW |
377 | 400 | //////////////////////////////////////////////////////////// |
378 | 401 | CSFML_GRAPHICS_API void sfRenderWindow_clear(sfRenderWindow* renderWindow, sfColor color); |
379 | 402 |
|
| 403 | +//////////////////////////////////////////////////////////// |
| 404 | +/// \brief Clear the stencil buffer to a specific value |
| 405 | +/// |
| 406 | +/// The specified value is truncated to the bit width of |
| 407 | +/// the current stencil buffer. |
| 408 | +/// |
| 409 | +/// \param renderWindow Render window object |
| 410 | +/// \param stencilValue Stencil value to clear to |
| 411 | +/// |
| 412 | +//////////////////////////////////////////////////////////// |
| 413 | +CSFML_GRAPHICS_API void sfRenderWindow_clearStencil(sfRenderWindow* renderWindow, sfStencilValue stencilValue); |
| 414 | + |
| 415 | +//////////////////////////////////////////////////////////// |
| 416 | +/// \brief Clear the entire target with a single color and stencil value |
| 417 | +/// |
| 418 | +/// The specified stencil value is truncated to the bit |
| 419 | +/// width of the current stencil buffer. |
| 420 | +/// |
| 421 | +/// \param renderWindow Render window object |
| 422 | +/// \param color Fill color to use to clear the render target |
| 423 | +/// \param stencilValue Stencil value to clear to |
| 424 | +/// |
| 425 | +//////////////////////////////////////////////////////////// |
| 426 | +CSFML_GRAPHICS_API void sfRenderWindow_clearColorAndStencil(sfRenderWindow* renderWindow, sfColor color, sfStencilValue stencilValue); |
| 427 | + |
380 | 428 | //////////////////////////////////////////////////////////// |
381 | 429 | /// \brief Change the current active view of a render window |
382 | 430 | /// |
@@ -417,6 +465,22 @@ CSFML_GRAPHICS_API const sfView* sfRenderWindow_getDefaultView(const sfRenderWin |
417 | 465 | //////////////////////////////////////////////////////////// |
418 | 466 | CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getViewport(const sfRenderWindow* renderWindow, const sfView* view); |
419 | 467 |
|
| 468 | +//////////////////////////////////////////////////////////// |
| 469 | +/// \brief Get the scissor rectangle of a view, applied to this render target |
| 470 | +/// |
| 471 | +/// The scissor rectangle is defined in the view as a ratio. This |
| 472 | +/// function simply applies this ratio to the current dimensions |
| 473 | +/// of the render target to calculate the pixels rectangle |
| 474 | +/// that the scissor rectangle actually covers in the target. |
| 475 | +/// |
| 476 | +/// \param renderWindow Render window object |
| 477 | +/// \param view The view for which we want to compute the scissor rectangle |
| 478 | +/// |
| 479 | +/// \return Scissor rectangle, expressed in pixels |
| 480 | +/// |
| 481 | +//////////////////////////////////////////////////////////// |
| 482 | +CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getScissor(const sfRenderWindow* renderWindow, const sfView* view); |
| 483 | + |
420 | 484 | //////////////////////////////////////////////////////////// |
421 | 485 | /// \brief Convert a point from window coordinates to world coordinates |
422 | 486 | /// |
|
0 commit comments