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-2024 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
35
36#include <SFML/System/Clock.hpp>
37#include <SFML/System/Time.hpp>
38
39#include <memory>
40
41#include <cstdint>
42
43
44namespace sf
45{
46namespace priv
47{
48class GlContext;
49}
50
56{
57public:
66
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
#define SFML_WINDOW_API
Utility class that measures the elapsed time.
Definition Clock.hpp:92
Base class for classes that require an OpenGL context.
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:89
Represents a time value.
Definition Time.hpp:42
VideoMode defines a video mode (size, bpp)
Definition VideoMode.hpp:44
Window that serves as a base for other windows.
Window that serves as a target for OpenGL rendering.
Window(const Window &)=delete
Deleted copy constructor.
Window(WindowHandle handle, const ContextSettings &settings={})
Construct the window from an existing control.
Window(VideoMode mode, const String &title, std::uint32_t style=Style::Default, State state=State::Windowed, const ContextSettings &settings={})
Construct a new window.
~Window() override
Destructor.
Window()
Default constructor.
Window(VideoMode mode, const String &title, State state, const ContextSettings &settings={})
Construct a new window.
Window(Window &&) noexcept
Move constructor.
Window & operator=(const Window &)=delete
Deleted copy assignment.
State
Enumeration of the window states.
"platform-specific" WindowHandle
Low-level window handle type, specific to each platform.
Structure defining the settings of the OpenGL context attached to a window.