Browse Source

Platform: disallow WindowFlag::Contextless when creating a GL context.

Used to be silently ignored in some places, silently discarded in some
other and probably causing an error elsewhere. Better be strict instead.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
a21636fee8
  1. 5
      src/Magnum/Platform/EmscriptenApplication.cpp
  2. 5
      src/Magnum/Platform/EmscriptenApplication.h
  3. 5
      src/Magnum/Platform/GlfwApplication.cpp
  4. 5
      src/Magnum/Platform/GlfwApplication.h
  5. 7
      src/Magnum/Platform/Sdl2Application.cpp
  6. 5
      src/Magnum/Platform/Sdl2Application.h

5
src/Magnum/Platform/EmscriptenApplication.cpp

@ -343,7 +343,10 @@ bool EmscriptenApplication::tryCreate(const Configuration& configuration) {
#ifdef MAGNUM_TARGET_GL
bool EmscriptenApplication::tryCreate(const Configuration& configuration, const GLConfiguration& glConfiguration) {
CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::EmscriptenApplication::tryCreate(): window with OpenGL context already created", false);
CORRADE_ASSERT(!(configuration.windowFlags() & Configuration::WindowFlag::Contextless),
"Platform::EmscriptenApplication::tryCreate(): cannot pass Configuration::WindowFlag::Contextless when creating an OpenGL context", false);
CORRADE_ASSERT(_context->version() == GL::Version::None,
"Platform::EmscriptenApplication::tryCreate(): window with OpenGL context already created", false);
/* Create emscripten WebGL context */
EmscriptenWebGLContextAttributes attrs;

5
src/Magnum/Platform/EmscriptenApplication.h

@ -1216,7 +1216,10 @@ class EmscriptenApplication::Configuration {
* @ref EmscriptenApplication(const Arguments&, const Configuration&),
* @ref create(const Configuration&) or
* @ref tryCreate(const Configuration&) to prevent implicit
* creation of an WebGL context.
* creation of an WebGL context. Can't be used with
* @ref EmscriptenApplication(const Arguments&, const Configuration&, const GLConfiguration&),
* @ref create(const Configuration&, const GLConfiguration&) or
* @ref tryCreate(const Configuration&, const GLConfiguration&).
*/
Contextless = 1 << 0,

5
src/Magnum/Platform/GlfwApplication.cpp

@ -409,7 +409,10 @@ GlfwApplication::InputEvent::Modifiers currentGlfwModifiers(GLFWwindow* window)
#ifdef MAGNUM_TARGET_GL
bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConfiguration& glConfiguration) {
CORRADE_ASSERT(!_window && _context->version() == GL::Version::None, "Platform::GlfwApplication::tryCreate(): window with OpenGL context already created", false);
CORRADE_ASSERT(!(configuration.windowFlags() & Configuration::WindowFlag::Contextless),
"Platform::GlfwApplication::tryCreate(): cannot pass Configuration::WindowFlag::Contextless when creating an OpenGL context", false);
CORRADE_ASSERT(!_window && _context->version() == GL::Version::None,
"Platform::GlfwApplication::tryCreate(): window with OpenGL context already created", false);
/* Save DPI scaling values from configuration for future use, scale window
based on those */

5
src/Magnum/Platform/GlfwApplication.h

@ -1113,7 +1113,10 @@ class GlfwApplication::Configuration {
* @ref GlfwApplication(const Arguments&, const Configuration&),
* @ref create(const Configuration&) or
* @ref tryCreate(const Configuration&) to prevent implicit
* creation of an OpenGL context.
* creation of an OpenGL context. Can't be used with
* @ref GlfwApplication(const Arguments&, const Configuration&, const GLConfiguration&),
* @ref create(const Configuration&, const GLConfiguration&) or
* @ref tryCreate(const Configuration&, const GLConfiguration&).
*
* @note Supported since GLFW 3.2.
*/

7
src/Magnum/Platform/Sdl2Application.cpp

@ -470,7 +470,10 @@ bool Sdl2Application::tryCreate(const Configuration& configuration) {
#ifdef MAGNUM_TARGET_GL
bool Sdl2Application::tryCreate(const Configuration& configuration, const GLConfiguration& glConfiguration) {
CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::Sdl2Application::tryCreate(): context already created", false);
CORRADE_ASSERT(!(configuration.windowFlags() & Configuration::WindowFlag::Contextless),
"Platform::Sdl2Application::tryCreate(): cannot pass Configuration::WindowFlag::Contextless when creating an OpenGL context", false);
CORRADE_ASSERT(_context->version() == GL::Version::None,
"Platform::Sdl2Application::tryCreate(): context already created", false);
/* Enable double buffering, set up buffer sizes */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
@ -621,7 +624,7 @@ bool Sdl2Application::tryCreate(const Configuration& configuration, const GLConf
if(!(_window = SDL_CreateWindow(configuration.title().data(),
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
scaledWindowSize.x(), scaledWindowSize.y(),
SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN|SDL_WINDOW_ALLOW_HIGHDPI|Uint32(configuration.windowFlags()&~Configuration::WindowFlag::Contextless))))
SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN|SDL_WINDOW_ALLOW_HIGHDPI|Uint32(configuration.windowFlags()))))
{
Error() << "Platform::Sdl2Application::tryCreate(): cannot create window:" << SDL_GetError();
return false;

5
src/Magnum/Platform/Sdl2Application.h

@ -1726,7 +1726,10 @@ class Sdl2Application::Configuration {
* @ref Sdl2Application(const Arguments&, const Configuration&),
* @ref create(const Configuration&) or
* @ref tryCreate(const Configuration&) to prevent implicit
* creation of an OpenGL context.
* creation of an OpenGL context. Can't be used with
* @ref Sdl2Application(const Arguments&, const Configuration&, const GLConfiguration&),
* @ref create(const Configuration&, const GLConfiguration&) or
* @ref tryCreate(const Configuration&, const GLConfiguration&).
*/
Contextless = 1u << 31, /* Hope this won't ever conflict with anything */

Loading…
Cancel
Save