Browse Source

Using integer vector aliases all over the place.

pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
43f6dbc72d
  1. 4
      doc/portability.dox
  2. 17
      src/AbstractShaderProgram.h
  3. 16
      src/AbstractTexture.cpp
  4. 36
      src/AbstractTexture.h
  5. 2
      src/CubeMapTexture.h
  6. 8
      src/CubeMapTextureArray.h
  7. 4
      src/Framebuffer.cpp
  8. 12
      src/Framebuffer.h
  9. 4
      src/Platform/AbstractXApplication.cpp
  10. 26
      src/Platform/AbstractXApplication.h
  11. 2
      src/Platform/GlutApplication.cpp
  12. 22
      src/Platform/GlutApplication.h
  13. 2
      src/Platform/GlxApplication.h
  14. 4
      src/Platform/NaClApplication.cpp
  15. 20
      src/Platform/NaClApplication.h
  16. 2
      src/Platform/Sdl2Application.cpp
  17. 18
      src/Platform/Sdl2Application.h
  18. 2
      src/Platform/XEglApplication.h
  19. 2
      src/Renderbuffer.h
  20. 8
      src/SceneGraph/AbstractCamera.h
  21. 6
      src/SceneGraph/Test/CameraTest.cpp
  22. 4
      src/Swizzle.h
  23. 38
      src/Test/SwizzleTest.cpp

4
doc/portability.dox

@ -157,7 +157,7 @@ class MyApplication: public ApplicationBase {
} }
protected: protected:
void viewportEvent(const Math::Vector2<GLsizei>& size) override { void viewportEvent(const Vector2i& size) override {
// ... // ...
} }
@ -165,7 +165,7 @@ class MyApplication: public ApplicationBase {
// ... // ...
} }
void keyPressEvent(Key key, Modifiers modifiers, const Math::Vector2<int>& position) { void keyPressEvent(Key key, Modifiers modifiers, const Vector2i& position) {
// ... // ...
} }
}; };

17
src/AbstractShaderProgram.h

@ -298,14 +298,13 @@ class MAGNUM_EXPORT AbstractShaderProgram {
* location `0`. * location `0`.
* *
* Template parameter @p T is the type which is used for shader * Template parameter @p T is the type which is used for shader
* attribute, e.g. @ref Math::Vector4 "Vector4<GLint>" for `ivec4`. * attribute, e.g. @ref Vector4i for `ivec4`. DataType is type of
* DataType is type of passed data when adding vertex buffers to mesh. * passed data when adding vertex buffers to mesh. By default it is
* By default it is the same as type used in shader (e.g. * the same as type used in shader (e.g. @ref DataType "DataType::Int"
* @ref DataType "DataType::Int" for @ref Math::Vector4 "Vector4<GLint>"). * for @ref Vector4i). It's also possible to pass integer data to
* It's also possible to pass integer data to floating-point shader * floating-point shader inputs. In this case you may want to
* inputs. In this case you may want to normalize the values (e.g. * normalize the values (e.g. color components from 0-255 to
* color components from 0-255 to 0.0f-1.0f) - see * 0.0f - 1.0f) -- see @ref DataOption "DataOption::Normalize".
* @ref DataOption "DataOption::Normalize".
* *
* Only some types are allowed as attribute types, see * Only some types are allowed as attribute types, see
* @ref AbstractShaderProgram-types or TypeTraits::AttributeType for * @ref AbstractShaderProgram-types or TypeTraits::AttributeType for
@ -425,7 +424,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
* @brief Constructor * @brief Constructor
* @param dataType Type of passed data. Default is the * @param dataType Type of passed data. Default is the
* same as type used in shader (e.g. DataType::Integer * same as type used in shader (e.g. DataType::Integer
* for Vector4<GLint>). * for Vector4i).
* @param dataOptions Data options. Default is no options. * @param dataOptions Data options. Default is no options.
*/ */
inline constexpr Attribute(DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()): _dataType(dataType), _dataOptions(dataOptions) {} inline constexpr Attribute(DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()): _dataType(dataType), _dataOptions(dataOptions) {}

16
src/AbstractTexture.cpp

@ -235,18 +235,18 @@ void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, Inte
} }
#endif #endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
bindInternal(); bindInternal();
glTexImage2D(target, mipLevel, internalFormat, size.x(), size.y(), 0, static_cast<GLenum>(components), static_cast<GLenum>(type), data); glTexImage2D(target, mipLevel, internalFormat, size.x(), size.y(), 0, static_cast<GLenum>(components), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
glTextureImage2DEXT(_id, target, mipLevel, internalFormat, size.x(), size.y(), 0, static_cast<GLenum>(components), static_cast<GLenum>(type), data); glTextureImage2DEXT(_id, target, mipLevel, internalFormat, size.x(), size.y(), 0, static_cast<GLenum>(components), static_cast<GLenum>(type), data);
} }
#endif #endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
bindInternal(); bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -263,7 +263,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel,
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
glTextureImage3DEXT(_id, target, mipLevel, internalFormat, size.x(), size.y(), size.z(), 0, static_cast<GLenum>(components), static_cast<GLenum>(type), data); glTextureImage3DEXT(_id, target, mipLevel, internalFormat, size.x(), size.y(), size.z(), 0, static_cast<GLenum>(components), static_cast<GLenum>(type), data);
} }
#endif #endif
@ -279,18 +279,18 @@ void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, c
} }
#endif #endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint mipLevel, const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::subImageImplementationDefault(GLenum target, GLint mipLevel, const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
bindInternal(); bindInternal();
glTexSubImage2D(target, mipLevel, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(components), static_cast<GLenum>(type), data); glTexSubImage2D(target, mipLevel, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(components), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
glTextureSubImage2DEXT(_id, target, mipLevel, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(components), static_cast<GLenum>(type), data); glTextureSubImage2DEXT(_id, target, mipLevel, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(components), static_cast<GLenum>(type), data);
} }
#endif #endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint mipLevel, const Math::Vector3<GLint>& offset, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::subImageImplementationDefault(GLenum target, GLint mipLevel, const Vector3i& offset, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
bindInternal(); bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -307,7 +307,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint mipLeve
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, const Math::Vector3<GLint>& offset, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, const Vector3i& offset, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) {
glTextureSubImage3DEXT(_id, target, mipLevel, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(components), static_cast<GLenum>(type), data); glTextureSubImage3DEXT(_id, target, mipLevel, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(components), static_cast<GLenum>(type), data);
} }
#endif #endif

