Added GLI for GLM tests
This commit is contained in:
27
test/external/gli/gtx/compression.hpp
vendored
Normal file
27
test/external/gli/gtx/compression.hpp
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/compression.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_COMPRESSION_INCLUDED
|
||||
#define GLI_GTX_COMPRESSION_INCLUDED
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace compression
|
||||
{
|
||||
|
||||
|
||||
}//namespace compression
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::compression;}
|
||||
|
||||
#include "compression.inl"
|
||||
|
||||
#endif//GLI_GTX_COMPRESSION_INCLUDED
|
||||
8
test/external/gli/gtx/compression.inl
vendored
Normal file
8
test/external/gli/gtx/compression.inl
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/compression.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
46
test/external/gli/gtx/fetch.hpp
vendored
Normal file
46
test/external/gli/gtx/fetch.hpp
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/fetch.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_FETCH_INCLUDED
|
||||
#define GLI_GTX_FETCH_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace fetch
|
||||
{
|
||||
template <typename genType>
|
||||
genType texelFetch(
|
||||
texture2D const & Texture,
|
||||
texture2D::dimensions_type const & Texcoord,
|
||||
texture2D::level_type const & Level);
|
||||
|
||||
template <typename genType>
|
||||
genType textureLod(
|
||||
texture2D const & Texture,
|
||||
texture2D::texcoord_type const & Texcoord,
|
||||
texture2D::level_type const & Level);
|
||||
|
||||
template <typename genType>
|
||||
void texelWrite(
|
||||
texture2D & Texture,
|
||||
texture2D::dimensions_type const & Texcoord,
|
||||
texture2D::level_type const & Level,
|
||||
genType const & Color);
|
||||
|
||||
}//namespace fetch
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::fetch;}
|
||||
|
||||
#include "fetch.inl"
|
||||
|
||||
#endif//GLI_GTX_FETCH_INCLUDED
|
||||
91
test/external/gli/gtx/fetch.inl
vendored
Normal file
91
test/external/gli/gtx/fetch.inl
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/fetch.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace fetch
|
||||
{
|
||||
template <typename genType>
|
||||
inline genType texelFetch
|
||||
(
|
||||
texture2D const & Image,
|
||||
texture2D::dimensions_type const & TexCoord,
|
||||
texture2D::level_type const & Level
|
||||
)
|
||||
{
|
||||
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
|
||||
|
||||
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
|
||||
texture2D::value_type const * const Data = Image[Level].data();
|
||||
|
||||
return reinterpret_cast<genType const * const>(Data)[TexCoord.x + TexCoord.y * Dimensions.x];
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline genType textureLod
|
||||
(
|
||||
texture2D const & Image,
|
||||
texture2D::texcoord_type const & TexCoord,
|
||||
texture2D::level_type const & Level
|
||||
)
|
||||
{
|
||||
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
|
||||
|
||||
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
|
||||
texture2D::value_type const * const Data = Image[Level].data();
|
||||
|
||||
std::size_t s_below = std::size_t(glm::floor(TexCoord.s * float(Dimensions.x - 1)));
|
||||
std::size_t s_above = std::size_t(glm::ceil( TexCoord.s * float(Dimensions.x - 1)));
|
||||
std::size_t t_below = std::size_t(glm::floor(TexCoord.t * float(Dimensions.y - 1)));
|
||||
std::size_t t_above = std::size_t(glm::ceil( TexCoord.t * float(Dimensions.y - 1)));
|
||||
|
||||
float s_step = 1.0f / float(Dimensions.x);
|
||||
float t_step = 1.0f / float(Dimensions.y);
|
||||
|
||||
float s_below_normalized = s_below / float(Dimensions.x);
|
||||
float s_above_normalized = s_above / float(Dimensions.x);
|
||||
float t_below_normalized = t_below / float(Dimensions.y);
|
||||
float t_above_normalized = t_above / float(Dimensions.y);
|
||||
|
||||
genType Value1 = reinterpret_cast<genType const * const>(Data)[s_below + t_below * Dimensions.x];
|
||||
genType Value2 = reinterpret_cast<genType const * const>(Data)[s_above + t_below * Dimensions.x];
|
||||
genType Value3 = reinterpret_cast<genType const * const>(Data)[s_above + t_above * Dimensions.x];
|
||||
genType Value4 = reinterpret_cast<genType const * const>(Data)[s_below + t_above * Dimensions.x];
|
||||
|
||||
float BlendA = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
|
||||
float BlendB = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
|
||||
float BlendC = float(TexCoord.t - t_below_normalized) * float(Dimensions.y - 1);
|
||||
|
||||
genType ValueA(glm::mix(Value1, Value2, BlendA));
|
||||
genType ValueB(glm::mix(Value4, Value3, BlendB));
|
||||
|
||||
return genType(glm::mix(ValueA, ValueB, BlendC));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
void texelWrite
|
||||
(
|
||||
texture2D & Image,
|
||||
texture2D::dimensions_type const & Texcoord,
|
||||
texture2D::level_type const & Level,
|
||||
genType const & Color
|
||||
)
|
||||
{
|
||||
genType * Data = (genType*)Image[Level].data();
|
||||
std::size_t Index = Texcoord.x + Texcoord.y * Image[Level].dimensions().x;
|
||||
|
||||
std::size_t Capacity = Image[Level].capacity();
|
||||
assert(Index < Capacity);
|
||||
|
||||
*(Data + Index) = Color;
|
||||
}
|
||||
|
||||
}//namespace fetch
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
33
test/external/gli/gtx/gl_texture2d.hpp
vendored
Normal file
33
test/external/gli/gtx/gl_texture2d.hpp
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-10-01
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gl_texture2d.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_GL_TEXTURE2D_INCLUDED
|
||||
#define GLI_GTX_GL_TEXTURE2D_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include "../gtx/loader.hpp"
|
||||
|
||||
#ifndef GL_VERSION_1_1
|
||||
#error "ERROR: OpenGL must be included before GLI_GTX_gl_texture2d"
|
||||
#endif//GL_VERSION_1_1
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gl_texture2d
|
||||
{
|
||||
GLuint createTexture2D(std::string const & Filename);
|
||||
}//namespace gl_texture2d
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::gl_texture2d;}
|
||||
|
||||
#include "gl_texture2d.inl"
|
||||
|
||||
#endif//GLI_GTX_GL_TEXTURE2D_INCLUDED
|
||||
210
test/external/gli/gtx/gl_texture2d.inl
vendored
Normal file
210
test/external/gli/gtx/gl_texture2d.inl
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-10-01
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gl_texture2d.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gl_texture2d{
|
||||
namespace detail
|
||||
{
|
||||
//GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, GL_COMPRESSED_RGBA, GL_COMPRESSED_SRGB, GL_COMPRESSED_SRGB_ALPHA,
|
||||
//GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or GL_SRGB8_ALPHA8
|
||||
struct texture_desc
|
||||
{
|
||||
GLint InternalFormat;
|
||||
GLint InternalFormatCompressed;
|
||||
GLint InternalFormatSRGB;
|
||||
GLint InternalFormatCompressedSRGB;
|
||||
GLenum ExternalFormat;
|
||||
GLenum ExternalFormatRev;
|
||||
GLenum Type;
|
||||
};
|
||||
|
||||
//GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA.
|
||||
//GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT,
|
||||
//GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
|
||||
//GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4,
|
||||
//GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
||||
//GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
|
||||
//GL_UNSIGNED_INT_2_10_10_10_REV
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
|
||||
# define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
|
||||
# endif
|
||||
|
||||
# ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
|
||||
# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
|
||||
# endif
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
|
||||
# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
|
||||
# endif
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
|
||||
# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
|
||||
# endif
|
||||
|
||||
inline texture_desc gli2ogl_cast(format const & Format)
|
||||
{
|
||||
texture_desc Cast[] =
|
||||
{
|
||||
{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE},
|
||||
|
||||
//// Normalized
|
||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
|
||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
|
||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
|
||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
|
||||
|
||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
|
||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
|
||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
|
||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
|
||||
|
||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
|
||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
|
||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
|
||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
|
||||
|
||||
// Unsigned
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
|
||||
|
||||
// Signed
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_BYTE},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_BYTE},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_BYTE},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_BYTE},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_SHORT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_SHORT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_SHORT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_SHORT},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_INT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_INT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_INT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_INT},
|
||||
|
||||
// Float
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_HALF_FLOAT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_HALF_FLOAT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_HALF_FLOAT},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_FLOAT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_FLOAT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_FLOAT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_FLOAT},
|
||||
|
||||
// Packed
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RGB9_E5, GL_RGB9_E5, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_R11F_G11F_B10F, GL_R11F_G11F_B10F, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RGBA4, GL_RGBA4, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RGB10_A2, GL_RGB10_A2, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
|
||||
// Depth
|
||||
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT},
|
||||
{GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
|
||||
{GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
|
||||
{GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT},
|
||||
{GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
|
||||
|
||||
// Compressed formats
|
||||
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_NONE, GL_NONE, GL_NONE},
|
||||
};
|
||||
|
||||
return Cast[Format];
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline GLuint createTexture2D(std::string const & Filename)
|
||||
{
|
||||
gli::texture2D Texture = gli::load(Filename);
|
||||
if(Texture.empty())
|
||||
return 0;
|
||||
|
||||
detail::texture_desc TextureDesc = detail::gli2ogl_cast(Texture.format());
|
||||
|
||||
GLint Alignment = 0;
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &Alignment);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
GLuint Name = 0;
|
||||
glGenTextures(1, &Name);
|
||||
glBindTexture(GL_TEXTURE_2D, Name);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Texture.levels() > 1 ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
if(size(Texture, BIT_PER_PIXEL) == size(Texture, BLOCK_SIZE) << 3)
|
||||
{
|
||||
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
GLint(Level),
|
||||
TextureDesc.InternalFormat,
|
||||
GLsizei(Texture[Level].dimensions().x),
|
||||
GLsizei(Texture[Level].dimensions().y),
|
||||
0,
|
||||
TextureDesc.ExternalFormatRev,
|
||||
TextureDesc.Type,
|
||||
Texture[Level].data());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
glCompressedTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
GLint(Level),
|
||||
TextureDesc.InternalFormat,
|
||||
GLsizei(Texture[Level].dimensions().x),
|
||||
GLsizei(Texture[Level].dimensions().y),
|
||||
0,
|
||||
GLsizei(Texture[Level].capacity()),
|
||||
Texture[Level].data());
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, Alignment);
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
}//namespace gl_texture_2d
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
38
test/external/gli/gtx/gradient.hpp
vendored
Normal file
38
test/external/gli/gtx/gradient.hpp
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gradient.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_GRADIENT_INCLUDED
|
||||
#define GLI_GTX_GRADIENT_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gradient
|
||||
{
|
||||
texture2D radial(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Center,
|
||||
float const & Radius,
|
||||
texture2D::texcoord_type const & Focal);
|
||||
|
||||
texture2D linear(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Point0,
|
||||
texture2D::texcoord_type const & Point1);
|
||||
|
||||
}//namespace gradient
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::gradient;}
|
||||
|
||||
#include "gradient.inl"
|
||||
|
||||
#endif//GLI_GTX_GRADIENT_INCLUDED
|
||||
74
test/external/gli/gtx/gradient.inl
vendored
Normal file
74
test/external/gli/gtx/gradient.inl
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gradient.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gradient
|
||||
{
|
||||
inline texture2D radial
|
||||
(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Center,
|
||||
float const & Radius,
|
||||
texture2D::texcoord_type const & Focal
|
||||
)
|
||||
{
|
||||
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
|
||||
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
|
||||
|
||||
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
|
||||
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
|
||||
{
|
||||
float Value = glm::radialGradient(
|
||||
Center * glm::vec2(Size),
|
||||
Radius,
|
||||
Focal * glm::vec2(Size),
|
||||
glm::vec2(x, y));
|
||||
|
||||
std::size_t Index = x + y * Result.dimensions().x;
|
||||
|
||||
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
|
||||
}
|
||||
|
||||
gli::texture2D Image(1);
|
||||
Image[0] = Result;
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline texture2D linear
|
||||
(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Point0,
|
||||
texture2D::texcoord_type const & Point1
|
||||
)
|
||||
{
|
||||
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
|
||||
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
|
||||
|
||||
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
|
||||
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
|
||||
{
|
||||
float Value = glm::linearGradient(
|
||||
Point0 * glm::vec2(Size),
|
||||
Point1 * glm::vec2(Size),
|
||||
texture2D::texcoord_type(x, y));
|
||||
|
||||
std::size_t Index = x + y * Result.dimensions().x;
|
||||
|
||||
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
|
||||
}
|
||||
|
||||
gli::texture2D Image(1);
|
||||
Image[0] = Result;
|
||||
return Image;
|
||||
}
|
||||
|
||||
}//namespace gradient
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
37
test/external/gli/gtx/loader.hpp
vendored
Normal file
37
test/external/gli/gtx/loader.hpp
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_INCLUDED
|
||||
#define GLI_GTX_LOADER_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include "../gtx/loader_dds9.hpp"
|
||||
#include "../gtx/loader_dds10.hpp"
|
||||
#include "../gtx/loader_tga.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader
|
||||
{
|
||||
inline texture2D load(
|
||||
std::string const & Filename);
|
||||
|
||||
inline void save(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader;}
|
||||
|
||||
#include "loader.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_INCLUDED
|
||||
48
test/external/gli/gtx/loader.inl
vendored
Normal file
48
test/external/gli/gtx/loader.inl
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader
|
||||
{
|
||||
inline texture2D load
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
if(Filename.find(".dds") != std::string::npos)
|
||||
return loadDDS10(Filename);
|
||||
else if(Filename.find(".tga") != std::string::npos)
|
||||
return loadTGA(Filename);
|
||||
else
|
||||
{
|
||||
assert(0); // File format not supported
|
||||
return texture2D();
|
||||
}
|
||||
}
|
||||
|
||||
inline void save
|
||||
(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
char const * File = Filename.c_str();
|
||||
|
||||
if(Filename.find(".dds") != std::string::npos)
|
||||
saveDDS10(Image, Filename);
|
||||
else if(Filename.find(".tga") != std::string::npos)
|
||||
saveTGA(Image, Filename);
|
||||
else
|
||||
assert(0); // File format not supported
|
||||
}
|
||||
|
||||
}//namespace loader
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
35
test/external/gli/gtx/loader_dds10.hpp
vendored
Normal file
35
test/external/gli/gtx/loader_dds10.hpp
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-26
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds10.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_DDS10_INCLUDED
|
||||
#define GLI_GTX_LOADER_DDS10_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include <fstream>
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds10
|
||||
{
|
||||
texture2D loadDDS10(
|
||||
std::string const & Filename);
|
||||
|
||||
void saveDDS10(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader_dds10
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader_dds10;}
|
||||
|
||||
#include "loader_dds10.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_DDS10_INCLUDED
|
||||
595
test/external/gli/gtx/loader_dds10.inl
vendored
Normal file
595
test/external/gli/gtx/loader_dds10.inl
vendored
Normal file
@@ -0,0 +1,595 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-26
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds10.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds10{
|
||||
namespace detail
|
||||
{
|
||||
// DDS Documentation
|
||||
/*
|
||||
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
|
||||
http://msdn.microsoft.com/en-us/library/bb943992.aspx
|
||||
*/
|
||||
|
||||
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
(glm::uint32)( \
|
||||
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
|
||||
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
|
||||
|
||||
enum DXGI_FORMAT
|
||||
{
|
||||
DXGI_FORMAT_UNKNOWN = 0,
|
||||
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
||||
DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
||||
DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
||||
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
||||
DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
||||
DXGI_FORMAT_R32G32B32_UINT = 7,
|
||||
DXGI_FORMAT_R32G32B32_SINT = 8,
|
||||
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
||||
DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
||||
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
||||
DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
||||
DXGI_FORMAT_R32G32_TYPELESS = 15,
|
||||
DXGI_FORMAT_R32G32_FLOAT = 16,
|
||||
DXGI_FORMAT_R32G32_UINT = 17,
|
||||
DXGI_FORMAT_R32G32_SINT = 18,
|
||||
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
||||
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
||||
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
||||
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
||||
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
||||
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
||||
DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
||||
DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
||||
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
||||
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
||||
DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
||||
DXGI_FORMAT_R16G16_TYPELESS = 33,
|
||||
DXGI_FORMAT_R16G16_FLOAT = 34,
|
||||
DXGI_FORMAT_R16G16_UNORM = 35,
|
||||
DXGI_FORMAT_R16G16_UINT = 36,
|
||||
DXGI_FORMAT_R16G16_SNORM = 37,
|
||||
DXGI_FORMAT_R16G16_SINT = 38,
|
||||
DXGI_FORMAT_R32_TYPELESS = 39,
|
||||
DXGI_FORMAT_D32_FLOAT = 40,
|
||||
DXGI_FORMAT_R32_FLOAT = 41,
|
||||
DXGI_FORMAT_R32_UINT = 42,
|
||||
DXGI_FORMAT_R32_SINT = 43,
|
||||
DXGI_FORMAT_R24G8_TYPELESS = 44,
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
||||
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
||||
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
||||
DXGI_FORMAT_R8G8_TYPELESS = 48,
|
||||
DXGI_FORMAT_R8G8_UNORM = 49,
|
||||
DXGI_FORMAT_R8G8_UINT = 50,
|
||||
DXGI_FORMAT_R8G8_SNORM = 51,
|
||||
DXGI_FORMAT_R8G8_SINT = 52,
|
||||
DXGI_FORMAT_R16_TYPELESS = 53,
|
||||
DXGI_FORMAT_R16_FLOAT = 54,
|
||||
DXGI_FORMAT_D16_UNORM = 55,
|
||||
DXGI_FORMAT_R16_UNORM = 56,
|
||||
DXGI_FORMAT_R16_UINT = 57,
|
||||
DXGI_FORMAT_R16_SNORM = 58,
|
||||
DXGI_FORMAT_R16_SINT = 59,
|
||||
DXGI_FORMAT_R8_TYPELESS = 60,
|
||||
DXGI_FORMAT_R8_UNORM = 61,
|
||||
DXGI_FORMAT_R8_UINT = 62,
|
||||
DXGI_FORMAT_R8_SNORM = 63,
|
||||
DXGI_FORMAT_R8_SINT = 64,
|
||||
DXGI_FORMAT_A8_UNORM = 65,
|
||||
DXGI_FORMAT_R1_UNORM = 66,
|
||||
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
||||
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
||||
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
||||
DXGI_FORMAT_BC1_TYPELESS = 70,
|
||||
DXGI_FORMAT_BC1_UNORM = 71,
|
||||
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
||||
DXGI_FORMAT_BC2_TYPELESS = 73,
|
||||
DXGI_FORMAT_BC2_UNORM = 74,
|
||||
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
||||
DXGI_FORMAT_BC3_TYPELESS = 76,
|
||||
DXGI_FORMAT_BC3_UNORM = 77,
|
||||
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
||||
DXGI_FORMAT_BC4_TYPELESS = 79,
|
||||
DXGI_FORMAT_BC4_UNORM = 80,
|
||||
DXGI_FORMAT_BC4_SNORM = 81,
|
||||
DXGI_FORMAT_BC5_TYPELESS = 82,
|
||||
DXGI_FORMAT_BC5_UNORM = 83,
|
||||
DXGI_FORMAT_BC5_SNORM = 84,
|
||||
DXGI_FORMAT_B5G6R5_UNORM = 85,
|
||||
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
||||
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
||||
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
||||
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
||||
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
||||
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
||||
DXGI_FORMAT_BC6H_TYPELESS = 94,
|
||||
DXGI_FORMAT_BC6H_UF16 = 95,
|
||||
DXGI_FORMAT_BC6H_SF16 = 96,
|
||||
DXGI_FORMAT_BC7_TYPELESS = 97,
|
||||
DXGI_FORMAT_BC7_UNORM = 98,
|
||||
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
||||
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
|
||||
};
|
||||
|
||||
enum D3D10_RESOURCE_DIMENSION
|
||||
{
|
||||
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
|
||||
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
|
||||
D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
|
||||
D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
|
||||
D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
|
||||
};
|
||||
|
||||
enum D3D10_RESOURCE_MISC_FLAG
|
||||
{
|
||||
D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1L,
|
||||
D3D10_RESOURCE_MISC_SHARED = 0x2L,
|
||||
D3D10_RESOURCE_MISC_TEXTURECUBE = 0x4L,
|
||||
D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10L,
|
||||
D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20L
|
||||
};
|
||||
|
||||
enum dds_format
|
||||
{
|
||||
GLI_D3DFMT_R8G8B8 = 20,
|
||||
GLI_D3DFMT_A8R8G8B8 = 21,
|
||||
GLI_D3DFMT_X8R8G8B8 = 22,
|
||||
GLI_D3DFMT_A8 = 28,
|
||||
GLI_D3DFMT_A2B10G10R10 = 31,
|
||||
GLI_D3DFMT_A8B8G8R8 = 32,
|
||||
GLI_D3DFMT_X8B8G8R8 = 33,
|
||||
GLI_D3DFMT_G16R16 = 34,
|
||||
GLI_D3DFMT_A2R10G10B10 = 35,
|
||||
GLI_D3DFMT_A16B16G16R16 = 36,
|
||||
|
||||
GLI_D3DFMT_L8 = 50,
|
||||
GLI_D3DFMT_A8L8 = 51,
|
||||
|
||||
GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
|
||||
GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
|
||||
GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
|
||||
GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
|
||||
GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
|
||||
GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
|
||||
|
||||
GLI_D3DFMT_D32 = 71,
|
||||
GLI_D3DFMT_D24S8 = 75,
|
||||
GLI_D3DFMT_D24X8 = 77,
|
||||
GLI_D3DFMT_D16 = 80,
|
||||
GLI_D3DFMT_L16 = 81,
|
||||
GLI_D3DFMT_D32F_LOCKABLE = 82,
|
||||
GLI_D3DFMT_D24FS8 = 83,
|
||||
|
||||
GLI_D3DFMT_R16F = 111,
|
||||
GLI_D3DFMT_G16R16F = 112,
|
||||
GLI_D3DFMT_A16B16G16R16F = 113,
|
||||
|
||||
GLI_D3DFMT_R32F = 114,
|
||||
GLI_D3DFMT_G32R32F = 115,
|
||||
GLI_D3DFMT_A32B32G32R32F = 116
|
||||
};
|
||||
|
||||
struct ddsHeader10
|
||||
{
|
||||
DXGI_FORMAT dxgiFormat;
|
||||
D3D10_RESOURCE_DIMENSION resourceDimension;
|
||||
glm::uint32 miscFlag; // D3D10_RESOURCE_MISC_GENERATE_MIPS
|
||||
glm::uint32 arraySize;
|
||||
glm::uint32 reserved;
|
||||
};
|
||||
|
||||
|
||||
inline gli::format format_fourcc2gli_cast(glm::uint32 const & FourCC)
|
||||
{
|
||||
switch(FourCC)
|
||||
{
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT1:
|
||||
return DXT1;
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT2:
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT3:
|
||||
return DXT3;
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT4:
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT5:
|
||||
return DXT5;
|
||||
case loader_dds9::detail::GLI_FOURCC_R16F:
|
||||
return R16F;
|
||||
case loader_dds9::detail::GLI_FOURCC_G16R16F:
|
||||
return RG16F;
|
||||
case loader_dds9::detail::GLI_FOURCC_A16B16G16R16F:
|
||||
return RGBA16F;
|
||||
case loader_dds9::detail::GLI_FOURCC_R32F:
|
||||
return R32F;
|
||||
case loader_dds9::detail::GLI_FOURCC_G32R32F:
|
||||
return RG32F;
|
||||
case loader_dds9::detail::GLI_FOURCC_A32B32G32R32F:
|
||||
return RGBA32F;
|
||||
|
||||
case loader_dds9::detail::GLI_D3DFMT_R8G8B8:
|
||||
return RGB8U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A8R8G8B8:
|
||||
case loader_dds9::detail::GLI_D3DFMT_X8R8G8B8:
|
||||
case loader_dds9::detail::GLI_D3DFMT_A8B8G8R8:
|
||||
case loader_dds9::detail::GLI_D3DFMT_X8B8G8R8:
|
||||
return RGBA8U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_R5G6B5:
|
||||
return R5G6B5;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A4R4G4B4:
|
||||
case loader_dds9::detail::GLI_D3DFMT_X4R4G4B4:
|
||||
return RGBA4;
|
||||
case loader_dds9::detail::GLI_D3DFMT_G16R16:
|
||||
return RG16U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A16B16G16R16:
|
||||
return RGBA16U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A2R10G10B10:
|
||||
case loader_dds9::detail::GLI_D3DFMT_A2B10G10R10:
|
||||
return RGB10A2;
|
||||
default:
|
||||
assert(0);
|
||||
return FORMAT_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline DXGI_FORMAT format_gli2dds_cast(gli::format const & Format)
|
||||
{
|
||||
DXGI_FORMAT Cast[] =
|
||||
{
|
||||
DXGI_FORMAT_UNKNOWN, //FORMAT_NULL,
|
||||
|
||||
// Unsigned integer formats
|
||||
DXGI_FORMAT_R8_UINT, //R8U,
|
||||
DXGI_FORMAT_R8G8_UINT, //RG8U,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB8U,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT, //RGBA8U,
|
||||
|
||||
DXGI_FORMAT_R16_UINT, //R16U,
|
||||
DXGI_FORMAT_R16G16_UINT, //RG16U,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB16U,
|
||||
DXGI_FORMAT_R16G16B16A16_UINT, //RGBA16U,
|
||||
|
||||
DXGI_FORMAT_R32_UINT, //R32U,
|
||||
DXGI_FORMAT_R32G32_UINT, //RG32U,
|
||||
DXGI_FORMAT_R32G32B32_UINT, //RGB32U,
|
||||
DXGI_FORMAT_R32G32B32A32_UINT, //RGBA32U,
|
||||
|
||||
// Signed integer formats
|
||||
DXGI_FORMAT_R8_SINT, //R8I,
|
||||
DXGI_FORMAT_R8G8_SINT, //RG8I,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB8I,
|
||||
DXGI_FORMAT_R8G8B8A8_SINT, //RGBA8I,
|
||||
|
||||
DXGI_FORMAT_R16_SINT, //R16I,
|
||||
DXGI_FORMAT_R16G16_SINT, //RG16I,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB16I,
|
||||
DXGI_FORMAT_R16G16B16A16_SINT, //RGBA16I,
|
||||
|
||||
DXGI_FORMAT_R32_SINT, //R32I,
|
||||
DXGI_FORMAT_R32G32_SINT, //RG32I,
|
||||
DXGI_FORMAT_R32G32B32_SINT, //RGB32I,
|
||||
DXGI_FORMAT_R32G32B32A32_SINT, //RGBA32I,
|
||||
|
||||
// Floating formats
|
||||
DXGI_FORMAT_R16_FLOAT, //R16F,
|
||||
DXGI_FORMAT_R16G16_FLOAT, //RG16F,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB16F,
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT, //RGBA16F,
|
||||
|
||||
DXGI_FORMAT_R32_FLOAT, //R32F,
|
||||
DXGI_FORMAT_R32G32_FLOAT, //RG32F,
|
||||
DXGI_FORMAT_R32G32B32_FLOAT, //RGB32F,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT, //RGBA32F,
|
||||
|
||||
// Packed formats
|
||||
DXGI_FORMAT_UNKNOWN, //RGBE8,
|
||||
DXGI_FORMAT_R9G9B9E5_SHAREDEXP, //RGB9E5,
|
||||
DXGI_FORMAT_R11G11B10_FLOAT,
|
||||
DXGI_FORMAT_B5G6R5_UNORM, //R5G6B5,
|
||||
DXGI_FORMAT_UNKNOWN, //RGBA4,
|
||||
DXGI_FORMAT_R10G10B10A2_TYPELESS, //RGB10A2,
|
||||
|
||||
// Depth formats
|
||||
DXGI_FORMAT_D16_UNORM, //D16,
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24X8,
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24S8,
|
||||
DXGI_FORMAT_D32_FLOAT, //D32F,
|
||||
DXGI_FORMAT_D32_FLOAT_S8X24_UINT, //D32FS8X24,
|
||||
|
||||
// Compressed formats
|
||||
DXGI_FORMAT_BC1_UNORM, //DXT1,
|
||||
DXGI_FORMAT_BC2_UNORM, //DXT3,
|
||||
DXGI_FORMAT_BC3_UNORM, //DXT5,
|
||||
DXGI_FORMAT_BC4_UNORM, //ATI1N_UNORM,
|
||||
DXGI_FORMAT_BC4_SNORM, //ATI1N_SNORM,
|
||||
DXGI_FORMAT_BC5_UNORM, //ATI2N_UNORM,
|
||||
DXGI_FORMAT_BC5_SNORM, //ATI2N_SNORM,
|
||||
DXGI_FORMAT_BC6H_UF16, //BP_FLOAT,
|
||||
DXGI_FORMAT_BC6H_SF16, //BP_FLOAT,
|
||||
DXGI_FORMAT_BC7_UNORM //BP,
|
||||
};
|
||||
|
||||
return Cast[Format];
|
||||
}
|
||||
|
||||
inline gli::format format_dds2gli_cast(DXGI_FORMAT const & Format)
|
||||
{
|
||||
gli::format Cast[] =
|
||||
{
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_UNKNOWN = 0,
|
||||
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
||||
gli::RGBA32F, //DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
||||
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
||||
gli::RGBA32I, //DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
||||
gli::RGB32U, //DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
||||
gli::RGB32F, //DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
||||
gli::RGB32U, //DXGI_FORMAT_R32G32B32_UINT = 7,
|
||||
gli::RGB32I, //DXGI_FORMAT_R32G32B32_SINT = 8,
|
||||
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
||||
gli::RGBA16F, //DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
||||
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
||||
gli::RG32U, //DXGI_FORMAT_R32G32_TYPELESS = 15,
|
||||
gli::RG32F, //DXGI_FORMAT_R32G32_FLOAT = 16,
|
||||
gli::RG32U, //DXGI_FORMAT_R32G32_UINT = 17,
|
||||
gli::RG32I, //DXGI_FORMAT_R32G32_SINT = 18,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
||||
gli::D32FS8X24, //DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
||||
gli::RG11B10F, //DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
||||
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
||||
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
||||
gli::RG16U, //DXGI_FORMAT_R16G16_TYPELESS = 33,
|
||||
gli::RG16F, //DXGI_FORMAT_R16G16_FLOAT = 34,
|
||||
gli::RG16U, //DXGI_FORMAT_R16G16_UNORM = 35,
|
||||
gli::RG16U, //DXGI_FORMAT_R16G16_UINT = 36,
|
||||
gli::RG16I, //DXGI_FORMAT_R16G16_SNORM = 37,
|
||||
gli::RG16I, //DXGI_FORMAT_R16G16_SINT = 38,
|
||||
gli::R32F, //DXGI_FORMAT_R32_TYPELESS = 39,
|
||||
gli::D32F, //DXGI_FORMAT_D32_FLOAT = 40,
|
||||
gli::R32F, //DXGI_FORMAT_R32_FLOAT = 41,
|
||||
gli::R32U, //DXGI_FORMAT_R32_UINT = 42,
|
||||
gli::R32I, //DXGI_FORMAT_R32_SINT = 43,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R24G8_TYPELESS = 44,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
||||
gli::RG8U, //DXGI_FORMAT_R8G8_TYPELESS = 48,
|
||||
gli::RG8U, //DXGI_FORMAT_R8G8_UNORM = 49,
|
||||
gli::RG8U, //DXGI_FORMAT_R8G8_UINT = 50,
|
||||
gli::RG8I, //DXGI_FORMAT_R8G8_SNORM = 51,
|
||||
gli::RG8I, //DXGI_FORMAT_R8G8_SINT = 52,
|
||||
gli::R16U, //DXGI_FORMAT_R16_TYPELESS = 53,
|
||||
gli::R16F, //DXGI_FORMAT_R16_FLOAT = 54,
|
||||
gli::D16, //DXGI_FORMAT_D16_UNORM = 55,
|
||||
gli::R16U, //DXGI_FORMAT_R16_UNORM = 56,
|
||||
gli::R16U, //DXGI_FORMAT_R16_UINT = 57,
|
||||
gli::R16I, //DXGI_FORMAT_R16_SNORM = 58,
|
||||
gli::R16I, //DXGI_FORMAT_R16_SINT = 59,
|
||||
gli::R8U, //DXGI_FORMAT_R8_TYPELESS = 60,
|
||||
gli::R8U, //DXGI_FORMAT_R8_UNORM = 61,
|
||||
gli::R8U, //DXGI_FORMAT_R8_UINT = 62,
|
||||
gli::R8I, //DXGI_FORMAT_R8_SNORM = 63,
|
||||
gli::R8I, //DXGI_FORMAT_R8_SINT = 64,
|
||||
gli::R8U, //DXGI_FORMAT_A8_UNORM = 65,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R1_UNORM = 66,
|
||||
gli::RGB9E5, //DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
||||
gli::DXT1, //DXGI_FORMAT_BC1_TYPELESS = 70,
|
||||
gli::DXT1, //DXGI_FORMAT_BC1_UNORM = 71,
|
||||
gli::DXT1, //DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
||||
gli::DXT3, //DXGI_FORMAT_BC2_TYPELESS = 73,
|
||||
gli::DXT3, //DXGI_FORMAT_BC2_UNORM = 74,
|
||||
gli::DXT3, //DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
||||
gli::DXT5, //DXGI_FORMAT_BC3_TYPELESS = 76,
|
||||
gli::DXT5, //DXGI_FORMAT_BC3_UNORM = 77,
|
||||
gli::DXT5, //DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
||||
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_TYPELESS = 79,
|
||||
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_UNORM = 80,
|
||||
gli::ATI1N_SNORM, //DXGI_FORMAT_BC4_SNORM = 81,
|
||||
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_TYPELESS = 82,
|
||||
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_UNORM = 83,
|
||||
gli::ATI2N_SNORM, //DXGI_FORMAT_BC5_SNORM = 84,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_B5G6R5_UNORM = 85,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
||||
gli::BP_UF16, //DXGI_FORMAT_BC6H_TYPELESS = 94,
|
||||
gli::BP_UF16, //DXGI_FORMAT_BC6H_UF16 = 95,
|
||||
gli::BP_SF16, //DXGI_FORMAT_BC6H_SF16 = 96,
|
||||
gli::BP, //DXGI_FORMAT_BC7_TYPELESS = 97,
|
||||
gli::BP, //DXGI_FORMAT_BC7_UNORM = 98,
|
||||
gli::BP, //DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
||||
gli::R32U //DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
|
||||
};
|
||||
|
||||
return Cast[Format];
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D loadDDS10
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(FileIn.fail())
|
||||
return texture2D();
|
||||
|
||||
loader_dds9::detail::ddsHeader HeaderDesc;
|
||||
detail::ddsHeader10 HeaderDesc10;
|
||||
char Magic[4];
|
||||
|
||||
//* Read magic number and check if valid .dds file
|
||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
||||
|
||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
||||
|
||||
// Get the surface descriptor
|
||||
FileIn.read((char*)&HeaderDesc, sizeof(HeaderDesc));
|
||||
if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC && HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
|
||||
FileIn.read((char*)&HeaderDesc10, sizeof(HeaderDesc10));
|
||||
|
||||
loader_dds9::detail::DDLoader Loader;
|
||||
if(HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
|
||||
Loader.Format = detail::format_dds2gli_cast(HeaderDesc10.dxgiFormat);
|
||||
else if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC)
|
||||
Loader.Format = detail::format_fourcc2gli_cast(HeaderDesc.format.fourCC);
|
||||
else
|
||||
{
|
||||
switch(HeaderDesc.format.bpp)
|
||||
{
|
||||
case 8:
|
||||
Loader.Format = R8U;
|
||||
break;
|
||||
case 16:
|
||||
Loader.Format = RG8U;
|
||||
break;
|
||||
case 24:
|
||||
Loader.Format = RGB8U;
|
||||
break;
|
||||
case 32:
|
||||
Loader.Format = RGBA8U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loader.BlockSize = size(image2D(texture2D::dimensions_type(0), Loader.Format), BLOCK_SIZE);
|
||||
Loader.BPP = size(image2D(image2D::dimensions_type(0), Loader.Format), BIT_PER_PIXEL);
|
||||
|
||||
std::size_t Width = HeaderDesc.width;
|
||||
std::size_t Height = HeaderDesc.height;
|
||||
|
||||
gli::format Format = Loader.Format;
|
||||
|
||||
std::streamoff Curr = FileIn.tellg();
|
||||
FileIn.seekg(0, std::ios_base::end);
|
||||
std::streamoff End = FileIn.tellg();
|
||||
FileIn.seekg(Curr, std::ios_base::beg);
|
||||
|
||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
||||
std::size_t Offset = 0;
|
||||
|
||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
||||
|
||||
//texture2D Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
||||
std::size_t MipMapCount = (HeaderDesc.flags & loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT) ? HeaderDesc.mipMapLevels : 1;
|
||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
// MipMapCount -= 2;
|
||||
texture2D Image(MipMapCount);
|
||||
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
|
||||
{
|
||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
||||
|
||||
std::size_t MipmapSize = 0;
|
||||
if((Loader.BlockSize << 3) > Loader.BPP)
|
||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
||||
else
|
||||
MipmapSize = Width * Height * Loader.BlockSize;
|
||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
||||
|
||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
||||
|
||||
image2D::dimensions_type Dimensions(Width, Height);
|
||||
Image[Level] = image2D(Dimensions, Format, MipmapData);
|
||||
|
||||
Offset += MipmapSize;
|
||||
Width >>= 1;
|
||||
Height >>= 1;
|
||||
}
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline void saveDDS10
|
||||
(
|
||||
gli::texture2D const & Image,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut)
|
||||
return;
|
||||
|
||||
char const * Magic = "DDS ";
|
||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
||||
|
||||
glm::uint32 Caps = loader_dds9::detail::GLI_DDSD_CAPS | loader_dds9::detail::GLI_DDSD_HEIGHT | loader_dds9::detail::GLI_DDSD_WIDTH | loader_dds9::detail::GLI_DDSD_PIXELFORMAT;
|
||||
|
||||
loader_dds9::detail::ddsHeader HeaderDesc;
|
||||
HeaderDesc.size = sizeof(loader_dds9::detail::ddsHeader);
|
||||
HeaderDesc.flags = Caps | (loader_dds9::detail::isCompressed(Image) ? loader_dds9::detail::GLI_DDSD_LINEARSIZE : loader_dds9::detail::GLI_DDSD_PITCH) | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
||||
HeaderDesc.width = Image[0].dimensions().x;
|
||||
HeaderDesc.height = Image[0].dimensions().y;
|
||||
HeaderDesc.pitch = loader_dds9::detail::isCompressed(Image) ? size(Image, LINEAR_SIZE) : 32;
|
||||
HeaderDesc.depth = 0;
|
||||
HeaderDesc.mipMapLevels = glm::uint32(Image.levels());
|
||||
HeaderDesc.format.size = sizeof(loader_dds9::detail::ddsPixelFormat);
|
||||
HeaderDesc.format.flags = loader_dds9::detail::GLI_DDPF_FOURCC;
|
||||
HeaderDesc.format.fourCC = loader_dds9::detail::GLI_FOURCC_DX10;
|
||||
HeaderDesc.format.bpp = size(Image, BIT_PER_PIXEL);
|
||||
HeaderDesc.format.redMask = 0;
|
||||
HeaderDesc.format.greenMask = 0;
|
||||
HeaderDesc.format.blueMask = 0;
|
||||
HeaderDesc.format.alphaMask = 0;
|
||||
HeaderDesc.surfaceFlags = loader_dds9::detail::GLI_DDSCAPS_TEXTURE | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSCAPS_MIPMAP : 0);
|
||||
HeaderDesc.cubemapFlags = 0;
|
||||
FileOut.write((char*)&HeaderDesc, sizeof(HeaderDesc));
|
||||
|
||||
detail::ddsHeader10 HeaderDesc10;
|
||||
HeaderDesc10.arraySize = 1;
|
||||
HeaderDesc10.resourceDimension = detail::D3D10_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
HeaderDesc10.miscFlag = 0;//Image.levels() > 0 ? detail::D3D10_RESOURCE_MISC_GENERATE_MIPS : 0;
|
||||
HeaderDesc10.dxgiFormat = detail::format_gli2dds_cast(Image.format());
|
||||
HeaderDesc10.reserved = 0;
|
||||
|
||||
FileOut.write((char*)&HeaderDesc10, sizeof(HeaderDesc10));
|
||||
|
||||
for(gli::texture2D::level_type Level = 0; Level < Image.levels(); ++Level)
|
||||
{
|
||||
gli::texture2D::size_type ImageSize = size(Image[Level], gli::LINEAR_SIZE);
|
||||
FileOut.write((char*)(Image[Level].data()), ImageSize);
|
||||
}
|
||||
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
|
||||
}//namespace loader_dds10
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
39
test/external/gli/gtx/loader_dds9.hpp
vendored
Normal file
39
test/external/gli/gtx/loader_dds9.hpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds9.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_DDS9_INCLUDED
|
||||
#define GLI_GTX_LOADER_DDS9_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include <fstream>
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds9
|
||||
{
|
||||
texture2D loadDDS9(
|
||||
std::string const & Filename);
|
||||
|
||||
void saveDDS9(
|
||||
texture2D const & Texture,
|
||||
std::string const & Filename);
|
||||
|
||||
void saveTextureCubeDDS9(
|
||||
textureCube const & Texture,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader_dds9
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader_dds9;}
|
||||
|
||||
#include "loader_dds9.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_DDS9_INCLUDED
|
||||
790
test/external/gli/gtx/loader_dds9.inl
vendored
Normal file
790
test/external/gli/gtx/loader_dds9.inl
vendored
Normal file
@@ -0,0 +1,790 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds9.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds9{
|
||||
namespace detail
|
||||
{
|
||||
// DDS Documentation
|
||||
/*
|
||||
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
|
||||
http://msdn.microsoft.com/en-us/library/bb943992.aspx
|
||||
*/
|
||||
|
||||
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
(glm::uint32)( \
|
||||
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
|
||||
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
|
||||
|
||||
//enum dds_format
|
||||
//{
|
||||
// GLI_D3DFMT_R8G8B8 = 20,
|
||||
// GLI_D3DFMT_A8R8G8B8 = 21,
|
||||
// GLI_D3DFMT_X8R8G8B8 = 22,
|
||||
// GLI_D3DFMT_A8 = 28,
|
||||
// GLI_D3DFMT_A2B10G10R10 = 31,
|
||||
// GLI_D3DFMT_A8B8G8R8 = 32,
|
||||
// GLI_D3DFMT_X8B8G8R8 = 33,
|
||||
// GLI_D3DFMT_G16R16 = 34,
|
||||
// GLI_D3DFMT_A2R10G10B10 = 35,
|
||||
// GLI_D3DFMT_A16B16G16R16 = 36,
|
||||
|
||||
// GLI_D3DFMT_L8 = 50,
|
||||
// GLI_D3DFMT_A8L8 = 51,
|
||||
|
||||
// GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
|
||||
// GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
|
||||
// GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
|
||||
// GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
|
||||
// GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
|
||||
// GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
|
||||
|
||||
// GLI_D3DFMT_D32 = 71,
|
||||
// GLI_D3DFMT_D24S8 = 75,
|
||||
// GLI_D3DFMT_D24X8 = 77,
|
||||
// GLI_D3DFMT_D16 = 80,
|
||||
// GLI_D3DFMT_L16 = 81,
|
||||
// GLI_D3DFMT_D32F_LOCKABLE = 82,
|
||||
// GLI_D3DFMT_D24FS8 = 83,
|
||||
|
||||
// GLI_D3DFMT_R16F = 111,
|
||||
// GLI_D3DFMT_G16R16F = 112,
|
||||
// GLI_D3DFMT_A16B16G16R16F = 113,
|
||||
|
||||
// GLI_D3DFMT_R32F = 114,
|
||||
// GLI_D3DFMT_G32R32F = 115,
|
||||
// GLI_D3DFMT_A32B32G32R32F = 116
|
||||
//};
|
||||
|
||||
enum ddsCubemapflag
|
||||
{
|
||||
GLI_DDSCAPS2_CUBEMAP = 0x00000200,
|
||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400,
|
||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800,
|
||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000,
|
||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000,
|
||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000,
|
||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000,
|
||||
GLI_DDSCAPS2_VOLUME = 0x00200000
|
||||
};
|
||||
|
||||
enum ddsSurfaceflag
|
||||
{
|
||||
GLI_DDSCAPS_COMPLEX = 0x00000008,
|
||||
GLI_DDSCAPS_MIPMAP = 0x00400000,
|
||||
GLI_DDSCAPS_TEXTURE = 0x00001000
|
||||
};
|
||||
|
||||
struct ddsPixelFormat
|
||||
{
|
||||
glm::uint32 size; // 32
|
||||
glm::uint32 flags;
|
||||
glm::uint32 fourCC;
|
||||
glm::uint32 bpp;
|
||||
glm::uint32 redMask;
|
||||
glm::uint32 greenMask;
|
||||
glm::uint32 blueMask;
|
||||
glm::uint32 alphaMask;
|
||||
};
|
||||
|
||||
struct ddsHeader
|
||||
{
|
||||
glm::uint32 size;
|
||||
glm::uint32 flags;
|
||||
glm::uint32 height;
|
||||
glm::uint32 width;
|
||||
glm::uint32 pitch;
|
||||
glm::uint32 depth;
|
||||
glm::uint32 mipMapLevels;
|
||||
glm::uint32 reserved1[11];
|
||||
ddsPixelFormat format;
|
||||
glm::uint32 surfaceFlags;
|
||||
glm::uint32 cubemapFlags;
|
||||
glm::uint32 reserved2[3];
|
||||
};
|
||||
|
||||
glm::uint32 const GLI_D3DFMT_R8G8B8 = 20;
|
||||
glm::uint32 const GLI_D3DFMT_A8R8G8B8 = 21;
|
||||
glm::uint32 const GLI_D3DFMT_X8R8G8B8 = 22;
|
||||
glm::uint32 const GLI_D3DFMT_R5G6B5 = 23;
|
||||
glm::uint32 const GLI_D3DFMT_X1R5G5B5 = 24;
|
||||
glm::uint32 const GLI_D3DFMT_A1R5G5B5 = 25;
|
||||
glm::uint32 const GLI_D3DFMT_A4R4G4B4 = 26;
|
||||
glm::uint32 const GLI_D3DFMT_X4R4G4B4 = 30;
|
||||
glm::uint32 const GLI_D3DFMT_A2B10G10R10 = 31;
|
||||
glm::uint32 const GLI_D3DFMT_A8B8G8R8 = 32;
|
||||
glm::uint32 const GLI_D3DFMT_X8B8G8R8 = 33;
|
||||
glm::uint32 const GLI_D3DFMT_G16R16 = 34;
|
||||
glm::uint32 const GLI_D3DFMT_A2R10G10B10 = 35;
|
||||
glm::uint32 const GLI_D3DFMT_A16B16G16R16 = 36;
|
||||
|
||||
|
||||
glm::uint32 const GLI_FOURCC_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1');
|
||||
glm::uint32 const GLI_FOURCC_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2');
|
||||
glm::uint32 const GLI_FOURCC_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3');
|
||||
glm::uint32 const GLI_FOURCC_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4');
|
||||
glm::uint32 const GLI_FOURCC_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5');
|
||||
glm::uint32 const GLI_FOURCC_ATI1 = GLI_MAKEFOURCC('A', 'T', 'I', '1'); // ATI1
|
||||
glm::uint32 const GLI_FOURCC_ATI2 = GLI_MAKEFOURCC('A', 'T', 'I', '2'); // ATI2 (AKA 3Dc)
|
||||
glm::uint32 const GLI_FOURCC_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0');
|
||||
glm::uint32 const GLI_FOURCC_BC4U = GLI_MAKEFOURCC('B', 'C', '4', 'U');
|
||||
glm::uint32 const GLI_FOURCC_BC4S = GLI_MAKEFOURCC('B', 'C', '4', 'S');
|
||||
glm::uint32 const GLI_FOURCC_BC5U = GLI_MAKEFOURCC('B', 'C', '5', 'U');
|
||||
glm::uint32 const GLI_FOURCC_BC5S = GLI_MAKEFOURCC('B', 'C', '5', 'S');
|
||||
glm::uint32 const GLI_FOURCC_BC6H = GLI_MAKEFOURCC('B', 'C', '6', 'H');
|
||||
glm::uint32 const GLI_FOURCC_BC7 = GLI_MAKEFOURCC('B', 'C', '7', 'U');
|
||||
|
||||
glm::uint32 const GLI_FOURCC_R16F = 0x0000006f; // 16-bit float Red
|
||||
glm::uint32 const GLI_FOURCC_G16R16F = 0x00000070; // 16-bit float Red/Green
|
||||
glm::uint32 const GLI_FOURCC_A16B16G16R16F = 0x00000071; // 16-bit float RGBA
|
||||
glm::uint32 const GLI_FOURCC_R32F = 0x00000072; // 32-bit float Red
|
||||
glm::uint32 const GLI_FOURCC_G32R32F = 0x00000073; // 32-bit float Red/Green
|
||||
glm::uint32 const GLI_FOURCC_A32B32G32R32F = 0x00000074; // 32-bit float RGBA
|
||||
|
||||
glm::uint32 const GLI_DDPF_ALPHAPIXELS = 0x00000001; // The surface has alpha channel information in the pixel format.
|
||||
glm::uint32 const GLI_DDPF_ALPHA = 0x00000002; // The pixel format contains alpha only information
|
||||
glm::uint32 const GLI_DDPF_FOURCC = 0x00000004; // The FourCC code is valid.
|
||||
glm::uint32 const GLI_DDPF_RGB = 0x00000040; // The RGB data in the pixel format structure is valid.
|
||||
//glm::uint32 const GLI_DDPF_COMPRESSED = 0x00000080; // The surface will accept pixel data in the format specified and compress it during the write.
|
||||
//glm::uint32 const GLI_DDPF_RGBTOYUV = 0x00000100; // The surface will accept RGB data and translate it during the write to YUV data.
|
||||
glm::uint32 const GLI_DDPF_YUV = 0x00000200; // Pixel format is YUV - YUV data in pixel format struct is valid.
|
||||
//glm::uint32 const GLI_DDPF_ZBUFFER = 0x00000400; // Pixel format is a z buffer only surface
|
||||
//glm::uint32 const GLI_DDPF_ZPIXELS = 0x00002000; // The surface contains Z information in the pixels
|
||||
//glm::uint32 const GLI_DDPF_STENCILBUFFER = 0x00004000; // The surface contains stencil information along with Z
|
||||
//glm::uint32 const GLI_DDPF_ALPHAPREMULT = 0x00008000; // Premultiplied alpha format -- the color components have been premultiplied by the alpha component.
|
||||
glm::uint32 const GLI_DDPF_LUMINANCE = 0x00020000; // Luminance data in the pixel format is valid.
|
||||
//glm::uint32 const GLI_DDPF_BUMPLUMINANCE = 0x00040000; // Use this flag for luminance-only or luminance+alpha surfaces, the bit depth is then ddpf.dwLuminanceBitCount.
|
||||
//glm::uint32 const GLI_DDPF_BUMPDUDV = 0x00080000; // Bump map dUdV data in the pixel format is valid.
|
||||
|
||||
glm::uint32 const GLI_DDSD_CAPS = 0x00000001;
|
||||
glm::uint32 const GLI_DDSD_HEIGHT = 0x00000002;
|
||||
glm::uint32 const GLI_DDSD_WIDTH = 0x00000004;
|
||||
glm::uint32 const GLI_DDSD_PITCH = 0x00000008;
|
||||
glm::uint32 const GLI_DDSD_PIXELFORMAT = 0x00001000;
|
||||
glm::uint32 const GLI_DDSD_MIPMAPCOUNT = 0x00020000;
|
||||
glm::uint32 const GLI_DDSD_LINEARSIZE = 0x00080000;
|
||||
glm::uint32 const GLI_DDSD_DEPTH = 0x00800000;
|
||||
|
||||
struct DDLoader
|
||||
{
|
||||
glm::uint32 BlockSize;
|
||||
glm::uint32 BPP;
|
||||
gli::format Format;
|
||||
};
|
||||
|
||||
enum format_type
|
||||
{
|
||||
FORMAT_TYPE_NULL,
|
||||
FORMAT_RGBA,
|
||||
FORMAT_FOURCC
|
||||
};
|
||||
|
||||
inline glm::uint32 getFormatFourCC(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case DXT1:
|
||||
return GLI_FOURCC_DXT1;
|
||||
case DXT3:
|
||||
return GLI_FOURCC_DXT3;
|
||||
case DXT5:
|
||||
return GLI_FOURCC_DXT5;
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
case BP:
|
||||
return GLI_FOURCC_DX10;
|
||||
case R16F:
|
||||
return GLI_FOURCC_R16F;
|
||||
case RG16F:
|
||||
return GLI_FOURCC_G16R16F;
|
||||
case RGBA16F:
|
||||
return GLI_FOURCC_A16B16G16R16F;
|
||||
case R32F:
|
||||
return GLI_FOURCC_R32F;
|
||||
case RG32F:
|
||||
return GLI_FOURCC_G32R32F;
|
||||
case RGBA32F:
|
||||
return GLI_FOURCC_A32B32G32R32F;
|
||||
}
|
||||
}
|
||||
|
||||
inline glm::uint32 getFormatBlockSize(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case DXT1:
|
||||
return 8;
|
||||
case DXT3:
|
||||
return 16;
|
||||
case DXT5:
|
||||
return 16;
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
return 16;
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
return 32;
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
return 32;
|
||||
case BP:
|
||||
return 32;
|
||||
case R16F:
|
||||
return 2;
|
||||
case RG16F:
|
||||
return 4;
|
||||
case RGBA16F:
|
||||
return 8;
|
||||
case R32F:
|
||||
return 4;
|
||||
case RG32F:
|
||||
return 8;
|
||||
case RGBA32F:
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
inline glm::uint32 getFormatFlags(gli::texture2D const & Image)
|
||||
{
|
||||
glm::uint32 Result = 0;
|
||||
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case R8U:
|
||||
case RG8U:
|
||||
case RGB8U:
|
||||
case RGBA8U:
|
||||
case R16U:
|
||||
case RG16U:
|
||||
case RGB16U:
|
||||
case RGBA16U:
|
||||
case R32U:
|
||||
case RG32U:
|
||||
case RGB32U:
|
||||
case RGBA32U:
|
||||
case R8I:
|
||||
case RG8I:
|
||||
case RGB8I:
|
||||
case RGBA8I:
|
||||
case R16I:
|
||||
case RG16I:
|
||||
case RGB16I:
|
||||
case RGBA16I:
|
||||
case R32I:
|
||||
case RG32I:
|
||||
case RGB32I:
|
||||
case RGBA32I:
|
||||
Result |= GLI_DDPF_RGB;
|
||||
break;
|
||||
case R16F:
|
||||
case RG16F:
|
||||
case RGB16F:
|
||||
case RGBA16F:
|
||||
case R32F:
|
||||
case RG32F:
|
||||
case RGB32F:
|
||||
case RGBA32F:
|
||||
case RGBE8:
|
||||
case RGB9E5:
|
||||
case RG11B10F:
|
||||
case R5G6B5:
|
||||
case RGBA4:
|
||||
case RGB10A2:
|
||||
case D16:
|
||||
case D24X8:
|
||||
case D24S8:
|
||||
case D32F:
|
||||
case D32FS8X24:
|
||||
case DXT1:
|
||||
case DXT3:
|
||||
case DXT5:
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
case BP:
|
||||
Result |= GLI_DDPF_FOURCC;
|
||||
break;
|
||||
};
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline glm::uint32 getFormatBPP(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case R8U:
|
||||
case R8I:
|
||||
return 8;
|
||||
case RG8U:
|
||||
case RG8I:
|
||||
return 16;
|
||||
case RGB8U:
|
||||
case RGB8I:
|
||||
return 24;
|
||||
case RGBA8U:
|
||||
case RGBA8I:
|
||||
return 32;
|
||||
case DXT1:
|
||||
return 4;
|
||||
case DXT3:
|
||||
return 8;
|
||||
case DXT5:
|
||||
return 8;
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
return 4;
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
return 8;
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
return 8;
|
||||
case BP:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool isCompressed(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return false;
|
||||
case DXT1:
|
||||
case DXT3:
|
||||
case DXT5:
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
case BP:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D loadDDS9
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(FileIn.fail())
|
||||
return texture2D();
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
char Magic[4];
|
||||
|
||||
//* Read magic number and check if valid .dds file
|
||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
||||
|
||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
||||
|
||||
// Get the surface descriptor
|
||||
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
std::size_t Width = SurfaceDesc.width;
|
||||
std::size_t Height = SurfaceDesc.height;
|
||||
|
||||
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
|
||||
|
||||
detail::DDLoader Loader;
|
||||
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
|
||||
{
|
||||
switch(SurfaceDesc.format.fourCC)
|
||||
{
|
||||
case detail::GLI_FOURCC_DX10:
|
||||
assert(0);
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT1:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = DXT1;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT3:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT3;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT5:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT5;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R16F:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G16R16F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RG16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A16B16G16R16F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RGBA16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R32F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = R32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G32R32F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RG32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A32B32G32R32F:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = RGBA32F;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return texture2D();
|
||||
}
|
||||
}
|
||||
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
|
||||
{
|
||||
switch(SurfaceDesc.format.bpp)
|
||||
{
|
||||
case 8:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R8U;
|
||||
break;
|
||||
case 16:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = RG8U;
|
||||
break;
|
||||
case 24:
|
||||
Loader.BlockSize = 3;
|
||||
Loader.Format = RGB8U;
|
||||
break;
|
||||
case 32:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RGBA8U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
gli::format Format = Loader.Format;
|
||||
|
||||
std::streamoff Curr = FileIn.tellg();
|
||||
FileIn.seekg(0, std::ios_base::end);
|
||||
std::streamoff End = FileIn.tellg();
|
||||
FileIn.seekg(Curr, std::ios_base::beg);
|
||||
|
||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
||||
std::size_t Offset = 0;
|
||||
|
||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
||||
|
||||
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
||||
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
|
||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
// MipMapCount -= 2;
|
||||
texture2D Image(MipMapCount);
|
||||
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
|
||||
{
|
||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
||||
|
||||
std::size_t MipmapSize = 0;
|
||||
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
||||
else
|
||||
MipmapSize = Width * Height * Loader.BlockSize;
|
||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
||||
|
||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
||||
|
||||
image2D::dimensions_type Dimensions(Width, Height);
|
||||
Image[Level] = image2D(Dimensions, Format, MipmapData);
|
||||
|
||||
Offset += MipmapSize;
|
||||
Width >>= 1;
|
||||
Height >>= 1;
|
||||
}
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline textureCube loadTextureCubeDDS9
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(FileIn.fail())
|
||||
return textureCube();
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
char Magic[4];
|
||||
|
||||
//* Read magic number and check if valid .dds file
|
||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
||||
|
||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
||||
|
||||
// Get the surface descriptor
|
||||
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
std::size_t Width = SurfaceDesc.width;
|
||||
std::size_t Height = SurfaceDesc.height;
|
||||
|
||||
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
|
||||
|
||||
detail::DDLoader Loader;
|
||||
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
|
||||
{
|
||||
switch(SurfaceDesc.format.fourCC)
|
||||
{
|
||||
case detail::GLI_FOURCC_DX10:
|
||||
assert(0);
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT1:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = DXT1;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT3:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT3;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT5:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT5;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R16F:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G16R16F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RG16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A16B16G16R16F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RGBA16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R32F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = R32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G32R32F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RG32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A32B32G32R32F:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = RGBA32F;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return textureCube();
|
||||
}
|
||||
}
|
||||
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
|
||||
{
|
||||
switch(SurfaceDesc.format.bpp)
|
||||
{
|
||||
case 8:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R8U;
|
||||
break;
|
||||
case 16:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = RG8U;
|
||||
break;
|
||||
case 24:
|
||||
Loader.BlockSize = 3;
|
||||
Loader.Format = RGB8U;
|
||||
break;
|
||||
case 32:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RGBA8U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
gli::format Format = Loader.Format;
|
||||
|
||||
std::streamoff Curr = FileIn.tellg();
|
||||
FileIn.seekg(0, std::ios_base::end);
|
||||
std::streamoff End = FileIn.tellg();
|
||||
FileIn.seekg(Curr, std::ios_base::beg);
|
||||
|
||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
||||
std::size_t Offset = 0;
|
||||
|
||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
||||
|
||||
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
||||
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
|
||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
// MipMapCount -= 2;
|
||||
textureCube Texture(MipMapCount);
|
||||
|
||||
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
|
||||
{
|
||||
Width = SurfaceDesc.width;
|
||||
Height = SurfaceDesc.height;
|
||||
|
||||
for(textureCube::size_type Level = 0; Level < Texture.levels() && (Width || Height); ++Level)
|
||||
{
|
||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
||||
|
||||
std::size_t MipmapSize = 0;
|
||||
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
||||
else
|
||||
MipmapSize = Width * Height * Loader.BlockSize;
|
||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
||||
|
||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
||||
|
||||
textureCube::dimensions_type Dimensions(Width, Height);
|
||||
Texture[textureCube::face_type(Face)][Level] = image2D(Dimensions, Format, MipmapData);
|
||||
|
||||
Offset += MipmapSize;
|
||||
Width >>= 1;
|
||||
Height >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Texture;
|
||||
}
|
||||
|
||||
inline void saveDDS9
|
||||
(
|
||||
texture2D const & Texture,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut)
|
||||
return;
|
||||
|
||||
char const * Magic = "DDS ";
|
||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
||||
|
||||
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT;
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
SurfaceDesc.size = sizeof(detail::ddsHeader);
|
||||
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
||||
SurfaceDesc.width = Texture[0].dimensions().x;
|
||||
SurfaceDesc.height = Texture[0].dimensions().y;
|
||||
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture) ? size(Texture, LINEAR_SIZE) : 32;
|
||||
SurfaceDesc.depth = 0;
|
||||
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
|
||||
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
|
||||
SurfaceDesc.format.flags = detail::getFormatFlags(Texture);
|
||||
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture);
|
||||
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture);
|
||||
SurfaceDesc.format.redMask = 0;
|
||||
SurfaceDesc.format.greenMask = 0;
|
||||
SurfaceDesc.format.blueMask = 0;
|
||||
SurfaceDesc.format.alphaMask = 0;
|
||||
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
|
||||
SurfaceDesc.cubemapFlags = 0;
|
||||
|
||||
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
texture2D::size_type ImageSize = size(Texture[Level], gli::LINEAR_SIZE);
|
||||
FileOut.write((char*)(Texture[Level].data()), ImageSize);
|
||||
}
|
||||
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
|
||||
inline void saveTextureCubeDDS9
|
||||
(
|
||||
textureCube const & Texture,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut || Texture.empty())
|
||||
return;
|
||||
|
||||
char const * Magic = "DDS ";
|
||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
||||
|
||||
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT | detail::GLI_DDSCAPS_COMPLEX;
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
SurfaceDesc.size = sizeof(detail::ddsHeader);
|
||||
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture[POSITIVE_X]) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
||||
SurfaceDesc.width = Texture[POSITIVE_X][0].dimensions().x;
|
||||
SurfaceDesc.height = Texture[POSITIVE_X][0].dimensions().y;
|
||||
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture[POSITIVE_X]) ? size(Texture[POSITIVE_X], LINEAR_SIZE) : 32;
|
||||
SurfaceDesc.depth = 0;
|
||||
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
|
||||
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
|
||||
SurfaceDesc.format.flags = detail::getFormatFlags(Texture[POSITIVE_X]);
|
||||
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture[POSITIVE_X]);
|
||||
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture[POSITIVE_X]);
|
||||
SurfaceDesc.format.redMask = 0;
|
||||
SurfaceDesc.format.greenMask = 0;
|
||||
SurfaceDesc.format.blueMask = 0;
|
||||
SurfaceDesc.format.alphaMask = 0;
|
||||
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
|
||||
SurfaceDesc.cubemapFlags =
|
||||
detail::GLI_DDSCAPS2_CUBEMAP | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEX | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEX | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEY | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEY | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEZ | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ;
|
||||
|
||||
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
texture2D::size_type ImageSize = size(Texture[textureCube::face_type(Face)][Level], gli::LINEAR_SIZE);
|
||||
FileOut.write((char*)(Texture[textureCube::face_type(Face)][Level].data()), ImageSize);
|
||||
}
|
||||
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
|
||||
}//namespace loader_dds9
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
36
test/external/gli/gtx/loader_tga.hpp
vendored
Normal file
36
test/external/gli/gtx/loader_tga.hpp
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_tga.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_TGA_INCLUDED
|
||||
#define GLI_GTX_LOADER_TGA_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_tga
|
||||
{
|
||||
texture2D loadTGA(
|
||||
std::string const & Filename);
|
||||
|
||||
void saveTGA(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader_tga
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader_tga;}
|
||||
|
||||
#include "loader_tga.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_TGA_INCLUDED
|
||||
159
test/external/gli/gtx/loader_tga.inl
vendored
Normal file
159
test/external/gli/gtx/loader_tga.inl
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_tga.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_tga
|
||||
{
|
||||
inline texture2D loadTGA
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!FileIn)
|
||||
return texture2D();
|
||||
|
||||
unsigned char IdentificationFieldSize;
|
||||
unsigned char ColorMapType;
|
||||
unsigned char ImageType;
|
||||
unsigned short ColorMapOrigin;
|
||||
unsigned short ColorMapLength;
|
||||
unsigned char ColorMapEntrySize;
|
||||
unsigned short OriginX;
|
||||
unsigned short OriginY;
|
||||
unsigned short Width;
|
||||
unsigned short Height;
|
||||
unsigned char TexelSize;
|
||||
unsigned char Descriptor;
|
||||
|
||||
FileIn.read((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
|
||||
FileIn.read((char*)&ColorMapType, sizeof(ColorMapType));
|
||||
FileIn.read((char*)&ImageType, sizeof(ImageType));
|
||||
FileIn.read((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
|
||||
FileIn.read((char*)&ColorMapLength, sizeof(ColorMapLength));
|
||||
FileIn.read((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
|
||||
FileIn.read((char*)&OriginX, sizeof(OriginX));
|
||||
FileIn.read((char*)&OriginY, sizeof(OriginY));
|
||||
FileIn.read((char*)&Width, sizeof(Width));
|
||||
FileIn.read((char*)&Height, sizeof(Height));
|
||||
FileIn.read((char*)&TexelSize, sizeof(TexelSize));
|
||||
FileIn.read((char*)&Descriptor, sizeof(Descriptor));
|
||||
|
||||
gli::format Format = gli::FORMAT_NULL;
|
||||
if(TexelSize == 24)
|
||||
Format = gli::RGB8U;
|
||||
else if(TexelSize == 32)
|
||||
Format = gli::RGBA8U;
|
||||
else
|
||||
assert(0);
|
||||
|
||||
image2D Mipmap(texture2D::dimensions_type(Width, Height), Format);
|
||||
|
||||
if (FileIn.fail() || FileIn.bad())
|
||||
{
|
||||
assert(0);
|
||||
return texture2D();
|
||||
}
|
||||
|
||||
switch(ImageType)
|
||||
{
|
||||
default:
|
||||
assert(0);
|
||||
return texture2D();
|
||||
|
||||
case 2:
|
||||
FileIn.seekg(18 + ColorMapLength, std::ios::beg);
|
||||
|
||||
char* IdentificationField = new char[IdentificationFieldSize + 1];
|
||||
FileIn.read(IdentificationField, IdentificationFieldSize);
|
||||
IdentificationField[IdentificationFieldSize] = '\0';
|
||||
delete[] IdentificationField;
|
||||
|
||||
std::size_t DataSize = Width * Height * (TexelSize >> 3);
|
||||
FileIn.read((char*)Mipmap.data(), std::streamsize(DataSize));
|
||||
|
||||
if(FileIn.fail() || FileIn.bad())
|
||||
return texture2D();
|
||||
break;
|
||||
}
|
||||
|
||||
FileIn.close();
|
||||
|
||||
texture2D Image(1);
|
||||
Image[0] = Mipmap;
|
||||
|
||||
// TGA images are saved in BGR or BGRA format.
|
||||
if(TexelSize == 24)
|
||||
Image.swizzle<glm::u8vec3>(glm::B, glm::G, glm::R, glm::A);
|
||||
if(TexelSize == 32)
|
||||
Image.swizzle<glm::u8vec4>(glm::B, glm::G, glm::R, glm::A);
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline void saveTGA
|
||||
(
|
||||
gli::texture2D const & ImageIn,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut)
|
||||
return;
|
||||
|
||||
gli::texture2D Image = duplicate(ImageIn);
|
||||
|
||||
unsigned char IdentificationFieldSize = 1;
|
||||
unsigned char ColorMapType = 0;
|
||||
unsigned char ImageType = 2;
|
||||
unsigned short ColorMapOrigin = 0;
|
||||
unsigned short ColorMapLength = 0;
|
||||
unsigned char ColorMapEntrySize = 0;
|
||||
unsigned short OriginX = 0;
|
||||
unsigned short OriginY = 0;
|
||||
unsigned short Width = Image[0].dimensions().x;
|
||||
unsigned short Height = Image[0].dimensions().y;
|
||||
unsigned char TexelSize = (unsigned char)(Image[0].value_size());
|
||||
unsigned char Descriptor = 0;
|
||||
|
||||
if(TexelSize == 24)
|
||||
Image.swizzle<glm::u8vec3>(glm::B, glm::G, glm::R, glm::A);
|
||||
if(TexelSize == 32)
|
||||
Image.swizzle<glm::u8vec4>(glm::B, glm::G, glm::R, glm::A);
|
||||
|
||||
FileOut.write((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
|
||||
FileOut.write((char*)&ColorMapType, sizeof(ColorMapType));
|
||||
FileOut.write((char*)&ImageType, sizeof(ImageType));
|
||||
FileOut.write((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
|
||||
FileOut.write((char*)&ColorMapLength, sizeof(ColorMapLength));
|
||||
FileOut.write((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
|
||||
FileOut.write((char*)&OriginX, sizeof(OriginX));
|
||||
FileOut.write((char*)&OriginY, sizeof(OriginY));
|
||||
FileOut.write((char*)&Width, sizeof(Width));
|
||||
FileOut.write((char*)&Height, sizeof(Height));
|
||||
FileOut.write((char*)&TexelSize, sizeof(TexelSize));
|
||||
FileOut.write((char*)&Descriptor, sizeof(Descriptor));
|
||||
|
||||
if (FileOut.fail () || FileOut.bad ())
|
||||
return;
|
||||
|
||||
FileOut.seekp(18 + ColorMapLength, std::ios::beg);
|
||||
char* IdentificationField = new char[IdentificationFieldSize + 1];
|
||||
FileOut.write(IdentificationField, std::streamsize(IdentificationFieldSize));
|
||||
delete[] IdentificationField;
|
||||
FileOut.write((char*)Image[0].data(), std::streamsize(Image[0].capacity()));
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
}//namespace loader_tga
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
27
test/external/gli/gtx/wavelet.hpp
vendored
Normal file
27
test/external/gli/gtx/wavelet.hpp
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-09
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/wavelet.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_WAVELET_INCLUDED
|
||||
#define GLI_GTX_WAVELET_INCLUDED
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace wavelet
|
||||
{
|
||||
|
||||
|
||||
}//namespace wavelet
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::wavelet;}
|
||||
|
||||
#include "wavelet.inl"
|
||||
|
||||
#endif//GLI_GTX_WAVELET_INCLUDED
|
||||
8
test/external/gli/gtx/wavelet.inl
vendored
Normal file
8
test/external/gli/gtx/wavelet.inl
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-09
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/wavelet.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user