Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 14 years ago
parent
commit
c93d77f360
  1. 6
      src/AbstractTexture.cpp
  2. 10
      src/AbstractTexture.h
  3. 8
      src/Contexts/EglContext.h
  4. 40
      src/Contexts/GlutContext.h
  5. 4
      src/Contexts/Sdl2Context.h

6
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<GLint>(wrapping[0]));

10
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<GLfloat>& color) {
bind();
glTexParameterfv(_target, GL_TEXTURE_BORDER_COLOR, color.data());
}

8
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<int>& position);
/*@}*/
private:
Display* xDisplay;
Window xWindow;

40
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<int>& position);
virtual void keyPressEvent(Key key, const Math::Vector2<int>& 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<int>& 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<int>& position);
virtual void mouseReleaseEvent(MouseButton button, const Math::Vector2<int>& 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>(key), {x, y});
instance->keyPressEvent(static_cast<Key>(key), {x, y});
}
inline static void staticMouseEvent(int button, int state, int x, int y) {
instance->mouseEvent(static_cast<MouseButton>(button), static_cast<MouseState>(state), {x, y});
if(state == GLUT_DOWN)
instance->mousePressEvent(static_cast<MouseButton>(button), {x, y});
else
instance->mouseReleaseEvent(static_cast<MouseButton>(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<int>&) {}
inline void GlutContext::mouseEvent(GlutContext::MouseButton, GlutContext::MouseState, const Math::Vector2<int>&) {}
inline void GlutContext::keyPressEvent(GlutContext::Key, const Math::Vector2<int>&) {}
inline void GlutContext::mousePressEvent(GlutContext::MouseButton, const Math::Vector2<int>&) {}
inline void GlutContext::mouseReleaseEvent(GlutContext::MouseButton, const Math::Vector2<int>&) {}
inline void GlutContext::mouseMotionEvent(const Math::Vector2<int>&) {}
}}

4
src/Contexts/Sdl2Context.h

@ -20,10 +20,10 @@
*/
#include "Magnum.h"
#include <SDL.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_scancode.h>
#include "AbstractContext.h"
#include <SDL2/SDL_scancode.h>
namespace Magnum { namespace Contexts {

Loading…
Cancel
Save