Commit 9e90c81e authored by Robert Menzel's avatar Robert Menzel

Merge branch 'master' of...

Merge branch 'master' of ssh://beatrix.informatik.rwth-aachen.de/data/git-repository/acgl/libraries/acgl
parents 8fd50ec7 a579773f
cmake @ 801556b2
Subproject commit 2ab8ddba5b6c77730193e734bfb63cc45ac93e77
Subproject commit 801556b2e0dee07c9661b35d9187cfe5dc3f7267
......@@ -18,6 +18,7 @@
#include <cmath>
#include <limits>
#include <algorithm>
namespace ACGL{
namespace Math{
......
......@@ -20,8 +20,8 @@ enum ColorSpace
COLOR_SPACE_SRGB
};
/// Converts an OpenGL color format to an equivalent format of the given color space. If there is no matching format, the format is returned unchanged.
GLenum formatToColorSpace(GLenum _inputFormat, ColorSpace _colorSpace);
//! Recommends an OpenGL internal format for a given pair of format and color spaces
GLenum recommendedInternalFormat(GLenum _format, ColorSpace _colorSpace);
} // OpenGL
} // ACGL
......
......@@ -16,6 +16,7 @@
#include <ACGL/OpenGL/Data/GeometryData.hh>
#include <string>
#include <algorithm>
namespace ACGL{
namespace OpenGL{
......
......@@ -16,6 +16,7 @@
#include <ACGL/Base/Macros.hh>
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Data/ColorSpace.hh>
#include <ACGL/OpenGL/Tools.hh>
#include <ACGL/Math/Math.hh>
......@@ -29,51 +30,59 @@ class TextureData
// ========================================================================================================= \/
public:
TextureData(void)
: pData(NULL),
width(0),
height(0),
depth(0),
format(GL_RGBA),
: mData(NULL),
mWidth(0),
mHeight(0),
mDepth(0),
mFormat(GL_RGBA),
mType(GL_UNSIGNED_BYTE),
paddingBytesPerRow(0)
mPaddingBytesPerRow(0),
mColorSpace(COLOR_SPACE_AUTO_DETECT)
{}
virtual ~TextureData(void)
{
delete[] pData;
delete[] mData;
}
// ========================================================================================================= \/
// ================================================================================================= GETTERS \/
// ========================================================================================================= \/
public:
GLubyte* getData (void) const { return pData; }
//! pointer to the raw pixel data
GLubyte* getData() const { return mData; }
//! width in pixel
GLsizei getWidth (void) const { return width; }
//! width in pixels
GLsizei getWidth() const { return mWidth; }
//! height in pixel
GLsizei getHeight (void) const { return height; }
//! height in pixels
GLsizei getHeight() const { return mHeight; }
//! depth in pixel
GLsizei getDepth (void) const { return depth; }
//! depth in pixels
GLsizei getDepth() const { return mDepth; }
//! channels etc. e.g. GL_RGB
GLenum getFormat (void) const { return format; }
//! channels etc. (e.g. GL_RGB)
GLenum getFormat() const { return mFormat; }
//! data type (e.g. GL_BYTE)
GLenum getType (void) const { return mType; }
GLenum getType() const { return mType; }
//! each line can have a few bytes of padding, number of bytes is returned
GLsizei getPadding (void) const { return paddingBytesPerRow; }
GLsizei getPadding() const { return mPaddingBytesPerRow; }
//! the color space in which the data is represented
ColorSpace getColorSpace() const { return mColorSpace; }
//! in bytes
glm::uvec3 getSize (void) const { return glm::uvec3( width, height, depth ); }
glm::uvec3 getSize() const { return glm::uvec3( mWidth, mHeight, mDepth ); }
//! the byte alignment of each pixel row, e.g. 1,2,4,8 (bytes)
//! the byte alignment of each pixel row, (e.g. 1, 2, 4, 8 bytes)
GLsizei getPackAlignment()const;
//! 1,2,3 or 4 based on format
GLsizei getNumberOfChannels() const;
//! 1, 2, 3 or 4 based on format
GLsizei getNumberOfChannels() const;
//! A recommended value for the internalFormat enum of a Texture object. Based on the format, type and color space
GLenum getRecommendedInternalFormat() const;
//! flips the image vertically as some image formats have a different coordinate system as OpenGL has. (flip it upside down)
void flipVertically();
......@@ -91,32 +100,35 @@ public:
// ================================================================================================= SETTERS \/
// ========================================================================================================= \/
public:
//! _pData has to be created by new GLubyte[...] and will get deleted by this TextureData object!
void setData (GLubyte* _pData) { pData = _pData; }
void setWidth (GLsizei _width) { width = _width; }
void setHeight(GLsizei _height) { height = _height; }
void setDepth (GLsizei _depth) { depth = _depth; }
void setFormat(GLenum _format) { format = _format; }
void setType (GLenum _type) { mType = _type; }
void setPadding(GLsizei _padding){ paddingBytesPerRow = _padding; }
void setSize (const glm::uvec3 &_size) { width = _size.x; height = _size.y; depth = _size.z; }
//! mData has to be created by new GLubyte[...] and will get deleted by this TextureData object!
void setData (GLubyte* _data) { mData = _data; }
void setWidth (GLsizei _width) { mWidth = _width; }
void setHeight (GLsizei _height) { mHeight = _height; }
void setDepth (GLsizei _depth) { mDepth = _depth; }
void setFormat (GLenum _format) { mFormat = _format; }
void setType (GLenum _type) { mType = _type; }
void setPadding (GLsizei _padding) { mPaddingBytesPerRow = _padding; }
void setColorSpace(ColorSpace _colorSpace) { mColorSpace = _colorSpace; }
void setSize (const glm::uvec3& _size) { mWidth = _size.x; mHeight = _size.y; mDepth = _size.z; }
//! deletes the data attached to this object
void deleteData() { delete[] pData; pData = NULL; }
void deleteData() { delete[] mData; mData = NULL; }
private:
size_t getBytesPerScanline() const;
// ========================================================================================================= \/
// ================================================================================================== FIELDS \/
// ========================================================================================================= \/
private:
size_t getBytesPerScanline() const;
GLubyte* pData;
GLsizei width;
GLsizei height;
GLsizei depth;
GLenum format; // channel types and count
GLenum mType; // data type
GLsizei paddingBytesPerRow; // number of padding bytes added per row: glReadPixel can read with padding and
// some image writers support/need this as well (e.g. QT)
GLubyte* mData;
GLsizei mWidth;
GLsizei mHeight;
GLsizei mDepth;
GLenum mFormat; // channel types and count
GLenum mType; // data type
GLsizei mPaddingBytesPerRow; // number of padding bytes added per row: glReadPixel can read with padding and
// some image writers support/need this as well (e.g. QT)
ColorSpace mColorSpace;
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureData)
......
......@@ -29,7 +29,7 @@ namespace OpenGL{
///////////////////////////////////////////////////////////////////////////////////////////////////
//! functionpointer which can be used for generic Texture loading
typedef SharedTextureData (*TextureLoadFuncPtr)(const std::string&);
typedef SharedTextureData (*TextureLoadFuncPtr)(const std::string&, ColorSpace);
//! registers a functionpointer to be used for loading specified file types (E.G. provide a load function which loads compressed)
void registerTextureLoadFunction(std::vector<std::string> _endings, TextureLoadFuncPtr _function);
......@@ -38,7 +38,7 @@ void registerTextureLoadFunction(std::vector<std::string> _endings, TextureLoadF
void unregisterTextureLoadFunction(TextureLoadFuncPtr _function);
//! generic load function that will use one of the loading functions below based on the file ending
SharedTextureData loadTextureData(const std::string &_filename);
SharedTextureData loadTextureData(const std::string &_filename, ColorSpace _colorSpace = COLOR_SPACE_AUTO_DETECT);
//! generic save function that will use one of the saving functions below based on the file ending
bool saveTextureData(const SharedTextureData &_textureData, const std::string &_filename);
......@@ -59,21 +59,21 @@ inline bool saveScreenshotWithDate( const std::string& _fileEnding = "png" ) {
///////////////////////////////////////////////////////////////////////////////////////////////////
//! loads from a PNG using the simple lodepng library
SharedTextureData loadTextureDataFromLodepng(const std::string &_filename);
SharedTextureData loadTextureDataFromLodepng(const std::string& _filename, ColorSpace _colorSpace = COLOR_SPACE_AUTO_DETECT);
#ifdef ACGL_COMPILE_WITH_QT
//! loads various formats from the QT library
SharedTextureData loadTextureDataFromQT(const std::string &_filename);
SharedTextureData loadTextureDataFromQT(const std::string& _filename, ColorSpace _colorSpace = COLOR_SPACE_AUTO_DETECT);
#endif
//! loads RGBE aka Radiance files
SharedTextureData loadTextureDataFromRGBE(const std::string &_filename);
SharedTextureData loadTextureDataFromRGBE(const std::string& _filename, ColorSpace _colorSpace = COLOR_SPACE_AUTO_DETECT);
//! loads EXR / OpenEXR files iff the library is present AT RUNTIME (linux only)
SharedTextureData loadTextureDataFromEXR(const std::string &_filename);
SharedTextureData loadTextureDataFromEXR(const std::string& _filename, ColorSpace _colorSpace = COLOR_SPACE_AUTO_DETECT);
//! loads PNM / PPM files:
SharedTextureData loadTextureDataFromPNM(const std::string &_filename);
SharedTextureData loadTextureDataFromPNM(const std::string& _filename, ColorSpace _colorSpace = COLOR_SPACE_AUTO_DETECT);
///////////////////////////////////////////////////////////////////////////////////////////////////
// library specific save
......
......@@ -26,7 +26,7 @@ const char *debugSeverityName( GLenum _type );
void ACGLRegisterDefaultDebugCallback();
//! default debug callback
void ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const GLchar *_message, const void *_userParam);
void APIENTRY ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const GLchar *_message, const void *_userParam);
} // OpenGL
} // ACGL
......
......@@ -57,6 +57,7 @@
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh>
#include <algorithm>
#include <string>
#include <vector>
......
......@@ -312,6 +312,12 @@ public:
glMultiDrawElements( mMode, count, type, indices, primcount );
}
inline void drawRangeElements( GLuint start,
GLsizei count )
{
glDrawRangeElements( mMode, start, getIndexCount(), count, getIndexType(), nullptr);
}
#if (ACGL_OPENGL_VERSION >= 32)
inline void multiDrawElements( GLsizei *count, GLenum type, GLvoid **indices, GLsizei primcount, GLint *basevertex ) const
{
......
......@@ -48,6 +48,9 @@ namespace StringHelpers
//! strips a string of all leading and trailing characters out of a given list (but leaves the ones in between)
std::string stripOfCharacters( const std::string &_string, const std::string &_charsToStrip );
//! converts an int to a string but adds leading zeros (e.g. _maxPadding = 2, 1 -> 01)
std::string intToString( const int _number, const int _maxPadding = 0 );
//! Convert a primitive type to a string (e.g. string s = toString(1.5f)), also supports some GLM types (but not complete)
template<class T>
std::string toString(const T& _t);
......
The MIT License
Copyright (c) 2005 - 2012 G-Truc Creation
Copyright (c) 2005 - 2013 G-Truc Creation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
......@@ -445,7 +445,14 @@ namespace detail
# define GLM_RESTRICT __declspec(restrict)
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31))
#elif(GLM_COMPILER & GLM_COMPILER_INTEL)
# define GLM_DEPRECATED
# define GLM_ALIGN(x) __declspec(align(x))
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
# define GLM_DEPRECATED __attribute__((__deprecated__))
# define GLM_ALIGN(x) __attribute__((aligned(x)))
# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
......
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
......
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
......
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
......
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
......
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
......@@ -36,7 +36,7 @@ namespace detail
template <typename genFIType>
struct Abs_<genFIType, true>
{
static genFIType get(genFIType const & x)
GLM_FUNC_QUALIFIER static genFIType get(genFIType const & x)
{
GLM_STATIC_ASSERT(
detail::type<genFIType>::is_float ||
......@@ -49,7 +49,7 @@ namespace detail
template <typename genFIType>
struct Abs_<genFIType, false>
{
static genFIType get(genFIType const & x)
GLM_FUNC_QUALIFIER static genFIType get(genFIType const & x)
{
GLM_STATIC_ASSERT(
detail::type<genFIType>::is_uint, "'abs' only accept floating-point and integer inputs");
......@@ -275,7 +275,7 @@ namespace detail
//// Only valid if (INT_MIN <= x-y <= INT_MAX)
//// min(x,y)
//r = y + ((x - y) & ((x - y) >> (sizeof(int) *
//CHAR_BIT 1)));
//CHAR_BIT - 1)));
//// max(x,y)
//r = x - ((x - y) & ((x - y) >> (sizeof(int) *
//CHAR_BIT - 1)));
......@@ -420,93 +420,87 @@ namespace detail
}
// mix
template <typename genTypeT, typename genTypeU>
GLM_FUNC_QUALIFIER genTypeT mix
template <typename genType>
GLM_FUNC_QUALIFIER genType mix
(
genTypeT const & x,
genTypeT const & y,
genTypeU const & a
genType const & x,
genType const & y,
genType const & a
)
{
// It could be a vector too
//GLM_STATIC_ASSERT(
// detail::type<genTypeT>::is_float &&
// detail::type<genTypeU>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float , "'genType' is not floating-point type");
//return x + a * (y - x);
return genTypeT(genTypeU(x) + a * genTypeU(y - x));
return x + a * (y - x);
}
template <typename valTypeA, typename valTypeB>
GLM_FUNC_QUALIFIER detail::tvec2<valTypeA> mix
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> mix
(
detail::tvec2<valTypeA> const & x,
detail::tvec2<valTypeA> const & y,
valTypeB const & a
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
valType const & a
)
{
return detail::tvec2<valTypeA>(
detail::tvec2<valTypeB>(x) + a * detail::tvec2<valTypeB>(y - x));
GLM_STATIC_ASSERT(detail::type<valType>::is_float , "'genType' is not floating-point type");
return x + a * (y - x);
}
template <typename valTypeA, typename valTypeB>
GLM_FUNC_QUALIFIER detail::tvec3<valTypeA> mix
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> mix
(
detail::tvec3<valTypeA> const & x,
detail::tvec3<valTypeA> const & y,
valTypeB const & a
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
valType const & a
)
{
return detail::tvec3<valTypeA>(
detail::tvec3<valTypeB>(x) + a * detail::tvec3<valTypeB>(y - x));
return x + a * (y - x);
}
template <typename valTypeA, typename valTypeB>
GLM_FUNC_QUALIFIER detail::tvec4<valTypeA> mix
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> mix
(
detail::tvec4<valTypeA> const & x,
detail::tvec4<valTypeA> const & y,
valTypeB const & a
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
valType const & a
)
{
return detail::tvec4<valTypeA>(
detail::tvec4<valTypeB>(x) + a * detail::tvec4<valTypeB>(y - x));
return x + a * (y - x);
}
template <typename valTypeA, typename valTypeB>
GLM_FUNC_QUALIFIER detail::tvec2<valTypeA> mix
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> mix
(
detail::tvec2<valTypeA> const & x,
detail::tvec2<valTypeA> const & y,
detail::tvec2<valTypeB> const & a
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
detail::tvec2<valType> const & a
)
{
return detail::tvec2<valTypeA>(
detail::tvec2<valTypeB>(x) + a * detail::tvec2<valTypeB>(y - x));
return x + a * (y - x);
}
template <typename valTypeA, typename valTypeB>
GLM_FUNC_QUALIFIER detail::tvec3<valTypeA> mix
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> mix
(
detail::tvec3<valTypeA> const & x,
detail::tvec3<valTypeA> const & y,
detail::tvec3<valTypeB> const & a
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
detail::tvec3<valType> const & a
)
{
return detail::tvec3<valTypeA>(
detail::tvec3<valTypeB>(x) + a * detail::tvec3<valTypeB>(y - x));
GLM_STATIC_ASSERT(detail::type<valType>::is_float , "'genType' is not floating-point type");
return x + a * (y - x);
}
template <typename valTypeA, typename valTypeB>
GLM_FUNC_QUALIFIER detail::tvec4<valTypeA> mix
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> mix
(
detail::tvec4<valTypeA> const & x,
detail::tvec4<valTypeA> const & y,
detail::tvec4<valTypeB> const & a
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
detail::tvec4<valType> const & a
)
{
return detail::tvec4<valTypeA>(
detail::tvec4<valTypeB>(x) + a * detail::tvec4<valTypeB>(y - x));
return x + a * (y - x);
}
//template <typename genTypeT>
......@@ -525,15 +519,63 @@ namespace detail
// return x + a * (y - x);
//}
template <typename genType>
GLM_FUNC_QUALIFIER genType mix
template <>
GLM_FUNC_QUALIFIER float mix
(
genType const & x,
genType const & y,
float const & x,
float const & y,
bool const & a
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
return a ? y : x;
}