SFML 3.0.1
Loading...
Searching...
No Matches
Window/Window.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2025 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 <SFML/Window/ContextSettings.hpp>
31#include <SFML/Window/GlResource.hpp>
32#include <SFML/Window/WindowBase.hpp>
33#include <SFML/Window/WindowEnums.hpp>
34#include <SFML/Window/WindowHandle.hpp>
35
36#include <SFML/System/Clock.hpp>
37#include <SFML/System/Time.hpp>
38
39#include <memory>
40
41#include <cstdint>
42
43
44 namespace sf
45{
46 namespace priv
47{
48 class GlContext;
49}
50
55 class SFML_WINDOW_API Window : public WindowBase, GlResource
56{
57 public:
65 Window();
66
88 Window(VideoMode mode,
89 const String& title,
90 std::uint32_t style = Style::Default,
91 State state = State::Windowed,
92 const ContextSettings& settings = {});
93
111 Window(VideoMode mode, const String& title, State state, const ContextSettings& settings = {});
112
127 explicit Window(WindowHandle handle, const ContextSettings& settings = {});
128
135 ~Window() override;
136
141 Window(const Window&) = delete;
142
147 Window& operator=(const Window&) = delete;
148
153 Window(Window&&) noexcept;
154
159 Window& operator=(Window&&) noexcept;
160
174 void create(VideoMode mode, const String& title, std::uint32_t style = Style::Default, State state = State::Windowed) override;
175
193 virtual void create(VideoMode mode, const String& title, std::uint32_t style, State state, const ContextSettings& settings);
194
207 void create(VideoMode mode, const String& title, State state) override;
208
225 virtual void create(VideoMode mode, const String& title, State state, const ContextSettings& settings);
226
237 void create(WindowHandle handle) override;
238
254 virtual void create(WindowHandle handle, const ContextSettings& settings);
255
266 void close() override;
267
279 [[nodiscard]] const ContextSettings& getSettings() const;
280
294 void setVerticalSyncEnabled(bool enabled);
295
311 void setFramerateLimit(unsigned int limit);
312
329 [[nodiscard]] bool setActive(bool active = true) const;
330
339 void display();
340
341private:
346 void initialize();
347
349 // Member data
351 std::unique_ptr<priv::GlContext> m_context;
352 Clock m_clock;
353 Time m_frameTimeLimit;
354};
355
356} // namespace sf
357
358
Clock.hpp
ContextSettings.hpp
GlResource.hpp
Time.hpp
WindowBase.hpp
WindowEnums.hpp
WindowHandle.hpp
SFML_WINDOW_API
#define SFML_WINDOW_API
Definition Window/Export.hpp:42
sf::Clock
Utility class that measures the elapsed time.
Definition Clock.hpp:92
sf::GlResource::GlResource
GlResource()
Default constructor.
sf::String
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:89
sf::Time
Represents a time value.
Definition Time.hpp:42
sf::VideoMode
VideoMode defines a video mode (size, bpp)
Definition VideoMode.hpp:44
sf::WindowBase::WindowBase
WindowBase()
Default constructor.
sf::Window::getSettings
const ContextSettings & getSettings() const
Get the settings of the OpenGL context of the window.
sf::Window::Window
Window(const Window &)=delete
Deleted copy constructor.
sf::Window::Window
Window(WindowHandle handle, const ContextSettings &settings={})
Construct the window from an existing control.
sf::Window::Window
Window(VideoMode mode, const String &title, std::uint32_t style=Style::Default, State state=State::Windowed, const ContextSettings &settings={})
Construct a new window.
sf::Window::~Window
~Window() override
Destructor.
sf::Window::Window
Window()
Default constructor.
sf::Window::setVerticalSyncEnabled
void setVerticalSyncEnabled(bool enabled)
Enable or disable vertical synchronization.
sf::Window::Window
Window(VideoMode mode, const String &title, State state, const ContextSettings &settings={})
Construct a new window.
sf::Window::setActive
bool setActive(bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
sf::Window::close
void close() override
Close the window and destroy all the attached resources.
sf::Window::Window
Window(Window &&) noexcept
Move constructor.
sf::Window::operator=
Window & operator=(const Window &)=delete
Deleted copy assignment.
sf::Window::display
void display()
Display on screen what has been rendered to the window so far.
sf::Window::create
void create(VideoMode mode, const String &title, std::uint32_t style=Style::Default, State state=State::Windowed) override
Create (or recreate) the window.
sf::Window::setFramerateLimit
void setFramerateLimit(unsigned int limit)
Limit the framerate to a maximum fixed frequency.
sf::State
State
Enumeration of the window states.
Definition WindowEnums.hpp:55
sf::WindowHandle
"platform-specific" WindowHandle
Low-level window handle type, specific to each platform.
Definition WindowHandle.hpp:68
sf::State::Windowed
@ Windowed
Floating window.
Definition WindowEnums.hpp:56
sf::Style::Default
@ Default
Default window style.
Definition WindowEnums.hpp:44
sf::Style
Definition WindowEnums.hpp:31
sf
Definition AudioResource.hpp:36
sf::ContextSettings
Structure defining the settings of the OpenGL context attached to a window.
Definition ContextSettings.hpp:39