Browse Source

Removed TypeTraits::imageType() and related function in *Image* classes.

It is now ambiguous whether data passed as `std::int8_t` are of
Type::Byte, Type::ByteInteger or whatnot. The user now must explicitly
specify both format and type.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
ac90cd8a45
  1. 18
      src/BufferedImage.h
  2. 27
      src/Image.h
  3. 14
      src/ImageWrapper.h
  4. 14
      src/Trade/ImageData.h
  5. 29
      src/TypeTraits.h

18
src/BufferedImage.h

@ -25,7 +25,6 @@
#include "AbstractImage.h"
#include "Buffer.h"
#include "DimensionTraits.h"
#include "TypeTraits.h"
namespace Magnum {
@ -74,23 +73,6 @@ template<std::uint8_t dimensions> class MAGNUM_EXPORT BufferedImage: public Abst
/** @brief %Image buffer */
inline Buffer* buffer() { return &_buffer; }
/**
* @brief Set image data
* @param size %Image size
* @param format Format of pixel data. Data type is
* detected from passed data array.
* @param data %Image data
* @param usage %Image buffer usage
*
* Updates the image buffer with given data. The data are not deleted
* after filling the buffer.
*
* @see setData(const Math::Vector<Dimensions, GLsizei>&, Format, Type, const GLvoid*, Buffer::Usage)
*/
template<class T> inline void setData(const typename DimensionTraits<Dimensions, GLsizei>::VectorType& size, Format format, const T* data, Buffer::Usage usage) {
setData(size, format, TypeTraits<T>::imageType(), data, usage);
}
/**
* @brief Set image data
* @param size %Image size

27
src/Image.h

@ -22,7 +22,6 @@
#include "Math/Vector3.h"
#include "AbstractImage.h"
#include "DimensionTraits.h"
#include "TypeTraits.h"
namespace Magnum {
@ -37,18 +36,6 @@ template<std::uint8_t dimensions> class Image: public AbstractImage {
public:
const static std::uint8_t Dimensions = dimensions; /**< @brief %Image dimension count */
/**
* @brief Constructor
* @param size %Image size
* @param format Format of pixel data. Data type is
* detected from passed data array.
* @param data %Image data with proper size
*
* Note that the image data are not copied on construction, but they
* are deleted on class destruction.
*/
template<class T> inline Image(const typename DimensionTraits<Dimensions, GLsizei>::VectorType& size, Format format, T* data): AbstractImage(format, TypeTraits<T>::imageType()), _size(size), _data(data) {}
/**
* @brief Constructor
* @param size %Image size
@ -81,20 +68,6 @@ template<std::uint8_t dimensions> class Image: public AbstractImage {
inline void* data() { return _data; }
inline const void* data() const { return _data; } /**< @overload */
/**
* @brief Set image data
* @param size %Image size
* @param format Format of pixel data. Data type is
* detected from passed data array.
* @param data %Image data
*
* Deletes previous data and replaces them with new. Note that the
* data are not copied, but they are deleted on destruction.
*/
template<class T> inline void setData(const typename DimensionTraits<Dimensions, GLsizei>::VectorType& size, Format format, T* data) {
setData(size, format, TypeTraits<T>::imageType(), data);
}
/**
* @brief Set image data
* @param size %Image size

14
src/ImageWrapper.h

@ -22,7 +22,6 @@
#include "Math/Vector3.h"
#include "AbstractImage.h"
#include "DimensionTraits.h"
#include "TypeTraits.h"
namespace Magnum {
@ -44,19 +43,6 @@ Interchangeable with Image, BufferedImage or Trade::ImageData.
template<std::uint8_t dimensions> class ImageWrapper: public AbstractImage {
public:
const static std::uint8_t Dimensions = dimensions; /**< @brief %Image dimension count */
/**
* @brief Constructor
* @param size %Image size
* @param format Format of pixel data. Data type is
* detected from passed data array.
* @param data %Image data with proper size
*
* Note that the image data are not copied on construction, but they
* are deleted on class destruction.
*/
template<class T> inline ImageWrapper(const typename DimensionTraits<Dimensions, GLsizei>::VectorType& size, Format format, T* data): AbstractImage(format, TypeTraits<T>::imageType()), _size(size), _data(data) {}
/**
* @brief Constructor
* @param size %Image size

14
src/Trade/ImageData.h

@ -22,7 +22,6 @@
#include "Math/Vector3.h"
#include "AbstractImage.h"
#include "DimensionTraits.h"
#include "TypeTraits.h"
namespace Magnum { namespace Trade {
@ -37,19 +36,6 @@ template<std::uint8_t dimensions> class ImageData: public AbstractImage {
public:
const static std::uint8_t Dimensions = dimensions; /**< @brief %Image dimension count */
/**
* @brief Constructor
* @param name %Image name
* @param size %Image size
* @param format Format of pixel data. Data type is
* detected from passed data array.
* @param data %Image data
*
* Note that the image data are not copied on construction, but they
* are deleted on class destruction.
*/
template<class T> inline ImageData(const std::string& name, const typename DimensionTraits<Dimensions, GLsizei>::VectorType& size, Format format, T* data): AbstractImage(format, TypeTraits<T>::imageType()), _name(name), _size(size), _data(reinterpret_cast<char*>(data)) {}
/**
* @brief Constructor
* @param name %Image name

29
src/TypeTraits.h

@ -22,7 +22,9 @@
#include <Utility/ConfigurationValue.h>
#include "Math/MathTypeTraits.h"
#include "AbstractImage.h"
#include "Magnum.h"
#include "magnumVisibility.h"
namespace Magnum {
@ -68,15 +70,6 @@ template<class T> struct TypeTraits: Math::MathTypeTraits<T> {
*/
inline constexpr static Type indexType();
/**
* @brief OpenGL type ID for pixel data
*
* Implemented only in types which can be used for image data, like
* GLubyte. This function is not present for types unusable for image data,
* like GLdouble and Matrix3.
*/
inline constexpr static AbstractImage::Type imageType();
/**
* @brief Size of plain OpenGL type
*
@ -182,7 +175,6 @@ template<> struct TypeTraits<GLubyte>: Math::MathTypeTraits<std::uint8_t> {
/* Can not be used for attributes */
inline constexpr static Type type() { return Type::UnsignedByte; }
inline constexpr static Type indexType() { return Type::UnsignedByte; }
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::UnsignedByte; }
inline constexpr static std::size_t size() { return sizeof(GLubyte); }
inline constexpr static std::size_t count() { return 1; }
};
@ -191,9 +183,6 @@ template<> struct TypeTraits<GLbyte>: Math::MathTypeTraits<std::int8_t> {
/* Can not be used for attributes */
inline constexpr static Type type() { return Type::Byte; }
/* Can not be used for indices */
#ifndef MAGNUM_TARGET_GLES2
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Byte; }
#endif
inline constexpr static std::size_t size() { return sizeof(GLbyte); }
inline constexpr static std::size_t count() { return 1; }
};
@ -202,7 +191,6 @@ template<> struct TypeTraits<GLushort>: Math::MathTypeTraits<std::uint16_t> {
/* Can not be used for attributes */
inline constexpr static Type type() { return Type::UnsignedShort; }
inline constexpr static Type indexType() { return Type::UnsignedShort; }
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::UnsignedShort; }
inline constexpr static std::size_t size() { return sizeof(GLushort); }
inline constexpr static std::size_t count() { return 1; }
};
@ -211,9 +199,6 @@ template<> struct TypeTraits<GLshort>: Math::MathTypeTraits<std::int16_t> {
/* Can not be used for attributes */
inline constexpr static Type type() { return Type::Short; }
/* Can not be used for indices */
#ifndef MAGNUM_TARGET_GLES2
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Short; }
#endif
inline constexpr static std::size_t size() { return sizeof(GLshort); }
inline constexpr static std::size_t count() { return 1; }
};
@ -222,7 +207,6 @@ template<> struct TypeTraits<GLuint>: Math::MathTypeTraits<std::uint32_t> {
typedef GLuint AttributeType;
inline constexpr static Type type() { return Type::UnsignedInt; }
inline constexpr static Type indexType() { return Type::UnsignedInt; }
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::UnsignedInt; }
inline constexpr static std::size_t size() { return sizeof(GLuint); }
inline constexpr static std::size_t count() { return 1; }
};
@ -231,9 +215,6 @@ template<> struct TypeTraits<GLint>: Math::MathTypeTraits<std::int32_t> {
typedef GLint AttributeType;
inline constexpr static Type type() { return Type::Int; }
/* Can not be used for indices */
#ifndef MAGNUM_TARGET_GLES2
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Int; }
#endif
inline constexpr static std::size_t size() { return sizeof(GLint); }
inline constexpr static std::size_t count() { return 1; }
};
@ -242,7 +223,6 @@ template<> struct TypeTraits<GLfloat>: Math::MathTypeTraits<float> {
typedef GLfloat AttributeType;
inline constexpr static Type type() { return Type::Float; }
/* Can not be used for indices */
inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Float; }
inline constexpr static std::size_t size() { return sizeof(GLfloat); }
inline constexpr static std::size_t count() { return 1; }
};
@ -252,7 +232,6 @@ template<> struct TypeTraits<GLdouble>: Math::MathTypeTraits<double> {
typedef GLdouble AttributeType;
inline constexpr static Type type() { return Type::Double; }
/* Can not be used for indices */
/* Can not be used for images */
inline constexpr static std::size_t size() { return sizeof(GLdouble); }
inline constexpr static std::size_t count() { return 1; }
};
@ -264,7 +243,6 @@ namespace Implementation {
inline constexpr static Type type() { return TypeTraits<T>::type(); }
/* Might be used for attributes, see below */
/* Can not be used for indices */
/* Can not be used for images */
inline constexpr static std::size_t size() { return sizeof(T); }
inline constexpr static std::size_t count() { return vectorSize; }
};
@ -311,7 +289,6 @@ namespace Implementation {
inline constexpr static Type type() { return TypeTraits<T>::type(); }
/* Might be used for attributes, see below */
/* Can not be used for indices */
/* Can not be used for images */
inline constexpr static std::size_t size() { return sizeof(T); }
inline constexpr static std::size_t count() { return rows; }
inline constexpr static std::size_t vectors() { return cols; }

Loading…
Cancel
Save