SFML - Simple and Fast Multimedia Library

SFML 3.0.2
Loading...
Searching...
No Matches
RenderWindow.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/Graphics/Export.hpp>
31
32#include <SFML/Graphics/RenderTarget.hpp>
33
34#include <SFML/Window/ContextSettings.hpp>
35#include <SFML/Window/VideoMode.hpp>
36#include <SFML/Window/Window.hpp>
37#include <SFML/Window/WindowEnums.hpp>
38#include <SFML/Window/WindowHandle.hpp>
39
40#include <SFML/System/Vector2.hpp>
41
42#include <cstdint>
43
44
45namespace sf
46{
47class Image;
48class String;
49
54 class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
55{
56public:
64 RenderWindow() = default;
65
86 RenderWindow(VideoMode mode,
87 const String& title,
88 std::uint32_t style = Style::Default,
89 State state = State::Windowed,
90 const ContextSettings& settings = {});
91
109 RenderWindow(VideoMode mode, const String& title, State state, const ContextSettings& settings = {});
110
127 explicit RenderWindow(WindowHandle handle, const ContextSettings& settings = {});
128
138 [[nodiscard]] Vector2u getSize() const override;
139
150 void setIcon(const Image& icon);
151 using Window::setIcon;
152
161 [[nodiscard]] bool isSrgb() const override;
162
179 [[nodiscard]] bool setActive(bool active = true) override;
180
181protected:
190 void onCreate() override;
191
199 void onResize() override;
200
201private:
203 // Member data
205 unsigned int m_defaultFrameBuffer{};
206};
207
208} // namespace sf
209
210
ContextSettings.hpp
Export.hpp
SFML_GRAPHICS_API
#define SFML_GRAPHICS_API
Definition Graphics/Export.hpp:42
RenderTarget.hpp
Vector2.hpp
VideoMode.hpp
WindowEnums.hpp
WindowHandle.hpp
Window.hpp
sf::Image
Class for loading, manipulating and saving images.
Definition Image.hpp:55
sf::RenderTarget::RenderTarget
RenderTarget(const RenderTarget &)=delete
Deleted copy constructor.
sf::RenderWindow::RenderWindow
RenderWindow(WindowHandle handle, const ContextSettings &settings={})
Construct the window from an existing control.
sf::RenderWindow::isSrgb
bool isSrgb() const override
Tell if the window will use sRGB encoding when drawing on it.
sf::RenderWindow::setActive
bool setActive(bool active=true) override
Activate or deactivate the window as the current target for OpenGL rendering.
sf::RenderWindow::RenderWindow
RenderWindow(VideoMode mode, const String &title, std::uint32_t style=Style::Default, State state=State::Windowed, const ContextSettings &settings={})
Construct a new window.
sf::RenderWindow::onResize
void onResize() override
Function called after the window has been resized.
sf::RenderWindow::onCreate
void onCreate() override
Function called after the window has been created.
sf::RenderWindow::setIcon
void setIcon(const Image &icon)
Change the window's icon.
sf::RenderWindow::RenderWindow
RenderWindow()=default
Default constructor.
sf::RenderWindow::RenderWindow
RenderWindow(VideoMode mode, const String &title, State state, const ContextSettings &settings={})
Construct a new window.
sf::RenderWindow::getSize
Vector2u getSize() const override
Get the size of the rendering region of the window.
sf::String
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:89
sf::VideoMode
VideoMode defines a video mode (size, bpp).
Definition VideoMode.hpp:44
sf::WindowBase::setIcon
void setIcon(Vector2u size, const std::uint8_t *pixels)
Change the window's icon.
sf::Window::Window
Window()
Default constructor.
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
Definition AudioResource.hpp:36
sf::Vector2u
Vector2< unsigned int > Vector2u
Definition Vector2.hpp:209
sf::ContextSettings
Structure defining the settings of the OpenGL context attached to a window.
Definition ContextSettings.hpp:39