mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-25 13:05:16 +01:00
426 lines
18 KiB
C
426 lines
18 KiB
C
////////////////////////////////////////////////////////////
|
|
//
|
|
// SFML - Simple and Fast Multimedia Library
|
|
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
|
//
|
|
// This software is provided 'as-is', without any express or implied warranty.
|
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
|
//
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
// including commercial applications, and to alter it and redistribute it freely,
|
|
// subject to the following restrictions:
|
|
//
|
|
// 1. The origin of this software must not be misrepresented;
|
|
// you must not claim that you wrote the original software.
|
|
// If you use this software in a product, an acknowledgment
|
|
// in the product documentation would be appreciated but is not required.
|
|
//
|
|
// 2. Altered source versions must be plainly marked as such,
|
|
// and must not be misrepresented as being the original software.
|
|
//
|
|
// 3. This notice may not be removed or altered from any source distribution.
|
|
//
|
|
////////////////////////////////////////////////////////////
|
|
|
|
#ifndef SFML_RENDERWINDOW_H
|
|
#define SFML_RENDERWINDOW_H
|
|
|
|
////////////////////////////////////////////////////////////
|
|
// Headers
|
|
////////////////////////////////////////////////////////////
|
|
#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>
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Construct a new render window
|
|
///
|
|
/// \param mode Video mode to use
|
|
/// \param title Title of the window
|
|
/// \param style Window style
|
|
/// \param settings Creation settings (pass NULL to use default values)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, sfUint32 style, const sfContextSettings* settings);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Construct a render window from an existing control
|
|
///
|
|
/// \param handle Platform-specific handle of the control
|
|
/// \param settings Creation settings (pass NULL to use default values)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Destroy an existing render window
|
|
///
|
|
/// \param renderWindow Render window to destroy
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_Destroy(sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Close a render window (but doesn't destroy the internal data)
|
|
///
|
|
/// \param renderWindow Render window to close
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_Close(sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Tell whether or not a render window is opened
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfBool sfRenderWindow_IsOpen(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the width of the rendering region of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return Width in pixels
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the height of the rendering region of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return Height in pixels
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the creation settings of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return Settings used to create the window
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the event on top of events stack of a render window, if any, and pop it
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param event Event to fill, if any
|
|
///
|
|
/// \return sfTrue if an event was returned, sfFalse if events stack was empty
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Wait for an event and return it
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param event Event to fill
|
|
///
|
|
/// \return sfFalse if an error occured
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Enable / disable vertical synchronization on a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Show or hide the mouse cursor on a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param show sfTrue to show, sfFalse to hide
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Change the position of a render window on screen
|
|
///
|
|
/// Only works for top-level windows
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param left Left position
|
|
/// \param top Top position
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Change the size of the rendering region of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param width New Width
|
|
/// \param height New Height
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Change the title of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param title New title
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Show or hide a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param show sfTrue to show, sfFalse to hide
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Enable or disable automatic key-repeat for keydown events
|
|
///
|
|
/// Automatic key-repeat is enabled by default
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param enabled sfTrue to enable, sfFalse to disable
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Change a render window's icon
|
|
///
|
|
/// \param renderWindow Renderw indow object
|
|
/// \param width Icon's width, in pixels
|
|
/// \param height Icon's height, in pixels
|
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Activate or deactivate a render window as the current target for rendering
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param active sfTrue to activate, sfFalse to deactivate
|
|
///
|
|
/// \return True if operation was successful, false otherwise
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Display a render window on screen
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_Display(sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Limit the framerate to a maximum fixed frequency for a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Change the joystick threshold, ie. the value below which no move event will be generated
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param threshold New threshold, in range [0, 100]
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Retrieve the OS-specific handle of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return Window handle
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Clear a render window with the given color
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param color Fill color
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Change the current active view of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param view Pointer to the new view
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the current active view of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return Current active view
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the default view of a render window
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return Default view of the render window
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Get the viewport of a view applied to this target
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param view Target view
|
|
///
|
|
/// \return Viewport rectangle, expressed in pixels in the current target
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const sfView* view);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Convert a point in window coordinates into view coordinates
|
|
///
|
|
/// \param renderWindow Render window object
|
|
/// \param windowX X coordinate of the point to convert, relative to the window
|
|
/// \param windowY Y coordinate of the point to convert, relative to the window
|
|
/// \param viewX Pointer to fill with the X coordinate of the converted point
|
|
/// \param viewY Pointer to fill with the Y coordinate of the converted point
|
|
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Draw a drawable object to the render-target
|
|
///
|
|
/// \param renderWindow render window object
|
|
/// \param object Object to draw
|
|
/// \param states Render states to use for drawing (NULL to use the default states)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* object, const sfRenderStates* states);
|
|
CSFML_GRAPHICS_API void sfRenderWindow_DrawText(sfRenderWindow* renderWindow, const sfText* 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);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Draw primitives defined by an array of vertices to a render window
|
|
///
|
|
/// \param renderWindow render window object
|
|
/// \param vertices Pointer to the vertices
|
|
/// \param vertexCount Number of vertices in the array
|
|
/// \param type Type of primitives to draw
|
|
/// \param states Render states to use for drawing (NULL to use the default states)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_DrawPrimitives(sfRenderWindow* renderWindow,
|
|
const sfVertex* vertices, unsigned int vertexCount,
|
|
sfPrimitiveType type, const sfRenderStates* states);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief 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:
|
|
/// \li SFML's internal states are not messed up by your OpenGL code
|
|
/// \li your OpenGL states are not modified by a call to a SFML function
|
|
///
|
|
/// 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.
|
|
///
|
|
/// \param renderWindow render window object
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_PushGLStates(sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief Restore the previously saved OpenGL render states and matrices
|
|
///
|
|
/// See the description of PushGLStates to get a detailed
|
|
/// description of these functions.
|
|
///
|
|
/// \param renderWindow render window object
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_PopGLStates(sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief 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.
|
|
///
|
|
/// \param renderWindow render window object
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API void sfRenderWindow_ResetGLStates(sfRenderWindow* renderWindow);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// \brief 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.
|
|
///
|
|
/// \param renderWindow Render window object
|
|
///
|
|
/// \return New image containing the captured contents
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
CSFML_GRAPHICS_API sfImage* sfRenderWindow_Capture(const sfRenderWindow* renderWindow);
|
|
|
|
|
|
#endif // SFML_RENDERWINDOW_H
|