From 6dafbd0c14dc1fca0039edaa42ab8afebb5e50bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 26 Feb 2021 13:20:30 +0100 Subject: [PATCH] Platform: since we #include the Context anyway, no need to PIMPL it. This removes one unnecessary allocation from each application startup. In some cases of the windowless apps the Platform::GLContext could be put directly into the class, in other cases it had to be wrapped in an Optional because we need delayed construction and/or earlier destruction. --- src/Magnum/Platform/AbstractXApplication.cpp | 5 ++--- src/Magnum/Platform/AbstractXApplication.h | 8 +++++--- src/Magnum/Platform/AndroidApplication.cpp | 5 ++--- src/Magnum/Platform/AndroidApplication.h | 7 +++++-- src/Magnum/Platform/EmscriptenApplication.cpp | 5 ++--- src/Magnum/Platform/EmscriptenApplication.h | 15 +++++++++++++-- src/Magnum/Platform/GlfwApplication.cpp | 5 ++--- src/Magnum/Platform/GlfwApplication.h | 8 +++++--- src/Magnum/Platform/Sdl2Application.cpp | 5 ++--- src/Magnum/Platform/Sdl2Application.h | 8 +++++--- src/Magnum/Platform/WindowlessCglApplication.cpp | 9 ++++----- src/Magnum/Platform/WindowlessCglApplication.h | 7 ++----- src/Magnum/Platform/WindowlessEglApplication.cpp | 5 ++--- src/Magnum/Platform/WindowlessEglApplication.h | 9 +++++---- src/Magnum/Platform/WindowlessGlxApplication.cpp | 9 ++++----- src/Magnum/Platform/WindowlessGlxApplication.h | 6 ++---- src/Magnum/Platform/WindowlessIosApplication.h | 6 ++---- src/Magnum/Platform/WindowlessIosApplication.mm | 8 ++++---- src/Magnum/Platform/WindowlessWglApplication.cpp | 9 ++++----- src/Magnum/Platform/WindowlessWglApplication.h | 6 ++---- .../Platform/WindowlessWindowsEglApplication.cpp | 9 ++++----- .../Platform/WindowlessWindowsEglApplication.h | 6 ++---- 22 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index 6a98a0ee6..d816e8363 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -29,7 +29,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #include "Implementation/AbstractContextHandler.h" @@ -42,7 +41,7 @@ AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandle create(configuration, glConfiguration); } -AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, NoCreateT): _contextHandler{contextHandler}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}}, _flags{Flag::Redraw} {} +AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, NoCreateT): _contextHandler{contextHandler}, _context{Containers::InPlaceInit, NoCreate, arguments.argc, arguments.argv}, _flags{Flag::Redraw} {} void AbstractXApplication::create() { create({}); } @@ -111,7 +110,7 @@ bool AbstractXApplication::tryCreate(const Configuration& configuration, const G AbstractXApplication::~AbstractXApplication() { /* Destroy Magnum context first to avoid it potentially accessing the now-destroyed GL context after */ - _context.reset(); + _context = Containers::NullOpt; /* Shut down context handler */ _contextHandler.reset(); diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index adc4193ef..e5e60c322 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -35,6 +35,7 @@ #ifdef MAGNUM_TARGET_GL #include #include +#include #include #include @@ -60,9 +61,8 @@ typedef int Bool; #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" #include "Magnum/Math/Vector2.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" namespace Magnum { namespace Platform { @@ -319,7 +319,9 @@ class AbstractXApplication { Atom _deleteWindow{}; Containers::Pointer> _contextHandler; - Containers::Pointer _context; + /* Has to be in an Optional because it gets explicitly destroyed before + the GL context */ + Containers::Optional _context; int _exitCode = 0; /** @todo Get this from the created window */ diff --git a/src/Magnum/Platform/AndroidApplication.cpp b/src/Magnum/Platform/AndroidApplication.cpp index e078c323f..f3ee497f0 100644 --- a/src/Magnum/Platform/AndroidApplication.cpp +++ b/src/Magnum/Platform/AndroidApplication.cpp @@ -30,7 +30,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #include "Magnum/Platform/ScreenedApplication.hpp" #include "Implementation/Egl.h" @@ -71,7 +70,7 @@ AndroidApplication::AndroidApplication(const Arguments& arguments, const Configu create(configuration, glConfiguration); } -AndroidApplication::AndroidApplication(const Arguments& arguments, NoCreateT): _state{arguments}, _context{new GLContext{NoCreate, 0, nullptr}} { +AndroidApplication::AndroidApplication(const Arguments& arguments, NoCreateT): _state{arguments}, _context{Containers::InPlaceInit, NoCreate} { /* Redirect debug output to Android log */ _logOutput.reset(new LogOutput); } @@ -79,7 +78,7 @@ AndroidApplication::AndroidApplication(const Arguments& arguments, NoCreateT): _ AndroidApplication::~AndroidApplication() { /* Destroy Magnum context first to avoid it potentially accessing the now-destroyed GL context after */ - _context.reset(); + _context = Containers::NullOpt; eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(_display, _glContext); diff --git a/src/Magnum/Platform/AndroidApplication.h b/src/Magnum/Platform/AndroidApplication.h index bcc28757d..6d00d55c0 100644 --- a/src/Magnum/Platform/AndroidApplication.h +++ b/src/Magnum/Platform/AndroidApplication.h @@ -32,13 +32,14 @@ #endif #include +#include #include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" #include "Magnum/Math/Vector4.h" #include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" #if defined(CORRADE_TARGET_ANDROID) || defined(DOXYGEN_GENERATING_OUTPUT) #include @@ -435,7 +436,9 @@ class AndroidApplication { EGLContext _glContext; Vector2i _previousMouseMovePosition{-1}; - Containers::Pointer _context; + /* Has to be in an Optional because it gets explicitly destroyed before + the GL context */ + Containers::Optional _context; Containers::Pointer _logOutput; CORRADE_ENUMSET_FRIEND_OPERATORS(Flags) diff --git a/src/Magnum/Platform/EmscriptenApplication.cpp b/src/Magnum/Platform/EmscriptenApplication.cpp index f8574e4a0..5e3e018ce 100644 --- a/src/Magnum/Platform/EmscriptenApplication.cpp +++ b/src/Magnum/Platform/EmscriptenApplication.cpp @@ -40,7 +40,6 @@ #ifdef MAGNUM_TARGET_GL #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #endif /** @todo drop once we don't support < 1.38.27 anymore */ @@ -237,7 +236,7 @@ EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, NoCreat { Utility::Arguments args{Implementation::windowScalingArguments()}; #ifdef MAGNUM_TARGET_GL - _context.reset(new GLContext{NoCreate, args, arguments.argc, arguments.argv}); + _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #else args.parse(arguments.argc, arguments.argv); #endif @@ -262,7 +261,7 @@ EmscriptenApplication::~EmscriptenApplication() { #ifdef MAGNUM_TARGET_GL /* Destroy Magnum context first to avoid it potentially accessing the now-destroyed GL context after */ - _context.reset(); + _context = Containers::NullOpt; emscripten_webgl_destroy_context(_glContext); #endif diff --git a/src/Magnum/Platform/EmscriptenApplication.h b/src/Magnum/Platform/EmscriptenApplication.h index 3d7d0b81f..585c24af1 100644 --- a/src/Magnum/Platform/EmscriptenApplication.h +++ b/src/Magnum/Platform/EmscriptenApplication.h @@ -36,14 +36,22 @@ #include #include + +/* Needed by the MAGNUM_EMSCRIPTENAPPLICATION_MAIN() macro */ +/** @todo use an Optional */ #include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" #include "Magnum/Math/Vector4.h" #include "Magnum/Platform/Platform.h" +#ifdef MAGNUM_TARGET_GL +#include + +#include "Magnum/Platform/GLContext.h" +#endif + #if defined(CORRADE_TARGET_EMSCRIPTEN) || defined(DOXYGEN_GENERATING_OUTPUT) #ifndef DOXYGEN_GENERATING_OUTPUT @@ -902,7 +910,10 @@ class EmscriptenApplication { #ifdef MAGNUM_TARGET_GL EMSCRIPTEN_WEBGL_CONTEXT_HANDLE _glContext{}; - Containers::Pointer _context; + /* Has to be in an Optional because we delay-create it in a constructor + with populated Arguments and it gets explicitly destroyed before the + GL context */ + Containers::Optional _context; #endif /* These are saved from command-line arguments */ diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 32d0d68f4..5e51f14ac 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -44,7 +44,6 @@ #ifdef MAGNUM_TARGET_GL #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #endif namespace Magnum { namespace Platform { @@ -82,7 +81,7 @@ GlfwApplication::GlfwApplication(const Arguments& arguments, NoCreateT): { Utility::Arguments args{Implementation::windowScalingArguments()}; #ifdef MAGNUM_TARGET_GL - _context.reset(new GLContext{NoCreate, args, arguments.argc, arguments.argv}); + _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #else /** @todo this is duplicated here and in Sdl2Application, figure out a nice non-duplicated way to handle this */ @@ -671,7 +670,7 @@ GlfwApplication::~GlfwApplication() { #ifdef MAGNUM_TARGET_GL /* Destroy Magnum context first to avoid it potentially accessing the now-destroyed GL context after */ - _context.reset(); + _context = Containers::NullOpt; #endif glfwDestroyWindow(_window); diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index b0135b8f8..2d27a7180 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -35,7 +35,6 @@ #include #include #include -#include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" @@ -43,7 +42,7 @@ #include "Magnum/Platform/Platform.h" #ifdef MAGNUM_TARGET_GL -#include "Magnum/GL/Context.h" +#include "Magnum/Platform/GLContext.h" #endif #ifndef DOXYGEN_GENERATING_OUTPUT @@ -757,7 +756,10 @@ class GlfwApplication { GLFWwindow* _window{nullptr}; Flags _flags; #ifdef MAGNUM_TARGET_GL - Containers::Pointer _context; + /* Has to be in an Optional because we delay-create it in a constructor + with populated Arguments and it gets explicitly destroyed before the + GL context */ + Containers::Optional _context; #endif int _exitCode = 0; diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 28f7c2d40..3b815f653 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -56,7 +56,6 @@ #ifdef MAGNUM_TARGET_GL #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #endif #if defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT) @@ -125,7 +124,7 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): { Utility::Arguments args{Implementation::windowScalingArguments()}; #ifdef MAGNUM_TARGET_GL - _context.reset(new GLContext{NoCreate, args, arguments.argc, arguments.argv}); + _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #else /** @todo this is duplicated here and in GlfwApplication, figure out a nice non-duplicated way to handle this */ @@ -798,7 +797,7 @@ Sdl2Application::~Sdl2Application() { #ifdef MAGNUM_TARGET_GL /* Destroy Magnum context first to avoid it potentially accessing the now-destroyed GL context after */ - _context.reset(); + _context = Containers::NullOpt; #ifndef CORRADE_TARGET_EMSCRIPTEN if(_glContext) SDL_GL_DeleteContext(_glContext); diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index b35d10b5f..acb6279be 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -34,7 +34,6 @@ #include #include #include -#include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" @@ -42,7 +41,7 @@ #include "Magnum/Platform/Platform.h" #ifdef MAGNUM_TARGET_GL -#include "Magnum/GL/Context.h" +#include "Magnum/Platform/GLContext.h" #endif #ifdef CORRADE_TARGET_WINDOWS /* Windows version of SDL2 redefines main(), we don't want that */ @@ -1209,7 +1208,10 @@ class Sdl2Application { #ifndef CORRADE_TARGET_EMSCRIPTEN SDL_GLContext _glContext{}; #endif - Containers::Pointer _context; + /* Has to be in an Optional because we delay-create it in a constructor + with populated Arguments and it gets explicitly destroyed before the + GL context */ + Containers::Optional _context; #endif Flags _flags; diff --git a/src/Magnum/Platform/WindowlessCglApplication.cpp b/src/Magnum/Platform/WindowlessCglApplication.cpp index 3fb0d1b7e..146780ab7 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.cpp +++ b/src/Magnum/Platform/WindowlessCglApplication.cpp @@ -32,7 +32,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" namespace Magnum { namespace Platform { @@ -114,7 +113,7 @@ WindowlessCglApplication::WindowlessCglApplication(const Arguments& arguments, c createContext(configuration); } -WindowlessCglApplication::WindowlessCglApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}} {} +WindowlessCglApplication::WindowlessCglApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{NoCreate, arguments.argc, arguments.argv} {} WindowlessCglApplication::~WindowlessCglApplication() = default; @@ -125,10 +124,10 @@ void WindowlessCglApplication::createContext(const Configuration& configuration) } bool WindowlessCglApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::WindowlessCglApplication::tryCreateContext(): context already created", false); + CORRADE_ASSERT(_context.version() == GL::Version::None, "Platform::WindowlessCglApplication::tryCreateContext(): context already created", false); - WindowlessCglContext glContext{configuration, _context.get()}; - if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate(configuration)) + WindowlessCglContext glContext{configuration, &_context}; + if(!glContext.isCreated() || !glContext.makeCurrent() || !_context.tryCreate(configuration)) return false; _glContext = std::move(glContext); diff --git a/src/Magnum/Platform/WindowlessCglApplication.h b/src/Magnum/Platform/WindowlessCglApplication.h index 07e908bff..a8f58a46d 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.h +++ b/src/Magnum/Platform/WindowlessCglApplication.h @@ -35,12 +35,9 @@ #include "Magnum/configure.h" #ifdef MAGNUM_TARGET_GL -#include - #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" #ifndef DOXYGEN_GENERATING_OUTPUT #define GL_SILENCE_DEPRECATION /* YES I KNOW, APPLE! FFS */ @@ -399,7 +396,7 @@ class WindowlessCglApplication { private: WindowlessCglContext _glContext; - Containers::Pointer _context; + Platform::GLContext _context; }; /** @hideinitializer diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index 844fe7e38..9b8e3547b 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -36,7 +36,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #include "Implementation/Egl.h" @@ -555,7 +554,7 @@ WindowlessEglApplication::WindowlessEglApplication(const Arguments& arguments, N .addOption("cuda-device", "").setHelp("cuda-device", "CUDA device to use. Takes precedence over --magnum-device.", "N") .setFromEnvironment("cuda-device"); #endif - _context.reset(new GLContext{NoCreate, args, arguments.argc, arguments.argv}); + _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #ifndef MAGNUM_TARGET_WEBGL if(args.value("device").empty()) @@ -588,7 +587,7 @@ bool WindowlessEglApplication::tryCreateContext(const Configuration& configurati .setCudaDevice(_commandLineCudaDevice); #endif - WindowlessEglContext glContext{mergedConfiguration, _context.get()}; + WindowlessEglContext glContext{mergedConfiguration, &*_context}; if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate(configuration)) return false; diff --git a/src/Magnum/Platform/WindowlessEglApplication.h b/src/Magnum/Platform/WindowlessEglApplication.h index 22340bfd1..6dbd46279 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.h +++ b/src/Magnum/Platform/WindowlessEglApplication.h @@ -50,7 +50,7 @@ #undef Button4 #undef Button5 #include -#include +#include #ifndef DOXYGEN_GENERATING_OUTPUT /* Unfortunately Xlib *needs* the Bool type, so provide a typedef instead */ @@ -58,9 +58,8 @@ typedef int Bool; #endif #include "Magnum/Magnum.h" -#include "Magnum/GL/Context.h" #include "Magnum/Tags.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" namespace Magnum { namespace Platform { @@ -689,7 +688,9 @@ class WindowlessEglApplication { private: WindowlessEglContext _glContext; - Containers::Pointer _context; + /* Unlike other windowless apps has to be in an Optional because we + delay-create it in a constructor with populated Arguments */ + Containers::Optional _context; #ifndef MAGNUM_TARGET_WEBGL /* These are saved from command-line arguments */ diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index ce8e23092..0d0cb3fb4 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -32,7 +32,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" /* Saner way to define the insane Xlib macros (anyway, FUCK YOU XLIB) */ namespace { enum { None = 0, Success = 0 }; } @@ -288,7 +287,7 @@ WindowlessGlxApplication::WindowlessGlxApplication(const Arguments& arguments, c createContext(configuration); } -WindowlessGlxApplication::WindowlessGlxApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}} {} +WindowlessGlxApplication::WindowlessGlxApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{NoCreate, arguments.argc, arguments.argv} {} void WindowlessGlxApplication::createContext() { createContext({}); } @@ -297,10 +296,10 @@ void WindowlessGlxApplication::createContext(const Configuration& configuration) } bool WindowlessGlxApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::WindowlessGlxApplication::tryCreateContext(): context already created", false); + CORRADE_ASSERT(_context.version() == GL::Version::None, "Platform::WindowlessGlxApplication::tryCreateContext(): context already created", false); - WindowlessGlxContext glContext{configuration, _context.get()}; - if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate(configuration)) + WindowlessGlxContext glContext{configuration, &_context}; + if(!glContext.isCreated() || !glContext.makeCurrent() || !_context.tryCreate(configuration)) return false; _glContext = std::move(glContext); diff --git a/src/Magnum/Platform/WindowlessGlxApplication.h b/src/Magnum/Platform/WindowlessGlxApplication.h index 1c1b0f85b..639625be5 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.h +++ b/src/Magnum/Platform/WindowlessGlxApplication.h @@ -34,13 +34,11 @@ #ifdef MAGNUM_TARGET_GL #include -#include /* Include our GL headers first to avoid conflicts */ #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" #include #include @@ -511,7 +509,7 @@ class WindowlessGlxApplication { private: WindowlessGlxContext _glContext; - Containers::Pointer _context; + Platform::GLContext _context; }; /** @hideinitializer diff --git a/src/Magnum/Platform/WindowlessIosApplication.h b/src/Magnum/Platform/WindowlessIosApplication.h index fdfb7cca2..d02e92b07 100644 --- a/src/Magnum/Platform/WindowlessIosApplication.h +++ b/src/Magnum/Platform/WindowlessIosApplication.h @@ -33,12 +33,10 @@ #ifdef MAGNUM_TARGET_GL #include -#include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" #ifdef __OBJC__ @class EAGLContext; @@ -354,7 +352,7 @@ class WindowlessIosApplication { private: WindowlessIosContext _glContext; - Containers::Pointer _context; + Platform::GLContext _context; }; /** @hideinitializer diff --git a/src/Magnum/Platform/WindowlessIosApplication.mm b/src/Magnum/Platform/WindowlessIosApplication.mm index 83756aeb8..a174de8e2 100644 --- a/src/Magnum/Platform/WindowlessIosApplication.mm +++ b/src/Magnum/Platform/WindowlessIosApplication.mm @@ -90,7 +90,7 @@ WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments, c createContext(configuration); } -WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}} {} +WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{NoCreate, arguments.argc, arguments.argv} {} void WindowlessIosApplication::createContext() { createContext({}); } @@ -99,10 +99,10 @@ void WindowlessIosApplication::createContext(const Configuration& configuration) } bool WindowlessIosApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::WindowlessIosApplication::tryCreateContext(): context already created", false); + CORRADE_ASSERT(_context.version() == GL::Version::None, "Platform::WindowlessIosApplication::tryCreateContext(): context already created", false); - WindowlessIosContext glContext{configuration, _context.get()}; - if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate()) + WindowlessIosContext glContext{configuration, &_context}; + if(!glContext.isCreated() || !glContext.makeCurrent() || !_context.tryCreate()) return false; _glContext = std::move(glContext); diff --git a/src/Magnum/Platform/WindowlessWglApplication.cpp b/src/Magnum/Platform/WindowlessWglApplication.cpp index e01037773..5f9482f3c 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWglApplication.cpp @@ -31,7 +31,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #ifndef DOXYGEN_GENERATING_OUTPUT /* Define stuff that we need because I can't be bothered with creating a new @@ -273,7 +272,7 @@ WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, c createContext(configuration); } -WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}} {} +WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{NoCreate, arguments.argc, arguments.argv} {} void WindowlessWglApplication::createContext() { createContext({}); } @@ -282,10 +281,10 @@ void WindowlessWglApplication::createContext(const Configuration& configuration) } bool WindowlessWglApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::WindowlessWglApplication::tryCreateContext(): context already created", false); + CORRADE_ASSERT(_context.version() == GL::Version::None, "Platform::WindowlessWglApplication::tryCreateContext(): context already created", false); - WindowlessWglContext glContext{configuration, _context.get()}; - if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate(configuration)) + WindowlessWglContext glContext{configuration, &_context}; + if(!glContext.isCreated() || !glContext.makeCurrent() || !_context.tryCreate(configuration)) return false; _glContext = std::move(glContext); diff --git a/src/Magnum/Platform/WindowlessWglApplication.h b/src/Magnum/Platform/WindowlessWglApplication.h index 6bf035a4b..71db719f2 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.h +++ b/src/Magnum/Platform/WindowlessWglApplication.h @@ -38,12 +38,10 @@ #endif #include #include -#include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" #ifndef DOXYGEN_GENERATING_OUTPUT /* Define stuff that we need because I can't be bothered with creating a new @@ -496,7 +494,7 @@ class WindowlessWglApplication { private: WindowlessWglContext _glContext; - Containers::Pointer _context; + Platform::GLContext _context; }; /** @hideinitializer diff --git a/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp b/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp index 8a9707d74..b153ac85d 100644 --- a/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp @@ -29,7 +29,6 @@ #include #include "Magnum/GL/Version.h" -#include "Magnum/Platform/GLContext.h" #include "Implementation/Egl.h" @@ -191,7 +190,7 @@ WindowlessWindowsEglApplication::WindowlessWindowsEglApplication(const Arguments createContext(configuration); } -WindowlessWindowsEglApplication::WindowlessWindowsEglApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}} {} +WindowlessWindowsEglApplication::WindowlessWindowsEglApplication(const Arguments& arguments, NoCreateT): _glContext{NoCreate}, _context{NoCreate, arguments.argc, arguments.argv} {} void WindowlessWindowsEglApplication::createContext() { createContext({}); } @@ -200,10 +199,10 @@ void WindowlessWindowsEglApplication::createContext(const Configuration& configu } bool WindowlessWindowsEglApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessWindowsEglApplication::tryCreateContext(): context already created", false); + CORRADE_ASSERT(_context.version() == Version::None, "Platform::WindowlessWindowsEglApplication::tryCreateContext(): context already created", false); - WindowlessWindowsEglContext glContext{configuration, _context.get()}; - if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate(configuration)) + WindowlessWindowsEglContext glContext{configuration, &_context}; + if(!glContext.isCreated() || !glContext.makeCurrent() || !_context.tryCreate(configuration)) return false; _glContext = std::move(glContext); diff --git a/src/Magnum/Platform/WindowlessWindowsEglApplication.h b/src/Magnum/Platform/WindowlessWindowsEglApplication.h index 80694d9b3..64c4701bc 100644 --- a/src/Magnum/Platform/WindowlessWindowsEglApplication.h +++ b/src/Magnum/Platform/WindowlessWindowsEglApplication.h @@ -40,12 +40,10 @@ #include #include #include -#include #include "Magnum/Magnum.h" #include "Magnum/Tags.h" -#include "Magnum/GL/Context.h" -#include "Magnum/Platform/Platform.h" +#include "Magnum/Platform/GLContext.h" namespace Magnum { namespace Platform { @@ -468,7 +466,7 @@ class WindowlessWindowsEglApplication { private: WindowlessWindowsEglContext _glContext; - Containers::Pointer _context; + Platform::GLContext _context; }; /** @hideinitializer