diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 625359b7f..fdce8c9ea 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -50,7 +50,7 @@ GLfloat AbstractTexture::maxSupportedAnisotropy() { void AbstractTexture::setMinificationFilter(Filter filter, Mipmap mipmap) { #ifndef MAGNUM_TARGET_GLES - CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE || mipmap == Mipmap::BaseLevel, "AbstractTexture: rectangle textures cannot have mipmaps", ) + CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE || mipmap == Mipmap::BaseLevel, "AbstractTexture: rectangle textures cannot have mipmaps", ); #endif bind(); @@ -60,7 +60,7 @@ void AbstractTexture::setMinificationFilter(Filter filter, Mipmap mipmap) { void AbstractTexture::generateMipmap() { #ifndef MAGNUM_TARGET_GLES - CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE, "AbstractTexture: rectangle textures cannot have mipmaps", ) + CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE, "AbstractTexture: rectangle textures cannot have mipmaps", ); #endif bind(); @@ -110,7 +110,7 @@ AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components comp #ifndef DOXYGEN_GENERATING_OUTPUT void AbstractTexture::DataHelper<2>::setWrapping(GLenum target, const Math::Vector<2, Wrapping>& wrapping) { #ifndef MAGNUM_TARGET_GLES - CORRADE_ASSERT(target != GL_TEXTURE_RECTANGLE || ((wrapping[0] == Wrapping::ClampToEdge || wrapping[0] == Wrapping::ClampToBorder) && (wrapping[0] == Wrapping::ClampToEdge || wrapping[1] == Wrapping::ClampToEdge)), "AbstractTexture: rectangle texture wrapping must either clamp to border or to edge", ) + CORRADE_ASSERT(target != GL_TEXTURE_RECTANGLE || ((wrapping[0] == Wrapping::ClampToEdge || wrapping[0] == Wrapping::ClampToBorder) && (wrapping[0] == Wrapping::ClampToEdge || wrapping[1] == Wrapping::ClampToEdge)), "AbstractTexture: rectangle texture wrapping must either clamp to border or to edge", ); #endif glTexParameteri(target, GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index ce766a7ab..cae04f499 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -327,19 +327,23 @@ class MAGNUM_EXPORT AbstractTexture { * Four-component RGBA, unsigned normalized, each component 4bit, * 16bit total. */ - RGBA4 = GL_RGBA4, + RGBA4 = GL_RGBA4 #ifndef MAGNUM_TARGET_GLES + , + /** * Three-component RGB, float, red and green 11bit, blue 10bit, * 32bit total. * @requires_gl * @requires_gl30 Extension @extension{EXT,packed_float} */ - RG11B10Float = GL_R11F_G11F_B10F, + RG11B10Float = GL_R11F_G11F_B10F #endif #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) + , + /** * Three-component RGB, unsigned normalized, red and blue 5bit, * green 6bit, 16bit total. @@ -619,7 +623,7 @@ class MAGNUM_EXPORT AbstractTexture { * to `ClampToBorder`. * @requires_gl */ - inline void setBorderColor(const Color4& color) { + inline void setBorderColor(const Color4& color) { bind(); glTexParameterfv(_target, GL_TEXTURE_BORDER_COLOR, color.data()); } diff --git a/src/Contexts/EglContext.h b/src/Contexts/EglContext.h index 29a961856..1c1c7f628 100644 --- a/src/Contexts/EglContext.h +++ b/src/Contexts/EglContext.h @@ -38,7 +38,7 @@ namespace Magnum { namespace Contexts { /** @brief X/EGL context -Currently only barebone implementation with no event handling. +Supports keyboard and mouse handling. */ class EglContext: public AbstractContext { public: @@ -74,6 +74,9 @@ class EglContext: public AbstractContext { /** @copydoc GlutContext::swapBuffers() */ inline void swapBuffers() { eglSwapBuffers(display, surface); } + /** @todo implement */ + inline void redraw() {} + /*@}*/ /** @{ @name Keyboard handling */ @@ -172,6 +175,7 @@ class EglContext: public AbstractContext { /*@}*/ /** @{ @name Mouse handling */ + public: /** @brief Mouse button */ enum class MouseButton: unsigned int { @@ -199,6 +203,8 @@ class EglContext: public AbstractContext { */ virtual void mouseReleaseEvent(MouseButton button, const Math::Vector2& position); + /*@}*/ + private: Display* xDisplay; Window xWindow; diff --git a/src/Contexts/GlutContext.h b/src/Contexts/GlutContext.h index 454bd5b0a..17a3c921c 100644 --- a/src/Contexts/GlutContext.h +++ b/src/Contexts/GlutContext.h @@ -123,11 +123,13 @@ class GlutContext: public AbstractContext { protected: /** - * @brief Key event + * @brief Key press event + * @param key Key pressed + * @param position Cursor position * * Called when an key is pressed. Default implementation does nothing. */ - virtual void keyEvent(Key key, const Math::Vector2& position); + virtual void keyPressEvent(Key key, const Math::Vector2& position); /*@}*/ @@ -143,12 +145,6 @@ class GlutContext: public AbstractContext { WheelDown = 4 /**< Wheel down */ }; - /** @brief Mouse state */ - enum class MouseState: int { - Up = GLUT_UP, /**< No button pressed */ - Down = GLUT_DOWN /**< Button pressed */ - }; - /** @brief Mouse cursor */ enum class MouseCursor: int { Default = GLUT_CURSOR_INHERIT, /**< Default cursor provided by parent window */ @@ -177,12 +173,20 @@ class GlutContext: public AbstractContext { protected: /** - * @brief Mouse event + * @brief Mouse press event * - * Called when mouse button is pressed or released. Default - * implementation does nothing. + * Called when mouse button is pressed. Default implementation does + * nothing. + */ + virtual void mousePressEvent(MouseButton button, const Math::Vector2& position); + + /** + * @brief Mouse release event + * + * Called when mouse button is released. Default implementation does + * nothing. */ - virtual void mouseEvent(MouseButton button, MouseState state, const Math::Vector2& position); + virtual void mouseReleaseEvent(MouseButton button, const Math::Vector2& position); /** * @brief Mouse motion event @@ -202,11 +206,14 @@ class GlutContext: public AbstractContext { } inline static void staticKeyEvent(int key, int x, int y) { - instance->keyEvent(static_cast(key), {x, y}); + instance->keyPressEvent(static_cast(key), {x, y}); } inline static void staticMouseEvent(int button, int state, int x, int y) { - instance->mouseEvent(static_cast(button), static_cast(state), {x, y}); + if(state == GLUT_DOWN) + instance->mousePressEvent(static_cast(button), {x, y}); + else + instance->mouseReleaseEvent(static_cast(button), {x, y}); } inline static void staticMouseMotionEvent(int x, int y) { @@ -224,8 +231,9 @@ class GlutContext: public AbstractContext { }; /* Implementations for inline functions with unused parameters */ -inline void GlutContext::keyEvent(GlutContext::Key, const Math::Vector2&) {} -inline void GlutContext::mouseEvent(GlutContext::MouseButton, GlutContext::MouseState, const Math::Vector2&) {} +inline void GlutContext::keyPressEvent(GlutContext::Key, const Math::Vector2&) {} +inline void GlutContext::mousePressEvent(GlutContext::MouseButton, const Math::Vector2&) {} +inline void GlutContext::mouseReleaseEvent(GlutContext::MouseButton, const Math::Vector2&) {} inline void GlutContext::mouseMotionEvent(const Math::Vector2&) {} }} diff --git a/src/Contexts/Sdl2Context.h b/src/Contexts/Sdl2Context.h index 221a2dccc..fb4b00a22 100644 --- a/src/Contexts/Sdl2Context.h +++ b/src/Contexts/Sdl2Context.h @@ -20,10 +20,10 @@ */ #include "Magnum.h" -#include +#include +#include #include "AbstractContext.h" -#include namespace Magnum { namespace Contexts {