SFML 3.0.0

- Main Page
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Context.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
30#include <SFML/Window/Export.hpp>
31
32#include <SFML/Window/GlResource.hpp>
33
34#include <SFML/System/Vector2.hpp>
35
36#include <memory>
37#include <string_view>
38
39#include <cstdint>
40
41
42 namespace sf
43{
44 namespace priv
45{
46 class GlContext;
47}
48
49 struct ContextSettings;
50
51 using GlFunctionPointer = void (*)();
52
57 class SFML_WINDOW_API Context : GlResource
58{
59 public:
66 Context();
67
74 ~Context();
75
80 Context(const Context&) = delete;
81
86 Context& operator=(const Context&) = delete;
87
92 Context(Context&& context) noexcept;
93
98 Context& operator=(Context&& context) noexcept;
99
108 [[nodiscard]] bool setActive(bool active);
109
120 [[nodiscard]] const ContextSettings& getSettings() const;
121
130 [[nodiscard]] static bool isExtensionAvailable(std::string_view name);
131
143 [[nodiscard]] static GlFunctionPointer getFunction(const char* name);
144
155 [[nodiscard]] static const Context* getActiveContext();
156
166 [[nodiscard]] static std::uint64_t getActiveContextId();
167
178 Context(const ContextSettings& settings, Vector2u size);
179
180 private:
182 // Member data
184 std::unique_ptr<priv::GlContext> m_context;
185};
186
187} // namespace sf
188
189
GlResource.hpp
Vector2.hpp
Export.hpp
SFML_WINDOW_API
#define SFML_WINDOW_API
Definition Window/Export.hpp:42
sf::Context
Class holding a valid drawing context.
Definition Context.hpp:58
sf::Context::setActive
bool setActive(bool active)
Activate or deactivate explicitly the context.
sf::Context::operator=
Context & operator=(const Context &)=delete
Deleted copy assignment.
sf::Context::getActiveContext
static const Context * getActiveContext()
Get the currently active context.
sf::Context::Context
Context(const Context &)=delete
Deleted copy constructor.
sf::Context::getSettings
const ContextSettings & getSettings() const
Get the settings of the context.
sf::Context::Context
Context(const ContextSettings &settings, Vector2u size)
Construct a in-memory context.
sf::Context::~Context
~Context()
Destructor.
sf::Context::Context
Context(Context &&context) noexcept
Move constructor.
sf::Context::isExtensionAvailable
static bool isExtensionAvailable(std::string_view name)
Check whether a given OpenGL extension is available.
sf::Context::getFunction
static GlFunctionPointer getFunction(const char *name)
Get the address of an OpenGL function.
sf::Context::operator=
Context & operator=(Context &&context) noexcept
Move assignment.
sf::Context::Context
Context()
Default constructor.
sf::Context::getActiveContextId
static std::uint64_t getActiveContextId()
Get the currently active context's ID.
sf::GlResource
Base class for classes that require an OpenGL context.
Definition GlResource.hpp:44
sf::Vector2< unsigned int >
sf
Definition AudioResource.hpp:36
sf::GlFunctionPointer
void(*)() GlFunctionPointer
Definition Context.hpp:51
sf::ContextSettings
Structure defining the settings of the OpenGL context attached to a window.
Definition ContextSettings.hpp:39