Documentation of SFML 2.6.1

Loading...
Searching...
No Matches
Window/Window.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 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#ifndef SFML_WINDOW_HPP
26#define SFML_WINDOW_HPP
27
29// Headers
31#include <SFML/Window/ContextSettings.hpp>
32#include <SFML/Window/GlResource.hpp>
33#include <SFML/Window/WindowBase.hpp>
34
35
36namespace sf
37{
38namespace priv
39{
40 class GlContext;
41}
42
43class Event;
44
49class SFML_WINDOW_API Window : public WindowBase, GlResource
50{
51public:
52
61
81 Window(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
82
97 explicit Window(WindowHandle handle, const ContextSettings& settings = ContextSettings());
98
105 virtual ~Window();
106
119 virtual void create(VideoMode mode, const String& title, Uint32 style = Style::Default);
120
138 virtual void create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings);
139
150 virtual void create(WindowHandle handle);
151
167 virtual void create(WindowHandle handle, const ContextSettings& settings);
168
179 virtual void close();
180
193
207 void setVerticalSyncEnabled(bool enabled);
208
224 void setFramerateLimit(unsigned int limit);
225
242 bool setActive(bool active = true) const;
243
252 void display();
253
254private:
255
268 bool filterEvent(const Event& event);
269
274 void initialize();
275
277 // Member data
279 priv::GlContext* m_context;
280 Clock m_clock;
281 Time m_frameTimeLimit;
282};
283
284} // namespace sf
285
286
287#endif // SFML_WINDOW_HPP
288
289
Utility class that measures the elapsed time.
Definition Clock.hpp:42
Defines a system event and its parameters.
Definition Event.hpp:45
Base class for classes that require an OpenGL context.
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:46
Represents a time value.
Definition Time.hpp:41
VideoMode defines a video mode (width, height, bpp)
Definition VideoMode.hpp:42
Window that serves as a base for other windows.
Window that serves as a target for OpenGL rendering.
const ContextSettings & getSettings() const
Get the settings of the OpenGL context of the window.
virtual void create(WindowHandle handle, const ContextSettings &settings)
Create (or recreate) the window from an existing control.
Window(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Construct a new window.
Window()
Default constructor.
void setVerticalSyncEnabled(bool enabled)
Enable or disable vertical synchronization.
virtual void create(WindowHandle handle)
Create (or recreate) the window from an existing control.
virtual void create(VideoMode mode, const String &title, Uint32 style, const ContextSettings &settings)
Create (or recreate) the window.
Window(WindowHandle handle, const ContextSettings &settings=ContextSettings())
Construct the window from an existing control.
virtual void close()
Close the window and destroy all the attached resources.
bool setActive(bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
virtual ~Window()
Destructor.
virtual void create(VideoMode mode, const String &title, Uint32 style=Style::Default)
Create (or recreate) the window.
void display()
Display on screen what has been rendered to the window so far.
void setFramerateLimit(unsigned int limit)
Limit the framerate to a maximum fixed frequency.
Structure defining the settings of the OpenGL context attached to a window.