|
|
|
@ -33,7 +33,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace Magnum { namespace Platform { |
|
|
|
namespace Magnum { namespace Platform { |
|
|
|
|
|
|
|
|
|
|
|
GlutApplication* GlutApplication::instance = nullptr; |
|
|
|
GlutApplication* GlutApplication::_instance = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
#ifndef DOXYGEN_GENERATING_OUTPUT |
|
|
|
#ifndef DOXYGEN_GENERATING_OUTPUT |
|
|
|
GlutApplication::GlutApplication(const Arguments& arguments): GlutApplication{arguments, Configuration{}} {} |
|
|
|
GlutApplication::GlutApplication(const Arguments& arguments): GlutApplication{arguments, Configuration{}} {} |
|
|
|
@ -43,9 +43,9 @@ GlutApplication::GlutApplication(const Arguments& arguments, const Configuration |
|
|
|
createContext(configuration); |
|
|
|
createContext(configuration); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t): c(nullptr) { |
|
|
|
GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t) { |
|
|
|
/* Save global instance */ |
|
|
|
/* Save global instance */ |
|
|
|
instance = this; |
|
|
|
_instance = this; |
|
|
|
|
|
|
|
|
|
|
|
/* Init GLUT */ |
|
|
|
/* Init GLUT */ |
|
|
|
glutInit(&arguments.argc, arguments.argv); |
|
|
|
glutInit(&arguments.argc, arguments.argv); |
|
|
|
@ -59,7 +59,7 @@ void GlutApplication::createContext(const Configuration& configuration) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool GlutApplication::tryCreateContext(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; |
|
|
|
unsigned int flags = GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH|GLUT_STENCIL; |
|
|
|
|
|
|
|
|
|
|
|
@ -96,45 +96,43 @@ bool GlutApplication::tryCreateContext(const Configuration& configuration) { |
|
|
|
glutMotionFunc(staticMouseMoveEvent); |
|
|
|
glutMotionFunc(staticMouseMoveEvent); |
|
|
|
glutDisplayFunc(staticDrawEvent); |
|
|
|
glutDisplayFunc(staticDrawEvent); |
|
|
|
|
|
|
|
|
|
|
|
c = new Platform::Context; |
|
|
|
_context.reset(new Platform::Context); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GlutApplication::~GlutApplication() { |
|
|
|
GlutApplication::~GlutApplication() = default; |
|
|
|
delete c; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::staticKeyPressEvent(unsigned char key, int x, int y) { |
|
|
|
void GlutApplication::staticKeyPressEvent(unsigned char key, int x, int y) { |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key), {x, y}); |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key), {x, y}); |
|
|
|
instance->keyPressEvent(e); |
|
|
|
_instance->keyPressEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::staticKeyReleaseEvent(unsigned char key, int x, int y) { |
|
|
|
void GlutApplication::staticKeyReleaseEvent(unsigned char key, int x, int y) { |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key), {x, y}); |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key), {x, y}); |
|
|
|
instance->keyReleaseEvent(e); |
|
|
|
_instance->keyReleaseEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::staticSpecialKeyPressEvent(int key, int x, int y){ |
|
|
|
void GlutApplication::staticSpecialKeyPressEvent(int key, int x, int y){ |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key << 16), {x, y}); |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key << 16), {x, y}); |
|
|
|
instance->keyPressEvent(e); |
|
|
|
_instance->keyPressEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::staticSpecialKeyReleaseEvent(int key, int x, int y){ |
|
|
|
void GlutApplication::staticSpecialKeyReleaseEvent(int key, int x, int y){ |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key << 16), {x, y}); |
|
|
|
KeyEvent e(static_cast<KeyEvent::Key>(key << 16), {x, y}); |
|
|
|
instance->keyReleaseEvent(e); |
|
|
|
_instance->keyReleaseEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::staticMouseEvent(int button, int state, int x, int y) { |
|
|
|
void GlutApplication::staticMouseEvent(int button, int state, int x, int y) { |
|
|
|
MouseEvent e(static_cast<MouseEvent::Button>(button), {x, y}); |
|
|
|
MouseEvent e(static_cast<MouseEvent::Button>(button), {x, y}); |
|
|
|
if(state == GLUT_DOWN) |
|
|
|
if(state == GLUT_DOWN) |
|
|
|
instance->mousePressEvent(e); |
|
|
|
_instance->mousePressEvent(e); |
|
|
|
else |
|
|
|
else |
|
|
|
instance->mouseReleaseEvent(e); |
|
|
|
_instance->mouseReleaseEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::staticMouseMoveEvent(int x, int y) { |
|
|
|
void GlutApplication::staticMouseMoveEvent(int x, int y) { |
|
|
|
MouseMoveEvent e({x, y}, MouseMoveEvent::Button::Left); |
|
|
|
MouseMoveEvent e({x, y}, MouseMoveEvent::Button::Left); |
|
|
|
instance->mouseMoveEvent(e); |
|
|
|
_instance->mouseMoveEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GlutApplication::viewportEvent(const Vector2i&) {} |
|
|
|
void GlutApplication::viewportEvent(const Vector2i&) {} |
|
|
|
|