diff --git a/src/Magnum/Platform/GlutApplication.cpp b/src/Magnum/Platform/GlutApplication.cpp index 7305288aa..f3a49ae70 100644 --- a/src/Magnum/Platform/GlutApplication.cpp +++ b/src/Magnum/Platform/GlutApplication.cpp @@ -33,7 +33,7 @@ namespace Magnum { namespace Platform { -GlutApplication* GlutApplication::instance = nullptr; +GlutApplication* GlutApplication::_instance = nullptr; #ifndef DOXYGEN_GENERATING_OUTPUT GlutApplication::GlutApplication(const Arguments& arguments): GlutApplication{arguments, Configuration{}} {} @@ -43,9 +43,9 @@ GlutApplication::GlutApplication(const Arguments& arguments, const Configuration createContext(configuration); } -GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t): c(nullptr) { +GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t) { /* Save global instance */ - instance = this; + _instance = this; /* Init GLUT */ glutInit(&arguments.argc, arguments.argv); @@ -59,7 +59,7 @@ void GlutApplication::createContext(const Configuration& configuration) { } bool GlutApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(!c, "Platform::GlutApplication::tryCreateContext(): context already created", false); + CORRADE_ASSERT(!_context, "Platform::GlutApplication::tryCreateContext(): context already created", false); unsigned int flags = GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH|GLUT_STENCIL; @@ -96,45 +96,43 @@ bool GlutApplication::tryCreateContext(const Configuration& configuration) { glutMotionFunc(staticMouseMoveEvent); glutDisplayFunc(staticDrawEvent); - c = new Platform::Context; + _context.reset(new Platform::Context); return true; } -GlutApplication::~GlutApplication() { - delete c; -} +GlutApplication::~GlutApplication() = default; void GlutApplication::staticKeyPressEvent(unsigned char key, int x, int y) { KeyEvent e(static_cast(key), {x, y}); - instance->keyPressEvent(e); + _instance->keyPressEvent(e); } void GlutApplication::staticKeyReleaseEvent(unsigned char key, int x, int y) { KeyEvent e(static_cast(key), {x, y}); - instance->keyReleaseEvent(e); + _instance->keyReleaseEvent(e); } void GlutApplication::staticSpecialKeyPressEvent(int key, int x, int y){ KeyEvent e(static_cast(key << 16), {x, y}); - instance->keyPressEvent(e); + _instance->keyPressEvent(e); } void GlutApplication::staticSpecialKeyReleaseEvent(int key, int x, int y){ KeyEvent e(static_cast(key << 16), {x, y}); - instance->keyReleaseEvent(e); + _instance->keyReleaseEvent(e); } void GlutApplication::staticMouseEvent(int button, int state, int x, int y) { MouseEvent e(static_cast(button), {x, y}); if(state == GLUT_DOWN) - instance->mousePressEvent(e); + _instance->mousePressEvent(e); else - instance->mouseReleaseEvent(e); + _instance->mouseReleaseEvent(e); } void GlutApplication::staticMouseMoveEvent(int x, int y) { MouseMoveEvent e({x, y}, MouseMoveEvent::Button::Left); - instance->mouseMoveEvent(e); + _instance->mouseMoveEvent(e); } void GlutApplication::viewportEvent(const Vector2i&) {} diff --git a/src/Magnum/Platform/GlutApplication.h b/src/Magnum/Platform/GlutApplication.h index 0fc247740..b9123aca8 100644 --- a/src/Magnum/Platform/GlutApplication.h +++ b/src/Magnum/Platform/GlutApplication.h @@ -29,6 +29,7 @@ * @brief Class @ref Magnum::Platform::GlutApplication, macro @ref MAGNUM_GLUTAPPLICATION_MAIN() */ +#include #include #include "Magnum/Magnum.h" @@ -246,7 +247,7 @@ class GlutApplication { private: static void staticViewportEvent(int x, int y) { - instance->viewportEvent({x, y}); + _instance->viewportEvent({x, y}); } static void staticKeyPressEvent(unsigned char key, int x, int y); @@ -260,12 +261,12 @@ class GlutApplication { static void staticMouseMoveEvent(int x, int y); static void staticDrawEvent() { - instance->drawEvent(); + _instance->drawEvent(); } - static GlutApplication* instance; + static GlutApplication* _instance; - Platform::Context* c; + std::unique_ptr _context; }; /**