Browse Source

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.
euler-xxx
Vladimír Vondruš 5 years ago
parent
commit
6dafbd0c14
  1. 5
      src/Magnum/Platform/AbstractXApplication.cpp
  2. 8
      src/Magnum/Platform/AbstractXApplication.h
  3. 5
      src/Magnum/Platform/AndroidApplication.cpp
  4. 7
      src/Magnum/Platform/AndroidApplication.h
  5. 5
      src/Magnum/Platform/EmscriptenApplication.cpp
  6. 15
      src/Magnum/Platform/EmscriptenApplication.h
  7. 5
      src/Magnum/Platform/GlfwApplication.cpp
  8. 8
      src/Magnum/Platform/GlfwApplication.h
  9. 5
      src/Magnum/Platform/Sdl2Application.cpp
  10. 8
      src/Magnum/Platform/Sdl2Application.h
  11. 9
      src/Magnum/Platform/WindowlessCglApplication.cpp
  12. 7
      src/Magnum/Platform/WindowlessCglApplication.h
  13. 5
      src/Magnum/Platform/WindowlessEglApplication.cpp
  14. 9
      src/Magnum/Platform/WindowlessEglApplication.h
  15. 9
      src/Magnum/Platform/WindowlessGlxApplication.cpp
  16. 6
      src/Magnum/Platform/WindowlessGlxApplication.h
  17. 6
      src/Magnum/Platform/WindowlessIosApplication.h
  18. 8
      src/Magnum/Platform/WindowlessIosApplication.mm
  19. 9
      src/Magnum/Platform/WindowlessWglApplication.cpp
  20. 6
      src/Magnum/Platform/WindowlessWglApplication.h
  21. 9
      src/Magnum/Platform/WindowlessWindowsEglApplication.cpp
  22. 6
      src/Magnum/Platform/WindowlessWindowsEglApplication.h

5
src/Magnum/Platform/AbstractXApplication.cpp

@ -29,7 +29,6 @@
#include <Corrade/Utility/System.h>
#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<GLConfiguration, Display*, VisualID, Window>* contextHandler, const Arguments& arguments, NoCreateT): _contextHandler{contextHandler}, _context{new GLContext{NoCreate, arguments.argc, arguments.argv}}, _flags{Flag::Redraw} {}
AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler<GLConfiguration, Display*, VisualID, Window>* 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();

8
src/Magnum/Platform/AbstractXApplication.h

@ -35,6 +35,7 @@
#ifdef MAGNUM_TARGET_GL
#include <string>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#include <X11/Xlib.h>
@ -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<Implementation::AbstractContextHandler<GLConfiguration, Display*, VisualID, Window>> _contextHandler;
Containers::Pointer<Platform::GLContext> _context;
/* Has to be in an Optional because it gets explicitly destroyed before
the GL context */
Containers::Optional<Platform::GLContext> _context;
int _exitCode = 0;
/** @todo Get this from the created window */

5
src/Magnum/Platform/AndroidApplication.cpp

@ -30,7 +30,6 @@
#include <android_native_app_glue.h>
#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);

7
src/Magnum/Platform/AndroidApplication.h

@ -32,13 +32,14 @@
#endif
#include <EGL/egl.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#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 <android/input.h>
@ -435,7 +436,9 @@ class AndroidApplication {
EGLContext _glContext;
Vector2i _previousMouseMovePosition{-1};
Containers::Pointer<Platform::GLContext> _context;
/* Has to be in an Optional because it gets explicitly destroyed before
the GL context */
Containers::Optional<Platform::GLContext> _context;
Containers::Pointer<LogOutput> _logOutput;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)

5
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

15
src/Magnum/Platform/EmscriptenApplication.h

@ -36,14 +36,22 @@
#include <string>
#include <Corrade/Containers/ArrayView.h>
/* Needed by the MAGNUM_EMSCRIPTENAPPLICATION_MAIN() macro */
/** @todo use an Optional */
#include <Corrade/Containers/Pointer.h>
#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 <Corrade/Containers/Optional.h>
#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<Platform::GLContext> _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<Platform::GLContext> _context;
#endif
/* These are saved from command-line arguments */

5
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);

8
src/Magnum/Platform/GlfwApplication.h

@ -35,7 +35,6 @@
#include <string>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#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<Platform::GLContext> _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<Platform::GLContext> _context;
#endif
int _exitCode = 0;

5
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);

8
src/Magnum/Platform/Sdl2Application.h

@ -34,7 +34,6 @@
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#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<Platform::GLContext> _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<Platform::GLContext> _context;
#endif
Flags _flags;

9
src/Magnum/Platform/WindowlessCglApplication.cpp

@ -32,7 +32,6 @@
#include <Corrade/Utility/Debug.h>
#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);

7
src/Magnum/Platform/WindowlessCglApplication.h

@ -35,12 +35,9 @@
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Containers/Pointer.h>
#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<Platform::GLContext> _context;
Platform::GLContext _context;
};
/** @hideinitializer

5
src/Magnum/Platform/WindowlessEglApplication.cpp

@ -36,7 +36,6 @@
#include <Corrade/Utility/String.h>
#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;

9
src/Magnum/Platform/WindowlessEglApplication.h

@ -50,7 +50,7 @@
#undef Button4
#undef Button5
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/Optional.h>
#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<Platform::GLContext> _context;
/* Unlike other windowless apps has to be in an Optional because we
delay-create it in a constructor with populated Arguments */
Containers::Optional<Platform::GLContext> _context;
#ifndef MAGNUM_TARGET_WEBGL
/* These are saved from command-line arguments */

9
src/Magnum/Platform/WindowlessGlxApplication.cpp

@ -32,7 +32,6 @@
#include <Corrade/Utility/Debug.h>
#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);

6
src/Magnum/Platform/WindowlessGlxApplication.h

@ -34,13 +34,11 @@
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Pointer.h>
/* 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 <GL/glx.h>
#include <X11/Xlib.h>
@ -511,7 +509,7 @@ class WindowlessGlxApplication {
private:
WindowlessGlxContext _glContext;
Containers::Pointer<Platform::GLContext> _context;
Platform::GLContext _context;
};
/** @hideinitializer

6
src/Magnum/Platform/WindowlessIosApplication.h

@ -33,12 +33,10 @@
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Pointer.h>
#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<Platform::GLContext> _context;
Platform::GLContext _context;
};
/** @hideinitializer

8
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);

9
src/Magnum/Platform/WindowlessWglApplication.cpp

@ -31,7 +31,6 @@
#include <Corrade/Utility/Debug.h>
#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);

6
src/Magnum/Platform/WindowlessWglApplication.h

@ -38,12 +38,10 @@
#endif
#include <windows.h>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Pointer.h>
#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<Platform::GLContext> _context;
Platform::GLContext _context;
};
/** @hideinitializer

9
src/Magnum/Platform/WindowlessWindowsEglApplication.cpp

@ -29,7 +29,6 @@
#include <Corrade/Utility/Debug.h>
#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);

6
src/Magnum/Platform/WindowlessWindowsEglApplication.h

@ -40,12 +40,10 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Pointer.h>
#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<Platform::GLContext> _context;
Platform::GLContext _context;
};
/** @hideinitializer

Loading…
Cancel
Save