Add API for sf::WindowBase

This commit is contained in:
Chris Thrasher authored and Lukas Dürrenberger committed 2023-11-19 13:23:39 +01:00
1 parent d90cd6f5ee
commit e2401417ef
10 files changed
+768 -64

No files matched your search

+1
View File
@@ -29,6 +29,7 @@
typedef struct sfContext sfContext;
typedef struct sfCursor sfCursor;
typedef struct sfWindow sfWindow;
typedef struct sfWindowBase sfWindowBase;
#endif // SFML_WINDOW_TYPES_H
+15
View File
@@ -28,6 +28,21 @@
#include <SFML/Window/Export.h>
typedef struct VkInstance_T* VkInstance;
#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
typedef struct VkSurfaceKHR_T* VkSurfaceKHR;
#else
typedef uint64_t VkSurfaceKHR;
#endif
struct VkAllocationCallbacks;
typedef void (*sfVulkanFunctionPointer)();
////////////////////////////////////////////////////////////
+2 -16
View File
@@ -31,26 +31,12 @@
#include <SFML/Window/Export.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowBase.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Types.h>
#include <SFML/System/Vector2.h>
////////////////////////////////////////////////////////////
/// \brief Enumeration of window creation styles
///
////////////////////////////////////////////////////////////
typedef enum
{
sfNone = 0, ///< No border / title bar (this flag and all others are mutually exclusive)
sfTitlebar = 1 << 0, ///< Title bar + fixed border
sfResize = 1 << 1, ///< Titlebar + resizable border + maximize button
sfClose = 1 << 2, ///< Titlebar + close button
sfFullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive)
sfDefaultStyle = sfTitlebar | sfResize | sfClose ///< Default window style
} sfWindowStyle;
////////////////////////////////////////////////////////////
/// \brief Enumeration of the context attribute flags
///
@@ -406,7 +392,7 @@ CSFML_WINDOW_API void sfWindow_setFramerateLimit(sfWindow* window, unsigned int
/// \brief Change the joystick threshold
///
/// The joystick threshold is the value below which
/// no JoyMoved event will be generated.
/// no JoystickMoved event will be generated.
///
/// \param window Window object
/// \param threshold New threshold, in the range [0, 100]
+384
View File
@@ -0,0 +1,384 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
//
// 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_WINDOWBASE_H
#define SFML_WINDOWBASE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Export.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Types.h>
#include <SFML/Window/Vulkan.h>
#include <SFML/System/Vector2.h>
////////////////////////////////////////////////////////////
/// \brief Enumeration of window creation styles
///
////////////////////////////////////////////////////////////
typedef enum
{
sfNone = 0, ///< No border / title bar (this flag and all others are mutually exclusive)
sfTitlebar = 1 << 0, ///< Title bar + fixed border
sfResize = 1 << 1, ///< Titlebar + resizable border + maximize button
sfClose = 1 << 2, ///< Titlebar + close button
sfFullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive)
sfDefaultStyle = sfTitlebar | sfResize | sfClose ///< Default window style
} sfWindowStyle;
////////////////////////////////////////////////////////////
/// \brief Construct a new window
///
/// This function creates the window with the size and pixel
/// depth defined in \a mode. An optional style can be passed to
/// customize the look and behaviour of the window (borders,
/// title bar, resizable, closable, ...). If \a style contains
/// sfFullscreen, then \a mode must be a valid video mode.
///
/// \param mode Video mode to use (defines the width, height and depth of the rendering area of the windowBase)
/// \param title Title of the window
/// \param style Window style
///
/// \return A new sfWindow object
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, sfUint32 style);
////////////////////////////////////////////////////////////
/// \brief Construct a new window (with a UTF-32 title)
///
/// This function creates the window with the size and pixel
/// depth defined in \a mode. An optional style can be passed to
/// customize the look and behaviour of the window (borders,
/// title bar, resizable, closable, ...). If \a style contains
/// sfFullscreen, then \a mode must be a valid video mode.
///
/// \param mode Video mode to use (defines the width, height and depth of the rendering area of the windowBase)
/// \param title Title of the window (UTF-32)
/// \param style Window style
///
/// \return A new sfWindow object
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfUint32* title, sfUint32 style);
////////////////////////////////////////////////////////////
/// \brief Construct a window from an existing control
///
/// \param handle Platform-specific handle of the control
///
/// \return A new sfWindow object
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowBase* sfWindowBase_createFromHandle(sfWindowHandle handle);
////////////////////////////////////////////////////////////
/// \brief Destroy a window
///
/// \param windowBase Window to destroy
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_destroy(sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Close a window and destroy all the attached resources
///
/// After calling this function, the sfWindow object remains
/// valid, you must call sfWindowBase_destroy to actually delete it.
/// All other functions such as sfWindowBase_pollEvent or sfWindowBase_display
/// will still work (i.e. you don't have to test sfWindowBase_isOpen
/// every time), and will have no effect on closed windows.
///
/// \param windowBase Window object
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_close(sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Tell whether or not a window is opened
///
/// This function returns whether or not the window exists.
/// Note that a hidden window (sfWindowBase_setVisible(sfFalse)) will return
/// sfTrue.
///
/// \param windowBase Window object
///
/// \return sfTrue if the window is opened, sfFalse if it has been closed
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfWindowBase_isOpen(const sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Pop the event on top of event queue, if any, and return it
///
/// This function is not blocking: if there's no pending event then
/// it will return false and leave \a event unmodified.
/// Note that more than one event may be present in the event queue,
/// thus you should always call this function in a loop
/// to make sure that you process every pending event.
///
/// \param windowBase Window object
/// \param event Event to be returned
///
/// \return sfTrue if an event was returned, or sfFalse if the event queue was empty
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfWindowBase_pollEvent(sfWindowBase* windowBase, sfEvent* event);
////////////////////////////////////////////////////////////
/// \brief Wait for an event and return it
///
/// This function is blocking: if there's no pending event then
/// it will wait until an event is received.
/// After this function returns (and no error occured),
/// the \a event object is always valid and filled properly.
/// This function is typically used when you have a thread that
/// is dedicated to events handling: you want to make this thread
/// sleep as long as no new event is received.
///
/// \param windowBase Window object
/// \param event Event to be returned
///
/// \return sfFalse if any error occured
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfWindowBase_waitEvent(sfWindowBase* windowBase, sfEvent* event);
////////////////////////////////////////////////////////////
/// \brief Get the position of a window
///
/// \param windowBase Window object
///
/// \return Position in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfVector2i sfWindowBase_getPosition(const sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Change the position of a window on screen
///
/// This function only works for top-level windows
/// (i.e. it will be ignored for windows created from
/// the handle of a child window/control).
///
/// \param windowBase Window object
/// \param position New position of the windowBase, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setPosition(sfWindowBase* windowBase, sfVector2i position);
////////////////////////////////////////////////////////////
/// \brief Get the size of the rendering region of a window
///
/// The size doesn't include the titlebar and borders
/// of the window.
///
/// \param windowBase Window object
///
/// \return Size in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfVector2u sfWindowBase_getSize(const sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Change the size of the rendering region of a window
///
/// \param windowBase Window object
/// \param size New size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setSize(sfWindowBase* windowBase, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Change the title of a window
///
/// \param windowBase Window object
/// \param title New title
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setTitle(sfWindowBase* windowBase, const char* title);
////////////////////////////////////////////////////////////
/// \brief Change the title of a window (with a UTF-32 string)
///
/// \param windowBase Window object
/// \param title New title
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const sfUint32* title);
////////////////////////////////////////////////////////////
/// \brief Change a window's icon
///
/// \a pixels must be an array of \a width x \a height pixels
/// in 32-bits RGBA format.
///
/// \param windowBase Window object
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the array of pixels in memory
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const sfUint8* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a window
///
/// \param windowBase Window object
/// \param visible sfTrue to show the windowBase, sfFalse to hide it
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setVisible(sfWindowBase* windowBase, sfBool visible);
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor
///
/// \param windowBase Window object
/// \param visible sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setMouseCursorVisible(sfWindowBase* windowBase, sfBool visible);
////////////////////////////////////////////////////////////
/// \brief Grab or release the mouse cursor
///
/// If set, grabs the mouse cursor inside this window's client
/// area so it may no longer be moved outside its bounds.
/// Note that grabbing is only active while the window has
/// focus and calling this function for fullscreen windows
/// won't have any effect (fullscreen windows always grab the
/// cursor).
///
/// \param grabbed sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setMouseCursorGrabbed(sfWindowBase* windowBase, sfBool grabbed);
////////////////////////////////////////////////////////////
/// \brief Set the displayed cursor to a native system cursor
///
/// Upon window creation, the arrow cursor is used by default.
///
/// \warning The cursor must not be destroyed while in use by
/// the window.
///
/// \warning Features related to Cursor are not supported on
/// iOS and Android.
///
/// \param windowBase Window object
/// \param cursor Native system cursor type to display
///
/// \see sfCursor_createFromSystem
/// \see sfCursor_createFromPixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setMouseCursor(sfWindowBase* windowBase, const sfCursor* cursor);
////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// If key repeat is enabled, you will receive repeated
/// KeyPress events while keeping a key pressed. If it is disabled,
/// you will only get a single event when the key is pressed.
///
/// Key repeat is enabled by default.
///
/// \param windowBase Window object
/// \param enabled sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setKeyRepeatEnabled(sfWindowBase* windowBase, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Change the joystick threshold
///
/// The joystick threshold is the value below which
/// no JoystickMoved event will be generated.
///
/// \param windowBase Window object
/// \param threshold New threshold, in the range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setJoystickThreshold(sfWindowBase* windowBase, float threshold);
////////////////////////////////////////////////////////////
/// \brief Request the current window to be made the active
/// foreground window
///
/// At any given time, only one window may have the input focus
/// to receive input events such as keystrokes or mouse events.
/// If a window requests focus, it only hints to the operating
/// system, that it would like to be focused. The operating system
/// is free to deny the request.
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_requestFocus(sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Check whether the window has the input focus
///
/// At any given time, only one window may have the input focus
/// to receive input events such as keystrokes or most mouse
/// events.
///
/// \return True if window has focus, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfWindowBase_hasFocus(const sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Get the OS-specific handle of the window
///
/// The type of the returned handle is sfWindowHandle,
/// which is a typedef to the handle type defined by the OS.
/// You shouldn't need to use this function, unless you have
/// very specific stuff to implement that SFML doesn't support,
/// or implement a temporary workaround until a bug is fixed.
///
/// \param windowBase Window object
///
/// \return System handle of the window
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowHandle sfWindowBase_getSystemHandle(const sfWindowBase* windowBase);
////////////////////////////////////////////////////////////
/// \brief Create a Vulkan rendering surface
///
/// \param windowBase Window object
/// \param instance Vulkan instance
/// \param surface Created surface
/// \param allocator Allocator to use
///
/// \return True if surface creation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfWindowBase_createVulkanSurface(sfWindowBase* windowBase, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator);
#endif // SFML_WINDOWBASE_H
+36 -36
View File
@@ -35,88 +35,88 @@
////////////////////////////////////////////////////////////
// Define a function to convert a sf::Event to a sfEvent
////////////////////////////////////////////////////////////
inline void convertEvent(const sf::Event& SFMLEvent, sfEvent* event)
inline void convertEvent(const sf::Event& sfmlEvent, sfEvent* event)
{
// Convert its type
event->type = static_cast<sfEventType>(SFMLEvent.type);
event->type = static_cast<sfEventType>(sfmlEvent.type);
// Fill its fields
switch (event->type)
{
case sfEvtResized :
event->size.width = SFMLEvent.size.width;
event->size.height = SFMLEvent.size.height;
event->size.width = sfmlEvent.size.width;
event->size.height = sfmlEvent.size.height;
break;
case sfEvtTextEntered :
event->text.unicode = SFMLEvent.text.unicode;
event->text.unicode = sfmlEvent.text.unicode;
break;
case sfEvtKeyReleased :
case sfEvtKeyPressed :
event->key.code = static_cast<sfKeyCode>(SFMLEvent.key.code);
event->key.scancode = static_cast<sfScancode>(SFMLEvent.key.scancode);
event->key.alt = SFMLEvent.key.alt ? sfTrue : sfFalse;
event->key.control = SFMLEvent.key.control ? sfTrue : sfFalse;
event->key.shift = SFMLEvent.key.shift ? sfTrue : sfFalse;
event->key.system = SFMLEvent.key.system ? sfTrue : sfFalse;
event->key.code = static_cast<sfKeyCode>(sfmlEvent.key.code);
event->key.scancode = static_cast<sfScancode>(sfmlEvent.key.scancode);
event->key.alt = sfmlEvent.key.alt ? sfTrue : sfFalse;
event->key.control = sfmlEvent.key.control ? sfTrue : sfFalse;
event->key.shift = sfmlEvent.key.shift ? sfTrue : sfFalse;
event->key.system = sfmlEvent.key.system ? sfTrue : sfFalse;
break;
case sfEvtMouseWheelMoved :
event->mouseWheel.delta = SFMLEvent.mouseWheel.delta;
event->mouseWheel.x = SFMLEvent.mouseWheel.x;
event->mouseWheel.y = SFMLEvent.mouseWheel.y;
event->mouseWheel.delta = sfmlEvent.mouseWheel.delta;
event->mouseWheel.x = sfmlEvent.mouseWheel.x;
event->mouseWheel.y = sfmlEvent.mouseWheel.y;
break;
case sfEvtMouseWheelScrolled :
event->mouseWheelScroll.wheel = static_cast<sfMouseWheel>(SFMLEvent.mouseWheelScroll.wheel);
event->mouseWheelScroll.delta = SFMLEvent.mouseWheelScroll.delta;
event->mouseWheelScroll.x = SFMLEvent.mouseWheelScroll.x;
event->mouseWheelScroll.y = SFMLEvent.mouseWheelScroll.y;
event->mouseWheelScroll.wheel = static_cast<sfMouseWheel>(sfmlEvent.mouseWheelScroll.wheel);
event->mouseWheelScroll.delta = sfmlEvent.mouseWheelScroll.delta;
event->mouseWheelScroll.x = sfmlEvent.mouseWheelScroll.x;
event->mouseWheelScroll.y = sfmlEvent.mouseWheelScroll.y;
break;
case sfEvtMouseButtonPressed :
case sfEvtMouseButtonReleased :
event->mouseButton.button = static_cast<sfMouseButton>(SFMLEvent.mouseButton.button);
event->mouseButton.x = SFMLEvent.mouseButton.x;
event->mouseButton.y = SFMLEvent.mouseButton.y;
event->mouseButton.button = static_cast<sfMouseButton>(sfmlEvent.mouseButton.button);
event->mouseButton.x = sfmlEvent.mouseButton.x;
event->mouseButton.y = sfmlEvent.mouseButton.y;
break;
case sfEvtMouseMoved :
event->mouseMove.x = SFMLEvent.mouseMove.x;
event->mouseMove.y = SFMLEvent.mouseMove.y;
event->mouseMove.x = sfmlEvent.mouseMove.x;
event->mouseMove.y = sfmlEvent.mouseMove.y;
break;
case sfEvtJoystickButtonPressed :
case sfEvtJoystickButtonReleased :
event->joystickButton.joystickId = SFMLEvent.joystickButton.joystickId;
event->joystickButton.button = SFMLEvent.joystickButton.button;
event->joystickButton.joystickId = sfmlEvent.joystickButton.joystickId;
event->joystickButton.button = sfmlEvent.joystickButton.button;
break;
case sfEvtJoystickMoved :
event->joystickMove.joystickId = SFMLEvent.joystickMove.joystickId;
event->joystickMove.axis = static_cast<sfJoystickAxis>(SFMLEvent.joystickMove.axis);
event->joystickMove.position = SFMLEvent.joystickMove.position;
event->joystickMove.joystickId = sfmlEvent.joystickMove.joystickId;
event->joystickMove.axis = static_cast<sfJoystickAxis>(sfmlEvent.joystickMove.axis);
event->joystickMove.position = sfmlEvent.joystickMove.position;
break;
case sfEvtJoystickConnected :
case sfEvtJoystickDisconnected :
event->joystickConnect.joystickId = SFMLEvent.joystickConnect.joystickId;
event->joystickConnect.joystickId = sfmlEvent.joystickConnect.joystickId;
break;
case sfEvtTouchBegan :
case sfEvtTouchMoved :
case sfEvtTouchEnded :
event->touch.finger = SFMLEvent.touch.finger;
event->touch.x = SFMLEvent.touch.x;
event->touch.y = SFMLEvent.touch.y;
event->touch.finger = sfmlEvent.touch.finger;
event->touch.x = sfmlEvent.touch.x;
event->touch.y = sfmlEvent.touch.y;
break;
case sfEvtSensorChanged :
event->sensor.sensorType = static_cast<sfSensorType>(SFMLEvent.sensor.type);
event->sensor.x = SFMLEvent.sensor.x;
event->sensor.y = SFMLEvent.sensor.y;
event->sensor.z = SFMLEvent.sensor.z;
event->sensor.sensorType = static_cast<sfSensorType>(sfmlEvent.sensor.type);
event->sensor.x = sfmlEvent.sensor.x;
event->sensor.y = sfmlEvent.sensor.y;
event->sensor.z = sfmlEvent.sensor.z;
break;
default :
+6 -6
View File
@@ -150,15 +150,15 @@ sfBool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event)
CSFML_CHECK_RETURN(event, sfFalse);
// Get the event
sf::Event SFMLEvent;
sfBool ret = renderWindow->This.pollEvent(SFMLEvent);
sf::Event sfmlEvent;
sfBool ret = renderWindow->This.pollEvent(sfmlEvent);
// No event, return
if (!ret)
return sfFalse;
// Convert the sf::Event event to a sfEvent
convertEvent(SFMLEvent, event);
convertEvent(sfmlEvent, event);
return sfTrue;
}
@@ -171,15 +171,15 @@ sfBool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfEvent* event)
CSFML_CHECK_RETURN(event, sfFalse);
// Get the event
sf::Event SFMLEvent;
sfBool ret = renderWindow->This.waitEvent(SFMLEvent);
sf::Event sfmlEvent;
sfBool ret = renderWindow->This.waitEvent(sfmlEvent);
// Error, return
if (!ret)
return sfFalse;
// Convert the sf::Event event to a sfEvent
convertEvent(SFMLEvent, event);
convertEvent(sfmlEvent, event);
return sfTrue;
}
+3
View File
@@ -32,8 +32,11 @@ set(SRC
${SRCROOT}/Vulkan.cpp
${INCROOT}/Vulkan.h
${SRCROOT}/Window.cpp
${SRCROOT}/WindowBase.cpp
${SRCROOT}/WindowStruct.h
${SRCROOT}/WindowBaseStruct.h
${INCROOT}/Window.h
${INCROOT}/WindowBase.h
${INCROOT}/WindowHandle.h
)
+6 -6
View File
@@ -132,15 +132,15 @@ sfBool sfWindow_pollEvent(sfWindow* window, sfEvent* event)
CSFML_CHECK_RETURN(event, sfFalse);
// Get the event
sf::Event SFMLEvent;
sfBool ret = window->This.pollEvent(SFMLEvent);
sf::Event sfmlEvent;
sfBool ret = window->This.pollEvent(sfmlEvent);
// No event, return
if (!ret)
return sfFalse;
// Convert the sf::Event event to a sfEvent
convertEvent(SFMLEvent, event);
convertEvent(sfmlEvent, event);
return sfTrue;
}
@@ -153,15 +153,15 @@ sfBool sfWindow_waitEvent(sfWindow* window, sfEvent* event)
CSFML_CHECK_RETURN(event, sfFalse);
// Get the event
sf::Event SFMLEvent;
sfBool ret = window->This.waitEvent(SFMLEvent);
sf::Event sfmlEvent;
sfBool ret = window->This.waitEvent(sfmlEvent);
// Error, return
if (!ret)
return sfFalse;
// Convert the sf::Event event to a sfEvent
convertEvent(SFMLEvent, event);
convertEvent(sfmlEvent, event);
return sfTrue;
}
+272
View File
@@ -0,0 +1,272 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
//
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/WindowBase.h>
#include <SFML/Window/WindowBaseStruct.h>
#include <SFML/Internal.h>
#include <SFML/Window/CursorStruct.h>
#include <SFML/ConvertEvent.h>
////////////////////////////////////////////////////////////
sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, sfUint32 style)
{
// Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel);
// Create the window
sfWindowBase* windowBase = new sfWindowBase;
windowBase->This.create(videoMode, title, style);
return windowBase;
}
////////////////////////////////////////////////////////////
sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfUint32* title, sfUint32 style)
{
// Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel);
// Create the window
sfWindowBase* windowBase = new sfWindowBase;
windowBase->This.create(videoMode, title, style);
return windowBase;
}
////////////////////////////////////////////////////////////
sfWindowBase* sfWindowBase_createFromHandle(sfWindowHandle handle)
{
// Create the window
sfWindowBase* windowBase = new sfWindowBase;
windowBase->This.create(handle);
return windowBase;
}
////////////////////////////////////////////////////////////
void sfWindowBase_destroy(sfWindowBase* windowBase)
{
delete windowBase;
}
////////////////////////////////////////////////////////////
void sfWindowBase_close(sfWindowBase* windowBase)
{
CSFML_CALL(windowBase, close());
}
////////////////////////////////////////////////////////////
sfBool sfWindowBase_isOpen(const sfWindowBase* windowBase)
{
CSFML_CALL_RETURN(windowBase, isOpen(), sfFalse);
}
////////////////////////////////////////////////////////////
sfBool sfWindowBase_pollEvent(sfWindowBase* windowBase, sfEvent* event)
{
CSFML_CHECK_RETURN(windowBase, sfFalse);
CSFML_CHECK_RETURN(event, sfFalse);
// Get the event
sf::Event sfmlEvent;
sfBool ret = windowBase->This.pollEvent(sfmlEvent);
// No event, return
if (!ret)
return sfFalse;
// Convert the sf::Event event to a sfEvent
convertEvent(sfmlEvent, event);
return sfTrue;
}
////////////////////////////////////////////////////////////
sfBool sfWindowBase_waitEvent(sfWindowBase* windowBase, sfEvent* event)
{
CSFML_CHECK_RETURN(windowBase, sfFalse);
CSFML_CHECK_RETURN(event, sfFalse);
// Get the event
sf::Event sfmlEvent;
sfBool ret = windowBase->This.waitEvent(sfmlEvent);
// Error, return
if (!ret)
return sfFalse;
// Convert the sf::Event event to a sfEvent
convertEvent(sfmlEvent, event);
return sfTrue;
}
////////////////////////////////////////////////////////////
sfVector2i sfWindowBase_getPosition(const sfWindowBase* windowBase)
{
sfVector2i position = {0, 0};
CSFML_CHECK_RETURN(windowBase, position);
sf::Vector2i sfmlPos = windowBase->This.getPosition();
position.x = sfmlPos.x;
position.y = sfmlPos.y;
return position;
}
////////////////////////////////////////////////////////////
void sfWindowBase_setPosition(sfWindowBase* windowBase, sfVector2i position)
{
CSFML_CALL(windowBase, setPosition(sf::Vector2i(position.x, position.y)));
}
////////////////////////////////////////////////////////////
sfVector2u sfWindowBase_getSize(const sfWindowBase* windowBase)
{
sfVector2u size = {0, 0};
CSFML_CHECK_RETURN(windowBase, size);
sf::Vector2u sfmlSize = windowBase->This.getSize();
size.x = sfmlSize.x;
size.y = sfmlSize.y;
return size;
}
////////////////////////////////////////////////////////////
void sfWindowBase_setSize(sfWindowBase* windowBase, sfVector2u size)
{
CSFML_CALL(windowBase, setSize(sf::Vector2u(size.x, size.y)));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setTitle(sfWindowBase* windowBase, const char* title)
{
CSFML_CALL(windowBase, setTitle(title));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const sfUint32* title)
{
CSFML_CALL(windowBase, setTitle(title));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const sfUint8* pixels)
{
CSFML_CALL(windowBase, setIcon(width, height, pixels));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setVisible(sfWindowBase* windowBase, sfBool visible)
{
CSFML_CALL(windowBase, setVisible(visible == sfTrue));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setMouseCursorVisible(sfWindowBase* windowBase, sfBool visible)
{
CSFML_CALL(windowBase, setMouseCursorVisible(visible == sfTrue));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setMouseCursorGrabbed(sfWindowBase* windowBase, sfBool grabbed)
{
CSFML_CALL(windowBase, setMouseCursorGrabbed(grabbed == sfTrue));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setMouseCursor(sfWindowBase* windowBase, const sfCursor* cursor)
{
CSFML_CHECK(cursor);
CSFML_CALL(windowBase, setMouseCursor(cursor->This));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setKeyRepeatEnabled(sfWindowBase* windowBase, sfBool enabled)
{
CSFML_CALL(windowBase, setKeyRepeatEnabled(enabled == sfTrue));
}
////////////////////////////////////////////////////////////
void sfWindowBase_setJoystickThreshold(sfWindowBase* windowBase, float threshold)
{
CSFML_CALL(windowBase, setJoystickThreshold(threshold));
}
////////////////////////////////////////////////////////////
void sfWindowBase_requestFocus(sfWindowBase* windowBase)
{
CSFML_CALL(windowBase, requestFocus());
}
////////////////////////////////////////////////////////////
sfBool sfWindowBase_hasFocus(const sfWindowBase* windowBase)
{
CSFML_CALL_RETURN(windowBase, hasFocus(), sfFalse);
}
////////////////////////////////////////////////////////////
sfWindowHandle sfWindowBase_getSystemHandle(const sfWindowBase* windowBase)
{
CSFML_CHECK_RETURN(windowBase, 0);
return static_cast<sfWindowHandle>(windowBase->This.getSystemHandle());
}
////////////////////////////////////////////////////////////
sfBool sfWindowBase_createVulkanSurface(sfWindowBase* windowBase, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator)
{
CSFML_CHECK_RETURN(instance, sfFalse);
CSFML_CHECK_RETURN(surface, sfFalse);
CSFML_CALL_RETURN(windowBase, createVulkanSurface(*instance, *surface, allocator), sfFalse);
}
+43
View File
@@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
//
// 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_WINDOWBASESTRUCT_H
#define SFML_WINDOWBASESTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/WindowBase.hpp>
////////////////////////////////////////////////////////////
// Internal structure of sfWindowBase
////////////////////////////////////////////////////////////
struct sfWindowBase
{
sf::WindowBase This;
};
#endif // SFML_WINDOWBASESTRUCT_H