36
src/AbstractTexture.h

@ -772,14 +772,14 @@ class MAGNUM_EXPORT AbstractTexture {
static Image1DImplementation image1DImplementation; static Image1DImplementation image1DImplementation;
#endif #endif
typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, InternalFormat, const Math::Vector2<GLsizei>&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*); typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, InternalFormat, const Vector2i&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*);
void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
static Image2DImplementation image2DImplementation; static Image2DImplementation image2DImplementation;
typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, InternalFormat, const Math::Vector3<GLsizei>&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*); typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, InternalFormat, const Vector3i&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*);
void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
static Image3DImplementation image3DImplementation; static Image3DImplementation image3DImplementation;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -789,14 +789,14 @@ class MAGNUM_EXPORT AbstractTexture {
static SubImage1DImplementation subImage1DImplementation; static SubImage1DImplementation subImage1DImplementation;
#endif #endif
typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Math::Vector2<GLint>&, const Math::Vector2<GLsizei>&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*); typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Vector2i&, const Vector2i&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*);
void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint mipLevel, const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint mipLevel, const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint mipLevel, const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint mipLevel, const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
static SubImage2DImplementation subImage2DImplementation; static SubImage2DImplementation subImage2DImplementation;
typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Math::Vector3<GLint>&, const Math::Vector3<GLsizei>&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*); typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Vector3i&, const Vector3i&, AbstractImage::Components, AbstractImage::ComponentType, const GLvoid*);
void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint mipLevel, const Math::Vector3<GLint>& offset, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint mipLevel, const Vector3i& offset, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint mipLevel, const Math::Vector3<GLint>& offset, const Math::Vector3<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data); void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint mipLevel, const Vector3i& offset, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data);
static SubImage3DImplementation subImage3DImplementation; static SubImage3DImplementation subImage3DImplementation;
GLuint _id; GLuint _id;
@ -860,12 +860,12 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
(texture->*image2DImplementation)(target, mipLevel, internalFormat, image->size(), image->components(), image->type(), image->data()); (texture->*image2DImplementation)(target, mipLevel, internalFormat, image->size(), image->components(), image->type(), image->data());
} }
template<class Image> inline static typename std::enable_if<Image::Dimensions == 2, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Math::Vector2<GLint>& offset, Image* image) { template<class Image> inline static typename std::enable_if<Image::Dimensions == 2, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Vector2i& offset, Image* image) {
(texture->*subImage2DImplementation)(target, mipLevel, offset, image->size(), image->components(), image->type(), image->data()); (texture->*subImage2DImplementation)(target, mipLevel, offset, image->size(), image->components(), image->type(), image->data());
} }
template<class Image> inline static typename std::enable_if<Image::Dimensions == 1, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Math::Vector2<GLint>& offset, Image* image) { template<class Image> inline static typename std::enable_if<Image::Dimensions == 1, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Vector2i& offset, Image* image) {
(texture->*subImage2DImplementation)(target, mipLevel, offset, Math::Vector2<GLint>(image->size(), 1), image->components(), image->type(), image->data()); (texture->*subImage2DImplementation)(target, mipLevel, offset, Vector2i(image->size(), 1), image->components(), image->type(), image->data());
} }
}; };
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
@ -886,12 +886,12 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
(texture->*image3DImplementation)(target, mipLevel, internalFormat, image->size(), image->components(), image->type(), image->data()); (texture->*image3DImplementation)(target, mipLevel, internalFormat, image->size(), image->components(), image->type(), image->data());
} }
template<class Image> inline static typename std::enable_if<Image::Dimensions == 3, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Math::Vector3<GLint>& offset, Image* image) { template<class Image> inline static typename std::enable_if<Image::Dimensions == 3, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Vector3i& offset, Image* image) {
(texture->*subImage3DImplementation)(target, mipLevel, offset, image->size(), image->components(), image->type(), image->data()); (texture->*subImage3DImplementation)(target, mipLevel, offset, image->size(), image->components(), image->type(), image->data());
} }
template<class Image> inline static typename std::enable_if<Image::Dimensions == 2, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Math::Vector3<GLint>& offset, Image* image) { template<class Image> inline static typename std::enable_if<Image::Dimensions == 2, void>::type setSub(AbstractTexture* texture, GLenum target, GLint mipLevel, const Vector3i& offset, Image* image) {
(texture->*subImage3DImplementation)(target, mipLevel, offset, Math::Vector3<GLint>(image->size(), 1), image->components(), image->type(), image->data()); (texture->*subImage3DImplementation)(target, mipLevel, offset, Vector3i(image->size(), 1), image->components(), image->type(), image->data());
} }
}; };
#endif #endif

2
src/CubeMapTexture.h

