CSFML 3.0.0
Loading...
Searching...
No Matches
Window/Window.h
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
30#include <CSFML/Window/Export.h>
31
32#include <CSFML/System/Time.h>
33#include <CSFML/System/Vector2.h>
34#include <CSFML/Window/Event.h>
35#include <CSFML/Window/Types.h>
36#include <CSFML/Window/VideoMode.h>
37#include <CSFML/Window/WindowBase.h>
38#include <CSFML/Window/WindowHandle.h>
39
40
45 typedef enum
46{
47 sfContextDefault = 0,
48 sfContextCore = 1 << 0,
49 sfContextDebug = 1 << 2
50} sfContextAttribute;
51
52
57 typedef struct
58{
59 unsigned int depthBits;
60 unsigned int stencilBits;
61 unsigned int antiAliasingLevel;
62 unsigned int majorVersion;
63 unsigned int minorVersion;
64 uint32_t attributeFlags;
65 bool sRgbCapable;
66} sfContextSettings;
67
68
91 CSFML_WINDOW_API sfWindow* sfWindow_create(sfVideoMode mode,
92 const char* title,
93 uint32_t style,
94 sfWindowState state,
95 const sfContextSettings* settings);
96
119 CSFML_WINDOW_API sfWindow* sfWindow_createUnicode(
120 sfVideoMode mode,
121 const sfChar32* title,
122 uint32_t style,
123 sfWindowState state,
124 const sfContextSettings* settings);
125
142 CSFML_WINDOW_API sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettings* settings);
143
150 CSFML_WINDOW_API void sfWindow_destroy(const sfWindow* window);
151
164 CSFML_WINDOW_API void sfWindow_close(sfWindow* window);
165
178 CSFML_WINDOW_API bool sfWindow_isOpen(const sfWindow* window);
179
193 CSFML_WINDOW_API sfContextSettings sfWindow_getSettings(const sfWindow* window);
194
210 CSFML_WINDOW_API bool sfWindow_pollEvent(sfWindow* window, sfEvent* event);
211
236 CSFML_WINDOW_API bool sfWindow_waitEvent(sfWindow* window, sfTime timeout, sfEvent* event);
237
246 CSFML_WINDOW_API sfVector2i sfWindow_getPosition(const sfWindow* window);
247
259 CSFML_WINDOW_API void sfWindow_setPosition(sfWindow* window, sfVector2i position);
260
272 CSFML_WINDOW_API sfVector2u sfWindow_getSize(const sfWindow* window);
273
281 CSFML_WINDOW_API void sfWindow_setSize(sfWindow* window, sfVector2u size);
282
292 CSFML_WINDOW_API void sfWindow_setMinimumSize(sfWindow* window, const sfVector2u* minimumSize);
293
303 CSFML_WINDOW_API void sfWindow_setMaximumSize(sfWindow* window, const sfVector2u* maximumSize);
304
312 CSFML_WINDOW_API void sfWindow_setTitle(sfWindow* window, const char* title);
313
321 CSFML_WINDOW_API void sfWindow_setUnicodeTitle(sfWindow* window, const sfChar32* title);
322
334 CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, sfVector2u size, const uint8_t* pixels);
335
343 CSFML_WINDOW_API void sfWindow_setVisible(sfWindow* window, bool visible);
344
357 CSFML_WINDOW_API void sfWindow_setVerticalSyncEnabled(sfWindow* window, bool enabled);
358
366 CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, bool visible);
367
382 CSFML_WINDOW_API void sfWindow_setMouseCursorGrabbed(sfWindow* window, bool grabbed);
383
402 CSFML_WINDOW_API void sfWindow_setMouseCursor(sfWindow* window, const sfCursor* cursor);
403
417 CSFML_WINDOW_API void sfWindow_setKeyRepeatEnabled(sfWindow* window, bool enabled);
418
430 CSFML_WINDOW_API void sfWindow_setFramerateLimit(sfWindow* window, unsigned int limit);
431
442 CSFML_WINDOW_API void sfWindow_setJoystickThreshold(sfWindow* window, float threshold);
443
461 CSFML_WINDOW_API bool sfWindow_setActive(sfWindow* window, bool active);
462
475 CSFML_WINDOW_API void sfWindow_requestFocus(sfWindow* window);
476
487 CSFML_WINDOW_API bool sfWindow_hasFocus(const sfWindow* window);
488
500 CSFML_WINDOW_API void sfWindow_display(sfWindow* window);
501
516 CSFML_WINDOW_API sfWindowHandle sfWindow_getNativeHandle(const sfWindow* window);
517
529 CSFML_WINDOW_API bool sfWindow_createVulkanSurface(sfWindow* window,
530 const VkInstance* instance,
531 VkSurfaceKHR* surface,
532 const VkAllocationCallbacks* allocator);
sfChar32
uint32_t sfChar32
Define sfChar32.
Definition Config.h:161
Event.h
Time.h
Vector2.h
VideoMode.h
VkSurfaceKHR
uint64_t VkSurfaceKHR
Definition Vulkan.h:42
VkInstance
struct VkInstance_T * VkInstance
Definition Vulkan.h:33
VkAllocationCallbacks
struct VkAllocationCallbacks VkAllocationCallbacks
Definition Vulkan.h:46
WindowBase.h
sfWindowState
sfWindowState
Enumeration of the window states.
Definition WindowBase.h:61
WindowHandle.h
Export.h
CSFML_WINDOW_API
#define CSFML_WINDOW_API
Definition Window/Export.h:42
Types.h
sfWindow
struct sfWindow sfWindow
Definition Window/Types.h:30
sfCursor
struct sfCursor sfCursor
Definition Window/Types.h:29
sfWindow_hasFocus
bool sfWindow_hasFocus(const sfWindow *window)
Check whether the window has the input focus.
sfWindow_destroy
void sfWindow_destroy(const sfWindow *window)
Destroy a window.
sfWindow_setFramerateLimit
void sfWindow_setFramerateLimit(sfWindow *window, unsigned int limit)
Limit the framerate to a maximum fixed frequency.
sfWindow_requestFocus
void sfWindow_requestFocus(sfWindow *window)
Request the current window to be made the active foreground window.
sfWindow_setActive
bool sfWindow_setActive(sfWindow *window, bool active)
Activate or deactivate a window as the current target for OpenGL rendering.
sfWindow_getSettings
sfContextSettings sfWindow_getSettings(const sfWindow *window)
Get the settings of the OpenGL context of a window.
sfWindow_waitEvent
bool sfWindow_waitEvent(sfWindow *window, sfTime timeout, sfEvent *event)
Wait for an event and return it.
sfWindow_setJoystickThreshold
void sfWindow_setJoystickThreshold(sfWindow *window, float threshold)
Change the joystick threshold.
sfWindow_setMinimumSize
void sfWindow_setMinimumSize(sfWindow *window, const sfVector2u *minimumSize)
Set the minimum window rendering region size.
sfWindow_getPosition
sfVector2i sfWindow_getPosition(const sfWindow *window)
Get the position of a window.
sfWindow_pollEvent
bool sfWindow_pollEvent(sfWindow *window, sfEvent *event)
Pop the event on top of event queue, if any, and return it.
sfWindow_setKeyRepeatEnabled
void sfWindow_setKeyRepeatEnabled(sfWindow *window, bool enabled)
Enable or disable automatic key-repeat.
sfWindow_createFromHandle
sfWindow * sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettings *settings)
Construct a window from an existing control.
sfWindow_setUnicodeTitle
void sfWindow_setUnicodeTitle(sfWindow *window, const sfChar32 *title)
Change the title of a window (with a UTF-32 string).
sfContextAttribute
sfContextAttribute
Enumeration of the context attribute flags.
Definition Window/Window.h:46
sfContextCore
@ sfContextCore
Core attribute.
Definition Window/Window.h:48
sfContextDebug
@ sfContextDebug
Debug attribute.
Definition Window/Window.h:49
sfContextDefault
@ sfContextDefault
Non-debug, compatibility context (this and the core attribute are mutually exclusive).
Definition Window/Window.h:47
sfWindow_setVerticalSyncEnabled
void sfWindow_setVerticalSyncEnabled(sfWindow *window, bool enabled)
Enable or disable vertical synchronization.
sfWindow_setMouseCursorGrabbed
void sfWindow_setMouseCursorGrabbed(sfWindow *window, bool grabbed)
Grab or release the mouse cursor.
sfWindow_setMouseCursorVisible
void sfWindow_setMouseCursorVisible(sfWindow *window, bool visible)
Show or hide the mouse cursor.
sfWindow_getNativeHandle
sfWindowHandle sfWindow_getNativeHandle(const sfWindow *window)
Get the OS-specific handle of the window.
sfWindow_createVulkanSurface
bool sfWindow_createVulkanSurface(sfWindow *window, const VkInstance *instance, VkSurfaceKHR *surface, const VkAllocationCallbacks *allocator)
Create a Vulkan rendering surface.
sfWindow_getSize
sfVector2u sfWindow_getSize(const sfWindow *window)
Get the size of the rendering region of a window.
sfWindow_setTitle
void sfWindow_setTitle(sfWindow *window, const char *title)
Change the title of a window.
sfWindow_setMaximumSize
void sfWindow_setMaximumSize(sfWindow *window, const sfVector2u *maximumSize)
Set the maximum window rendering region size.
sfWindow_setMouseCursor
void sfWindow_setMouseCursor(sfWindow *window, const sfCursor *cursor)
Set the displayed cursor to a native system cursor.
sfWindow_setVisible
void sfWindow_setVisible(sfWindow *window, bool visible)
Show or hide a window.
sfWindow_display
void sfWindow_display(sfWindow *window)
Display on screen what has been rendered to the window so far.
sfWindow_create
sfWindow * sfWindow_create(sfVideoMode mode, const char *title, uint32_t style, sfWindowState state, const sfContextSettings *settings)
Construct a new window.
sfWindow_setSize
void sfWindow_setSize(sfWindow *window, sfVector2u size)
Change the size of the rendering region of a window.
sfWindow_setIcon
void sfWindow_setIcon(sfWindow *window, sfVector2u size, const uint8_t *pixels)
Change a window's icon.
sfWindow_close
void sfWindow_close(sfWindow *window)
Close a window and destroy all the attached resources.
sfWindow_isOpen
bool sfWindow_isOpen(const sfWindow *window)
Tell whether or not a window is opened.
sfWindow_createUnicode
sfWindow * sfWindow_createUnicode(sfVideoMode mode, const sfChar32 *title, uint32_t style, sfWindowState state, const sfContextSettings *settings)
Construct a new window (with a UTF-32 title).
sfWindow_setPosition
void sfWindow_setPosition(sfWindow *window, sfVector2i position)
Change the position of a window on screen.
sfContextSettings
Structure defining the window's creation settings.
Definition Window/Window.h:58
sfContextSettings::antiAliasingLevel
unsigned int antiAliasingLevel
Level of anti-aliasing.
Definition Window/Window.h:61
sfContextSettings::depthBits
unsigned int depthBits
Bits of the depth buffer.
Definition Window/Window.h:59
sfContextSettings::sRgbCapable
bool sRgbCapable
Whether the context framebuffer is sRGB capable.
Definition Window/Window.h:65
sfContextSettings::stencilBits
unsigned int stencilBits
Bits of the stencil buffer.
Definition Window/Window.h:60
sfContextSettings::majorVersion
unsigned int majorVersion
Major number of the context version to create.
Definition Window/Window.h:62
sfContextSettings::attributeFlags
uint32_t attributeFlags
The attribute flags to create the context with.
Definition Window/Window.h:64
sfContextSettings::minorVersion
unsigned int minorVersion
Minor number of the context version to create.
Definition Window/Window.h:63
sfTime
Represents a time value.
Definition Time.h:38
sfVector2i
2-component vector of integers
Definition Vector2.h:38
sfVector2u
2-component vector of unsigned integers
Definition Vector2.h:49
sfVideoMode
sfVideoMode defines a video mode (width, height, bpp, frequency) and provides functions for getting m...
Definition VideoMode.h:44
sfEvent
sfEvent defines a system event and its parameters
Definition Event.h:210