@ -122,7 +122,7 @@ class CubeMapTexture: public AbstractTexture {
* @param coordinate Coordinate * @param coordinate Coordinate
* @return Pointer to self (for method chaining) * @return Pointer to self (for method chaining)
*/ */
template<class Image> inline CubeMapTexture* setSubData(Coordinate coordinate, GLint mipLevel, const Math::Vector2<GLint>& offset, const Image* image) { template<class Image> inline CubeMapTexture* setSubData(Coordinate coordinate, GLint mipLevel, const Vector2i& offset, const Image* image) {
DataHelper<2>::setSub(this, static_cast<GLenum>(coordinate), mipLevel, offset, image); DataHelper<2>::setSub(this, static_cast<GLenum>(coordinate), mipLevel, offset, image);
return this; return this;
} }

8
src/CubeMapTextureArray.h

@ -127,8 +127,8 @@ class CubeMapTextureArray: public AbstractTexture {
* *
* @see setSubData(GLsizei, Coordinate, GLint, const Math::Vector<2, GLint>&, const Image*) * @see setSubData(GLsizei, Coordinate, GLint, const Math::Vector<2, GLint>&, const Image*)
*/ */
template<class Image> inline CubeMapTextureArray* setSubData(GLint mipLevel, const Math::Vector3<GLint>& offset, const Image* image) { template<class Image> inline CubeMapTextureArray* setSubData(GLint mipLevel, const Vector3i& offset, const Image* image) {
DataHelper<3>::setSub(this, GL_TEXTURE_CUBE_MAP_ARRAY, mipLevel, offset, image, Math::Vector3<GLsizei>(Math::Vector<Image::Dimensions, GLsizei>())); DataHelper<3>::setSub(this, GL_TEXTURE_CUBE_MAP_ARRAY, mipLevel, offset, image, Vector3i(Math::Vector<Image::Dimensions, GLsizei>()));
return this; return this;
} }
@ -147,8 +147,8 @@ class CubeMapTextureArray: public AbstractTexture {
* *
* @see setSubData(GLint, const Math::Vector<3, GLint>&, const Image*) * @see setSubData(GLint, const Math::Vector<3, GLint>&, const Image*)
*/ */
template<class Image> inline CubeMapTextureArray* setSubData(GLsizei layer, Coordinate coordinate, GLint mipLevel, const Math::Vector2<GLint>& offset, const Image* image) { template<class Image> inline CubeMapTextureArray* setSubData(GLsizei layer, Coordinate coordinate, GLint mipLevel, const Vector2i& offset, const Image* image) {
DataHelper<3>::setSub(this, GL_TEXTURE_CUBE_MAP_ARRAY, mipLevel, Math::Vector3<GLint>(offset, layer*6+static_cast<GLsizei>(coordinate)), image, Math::Vector<2, GLsizei>(Math::Vector<Image::Dimensions, GLsizei>())); DataHelper<3>::setSub(this, GL_TEXTURE_CUBE_MAP_ARRAY, mipLevel, Vector3i(offset, layer*6+static_cast<GLsizei>(coordinate)), image, Vector2i(Math::Vector<Image::Dimensions, GLsizei>()));
return this; return this;
} }

4
src/Framebuffer.cpp

@ -45,14 +45,14 @@ void Framebuffer::mapForDraw(std::initializer_list<std::int8_t> colorAttachments
delete[] attachments; delete[] attachments;
} }
void Framebuffer::read(const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, Image2D* image) { void Framebuffer::read(const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, Image2D* image) {
char* data = new char[AbstractImage::pixelSize(components, type)*size.product()]; char* data = new char[AbstractImage::pixelSize(components, type)*size.product()];
glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(components), static_cast<GLenum>(type), data); glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(components), static_cast<GLenum>(type), data);
image->setData(size, components, type, data); image->setData(size, components, type, data);
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void Framebuffer::read(const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, BufferedImage2D* image, Buffer::Usage usage) { void Framebuffer::read(const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, BufferedImage2D* image, Buffer::Usage usage) {
/* If the buffer doesn't have sufficient size, resize it */ /* If the buffer doesn't have sufficient size, resize it */
/** @todo Explicitly reset also when buffer usage changes */ /** @todo Explicitly reset also when buffer usage changes */
if(image->size() != size || image->components() != components || image->type() != type) if(image->size() != size || image->components() != components || image->type() != type)

12
src/Framebuffer.h

@ -127,7 +127,7 @@ class MAGNUM_EXPORT Framebuffer {
* Call when window size changes. * Call when window size changes.
* @see @fn_gl{Viewport} * @see @fn_gl{Viewport}
*/ */
inline static void setViewport(const Math::Vector2<GLint>& position, const Math::Vector2<GLsizei>& size) { inline static void setViewport(const Vector2i& position, const Vector2i& size) {
glViewport(position.x(), position.y(), size.x(), size.y()); glViewport(position.x(), position.y(), size.x(), size.y());
} }
@ -211,7 +211,7 @@ class MAGNUM_EXPORT Framebuffer {
* @attention You have to enable scissoring with setFeature() first. * @attention You have to enable scissoring with setFeature() first.
* @see @fn_gl{Scissor} * @see @fn_gl{Scissor}
*/ */
inline static void setScissor(const Math::Vector2<GLint>& bottomLeft, const Math::Vector2<GLsizei>& size) { inline static void setScissor(const Vector2i& bottomLeft, const Vector2i& size) {
glScissor(bottomLeft.x(), bottomLeft.y(), size.x(), size.y()); glScissor(bottomLeft.x(), bottomLeft.y(), size.x(), size.y());
} }
@ -1235,7 +1235,7 @@ class MAGNUM_EXPORT Framebuffer {
* @requires_gl30 Extension @extension{EXT,framebuffer_blit} * @requires_gl30 Extension @extension{EXT,framebuffer_blit}
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} * @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit}
*/ */
inline static void blit(const Math::Vector2<GLint>& bottomLeft, const Math::Vector2<GLint>& topRight, const Math::Vector2<GLint>& destinationBottomLeft, const Math::Vector2<GLint>& destinationTopRight, BlitMask blitMask, AbstractTexture::Filter filter) { inline static void blit(const Vector2i& bottomLeft, const Vector2i& topRight, const Vector2i& destinationBottomLeft, const Vector2i& destinationTopRight, BlitMask blitMask, AbstractTexture::Filter filter) {
/** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */ /** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glBlitFramebuffer(bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), destinationBottomLeft.x(), destinationBottomLeft.y(), destinationTopRight.x(), destinationTopRight.y(), static_cast<GLbitfield>(blitMask), static_cast<GLenum>(filter)); glBlitFramebuffer(bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), destinationBottomLeft.x(), destinationBottomLeft.y(), destinationTopRight.x(), destinationTopRight.y(), static_cast<GLbitfield>(blitMask), static_cast<GLenum>(filter));
@ -1266,7 +1266,7 @@ class MAGNUM_EXPORT Framebuffer {
* @requires_gl30 Extension @extension{EXT,framebuffer_blit} * @requires_gl30 Extension @extension{EXT,framebuffer_blit}
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} * @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit}
*/ */
inline static void blit(const Math::Vector2<GLint>& bottomLeft, const Math::Vector2<GLint>& topRight, BlitMask blitMask) { inline static void blit(const Vector2i& bottomLeft, const Vector2i& topRight, BlitMask blitMask) {
/** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */ /** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glBlitFramebuffer(bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), static_cast<GLbitfield>(blitMask), static_cast<GLenum>(AbstractTexture::Filter::NearestNeighbor)); glBlitFramebuffer(bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), bottomLeft.x(), bottomLeft.y(), topRight.x(), topRight.y(), static_cast<GLbitfield>(blitMask), static_cast<GLenum>(AbstractTexture::Filter::NearestNeighbor));
@ -1288,7 +1288,7 @@ class MAGNUM_EXPORT Framebuffer {
* @see @fn_gl{ReadPixels} * @see @fn_gl{ReadPixels}
* @requires_gl30 Extension @extension{EXT,framebuffer_object} * @requires_gl30 Extension @extension{EXT,framebuffer_object}
*/ */
static void read(const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, Image2D* image); static void read(const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, Image2D* image);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** /**
@ -1304,7 +1304,7 @@ class MAGNUM_EXPORT Framebuffer {
* @requires_gl30 Extension @extension{EXT,framebuffer_object} * @requires_gl30 Extension @extension{EXT,framebuffer_object}
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. * @requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0.
*/ */
static void read(const Math::Vector2<GLint>& offset, const Math::Vector2<GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, BufferedImage2D* image, Buffer::Usage usage); static void read(const Vector2i& offset, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, BufferedImage2D* image, Buffer::Usage usage);
#endif #endif
/*@}*/ /*@}*/

4
src/Platform/AbstractXApplication.cpp

@ -29,7 +29,7 @@ using namespace std;
namespace Magnum { namespace Platform { namespace Magnum { namespace Platform {
AbstractXApplication::AbstractXApplication(AbstractContextHandler<Display*, VisualID, Window>* contextHandler, int&, char**, const string& title, const Math::Vector2<GLsizei>& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) { AbstractXApplication::AbstractXApplication(AbstractContextHandler<Display*, VisualID, Window>* contextHandler, int&, char**, const string& title, const Vector2i& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) {
/* Get default X display */ /* Get default X display */
display = XOpenDisplay(0); display = XOpenDisplay(0);
@ -108,7 +108,7 @@ int AbstractXApplication::exec() {
switch(event.type) { switch(event.type) {
/* Window resizing */ /* Window resizing */
case ConfigureNotify: { case ConfigureNotify: {
Math::Vector2<GLsizei> size(event.xconfigure.width, event.xconfigure.height); Vector2i size(event.xconfigure.width, event.xconfigure.height);
if(size != viewportSize) { if(size != viewportSize) {
viewportSize = size; viewportSize = size;
viewportEvent(size); viewportEvent(size);

26
src/Platform/AbstractXApplication.h

@ -57,7 +57,7 @@ class AbstractXApplication {
* *
* Creates window with double-buffered OpenGL ES 2 context. * Creates window with double-buffered OpenGL ES 2 context.
*/ */
AbstractXApplication(AbstractContextHandler<Display*, VisualID, Window>* contextHandler, int& argc, char** argv, const std::string& title = "Magnum X application", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600)); AbstractXApplication(AbstractContextHandler<Display*, VisualID, Window>* contextHandler, int& argc, char** argv, const std::string& title = "Magnum X application", const Vector2i& size = Vector2i(800, 600));
/** /**
* @brief Destructor * @brief Destructor
@ -79,7 +79,7 @@ class AbstractXApplication {
protected: protected:
/** @copydoc GlutApplication::viewportEvent() */ /** @copydoc GlutApplication::viewportEvent() */
virtual void viewportEvent(const Math::Vector2<GLsizei>& size) = 0; virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc GlutApplication::drawEvent() */ /** @copydoc GlutApplication::drawEvent() */
virtual void drawEvent() = 0; virtual void drawEvent() = 0;
@ -209,7 +209,7 @@ class AbstractXApplication {
* *
* Called when an key is pressed. Default implementation does nothing. * Called when an key is pressed. Default implementation does nothing.
*/ */
virtual void keyPressEvent(Key key, Modifiers modifiers, const Math::Vector2<int>& position); virtual void keyPressEvent(Key key, Modifiers modifiers, const Vector2i& position);
/** /**
* @brief Key press event * @brief Key press event
@ -219,7 +219,7 @@ class AbstractXApplication {
* *
* Called when an key is released. Default implementation does nothing. * Called when an key is released. Default implementation does nothing.
*/ */
virtual void keyReleaseEvent(Key key, Modifiers modifiers, const Math::Vector2<int>& position); virtual void keyReleaseEvent(Key key, Modifiers modifiers, const Vector2i& position);
/*@}*/ /*@}*/
@ -249,7 +249,7 @@ class AbstractXApplication {
* Called when mouse button is pressed. Default implementation does * Called when mouse button is pressed. Default implementation does
* nothing. * nothing.
*/ */
virtual void mousePressEvent(MouseButton button, Modifiers modifiers, const Math::Vector2<int>& position); virtual void mousePressEvent(MouseButton button, Modifiers modifiers, const Vector2i& position);
/** /**
* @brief Mouse release event * @brief Mouse release event
@ -260,7 +260,7 @@ class AbstractXApplication {
* Called when mouse button is released. Default implementation does * Called when mouse button is released. Default implementation does
* nothing. * nothing.
*/ */
virtual void mouseReleaseEvent(MouseButton button, Modifiers modifiers, const Math::Vector2<int>& position); virtual void mouseReleaseEvent(MouseButton button, Modifiers modifiers, const Vector2i& position);
/** /**
* @brief Mouse motion event * @brief Mouse motion event
@ -269,7 +269,7 @@ class AbstractXApplication {
* *
* Called when mouse is moved. * Called when mouse is moved.
*/ */
virtual void mouseMotionEvent(Modifiers modifiers, const Math::Vector2<int>& position); virtual void mouseMotionEvent(Modifiers modifiers, const Vector2i& position);
/*@}*/ /*@}*/
@ -291,7 +291,7 @@ class AbstractXApplication {
Context* c; Context* c;
/** @todo Get this from the created window */ /** @todo Get this from the created window */
Math::Vector2<GLsizei> viewportSize; Vector2i viewportSize;
Flags flags; Flags flags;
}; };
@ -328,11 +328,11 @@ CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Modifiers)
CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Flags) CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Flags)
/* Implementations for inline functions with unused parameters */ /* Implementations for inline functions with unused parameters */
inline void AbstractXApplication::keyPressEvent(Key, Modifiers, const Math::Vector2<int>&) {} inline void AbstractXApplication::keyPressEvent(Key, Modifiers, const Vector2i&) {}
inline void AbstractXApplication::keyReleaseEvent(Key, Modifiers, const Math::Vector2<int>&) {} inline void AbstractXApplication::keyReleaseEvent(Key, Modifiers, const Vector2i&) {}
inline void AbstractXApplication::mousePressEvent(MouseButton, Modifiers, const Math::Vector2<int>&) {} inline void AbstractXApplication::mousePressEvent(MouseButton, Modifiers, const Vector2i&) {}
inline void AbstractXApplication::mouseReleaseEvent(MouseButton, Modifiers, const Math::Vector2<int>&) {} inline void AbstractXApplication::mouseReleaseEvent(MouseButton, Modifiers, const Vector2i&) {}
inline void AbstractXApplication::mouseMotionEvent(Modifiers, const Math::Vector2<int>&) {} inline void AbstractXApplication::mouseMotionEvent(Modifiers, const Vector2i&) {}
}} }}

2
src/Platform/GlutApplication.cpp

@ -22,7 +22,7 @@ namespace Magnum { namespace Platform {
GlutApplication* GlutApplication::instance = nullptr; GlutApplication* GlutApplication::instance = nullptr;
GlutApplication::GlutApplication(int& argc, char** argv, const std::string& title, const Math::Vector2<GLsizei>& size) { GlutApplication::GlutApplication(int& argc, char** argv, const std::string& title, const Vector2i& size) {
/* Save global instance */ /* Save global instance */
instance = this; instance = this;

22
src/Platform/GlutApplication.h

@ -61,7 +61,7 @@ class GlutApplication {
* *
* Creates double-buffered RGBA window with depth and stencil buffers. * Creates double-buffered RGBA window with depth and stencil buffers.
*/ */
GlutApplication(int& argc, char** argv, const std::string& title = "Magnum GLUT application", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600)); GlutApplication(int& argc, char** argv, const std::string& title = "Magnum GLUT application", const Vector2i& size = Vector2i(800, 600));
virtual ~GlutApplication(); virtual ~GlutApplication();
@ -84,7 +84,7 @@ class GlutApplication {
* Framebuffer::setViewport() (and SceneGraph::AbstractCamera::setViewport(), * Framebuffer::setViewport() (and SceneGraph::AbstractCamera::setViewport(),
* if using scene graph). * if using scene graph).
*/ */
virtual void viewportEvent(const Math::Vector2<GLsizei>& size) = 0; virtual void viewportEvent(const Vector2i& size) = 0;
/** /**
* @brief Draw event * @brief Draw event
@ -157,7 +157,7 @@ class GlutApplication {
* *
* Called when an key is pressed. Default implementation does nothing. * Called when an key is pressed. Default implementation does nothing.
*/ */
virtual void keyPressEvent(Key key, const Math::Vector2<int>& position); virtual void keyPressEvent(Key key, const Vector2i& position);
/*@}*/ /*@}*/
@ -203,7 +203,7 @@ class GlutApplication {
} }
/** @brief Warp mouse cursor to given coordinates */ /** @brief Warp mouse cursor to given coordinates */
inline void warpMouseCursor(const Math::Vector2<GLsizei>& position) { inline void warpMouseCursor(const Vector2i& position) {
glutWarpPointer(position.x(), position.y()); glutWarpPointer(position.x(), position.y());
} }
@ -214,7 +214,7 @@ class GlutApplication {
* Called when mouse button is pressed. Default implementation does * Called when mouse button is pressed. Default implementation does
* nothing. * nothing.
*/ */
virtual void mousePressEvent(MouseButton button, const Math::Vector2<int>& position); virtual void mousePressEvent(MouseButton button, const Vector2i& position);
/** /**
* @brief Mouse release event * @brief Mouse release event
@ -222,7 +222,7 @@ class GlutApplication {
* Called when mouse button is released. Default implementation does * Called when mouse button is released. Default implementation does
* nothing. * nothing.
*/ */
virtual void mouseReleaseEvent(MouseButton button, const Math::Vector2<int>& position); virtual void mouseReleaseEvent(MouseButton button, const Vector2i& position);
/** /**
* @brief Mouse motion event * @brief Mouse motion event
@ -231,7 +231,7 @@ class GlutApplication {
* implementation does nothing. * implementation does nothing.
* @see setMouseTracking() * @see setMouseTracking()
*/ */
virtual void mouseMotionEvent(const Math::Vector2<int>& position); virtual void mouseMotionEvent(const Vector2i& position);
/*@}*/ /*@}*/
@ -293,10 +293,10 @@ When no other application header is included this macro is also aliased to
#endif #endif
/* Implementations for inline functions with unused parameters */ /* Implementations for inline functions with unused parameters */
inline void GlutApplication::keyPressEvent(Key, const Math::Vector2<int>&) {} inline void GlutApplication::keyPressEvent(Key, const Vector2i&) {}
inline void GlutApplication::mousePressEvent(MouseButton, const Math::Vector2<int>&) {} inline void GlutApplication::mousePressEvent(MouseButton, const Vector2i&) {}
inline void GlutApplication::mouseReleaseEvent(MouseButton, const Math::Vector2<int>&) {} inline void GlutApplication::mouseReleaseEvent(MouseButton, const Vector2i&) {}
inline void GlutApplication::mouseMotionEvent(const Math::Vector2<int>&) {} inline void GlutApplication::mouseMotionEvent(const Vector2i&) {}
}} }}

2
src/Platform/GlxApplication.h

@ -53,7 +53,7 @@ class GlxApplication: public AbstractXApplication {
* Creates window with double-buffered OpenGL 3.2 core context or * Creates window with double-buffered OpenGL 3.2 core context or
* OpenGL ES 2.0 context, if targetting OpenGL ES. * OpenGL ES 2.0 context, if targetting OpenGL ES.
*/ */
inline GlxApplication(int& argc, char** argv, const std::string& title = "Magnum GLX application", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600)): AbstractXApplication(new GlxContextHandler, argc, argv, title, size) {} inline GlxApplication(int& argc, char** argv, const std::string& title = "Magnum GLX application", const Vector2i& size = Vector2i(800, 600)): AbstractXApplication(new GlxContextHandler, argc, argv, title, size) {}
}; };
}} }}

4
src/Platform/NaClApplication.cpp

@ -23,7 +23,7 @@
namespace Magnum { namespace Platform { namespace Magnum { namespace Platform {
NaClApplication::NaClApplication(PP_Instance instance, const Math::Vector2<GLsizei>& size): Instance(instance), Graphics3DClient(this), MouseLock(this), viewportSize(size) { NaClApplication::NaClApplication(PP_Instance instance, const Vector2i& size): Instance(instance), Graphics3DClient(this), MouseLock(this), viewportSize(size) {
int32_t attributes[] = { int32_t attributes[] = {
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24, PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
@ -101,7 +101,7 @@ void NaClApplication::DidChangeView(const pp::View& view) {
else return; else return;
} }
Math::Vector2<GLsizei> size(view.GetRect().width(), view.GetRect().height()); Vector2i size(view.GetRect().width(), view.GetRect().height());
/* Canvas resized */ /* Canvas resized */
if(viewportSize != size) { if(viewportSize != size) {

20
src/Platform/NaClApplication.h

@ -72,7 +72,7 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
* *
* Creates double-buffered RGBA canvas with depth and stencil buffers. * Creates double-buffered RGBA canvas with depth and stencil buffers.
*/ */
explicit NaClApplication(PP_Instance instance, const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(640, 480)); explicit NaClApplication(PP_Instance instance, const Vector2i& size = Vector2i(640, 480));
~NaClApplication(); ~NaClApplication();
@ -94,7 +94,7 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
/** @{ @name Drawing functions */ /** @{ @name Drawing functions */
/** @copydoc GlutApplication::viewportEvent() */ /** @copydoc GlutApplication::viewportEvent() */
virtual void viewportEvent(const Math::Vector2<GLsizei>& size) = 0; virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc GlutApplication::drawEvent() */ /** @copydoc GlutApplication::drawEvent() */
virtual void drawEvent() = 0; virtual void drawEvent() = 0;
@ -205,7 +205,7 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
pp::Graphics3D* graphics; pp::Graphics3D* graphics;
pp::Fullscreen* fullscreen; pp::Fullscreen* fullscreen;
Context* c; Context* c;
Math::Vector2<GLsizei> viewportSize; Vector2i viewportSize;
Flags flags; Flags flags;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags) CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)
@ -399,13 +399,13 @@ class NaClApplication::MouseEvent: public NaClApplication::InputEvent {
inline Button button() const { return _button; } inline Button button() const { return _button; }
/** @brief Position */ /** @brief Position */
inline Math::Vector2<int> position() const { return _position; } inline Vector2i position() const { return _position; }
private: private:
inline MouseEvent(Button button, const Math::Vector2<int>& position, Modifiers modifiers): InputEvent(modifiers), _button(button), _position(position) {} inline MouseEvent(Button button, const Vector2i& position, Modifiers modifiers): InputEvent(modifiers), _button(button), _position(position) {}
const Button _button; const Button _button;
const Math::Vector2<int> _position; const Vector2i _position;
}; };
/** /**
@ -419,19 +419,19 @@ class NaClApplication::MouseMoveEvent: public NaClApplication::InputEvent {
public: public:
/** @brief Position */ /** @brief Position */
inline Math::Vector2<int> position() const { return _position; } inline Vector2i position() const { return _position; }
/** /**
* @brief Relative position * @brief Relative position
* *
* Position relative to previous event. * Position relative to previous event.
*/ */
inline Math::Vector2<int> relativePosition() const { return _relativePosition; } inline Vector2i relativePosition() const { return _relativePosition; }
private: private:
inline MouseMoveEvent(const Math::Vector2<int>& position, const Math::Vector2<int>& relativePosition, Modifiers modifiers): InputEvent(modifiers), _position(position), _relativePosition(relativePosition) {} inline MouseMoveEvent(const Vector2i& position, const Vector2i& relativePosition, Modifiers modifiers): InputEvent(modifiers), _position(position), _relativePosition(relativePosition) {}
const Math::Vector2<int> _position, _relativePosition; const Vector2i _position, _relativePosition;
}; };
CORRADE_ENUMSET_OPERATORS(NaClApplication::Flags) CORRADE_ENUMSET_OPERATORS(NaClApplication::Flags)

2
src/Platform/Sdl2Application.cpp

@ -40,7 +40,7 @@ Sdl2Application::InputEvent::Modifiers fixedModifiers(Uint16 mod) {
} }
Sdl2Application::Sdl2Application(int, char**, const std::string& name, const Math::Vector2<GLsizei>& size): _redraw(true) { Sdl2Application::Sdl2Application(int, char**, const std::string& name, const Vector2i& size): _redraw(true) {
if(SDL_Init(SDL_INIT_VIDEO) < 0) { if(SDL_Init(SDL_INIT_VIDEO) < 0) {
Error() << "Cannot initialize SDL."; Error() << "Cannot initialize SDL.";
exit(1); exit(1);

18
src/Platform/Sdl2Application.h

@ -65,7 +65,7 @@ class Sdl2Application {
* @param title Window title * @param title Window title
* @param size Window size * @param size Window size
*/ */
Sdl2Application(int argc, char** argv, const std::string& title = "Magnum SDL2 application", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600)); Sdl2Application(int argc, char** argv, const std::string& title = "Magnum SDL2 application", const Vector2i& size = Vector2i(800, 600));
/** /**
* @brief Destructor * @brief Destructor
@ -85,7 +85,7 @@ class Sdl2Application {
/** @{ @name Drawing functions */ /** @{ @name Drawing functions */
/** @copydoc GlutApplication::viewportEvent() */ /** @copydoc GlutApplication::viewportEvent() */
virtual void viewportEvent(const Math::Vector2<GLsizei>& size) = 0; virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc GlutApplication::drawEvent() */ /** @copydoc GlutApplication::drawEvent() */
virtual void drawEvent() = 0; virtual void drawEvent() = 0;
@ -351,7 +351,7 @@ class Sdl2Application::MouseEvent: public Sdl2Application::InputEvent {
inline Button button() const { return _button; } inline Button button() const { return _button; }
/** @brief Position */ /** @brief Position */
inline Math::Vector2<int> position() const { return _position; } inline Vector2i position() const { return _position; }
/** /**
* @brief Modifiers * @brief Modifiers
@ -361,10 +361,10 @@ class Sdl2Application::MouseEvent: public Sdl2Application::InputEvent {
Modifiers modifiers(); Modifiers modifiers();
private: private:
inline MouseEvent(Button button, const Math::Vector2<int>& position): _button(button), _position(position), modifiersLoaded(false) {} inline MouseEvent(Button button, const Vector2i& position): _button(button), _position(position), modifiersLoaded(false) {}
const Button _button; const Button _button;
const Math::Vector2<int> _position; const Vector2i _position;
bool modifiersLoaded; bool modifiersLoaded;
Modifiers _modifiers; Modifiers _modifiers;
}; };
@ -379,14 +379,14 @@ class Sdl2Application::MouseMoveEvent: public Sdl2Application::InputEvent {
public: public:
/** @brief Position */ /** @brief Position */
inline Math::Vector2<int> position() const { return _position; } inline Vector2i position() const { return _position; }
/** /**
* @brief Relative position * @brief Relative position
* *
* Position relative to previous event. * Position relative to previous event.
*/ */
inline Math::Vector2<int> relativePosition() const { return _relativePosition; } inline Vector2i relativePosition() const { return _relativePosition; }
/** /**
* @brief Modifiers * @brief Modifiers
@ -396,9 +396,9 @@ class Sdl2Application::MouseMoveEvent: public Sdl2Application::InputEvent {
Modifiers modifiers(); Modifiers modifiers();
private: private:
inline MouseMoveEvent(const Math::Vector2<int>& position, const Math::Vector2<int>& relativePosition): _position(position), _relativePosition(relativePosition), modifiersLoaded(false) {} inline MouseMoveEvent(const Vector2i& position, const Vector2i& relativePosition): _position(position), _relativePosition(relativePosition), modifiersLoaded(false) {}
const Math::Vector2<int> _position, _relativePosition; const Vector2i _position, _relativePosition;
bool modifiersLoaded; bool modifiersLoaded;
Modifiers _modifiers; Modifiers _modifiers;
}; };

2
src/Platform/XEglApplication.h

@ -52,7 +52,7 @@ class XEglApplication: public AbstractXApplication {
* *
* Creates window with double-buffered OpenGL ES 2 context. * Creates window with double-buffered OpenGL ES 2 context.
*/ */
inline XEglApplication(int& argc, char** argv, const std::string& title = "Magnum X/EGL application", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600)): AbstractXApplication(new EglContextHandler, argc, argv, title, size) {} inline XEglApplication(int& argc, char** argv, const std::string& title = "Magnum X/EGL application", const Vector2i& size = Vector2i(800, 600)): AbstractXApplication(new EglContextHandler, argc, argv, title, size) {}
}; };
}} }}

2
src/Renderbuffer.h

@ -230,7 +230,7 @@ class Renderbuffer {
* *
* @see bind(), @fn_gl{RenderbufferStorage} * @see bind(), @fn_gl{RenderbufferStorage}
*/ */
inline void setStorage(InternalFormat internalFormat, const Math::Vector2<GLsizei>& size) { inline void setStorage(InternalFormat internalFormat, const Vector2i& size) {
bind(); bind();
glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, size.x(), size.y()); glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, size.x(), size.y());
} }

8
src/SceneGraph/AbstractCamera.h

@ -40,7 +40,7 @@ enum class AspectRatioPolicy: std::uint8_t {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
namespace Implementation { namespace Implementation {
template<std::uint8_t dimensions, class T> typename DimensionTraits<dimensions, T>::MatrixType aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Math::Vector2<GLsizei>& viewport); template<std::uint8_t dimensions, class T> typename DimensionTraits<dimensions, T>::MatrixType aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Vector2i& viewport);
} }
#endif #endif
@ -121,7 +121,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions
} }
/** @brief Viewport size */ /** @brief Viewport size */
inline Math::Vector2<GLsizei> viewport() const { return _viewport; } inline Vector2i viewport() const { return _viewport; }
/** /**
* @brief Set viewport size * @brief Set viewport size
@ -130,7 +130,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions
* according to aspect ratio policy. * according to aspect ratio policy.
* @see setAspectRatioPolicy() * @see setAspectRatioPolicy()
*/ */
virtual void setViewport(const Math::Vector2<GLsizei>& size); virtual void setViewport(const Vector2i& size);
/** /**
* @brief Draw * @brief Draw
@ -158,7 +158,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions
typename DimensionTraits<dimensions, T>::MatrixType _projectionMatrix; typename DimensionTraits<dimensions, T>::MatrixType _projectionMatrix;
typename DimensionTraits<dimensions, T>::MatrixType _cameraMatrix; typename DimensionTraits<dimensions, T>::MatrixType _cameraMatrix;
Math::Vector2<GLsizei> _viewport; Vector2i _viewport;
}; };
template<std::uint8_t dimensions, class T> inline AbstractCamera<dimensions, T>::~AbstractCamera() {} template<std::uint8_t dimensions, class T> inline AbstractCamera<dimensions, T>::~AbstractCamera() {}

6
src/SceneGraph/Test/CameraTest.cpp

@ -47,13 +47,13 @@ CameraTest::CameraTest() {
void CameraTest::fixAspectRatio() { void CameraTest::fixAspectRatio() {
Vector2 projectionScale(0.5f, 1.0f/3.0f); Vector2 projectionScale(0.5f, 1.0f/3.0f);
Math::Vector2<GLsizei> size(400, 300); Vector2i size(400, 300);
/* Division by zero */ /* Division by zero */
Vector2 projectionScaleZeroY(0.5f, 0.0f); Vector2 projectionScaleZeroY(0.5f, 0.0f);
Vector2 projectionScaleZeroX(0.0f, 0.5f); Vector2 projectionScaleZeroX(0.0f, 0.5f);
Math::Vector2<GLsizei> sizeZeroY(400, 0); Vector2i sizeZeroY(400, 0);
Math::Vector2<GLsizei> sizeZeroX(0, 300); Vector2i sizeZeroX(0, 300);
CORRADE_COMPARE((Implementation::aspectRatioFix<3, GLfloat>(AspectRatioPolicy::Clip, projectionScaleZeroX, size)), Matrix4()); CORRADE_COMPARE((Implementation::aspectRatioFix<3, GLfloat>(AspectRatioPolicy::Clip, projectionScaleZeroX, size)), Matrix4());
CORRADE_COMPARE((Implementation::aspectRatioFix<3, GLfloat>(AspectRatioPolicy::Clip, projectionScaleZeroY, size)), Matrix4()); CORRADE_COMPARE((Implementation::aspectRatioFix<3, GLfloat>(AspectRatioPolicy::Clip, projectionScaleZeroY, size)), Matrix4());
CORRADE_COMPARE((Implementation::aspectRatioFix<3, GLfloat>(AspectRatioPolicy::Clip, projectionScale, sizeZeroY)), Matrix4()); CORRADE_COMPARE((Implementation::aspectRatioFix<3, GLfloat>(AspectRatioPolicy::Clip, projectionScale, sizeZeroY)), Matrix4());

4
src/Swizzle.h

@ -90,7 +90,7 @@ namespace Implementation {
Creates new vector from given components. Example: Creates new vector from given components. Example:
@code @code
Vector4<std::int32_t> original(-1, 2, 3, 4); Vector4i original(-1, 2, 3, 4);
auto vec = swizzle<'a', '1', '0', 'r', 'g', 'b'>(original); auto vec = swizzle<'a', '1', '0', 'r', 'g', 'b'>(original);
// vec == { 4, 1, 0, -1, 2, 3 } // vec == { 4, 1, 0, -1, 2, 3 }
@ -118,7 +118,7 @@ template<char ...components, class T> inline constexpr typename Implementation::
Creates new vector from given components. Example: Creates new vector from given components. Example:
@code @code
Vector4<std::int32_t> original(-1, 2, 3, 4); Vector4i original(-1, 2, 3, 4);
auto vec = swizzle(original, "a10rgb"); auto vec = swizzle(original, "a10rgb");
// vec == { 4, 1, 0, -1, 2, 3 } // vec == { 4, 1, 0, -1, 2, 3 }

38
src/Test/SwizzleTest.cpp

@ -23,10 +23,6 @@ CORRADE_TEST_MAIN(Magnum::Test::SwizzleTest)
namespace Magnum { namespace Test { namespace Magnum { namespace Test {
typedef Math::Vector2<int32_t> Vector2;
typedef Math::Vector3<int32_t> Vector3;
typedef Math::Vector4<int32_t> Vector4;
SwizzleTest::SwizzleTest() { SwizzleTest::SwizzleTest() {
addTests(&SwizzleTest::xyzw, addTests(&SwizzleTest::xyzw,
&SwizzleTest::rgba, &SwizzleTest::rgba,
@ -37,42 +33,42 @@ SwizzleTest::SwizzleTest() {
} }
void SwizzleTest::xyzw() { void SwizzleTest::xyzw() {
Vector4 orig(2, 4, 5, 7); Vector4i orig(2, 4, 5, 7);
Vector4 swizzled(5, 2, 7, 4); Vector4i swizzled(5, 2, 7, 4);
CORRADE_COMPARE(swizzle(orig, "zxwy"), swizzled); CORRADE_COMPARE(swizzle(orig, "zxwy"), swizzled);
CORRADE_COMPARE((swizzle<'z', 'x', 'w', 'y'>(orig)), swizzled); CORRADE_COMPARE((swizzle<'z', 'x', 'w', 'y'>(orig)), swizzled);
} }
void SwizzleTest::rgba() { void SwizzleTest::rgba() {
Vector4 orig(2, 4, 5, 7); Vector4i orig(2, 4, 5, 7);
Vector4 swizzled(5, 2, 7, 4); Vector4i swizzled(5, 2, 7, 4);
CORRADE_COMPARE(swizzle(orig, "brag"), swizzled); CORRADE_COMPARE(swizzle(orig, "brag"), swizzled);
CORRADE_COMPARE((swizzle<'b', 'r', 'a', 'g'>(orig)), swizzled); CORRADE_COMPARE((swizzle<'b', 'r', 'a', 'g'>(orig)), swizzled);
} }
void SwizzleTest::constants() { void SwizzleTest::constants() {
Vector4 orig(2, 4, 5, 7); Vector4i orig(2, 4, 5, 7);
Vector4 swizzled(1, 7, 0, 4); Vector4i swizzled(1, 7, 0, 4);
CORRADE_COMPARE(swizzle(orig, "1w0g"), swizzled); CORRADE_COMPARE(swizzle(orig, "1w0g"), swizzled);
CORRADE_COMPARE((swizzle<'1', 'w', '0', 'g'>(orig)), swizzled); CORRADE_COMPARE((swizzle<'1', 'w', '0', 'g'>(orig)), swizzled);
} }
void SwizzleTest::fromSmall() { void SwizzleTest::fromSmall() {
/* Force compile-time evaluation for both */ /* Force compile-time evaluation for both */
constexpr Vector2 orig(1, 2); constexpr Vector2i orig(1, 2);
constexpr Vector3 swizzled(swizzle(orig, "gxr")); constexpr Vector3i swizzled(swizzle(orig, "gxr"));
CORRADE_VERIFY((integral_constant<bool, swizzled.x() == 2>::value)); CORRADE_VERIFY((integral_constant<bool, swizzled.x() == 2>::value));
CORRADE_COMPARE((swizzle<'g', 'x', 'r'>(orig)), Vector3(2, 1, 1)); CORRADE_COMPARE((swizzle<'g', 'x', 'r'>(orig)), Vector3i(2, 1, 1));
} }
void SwizzleTest::type() { void SwizzleTest::type() {
Vector4 orig; Vector4i orig;
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a'>(orig)), Vector2>::value)); CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a'>(orig)), Vector2i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(orig, "ya")), Vector2>::value)); CORRADE_VERIFY((is_same<decltype(swizzle(orig, "ya")), Vector2i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'z', 'a'>(orig)), Vector3>::value)); CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'z', 'a'>(orig)), Vector3i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(orig, "yza")), Vector3>::value)); CORRADE_VERIFY((is_same<decltype(swizzle(orig, "yza")), Vector3i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a', 'y', 'x'>(orig)), Vector4>::value)); CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a', 'y', 'x'>(orig)), Vector4i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(orig, "yayx")), Vector4>::value)); CORRADE_VERIFY((is_same<decltype(swizzle(orig, "yayx")), Vector4i>::value));
Color3<float> origColor3; Color3<float> origColor3;
Color4<double> origColor4; Color4<double> origColor4;
@ -87,7 +83,7 @@ void SwizzleTest::type() {
} }
void SwizzleTest::defaultType() { void SwizzleTest::defaultType() {
Vector4 orig(1, 2, 3, 4); Vector4i orig(1, 2, 3, 4);
CORRADE_COMPARE(swizzle<'b'>(orig), (Math::Vector<1, int32_t>(3))); CORRADE_COMPARE(swizzle<'b'>(orig), (Math::Vector<1, int32_t>(3)));
CORRADE_COMPARE(swizzle(orig, "b"), (Math::Vector<1, int32_t>(3))); CORRADE_COMPARE(swizzle(orig, "b"), (Math::Vector<1, int32_t>(3)));
CORRADE_COMPARE((swizzle<'b', 'r', 'a', 'g', 'z', 'y', 'x'>(orig)), (Math::Vector<7, int32_t>(3, 1, 4, 2, 3, 2, 1))); CORRADE_COMPARE((swizzle<'b', 'r', 'a', 'g', 'z', 'y', 'x'>(orig)), (Math::Vector<7, int32_t>(3, 1, 4, 2, 3, 2, 1)));

Loading…
Cancel
Save