Added Vulkan examples sources!

This commit is contained in:
saschawillems 2016-02-16 15:07:25 +01:00
parent 367fda186b
commit c91341813c
868 changed files with 514080 additions and 5584 deletions

30
external/gli/gli/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,30 @@
set(NAME gli)
file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp)
file(GLOB_RECURSE CORE_INLINE ./core/*.inl)
file(GLOB_RECURSE CORE_HEADER ./core/*.hpp)
file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_executable(${NAME} ${ROOT_TEXT} ${ROOT_MD}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER})

49
external/gli/gli/comparison.hpp vendored Normal file
View file

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/comparison.hpp
/// @date 2013-02-04 / 2013-02-04
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "image.hpp"
#include "texture1d.hpp"
#include "texture1d_array.hpp"
#include "texture2d.hpp"
#include "texture2d_array.hpp"
#include "texture3d.hpp"
#include "texture_cube.hpp"
#include "texture_cube_array.hpp"
namespace gli
{
bool operator==(image const & ImageA, image const & ImageB);
bool operator!=(image const & ImageA, image const & ImageB);
bool operator==(texture const & A, texture const & B);
bool operator!=(texture const & A, texture const & B);
}//namespace gli
#include "./core/comparison.inl"

98
external/gli/gli/copy.hpp vendored Normal file
View file

@ -0,0 +1,98 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/copy.hpp
/// @date 2013-02-01 / 2013-02-03
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "image.hpp"
#include "texture1d.hpp"
#include "texture1d_array.hpp"
#include "texture2d.hpp"
#include "texture2d_array.hpp"
#include "texture3d.hpp"
#include "texture_cube.hpp"
#include "texture_cube_array.hpp"
namespace gli
{
/// Copy an image and create a new image with a new storage allocation.
image copy(image const & Image);
/// Copy a texture and create a new texture with a new storage allocation.
texture copy(texture const & Texture);
/// Copy a texture and create a new texture with a new storage allocation.
template <typename texType>
texture copy(texType const & Texture);
/// Copy a texture and create a new texture with a new storage allocation but a different format.
/// The format must be a compatible format, a format which block size match the original format.
template <typename texType>
texture copy(texType const & Texture, format Format);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
texture1D const & Texture,
texture1D::size_type BaseLevel, texture1D::size_type MaxLevel);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
texture1DArray const & Texture,
texture1DArray::size_type BaseLayer, texture1DArray::size_type MaxLayer,
texture1DArray::size_type BaseLevel, texture1DArray::size_type MaxLevel);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
texture2D const & Texture,
texture2D::size_type BaseLevel, texture2D::size_type MaxLevel);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
texture2DArray const & Texture,
texture2DArray::size_type BaseLayer, texture2DArray::size_type MaxLayer,
texture2DArray::size_type BaseLevel, texture2DArray::size_type MaxLevel);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
texture3D const & Texture,
texture3D::size_type BaseLevel, texture3D::size_type MaxLevel);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
textureCube const & Texture,
textureCube::size_type BaseFace, textureCube::size_type MaxFace,
textureCube::size_type BaseLevel, textureCube::size_type MaxLevel);
/// Copy a subset of a texture and create a new texture with a new storage allocation.
texture copy(
textureCubeArray const & Texture,
textureCubeArray::size_type BaseLayer, textureCubeArray::size_type MaxLayer,
textureCubeArray::size_type BaseFace, textureCubeArray::size_type MaxFace,
textureCubeArray::size_type BaseLevel, textureCubeArray::size_type MaxLevel);
}//namespace gli
#include "./core/copy.inl"

129
external/gli/gli/core/comparison.inl vendored Normal file
View file

@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/comparison.inl
/// @date 2013-02-04 / 2013-02-04
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <cstring>
namespace gli{
namespace detail
{
inline bool equalData(texture const & TextureA, texture const & TextureB)
{
if(TextureA.data() == TextureB.data())
return true;
void const* PointerA = TextureA.data();
void const* PointerB = TextureB.data();
if(std::memcmp(PointerA, PointerB, TextureA.size()) == 0)
return true;
return false;
}
}//namespace detail
inline bool operator==(image const & ImageA, image const & ImageB)
{
if(!glm::all(glm::equal(ImageA.dimensions(), ImageB.dimensions())))
return false;
if(ImageA.size() != ImageB.size())
return false;
for(std::size_t i = 0; i < ImageA.size<glm::byte>(); ++i)
if(*(ImageA.data<glm::byte>() + i) != *(ImageB.data<glm::byte>() + i))
return false;
return true;
}
inline bool operator!=(image const & ImageA, image const & ImageB)
{
if(!glm::all(glm::equal(ImageA.dimensions(), ImageB.dimensions())))
return true;
if(ImageA.size() != ImageB.size())
return true;
for(std::size_t i = 0; i < ImageA.size<glm::byte>(); ++i)
if(*(ImageA.data<glm::byte>() + i) != *(ImageB.data<glm::byte>() + i))
return true;
return false;
}
inline bool equal(texture const & TextureA, texture const & TextureB)
{
if(TextureA.empty() && TextureB.empty())
return true;
if(TextureA.empty() != TextureB.empty())
return false;
if(TextureA.target() != TextureB.target())
return false;
if(TextureA.layers() != TextureB.layers())
return false;
if(TextureA.faces() != TextureB.faces())
return false;
if(TextureA.levels() != TextureB.levels())
return false;
if(TextureA.format() != TextureB.format())
return false;
if(TextureA.size() != TextureB.size())
return false;
return detail::equalData(TextureA, TextureB);
}
inline bool notEqual(texture const & TextureA, texture const & TextureB)
{
if(TextureA.empty() && TextureB.empty())
return false;
if(TextureA.empty() != TextureB.empty())
return true;
if(TextureA.target() != TextureB.target())
return true;
if(TextureA.layers() != TextureB.layers())
return true;
if(TextureA.faces() != TextureB.faces())
return true;
if(TextureA.levels() != TextureB.levels())
return true;
if(TextureA.format() != TextureB.format())
return true;
if(TextureA.size() != TextureB.size())
return true;
return !detail::equalData(TextureA, TextureB);
}
inline bool operator==(gli::texture const & A, gli::texture const & B)
{
return gli::equal(A, B);
}
inline bool operator!=(gli::texture const & A, gli::texture const & B)
{
return gli::notEqual(A, B);
}
}//namespace gli

256
external/gli/gli/core/copy.inl vendored Normal file
View file

@ -0,0 +1,256 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/copy.inl
/// @date 2013-01-23 / 2013-02-03
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline image copy(image const & Image)
{
image Result(Image.format(), Image.dimensions());
memcpy(Result.data(), Image.data(), Image.size());
return Result;
}
inline texture copy(texture const & Texture)
{
texture Copy(
Texture.target(),
Texture.format(),
Texture.dimensions(),
Texture.layers(),
Texture.faces(),
Texture.levels());
memcpy(Copy.data(), Texture.data(), Copy.size());
return Copy;
}
template <typename texType>
inline texture copy(texType const & Texture)
{
texture Copy(
Texture.target(),
Texture.format(),
Texture.texture::dimensions(),
Texture.layers(),
Texture.faces(),
Texture.levels());
memcpy(Copy.data(), Texture.data(), Copy.size());
return Copy;
}
template <typename texType>
inline texture copy(texType const & Texture, typename texType::format_type Format)
{
assert(block_size(Texture.format()) == block_size(Format));
texture Copy(
Texture.target(),
Format,
Texture.dimensions(),
Texture.layers(),
Texture.faces(),
Texture.levels());
memcpy(Copy.data(), Texture.data(), Copy.size());
return Copy;
}
inline texture copy
(
texture1D const & Texture,
texture1D::size_type BaseLevel, texture1D::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
texture1D Copy(
Texture.format(),
texture1D::dim_type(Texture[BaseLevel].dimensions().x),
MaxLevel - BaseLevel + 1);
memcpy(Copy.data(), Texture[BaseLevel].data(), Copy.size());
return Copy;
}
inline texture copy
(
texture1DArray const & Texture,
texture1DArray::size_type BaseLayer, texture1DArray::size_type MaxMayer,
texture1DArray::size_type BaseLevel, texture1DArray::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseLayer <= MaxMayer);
assert(BaseLayer < Texture.layers());
assert(MaxMayer < Texture.layers());
texture1DArray Copy(
Texture.format(),
texture1DArray::dim_type(Texture[BaseLayer][BaseLevel].dimensions().x),
MaxMayer - BaseLayer + 1,
MaxLevel - BaseLevel + 1);
for(texture1DArray::size_type Layer = 0; Layer < Copy.layers(); ++Layer)
memcpy(Copy[Layer].data(), Texture[Layer + BaseLayer][BaseLevel].data(), Copy[Layer].size());
return Copy;
}
inline texture copy
(
texture2D const & Texture,
texture2D::size_type BaseLevel, texture2D::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
texture2D Copy(
Texture.format(),
texture2D::dim_type(Texture[BaseLevel].dimensions().x),
MaxLevel - BaseLevel + 1);
memcpy(Copy.data(), Texture[BaseLevel].data(), Copy.size());
return Copy;
}
inline texture copy
(
texture2DArray const & Texture,
texture2DArray::size_type BaseLayer, texture2DArray::size_type MaxMayer,
texture2DArray::size_type BaseLevel, texture2DArray::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseLayer <= MaxMayer);
assert(BaseLayer < Texture.layers());
assert(MaxMayer < Texture.layers());
texture2DArray Copy(
Texture.format(),
texture2DArray::dim_type(Texture[BaseLayer][BaseLevel].dimensions()),
MaxMayer - BaseLayer + 1,
MaxLevel - BaseLevel + 1);
for(texture2DArray::size_type Layer = 0; Layer < Copy.layers(); ++Layer)
memcpy(Copy[Layer].data(), Texture[Layer + BaseLayer][BaseLevel].data(), Copy[Layer].size());
return Copy;
}
inline texture copy
(
texture3D const & Texture,
texture3D::size_type BaseLevel, texture3D::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
texture3D Copy(
Texture.format(),
texture3D::dim_type(Texture[BaseLevel].dimensions()),
MaxLevel - BaseLevel + 1);
memcpy(Copy.data(), Texture[BaseLevel].data(), Copy.size());
return Copy;
}
inline texture copy
(
textureCube const & Texture,
textureCube::size_type BaseFace, textureCube::size_type MaxFace,
textureCube::size_type BaseLevel, textureCube::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseFace <= MaxFace);
assert(BaseFace < Texture.faces());
assert(MaxFace < Texture.faces());
textureCube Copy(
Texture.format(),
textureCube::dim_type(Texture[BaseFace][BaseLevel].dimensions()),
MaxLevel - BaseLevel + 1);
for(textureCube::size_type Face = 0; Face < Copy.faces(); ++Face)
memcpy(Copy[Face].data(), Texture[Face + BaseFace][BaseLevel].data(), Copy[Face].size());
return Copy;
}
inline texture copy
(
textureCubeArray const & Texture,
textureCubeArray::size_type BaseLayer, textureCubeArray::size_type MaxLayer,
textureCubeArray::size_type BaseFace, textureCubeArray::size_type MaxFace,
textureCubeArray::size_type BaseLevel, textureCubeArray::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseFace <= MaxFace);
assert(BaseFace < Texture.faces());
assert(MaxFace < Texture.faces());
assert(BaseLayer <= MaxLayer);
assert(BaseLayer < Texture.layers());
assert(MaxLayer < Texture.layers());
textureCubeArray Copy(
Texture.format(),
textureCubeArray::dim_type(Texture[BaseLayer][BaseFace][BaseLevel].dimensions()),
MaxLayer - BaseLayer + 1,
MaxLevel - BaseLevel + 1);
for(textureCubeArray::size_type Layer = 0; Layer < Copy.layers(); ++Layer)
for(textureCubeArray::size_type Face = 0; Face < Copy[Layer].faces(); ++Face)
memcpy(Copy[Layer][Face].data(), Texture[Layer + BaseLayer][Face + BaseFace][BaseLevel].data(), Copy[Layer][Face].size());
return Copy;
}
}//namespace gli

4
external/gli/gli/core/dummy.cpp vendored Normal file
View file

@ -0,0 +1,4 @@
int main()
{
}

243
external/gli/gli/core/dx.inl vendored Normal file
View file

@ -0,0 +1,243 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/dx.inl
/// @date 2013-11-09 / 2013-11-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline dx::dx()
{
static format const Table[] =
{
// unorm formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_UNORM, glm::u32vec4(0x00FF0000, 0x00000000, 0x00000000, 0x00000000)}, //R8_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x00000000, 0x00000000)}, //RG8_UNORM,
{DDPF_RGB, D3DFMT_R8G8B8, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)}, //RGB8_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //RGBA8_UNORM,
{DDPF_FOURCC, D3DFMT_L16, DXGI_FORMAT_R16_UNORM, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //R16_UNORM,
{DDPF_FOURCC, D3DFMT_G16R16, DXGI_FORMAT_R16G16_UNORM, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //RG16_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB16_UNORM,
{DDPF_FOURCC, D3DFMT_A16B16G16R16, DXGI_FORMAT_R16G16B16A16_UNORM, glm::u32vec4(0)}, //RGBA16_UNORM,
// snorm formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_SNORM, glm::u32vec4(0)}, //R8_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_SNORM, glm::u32vec4(0)}, //RG8_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB8_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_SNORM, glm::u32vec4(0)}, //RGBA8_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_SNORM, glm::u32vec4(0)}, //R16_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16_SNORM, glm::u32vec4(0)}, //RG16_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB16_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16B16A16_SNORM, glm::u32vec4(0)}, //RGBA16_SNORM,
// Unsigned integer formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_UINT, glm::u32vec4(0)}, //R8U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_UINT, glm::u32vec4(0)}, //RG8U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB8U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_UINT, glm::u32vec4(0)}, //RGBA8U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_UINT, glm::u32vec4(0)}, //R16U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16_UINT, glm::u32vec4(0)}, //RG16U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB16U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16B16A16_UINT, glm::u32vec4(0)}, //RGBA16U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32_UINT, glm::u32vec4(0)}, //R32U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32_UINT, glm::u32vec4(0)}, //RG32U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32_UINT, glm::u32vec4(0)}, //RGB32U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32A32_UINT, glm::u32vec4(0)}, //RGBA32U,
/// Signed integer formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_SINT, glm::u32vec4(0)}, //R8I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_SINT, glm::u32vec4(0)}, //RG8I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB8I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_SINT, glm::u32vec4(0)}, //RGBA8I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_SINT, glm::u32vec4(0)}, //R16I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16_SINT, glm::u32vec4(0)}, //RG16I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB16I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16B16A16_SINT, glm::u32vec4(0)}, //RGBA16I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32_SINT, glm::u32vec4(0)}, //R32I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32_SINT, glm::u32vec4(0)}, //RG32I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32_SINT, glm::u32vec4(0)}, //RGB32I,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32A32_SINT, glm::u32vec4(0)}, //RGBA32I,
/// Floating formats
{DDPF_FOURCC, D3DFMT_R16F, DXGI_FORMAT_R16_FLOAT, glm::u32vec4(0)}, //R16F,
{DDPF_FOURCC, D3DFMT_G16R16F, DXGI_FORMAT_R16G16_FLOAT, glm::u32vec4(0)}, //RG16F,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB16F,
{DDPF_FOURCC, D3DFMT_A16B16G16R16F, DXGI_FORMAT_R16G16B16A16_FLOAT, glm::u32vec4(0)}, //RGBA16F,
{DDPF_FOURCC, D3DFMT_R32F, DXGI_FORMAT_R32_FLOAT, glm::u32vec4(0xFFFFFFFF, 0x0000000, 0x0000000, 0x0000000)}, //R32F,
{DDPF_FOURCC, D3DFMT_G32R32F, DXGI_FORMAT_R32G32_FLOAT, glm::u32vec4(0)}, //RG32F,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32_FLOAT, glm::u32vec4(0)}, //RGB32F,
{DDPF_FOURCC, D3DFMT_A32B32G32R32F, DXGI_FORMAT_R32G32B32A32_FLOAT, glm::u32vec4(0)}, //RGBA32F,
/// sRGB formats
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //SR8,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //SRG8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, glm::u32vec4(0)}, //SRGB8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, glm::u32vec4(0)}, //SRGB8_ALPHA8,
/// Packed formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R10G10B10A2_UNORM, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //RGB10A2_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R10G10B10A2_UINT, glm::u32vec4(0)}, //RGB10A2U,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, glm::u32vec4(0)}, //RGB9E5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R11G11B10_FLOAT, glm::u32vec4(0)}, //RG11B10F,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0x70, 0x38, 0xC0, 0x00)}, //RG3B2,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B5G6R5_UNORM, glm::u32vec4(0xf800, 0x07e0, 0x001f, 0x0000)}, //R5G6B5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B5G5R5A1_UNORM, glm::u32vec4(0x7c00, 0x03e0, 0x001f, 0x8000)}, //RGB5A1,
{DDPF_FOURCC, D3DFMT_A4R4G4B4, DXGI_FORMAT_B4G4R4A4_UNORM, glm::u32vec4(0x0F00, 0x00F0, 0x000F, 0xF000)}, //RGBA4,
/// Swizzle formats
{DDPF_RGB, D3DFMT_R8G8B8, DXGI_FORMAT_B8G8R8X8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)}, //FORMAT_BGRX8_UNORM,
{DDPF_RGBA, D3DFMT_A8R8G8B8, DXGI_FORMAT_B8G8R8A8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //BGRA8_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)}, //SBGR8_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //SBGR8_ALPHA8_UNORM,
/// Luminance Alpha formats
{DDPF_LUMINANCE, D3DFMT_L8, DXGI_FORMAT_R8_UNORM, glm::u32vec4(0x000000FF, 0x00000000, 0x00000000, 0x00000000)}, //L8_UNORM,
{DDPF_ALPHA, D3DFMT_A8, DXGI_FORMAT_R8_UNORM, glm::u32vec4(0x00000000, 0x00000000, 0x00000000, 0x000000FF)}, //A8_UNORM,
{DDPF_LUMINANCE_ALPHA, D3DFMT_A8L8, DXGI_FORMAT_R8G8_UNORM, glm::u32vec4(0x000000FF, 0x00000000, 0x00000000, 0x0000FF00)}, //LA8_UNORM,
{DDPF_LUMINANCE, D3DFMT_L16, DXGI_FORMAT_R16_UNORM, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //L16_UNORM,
{DDPF_ALPHA, D3DFMT_UNKNOWN, DXGI_FORMAT_R16_UNORM, glm::u32vec4(0x00000000, 0x00000000, 0x00000000, 0x0000FFFF)}, //A16_UNORM,
{DDPF_LUMINANCE_ALPHA, D3DFMT_UNKNOWN, DXGI_FORMAT_R16_UNORM, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0xFFFF0000)}, //LA16_UNORM,
/// Depth formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D16_UNORM, glm::u32vec4(0)}, //D16,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //D24X8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D24_UNORM_S8_UINT, glm::u32vec4(0)}, //D24S8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D32_FLOAT, glm::u32vec4(0)}, //D32F,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, glm::u32vec4(0)}, //D32FS8X24,
/// Compressed formats
{DDPF_FOURCC, D3DFMT_DXT1, DXGI_FORMAT_BC1_UNORM, glm::u32vec4(0)}, //RGB_DXT1,
{DDPF_FOURCC_ALPHAPIXELS, D3DFMT_DXT1, DXGI_FORMAT_BC1_UNORM, glm::u32vec4(0)}, //RGBA_DXT1,
{DDPF_FOURCC_ALPHAPIXELS, D3DFMT_DXT3, DXGI_FORMAT_BC2_UNORM, glm::u32vec4(0)}, //RGBA_DXT3,
{DDPF_FOURCC_ALPHAPIXELS, D3DFMT_DXT5, DXGI_FORMAT_BC3_UNORM, glm::u32vec4(0)}, //RGBA_DXT5,
{DDPF_FOURCC, D3DFMT_ATI1, DXGI_FORMAT_BC4_UNORM, glm::u32vec4(0)}, //R_ATI1N_UNORM,
{DDPF_FOURCC, D3DFMT_AT1N, DXGI_FORMAT_BC4_SNORM, glm::u32vec4(0)}, //R_ATI1N_SNORM,
{DDPF_FOURCC, D3DFMT_ATI2, DXGI_FORMAT_BC5_UNORM, glm::u32vec4(0)}, //RG_ATI2N_UNORM,
{DDPF_FOURCC, D3DFMT_AT2N, DXGI_FORMAT_BC5_SNORM, glm::u32vec4(0)}, //RG_ATI2N_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC6H_UF16, glm::u32vec4(0)}, //RGB_BP_UF16,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC6H_SF16, glm::u32vec4(0)}, //RGB_BP_SF16,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC7_UNORM, glm::u32vec4(0)}, //RGB_BP_UNORM,
{DDPF_FOURCC, D3DFMT_POWERVR_4BPP, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB_PVRTC_4BPP,
{DDPF_FOURCC, D3DFMT_POWERVR_2BPP, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGB_PVRTC_2BPP,
{DDPF_FOURCC, D3DFMT_POWERVR_4BPP, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGBA_PVRTC_4BPP,
{DDPF_FOURCC, D3DFMT_POWERVR_2BPP, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGBA_PVRTC_2BPP,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGBA_PVRTC2_4BPP,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGBA_PVRTC2_2BPP,
{DDPF_FOURCC, D3DFMT_ATC, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //ATC_RGB,
{DDPF_FOURCC, D3DFMT_ATCA, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //ATC_RGBA_EXPLICIT_ALPHA,
{DDPF_FOURCC, D3DFMT_ATCI, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //ATC_RGBA_INTERPOLATED_ALPHA,
{DDPF_FOURCC, D3DFMT_ETC, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGB_ETC_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGB2_ETC_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGBA_ETC2_PUNCHTHROUGH_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RGBA_ETC2_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //R11_EAC_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //R11_EAC_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RG11_EAC_UNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //RG11_EAC_SNORM,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_4X4_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_4x4,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X4_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_5x4,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_5x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_6x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X6_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_6x6,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_8x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X6_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_8x6,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X8_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_8x8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X6_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x6,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X8_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X10_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x10,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X10_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_12x10,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X12_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_12x12,
// Compressed sRGB formats
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC1_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGB_DXT1_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC1_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA_DXT1_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC2_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA_DXT3_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC3_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA_DXT5_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC7_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGB_BP_SRGB,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGB_PVRTC1_8X8_SRGB,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGB_PVRTC1_16X8_SRGB,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC1_8X8_SRGB,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC1_16X8_SRGB,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC2_8X8_SRGB,
{DDPF_FOURCC, D3DFMT_UNKNOWN, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC2_16X8_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGB_ETC_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGBA_ETC2_PUNCHTHROUGH_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_UNKNOWN, glm::u32vec4(0)}, //FORMAT_RGBA_ETC2_SRGB,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_4X4_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_4x4,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X4_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_5x4,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_5x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_6x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X6_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_6x6,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_8x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X6_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_8x6,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X8_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_8x8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x5,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X6_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x6,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X8_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x8,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X10_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x10,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X10_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_12x10,
{DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X12_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_12x12,
};
static_assert(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats");
std::copy(&Table[0], &Table[0] + FORMAT_COUNT, this->Translation.begin());
}
inline dx::format const & dx::translate(gli::format const & Format) const
{
return Translation[Format];
}
inline gli::format dx::find(dx::D3DFORMAT FourCC)
{
for(int FormatIndex = 0; FormatIndex < FORMAT_COUNT; ++FormatIndex)
{
if(this->Translation[FormatIndex].D3DFormat != FourCC)
continue;
return static_cast<gli::format>(FormatIndex);
}
return static_cast<gli::format>(FORMAT_INVALID);
}
inline gli::format dx::find(dx::dxgiFormat Format)
{
for(int FormatIndex = 0; FormatIndex < FORMAT_COUNT; ++FormatIndex)
{
if(this->Translation[FormatIndex].DXGIFormat != Format)
continue;
return static_cast<gli::format>(FormatIndex);
}
return static_cast<gli::format>(FORMAT_INVALID);
}
}//namespace gli

62
external/gli/gli/core/fetch.hpp vendored Normal file
View file

@ -0,0 +1,62 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/fetch.hpp
/// @date 2008-12-19 / 2013-01-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../gli.hpp"
namespace gli
{
/// Fetch a texel from a texture
/// The texture format must be uncompressed
template <typename genType>
genType texel_fetch(
texture2D const & Texture,
texture2D::dim_type const & Texcoord,
texture2D::size_type const & Level);
/// Write a texel to a texture
/// The texture format must be uncompressed
template <typename genType>
void texel_write(
texture2D & Texture,
texture2D::dim_type const & Texcoord,
texture2D::size_type const & Level,
genType const & Color);
/// Sample a pixel from a texture
/// The texture format must be uncompressed
template <typename genType>
genType texture_lod(
texture2D const & Texture,
texture2D::texcoord_type const & Texcoord,
texture2D::size_type const & Level);
}//namespace gli
#include "fetch.inl"

107
external/gli/gli/core/fetch.inl vendored Normal file
View file

@ -0,0 +1,107 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/gtx/fetch.inl
/// @date 2008-12-19 / 2013-01-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
template <typename genType>
inline genType texel_fetch
(
texture2D const & Texture,
texture2D::dim_type const & TexCoord,
texture2D::size_type const & Level
)
{
assert(!Texture.empty());
assert(!is_compressed(Texture.format()));
assert(block_size(Texture.format()) == sizeof(genType));
image::dim_type Dimensions = Texture[Level].dimensions();
genType const * const Data = reinterpret_cast<genType const * const >(Texture[Level].data());
return reinterpret_cast<genType const * const>(Data)[TexCoord.x + TexCoord.y * Dimensions.x];
}
template <typename genType>
void texel_write
(
texture2D & Texture,
texture2D::dim_type const & Texcoord,
texture2D::size_type const & Level,
genType const & Color
)
{
assert(!Texture.empty());
assert(!is_compressed(Texture.format()));
assert(block_size(Texture.format()) == sizeof(genType));
genType * Data = Texture[Level].data<genType>();
std::size_t Index = Texcoord.x + Texcoord.y * Texture[Level].dimensions().x;
std::size_t Capacity = Texture[Level].size();
assert(Index < Capacity);
*(Data + Index) = Color;
}
template <typename genType>
inline genType texture_lod
(
texture2D const & Texture,
texture2D::texcoord_type const & Texcoord,
texture2D::size_type const & Level
)
{
//assert(Texture.format() == R8U || Texture.format() == RG8U || Texture.format() == RGB8U || Texture.format() == RGBA8U);
image::dim_type Dimensions = Texture[Level].dimensions();
genType const * const Data = reinterpret_cast<genType const * const>(Texture[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_below_normalized = s_below / float(Dimensions.x);
float t_below_normalized = t_below / 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));
}
}//namespace gli

41
external/gli/gli/core/flip.hpp vendored Normal file
View file

@ -0,0 +1,41 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/flip.hpp
/// @date 2014-01-17 / 2014-01-17
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../texture2d.hpp"
#include "../texture2d_array.hpp"
namespace gli
{
template <typename texture>
texture flip(texture const & Texture);
}//namespace gli
#include "flip.inl"

89
external/gli/gli/core/flip.inl vendored Normal file
View file

@ -0,0 +1,89 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/flip.inl
/// @date 2014-01-17 / 2014-01-17
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace detail
{
inline void flip(image ImageDst, image ImageSrc, std::size_t BlockSize)
{
std::size_t const LineSize = BlockSize * ImageDst.dimensions().x;
for(std::size_t y = 0; y < ImageDst.dimensions().y; ++y)
{
std::size_t OffsetDst = LineSize * y;
std::size_t OffsetSrc = ImageSrc.size() - (LineSize * (y + 1));
memcpy(
ImageDst.data<glm::byte>() + OffsetDst,
ImageSrc.data<glm::byte>() + OffsetSrc,
LineSize);
}
}
}//namespace detail
/*
template <>
inline image flip(image const & Image)
{
}
*/
template <>
inline texture2D flip(texture2D const & Texture)
{
assert(!gli::is_compressed(Texture.format()));
texture2D Flip(Texture.format(), Texture.dimensions(), Texture.levels());
gli::size_t const BlockSize = block_size(Texture.format());
for(std::size_t Level = 0; Level < Flip.levels(); ++Level)
detail::flip(Flip[Level], Texture[Level], BlockSize);
return Flip;
}
template <>
inline texture2DArray flip(texture2DArray const & Texture)
{
assert(!gli::is_compressed(Texture.format()));
texture2DArray Flip(Texture.format(), Texture.dimensions(), Texture.layers(), Texture.levels());
gli::size_t const BlockSize = block_size(Texture.format());
for(std::size_t Layer = 0; Layer < Flip.layers(); ++Layer)
for(std::size_t Level = 0; Level < Flip.levels(); ++Level)
detail::flip(Flip[Layer][Level], Texture[Layer][Level], BlockSize);
return Flip;
}
}//namespace gli

266
external/gli/gli/core/format.inl vendored Normal file
View file

@ -0,0 +1,266 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/format.inl
/// @date 2012-10-16 / 2015-06-16
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace detail
{
enum
{
CAP_COMPRESSED_BIT = (1 << 0),
CAP_PACKED_BIT = (1 << 1),
CAP_NORMALIZED_BIT = (1 << 2),
CAP_SCALED_BIT = (1 << 3),
CAP_UNSIGNED_BIT = (1 << 4),
CAP_SIGNED_BIT = (1 << 5),
CAP_INTEGER_BIT = (1 << 6),
CAP_FLOAT_BIT = (1 << 7),
CAP_DEPTH_BIT = (1 << 8),
CAP_STENCIL_BIT = (1 << 9),
CAP_COLORSPACE_SRGB_BIT = (1 << 10),
CAP_SWIZZLE_BIT = (1 << 11),
CAP_LUMINANCE_ALPHA_BIT = (1 << 12)
};
struct formatInfo
{
std::uint8_t BlockSize;
glm::u8vec3 BlockDimensions;
std::uint8_t Component;
std::uint16_t Flags;
};
inline formatInfo const & get_format_info(format Format)
{
static formatInfo const Table[] =
{
// unorm formats
{ 1, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R8_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 2, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG8_UNORM,
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB8_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA8_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R16_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG16_UNORM,
{ 6, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB16_UNORM,
{ 8, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA16_UNORM,
// snorm formats
{ 1, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R8_SNORM,
{ 2, glm::u8vec3(1, 1, 1), 2, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG8_SNORM,
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB8_SNORM,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA8_SNORM,
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SNORM,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SNORM,
{ 6, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB16_SNORM,
{ 8, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SNORM,
// Unsigned integer formats
{ 1, glm::u8vec3(1, 1, 1), 1, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R8_UINT,
{ 2, glm::u8vec3(1, 1, 1), 2, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG8_UINT,
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB8_UINT,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA8_UINT,
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R16_UINT,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG16_UINT,
{ 6, glm::u8vec3(1, 1, 1), 3, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB16_UINT,
{ 8, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA16_UINT,
{ 4, glm::u8vec3(1, 1, 1), 1, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R32_UINT,
{ 8, glm::u8vec3(1, 1, 1), 2, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG32_UINT,
{ 12, glm::u8vec3(1, 1, 1), 3, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB32_UINT,
{ 16, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA32_UINT,
/// Signed integer formats
{ 1, glm::u8vec3(1, 1, 1), 1, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R8_SINT,
{ 2, glm::u8vec3(1, 1, 1), 2, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG8_SINT,
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB8_SINT,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA8_SINT,
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SINT,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SINT,
{ 6, glm::u8vec3(1, 1, 1), 3, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB16_SINT,
{ 8, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SINT,
{ 4, glm::u8vec3(1, 1, 1), 1, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R32_SINT,
{ 8, glm::u8vec3(1, 1, 1), 2, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG32_SINT,
{ 12, glm::u8vec3(1, 1, 1), 3, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB32_SINT,
{ 16, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA32_SINT,
/// Floating formats
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SFLOAT,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SFLOAT,
{ 6, glm::u8vec3(1, 1, 1), 3, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB16_SFLOAT,
{ 8, glm::u8vec3(1, 1, 1), 4, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SFLOAT,
{ 4, glm::u8vec3(1, 1, 1), 1, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_R32_SFLOAT,
{ 8, glm::u8vec3(1, 1, 1), 2, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG32_SFLOAT,
{ 12, glm::u8vec3(1, 1, 1), 3, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB32_SFLOAT,
{ 16, glm::u8vec3(1, 1, 1), 4, CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA32_SFLOAT,
/// sRGB formats
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_R8_SRGB,
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_RG8_SRGB,
{ 3, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_RGB8_SRGB,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_RGBA8_SRGB,
/// Packed formats
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED_BIT}, //FORMAT_RGB10A2_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_PACKED_BIT}, //FORMAT_RGB10A2_UINT,
{ 4, glm::u8vec3(1, 1, 1), 3, CAP_PACKED_BIT | CAP_FLOAT_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB9E5_UFLOAT,
{ 4, glm::u8vec3(1, 1, 1), 3, CAP_PACKED_BIT | CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG11B10_UFLOAT,
{ 1, glm::u8vec3(1, 1, 1), 3, CAP_PACKED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG3B2_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 3, CAP_PACKED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R5G6B5_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 4, CAP_PACKED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB5A1_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 4, CAP_PACKED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA4_UNORM,
// Swizzle formats
{ 4, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGRX8_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGRA8_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 3, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_BGRX8_SRGB,
{ 4, glm::u8vec3(1, 1, 1), 4, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_BGRA8_SRGB,
// Luminance Alpha formats
{ 1, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT}, //FORMAT_L8_UNORM,
{ 1, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT}, //FORMAT_A8_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 2, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT}, //FORMAT_LA8_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT}, //FORMAT_L16_UNORM,
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT}, //FORMAT_A16_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT}, //FORMAT_LA16_UNORM,
/// Depth formats
{ 2, glm::u8vec3(1, 1, 1), 1, CAP_DEPTH_BIT | CAP_INTEGER_BIT}, //FORMAT_D16_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 1, CAP_DEPTH_BIT | CAP_INTEGER_BIT}, //FORMAT_D24_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 2, CAP_DEPTH_BIT | CAP_STENCIL_BIT}, //FORMAT_D24S8_UNORM,
{ 4, glm::u8vec3(1, 1, 1), 1, CAP_DEPTH_BIT | CAP_FLOAT_BIT}, //FORMAT_D32_UFLOAT,
{ 8, glm::u8vec3(1, 1, 1), 2, CAP_DEPTH_BIT | CAP_STENCIL_BIT | CAP_FLOAT_BIT}, //FORMAT_D32_UFLOAT_S8_UNORM,
/// Compressed formats
{ 8, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_DXT1_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT1_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT3_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT5_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 1, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R_ATI1N_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 1, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R_ATI1N_SNORM,
{ 16, glm::u8vec3(4, 4, 1), 2, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG_ATI2N_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 2, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG_ATI2N_SNORM,
{ 16, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_FLOAT_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_BP_UFLOAT,
{ 16, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB_BP_SFLOAT,
{ 16, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_BP_UNORM,
{ 32, glm::u8vec3(8, 8, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_PVRTC1_8X8_UNORM,
{ 32, glm::u8vec3(16, 8, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_PVRTC1_16X8_UNORM,
{ 32, glm::u8vec3(8, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC1_8X8_UNORM,
{ 32, glm::u8vec3(16, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC1_16X8_UNORM,
{ 32, glm::u8vec3(8, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC2_8X8_UNORM,
{ 32, glm::u8vec3(16, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC2_16X8_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_ATC_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ATC_EXPLICIT_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ATC_INTERPOLATED_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_ETC_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_ETC2_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ETC2_PUNCHTHROUGH_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ETC2_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 1, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R11_EAC_UNORM,
{ 8, glm::u8vec3(4, 4, 1), 1, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R11_EAC_SNORM,
{ 16, glm::u8vec3(4, 4, 1), 2, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG11_EAC_UNORM,
{ 16, glm::u8vec3(4, 4, 1), 2, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG11_EAC_SNORM,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_4X4_UNORM,
{ 16, glm::u8vec3(5, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X4_UNORM,
{ 16, glm::u8vec3(5, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X5_UNORM,
{ 16, glm::u8vec3(6, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X5_UNORM,
{ 16, glm::u8vec3(6, 6, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X6_UNORM,
{ 16, glm::u8vec3(8, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X5_UNORM,
{ 16, glm::u8vec3(8, 6, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X6_UNORM,
{ 16, glm::u8vec3(8, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X8_UNORM,
{ 16, glm::u8vec3(10, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X5_UNORM,
{ 16, glm::u8vec3(10, 6, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X6_UNORM,
{ 16, glm::u8vec3(10, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X8_UNORM,
{ 16, glm::u8vec3(10, 10, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X10_UNORM,
{ 16, glm::u8vec3(12, 10, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X10_UNORM,
{ 16, glm::u8vec3(12, 12, 1), 4, CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X12_UNORM,
// Compressed sRGB formats
{ 8, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_DXT1_SRGB,
{ 8, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT1_SRGB,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT3_SRGB,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT5_SRGB,
{ 16, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_BP_SRGB,
{ 32, glm::u8vec3(8, 8, 1), 3, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_PVRTC1_8X8_SRGB,
{ 32, glm::u8vec3(16, 8, 1), 3, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_PVRTC1_16X8_SRGB,
{ 32, glm::u8vec3(8, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC1_8X8_SRGB,
{ 32, glm::u8vec3(16, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC1_16X8_SRGB,
{ 32, glm::u8vec3(8, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC2_8X8_SRGB,
{ 32, glm::u8vec3(16, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_PVRTC2_16X8_SRGB,
{ 8, glm::u8vec3(4, 4, 1), 3, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_ETC2_SRGB,
{ 8, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ETC2_PUNCHTHROUGH_SRGB,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ETC2_SRGB,
{ 16, glm::u8vec3(4, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC4X4_SRGB,
{ 16, glm::u8vec3(5, 4, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC5X4_SRGB,
{ 16, glm::u8vec3(5, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC5X5_SRGB,
{ 16, glm::u8vec3(6, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC6X5_SRGB,
{ 16, glm::u8vec3(6, 6, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC6X6_SRGB,
{ 16, glm::u8vec3(8, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC8X5_SRGB,
{ 16, glm::u8vec3(8, 6, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC8X6_SRGB,
{ 16, glm::u8vec3(8, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC8X8_SRGB,
{ 16, glm::u8vec3(10, 5, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC10X5_SRGB,
{ 16, glm::u8vec3(10, 6, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC10X6_SRGB,
{ 16, glm::u8vec3(10, 8, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC10X8_SRGB,
{ 16, glm::u8vec3(10, 10, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC10X10_SRGB,
{ 16, glm::u8vec3(12, 10, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC12X10_SRGB,
{ 16, glm::u8vec3(12, 12, 1), 4, CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC12X12_SRGB,
};
GLM_STATIC_ASSERT(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats");
assert(Format != static_cast<format>(FORMAT_INVALID));
return Table[Format];
};
inline std::uint32_t bits_per_pixel(format Format)
{
detail::formatInfo const & Info = detail::get_format_info(Format);
return Info.BlockSize * 8 / (Info.BlockDimensions.x * Info.BlockDimensions.y * Info.BlockDimensions.z);
}
}//namespace detail
inline std::uint32_t block_size(format Format)
{
return detail::get_format_info(Format).BlockSize;
}
inline gli::dim3_t block_dimensions(format Format)
{
return gli::dim3_t(detail::get_format_info(Format).BlockDimensions);
}
inline std::uint32_t component_count(format Format)
{
return detail::get_format_info(Format).Component;
}
}//namespace gli

View file

@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/generate_mipmaps.hpp
/// @date 2010-09-27 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../texture2d.hpp"
namespace gli
{
template <typename texture>
texture generate_mipmaps(texture & Texture);
}//namespace gli
#include "generate_mipmaps.inl"

View file

@ -0,0 +1,78 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/generate_mipmaps.inl
/// @date 2010-09-27 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace detail
{
}//namespace detail
template <>
inline texture2D generate_mipmaps(texture2D & Texture)
{
texture2D Result(Texture.format(), Texture.dimensions());
texture2D::size_type const Components(gli::component_count(Result.format()));
for(texture2D::size_type Level = Texture.base_level(); Level < Texture.max_level(); ++Level)
{
// Src
std::size_t BaseWidth = Result[Level].dimensions().x;
void * DataSrc = Result[Level + 0].data();
// Dst
texture2D::dim_type LevelDimensions = texture2D::dim_type(Result[Level].dimensions()) >> texture2D::dim_type(1);
LevelDimensions = glm::max(LevelDimensions, texture2D::dim_type(1));
void * DataDst = Result[Level + 1].data();
for(std::size_t j = 0; j < LevelDimensions.y; ++j)
for(std::size_t i = 0; i < LevelDimensions.x; ++i)
for(std::size_t c = 0; c < Components; ++c)
{
std::size_t x = (i << 1);
std::size_t y = (j << 1);
std::size_t Index00 = ((x + 0) + (y + 0) * BaseWidth) * Components + c;
std::size_t Index01 = ((x + 0) + (y + 1) * BaseWidth) * Components + c;
std::size_t Index11 = ((x + 1) + (y + 1) * BaseWidth) * Components + c;
std::size_t Index10 = ((x + 1) + (y + 0) * BaseWidth) * Components + c;
glm::u32 Data00 = reinterpret_cast<glm::byte *>(DataSrc)[Index00];
glm::u32 Data01 = reinterpret_cast<glm::byte *>(DataSrc)[Index01];
glm::u32 Data11 = reinterpret_cast<glm::byte *>(DataSrc)[Index11];
glm::u32 Data10 = reinterpret_cast<glm::byte *>(DataSrc)[Index10];
std::size_t IndexDst = (x + y * LevelDimensions.x) * Components + c;
*(reinterpret_cast<glm::byte *>(DataDst) + IndexDst) = (Data00 + Data01 + Data11 + Data10) >> 2;
}
}
return Result;
}
}//namespace gli

257
external/gli/gli/core/gl.inl vendored Normal file
View file

@ -0,0 +1,257 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/gl.inl
/// @date 2013-11-09 / 2013-11-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <algorithm>
namespace gli
{
inline gl::gl()
{
static format const Table[] =
{
// unorm formats
{INTERNAL_R8_UNORM, EXTERNAL_RED, TYPE_U8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R8_UNORM,
{INTERNAL_RG8_UNORM, EXTERNAL_RG, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG8_UNORM,
{INTERNAL_RGB8_UNORM, EXTERNAL_RGB, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB8_UNORM,
{INTERNAL_RGBA8_UNORM, EXTERNAL_RGBA, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA8_UNORM,
{INTERNAL_R16_UNORM, EXTERNAL_RED, TYPE_U16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R16_UNORM,
{INTERNAL_RG16_UNORM, EXTERNAL_RG, TYPE_U16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG16_UNORM,
{INTERNAL_RGB16_UNORM, EXTERNAL_RGB, TYPE_U16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB16_UNORM,
{INTERNAL_RGBA16_UNORM, EXTERNAL_RGBA, TYPE_U16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA16_UNORM,
// snorm formats
{INTERNAL_R8_SNORM, EXTERNAL_RED, TYPE_I8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R8_SNORM,
{INTERNAL_RG8_SNORM, EXTERNAL_RG, TYPE_I8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG8_SNORM,
{INTERNAL_RGB8_SNORM, EXTERNAL_RGB, TYPE_I8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB8_SNORM,
{INTERNAL_RGBA8_SNORM, EXTERNAL_RGBA, TYPE_I8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA8_SNORM,
{INTERNAL_R16_SNORM, EXTERNAL_RED, TYPE_I16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R16_SNORM,
{INTERNAL_RG16_SNORM, EXTERNAL_RG, TYPE_I16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG16_SNORM,
{INTERNAL_RGB16_SNORM, EXTERNAL_RGB, TYPE_I16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB16_SNORM,
{INTERNAL_RGBA16_SNORM, EXTERNAL_RGBA, TYPE_I16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA16_SNORM,
// Unsigned integer formats
{INTERNAL_R8U, EXTERNAL_RED_INTEGER, TYPE_U8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R8U,
{INTERNAL_RG8U, EXTERNAL_RG_INTEGER, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG8U,
{INTERNAL_RGB8U, EXTERNAL_RGB_INTEGER, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB8U,
{INTERNAL_RGBA8U, EXTERNAL_RGBA_INTEGER, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA8U,
{INTERNAL_R16U, EXTERNAL_RED_INTEGER, TYPE_U16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R16U,
{INTERNAL_RG16U, EXTERNAL_RG_INTEGER, TYPE_U16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG16U,
{INTERNAL_RGB16U, EXTERNAL_RGB_INTEGER, TYPE_U16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB16U,
{INTERNAL_RGBA16U, EXTERNAL_RGBA_INTEGER, TYPE_U16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA16U,
{INTERNAL_R32U, EXTERNAL_RED_INTEGER, TYPE_U32, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R32U,
{INTERNAL_RG32U, EXTERNAL_RG_INTEGER, TYPE_U32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG32U,
{INTERNAL_RGB32U, EXTERNAL_RGB_INTEGER, TYPE_U32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB32U,
{INTERNAL_RGBA32U, EXTERNAL_RGBA_INTEGER, TYPE_U32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA32U,
/// Signed integer formats
{INTERNAL_R8I, EXTERNAL_RED_INTEGER, TYPE_I8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R8I,
{INTERNAL_RG8I, EXTERNAL_RG_INTEGER, TYPE_I8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG8I,
{INTERNAL_RGB8I, EXTERNAL_RGB_INTEGER, TYPE_I8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB8I,
{INTERNAL_RGBA8I, EXTERNAL_RGBA_INTEGER, TYPE_I8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA8I,
{INTERNAL_R16I, EXTERNAL_RED_INTEGER, TYPE_I16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R16I,
{INTERNAL_RG16I, EXTERNAL_RG_INTEGER, TYPE_I16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG16I,
{INTERNAL_RGB16I, EXTERNAL_RGB_INTEGER, TYPE_I16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB16I,
{INTERNAL_RGBA16I, EXTERNAL_RGBA_INTEGER, TYPE_I16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA16I,
{INTERNAL_R32I, EXTERNAL_RED_INTEGER, TYPE_I32, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R32I,
{INTERNAL_RG32I, EXTERNAL_RG_INTEGER, TYPE_I32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG32I,
{INTERNAL_RGB32I, EXTERNAL_RGB_INTEGER, TYPE_I32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB32I,
{INTERNAL_RGBA32I, EXTERNAL_RGBA_INTEGER, TYPE_I32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA32I,
/// Floating formats
{INTERNAL_R16F, EXTERNAL_RED, TYPE_F16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R16F,
{INTERNAL_RG16F, EXTERNAL_RG, TYPE_F16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG16F,
{INTERNAL_RGB16F, EXTERNAL_RGB, TYPE_F16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB16F,
{INTERNAL_RGBA16F, EXTERNAL_RGBA, TYPE_F16, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA16F,
{INTERNAL_R32F, EXTERNAL_RED, TYPE_F32, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R32F,
{INTERNAL_RG32F, EXTERNAL_RG, TYPE_F32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG32F,
{INTERNAL_RGB32F, EXTERNAL_RGB, TYPE_F32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB32F,
{INTERNAL_RGBA32F, EXTERNAL_RGBA, TYPE_F32, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA32F,
/// sRGB formats
{INTERNAL_SR8, EXTERNAL_RED, TYPE_U8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //SR8_UNORM,
{INTERNAL_SRG8, EXTERNAL_RG, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //SRG8_UNORM,
{INTERNAL_SRGB8, EXTERNAL_RGB, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //SRGB8_UNORM,
{INTERNAL_SRGB8_ALPHA8, EXTERNAL_RGBA, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_UNORM,
/// Packed formats
{INTERNAL_RGB10A2_UNORM, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGB10A2_UNORM,
{INTERNAL_RGB10A2U, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGB10A2, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGB10A2U,
{INTERNAL_RGB9E5, EXTERNAL_RGB, TYPE_UINT32_RGB9_E5, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB9E5,
{INTERNAL_RG11B10F, EXTERNAL_RGB, TYPE_UINT32_RG11B10F, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RG11B10F,
{INTERNAL_RG3B2, EXTERNAL_RGB, TYPE_UINT8_RG3B2, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RG3B2,
{INTERNAL_R5G6B5, EXTERNAL_RGB, TYPE_UINT16_R5G6B5, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //R5G6B5,
{INTERNAL_RGB5A1, EXTERNAL_RGBA, TYPE_UINT16_RGB5A1, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGB5A1,
{INTERNAL_RGBA4, EXTERNAL_RGBA, TYPE_UINT16_RGBA4, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA4,
// Swizzle formats
{INTERNAL_RGB8_UNORM, EXTERNAL_BGRA, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //FORMAT_BGRX8_UNORM,
{INTERNAL_RGBA8_UNORM, EXTERNAL_BGRA, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //FORMAT_BGRA8_UNORM,
{INTERNAL_SRGB8, EXTERNAL_BGRA, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //FORMAT_BGRX8_SRGB,
{INTERNAL_SRGB8_ALPHA8, EXTERNAL_BGRA, TYPE_U8, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //FORMAT_BGRA8_SRGB,
// Luminance Alpha formats
{INTERNAL_RG8_UNORM, EXTERNAL_RED, TYPE_U8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //L8_UNORM,
{INTERNAL_RGB8_UNORM, EXTERNAL_RED, TYPE_U8, {SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_RED}}, //A8_UNORM,
{INTERNAL_RG8_UNORM, EXTERNAL_RG, TYPE_U8, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_GREEN}}, //LA8_UNORM,
{INTERNAL_R16_UNORM, EXTERNAL_RED, TYPE_U16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //L16_UNORM,
{INTERNAL_R16_UNORM, EXTERNAL_RED, TYPE_U16, {SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_RED}}, //A16_UNORM,
{INTERNAL_RG16_UNORM, EXTERNAL_RG, TYPE_U16, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_GREEN}}, //LA16_UNORM,
/// Depth formats
{INTERNAL_D16, EXTERNAL_DEPTH, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //D16,
{INTERNAL_D24, EXTERNAL_DEPTH, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //D24X8,
{INTERNAL_D24S8, EXTERNAL_DEPTH_STENCIL, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //D24S8,
{INTERNAL_D32F, EXTERNAL_DEPTH, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //D32F,
{INTERNAL_D32FS8X24, EXTERNAL_DEPTH_STENCIL, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //D32FS8X24,
/// Compressed formats
{INTERNAL_RGB_DXT1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB_DXT1_UNORM,
{INTERNAL_RGBA_DXT1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_DXT1_UNORM,
{INTERNAL_RGBA_DXT3, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_DXT3_UNORM,
{INTERNAL_RGBA_DXT5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_DXT5_UNORM,
{INTERNAL_R_ATI1N_UNORM, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R_ATI1N_UNORM,
{INTERNAL_R_ATI1N_SNORM, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE}}, //R_ATI1N_SNORM,
{INTERNAL_RG_ATI2N_UNORM, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG_ATI2N_UNORM,
{INTERNAL_RG_ATI2N_SNORM, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE}}, //RG_ATI2N_SNORM,
{INTERNAL_RGB_BP_UNSIGNED_FLOAT, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB_BP_UF16,
{INTERNAL_RGB_BP_SIGNED_FLOAT, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB_BP_SF16,
{INTERNAL_RGB_BP_UNORM, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB_BP_UNORM,
{INTERNAL_RGB_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB_PVRTC_4BPP_UNORM,
{INTERNAL_RGB_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //RGB_PVRTC_2BPP_UNORM,
{INTERNAL_RGBA_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_PVRTC_4BPP_UNORM,
{INTERNAL_RGBA_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_PVRTC_2BPP_UNORM,
{INTERNAL_RGBA_PVRTC_4BPPV2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_PVRTC2_4BPP_UNORM,
{INTERNAL_RGBA_PVRTC_2BPPV2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_PVRTC2_2BPP_UNORM,
{INTERNAL_ATC_RGB, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //ATC_RGB_UNORM,
{INTERNAL_ATC_RGBA_EXPLICIT_ALPHA, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //ATC_RGBA_EXPLICIT_ALPHA_UNORM,
{INTERNAL_ATC_RGBA_INTERPOLATED_ALPHA, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //ATC_RGBA_INTERPOLATED_ALPHA_UNORM,
{INTERNAL_RGB_ETC, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //FORMAT_RGB_ETC_UNORM,
{INTERNAL_RGB_ETC2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //FORMAT_RGB_ETC2_UNORM,
{INTERNAL_RGBA_PUNCHTHROUGH_ETC2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //FORMAT_RGBA_ETC2_PUNCHTHROUGH_UNORM,
{INTERNAL_RGBA_ETC2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //FORMAT_RGBA_ETC2_UNORM,
{INTERNAL_R11_EAC, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //R11_EAC_UNORM,
{INTERNAL_SIGNED_R11_EAC, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //R11_EAC_SNORM,
{INTERNAL_RG11_EAC, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RG11_EAC_UNORM,
{INTERNAL_SIGNED_RG11_EAC, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RG11_EAC_SNORM,
{INTERNAL_RGBA_ASTC_4x4, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_4x4_UNORM,
{INTERNAL_RGBA_ASTC_5x4, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_5x4_UNORM,
{INTERNAL_RGBA_ASTC_5x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_5x5_UNORM,
{INTERNAL_RGBA_ASTC_6x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_6x5_UNORM,
{INTERNAL_RGBA_ASTC_6x6, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_6x6_UNORM,
{INTERNAL_RGBA_ASTC_8x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_8x5_UNORM,
{INTERNAL_RGBA_ASTC_8x6, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_8x6_UNORM,
{INTERNAL_RGBA_ASTC_8x8, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_8x8_UNORM,
{INTERNAL_RGBA_ASTC_10x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_10x5_UNORM,
{INTERNAL_RGBA_ASTC_10x6, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_10x6_UNORM,
{INTERNAL_RGBA_ASTC_10x8, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_10x8_UNORM,
{INTERNAL_RGBA_ASTC_10x10, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_10x10_UNORM,
{INTERNAL_RGBA_ASTC_12x10, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_12x10_UNORM,
{INTERNAL_RGBA_ASTC_12x12, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //RGBA_ASTC_12x12_UNORM,
// sRGB compressed formats
{INTERNAL_SRGB_DXT1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //SRGB_DXT1_UNORM,
{INTERNAL_SRGB_ALPHA_DXT1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_DXT1_UNORM,
{INTERNAL_SRGB_ALPHA_DXT3, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_DXT3_UNORM,
{INTERNAL_SRGB_ALPHA_DXT5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_DXT5_UNORM,
{INTERNAL_SRGB_BP_UNORM, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //SRGB_BP_UNORM,
{INTERNAL_SRGB_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //SRGB_PVRTC_4BPP_UNORM,
{INTERNAL_SRGB_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE}}, //SRGB_PVRTC_2BPP_UNORM,
{INTERNAL_SRGB_ALPHA_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_ALPHA_PVRTC_4BPP_UNORM,
{INTERNAL_SRGB_ALPHA_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_ALPHA_PVRTC_2BPP_UNORM,
{INTERNAL_SRGB_ALPHA_PVRTC_2BPPV2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_ALPHA_PVRTC2_4BPP_UNORM,
{INTERNAL_SRGB_ALPHA_PVRTC_4BPPV2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_ALPHA_PVRTC2_2BPP_UNORM,
{INTERNAL_SRGB8_ETC2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_ETC2_UNORM,
{INTERNAL_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB_ETC2_PUNCHTHROUGH_ALPHA_UNORM,
{INTERNAL_SRGB8_ALPHA8_ETC2_EAC, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGBA_ETC2_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_4x4, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_4x4_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_5x4, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_5x4_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_5x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_5x5_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_6x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_6x5_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_6x6, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_6x6_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_8x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_8x5_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_8x6, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_8x6_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_8x8, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_8x8_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_10x5, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_10x5_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_10x6, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_10x6_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_10x8, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_10x8_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_10x10, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_10x10_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_12x10, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_12x10_UNORM,
{INTERNAL_SRGB8_ALPHA8_ASTC_12x12, EXTERNAL_NONE, TYPE_NONE, {SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA}}, //SRGB8_ALPHA8_ASTC_12x12_UNORM,
};
static_assert(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats");
std::copy(&Table[0], &Table[0] + FORMAT_COUNT, this->Translation.begin());
}
inline gl::target const & gl::translate(gli::target Target) const
{
static gl::target const Table[] =
{
gl::TARGET_1D,
gl::TARGET_1D_ARRAY,
gl::TARGET_2D,
gl::TARGET_2D_ARRAY,
gl::TARGET_3D,
gl::TARGET_CUBE,
gl::TARGET_CUBE_ARRAY
};
static_assert(sizeof(Table) / sizeof(Table[0]) == TARGET_COUNT, "GLI error: format descriptor list doesn't match number of supported formats");
return Table[Target];
}
inline gl::format const & gl::translate(gli::format Format) const
{
return this->Translation[Format];
}
inline gli::format gl::find(gl::internalFormat InternalFormat, gl::externalFormat ExternalFormat, gl::typeFormat Type)
{
for (int FormatIndex = 0; FormatIndex < FORMAT_COUNT; ++FormatIndex)
{
if (this->Translation[FormatIndex].Internal != InternalFormat)
continue;
if (this->Translation[FormatIndex].External != ExternalFormat)
continue;
if (this->Translation[FormatIndex].Type != Type)
continue;
return static_cast<gli::format>(FormatIndex);
}
return static_cast<gli::format>(FORMAT_INVALID);
}
}//namespace gli

278
external/gli/gli/core/image.inl vendored Normal file
View file

@ -0,0 +1,278 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/image.inl
/// @date 2011-10-06 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace detail
{
inline size_t texelLinearAdressing
(
dim1_t const & Dimensions,
dim1_t const & TexelCoord
)
{
assert(glm::all(glm::lessThan(TexelCoord, Dimensions)));
return TexelCoord.x;
}
inline size_t texelLinearAdressing
(
dim2_t const & Dimensions,
dim2_t const & TexelCoord
)
{
assert(TexelCoord.x < Dimensions.x);
assert(TexelCoord.y < Dimensions.y);
return TexelCoord.x + Dimensions.x * TexelCoord.y;
}
inline size_t texelLinearAdressing
(
dim3_t const & Dimensions,
dim3_t const & TexelCoord
)
{
assert(TexelCoord.x < Dimensions.x);
assert(TexelCoord.y < Dimensions.y);
assert(TexelCoord.z < Dimensions.z);
return TexelCoord.x + Dimensions.x * (TexelCoord.y + Dimensions.y * TexelCoord.z);
}
inline size_t texelMortonAdressing
(
dim1_t const & Dimensions,
dim1_t const & TexelCoord
)
{
assert(TexelCoord.x < Dimensions.x);
return TexelCoord.x;
}
inline size_t texelMortonAdressing
(
dim2_t const & Dimensions,
dim2_t const & TexelCoord
)
{
assert(TexelCoord.x < Dimensions.x && TexelCoord.x < std::numeric_limits<std::uint32_t>::max());
assert(TexelCoord.y < Dimensions.y && TexelCoord.y < std::numeric_limits<std::uint32_t>::max());
glm::u32vec2 const Input(TexelCoord);
return glm::bitfieldInterleave(Input.x, Input.y);
}
inline size_t texelMortonAdressing
(
dim3_t const & Dimensions,
dim3_t const & TexelCoord
)
{
assert(TexelCoord.x < Dimensions.x);
assert(TexelCoord.y < Dimensions.y);
assert(TexelCoord.z < Dimensions.z);
glm::u32vec3 const Input(TexelCoord);
return glm::bitfieldInterleave(Input.x, Input.y, Input.z);
}
}//namespace detail
inline image::image()
: Format(static_cast<gli::format>(FORMAT_INVALID))
, BaseLevel(0)
, Data(nullptr)
, Size(0)
{}
inline image::image
(
format_type Format,
dim_type const & Dimensions
)
: Storage(std::make_shared<storage>(Format, Dimensions, 1, 1, 1))
, Format(Format)
, BaseLevel(0)
, Data(Storage->data())
, Size(compute_size(0))
{}
inline image::image
(
std::shared_ptr<storage> Storage,
format_type Format,
size_type BaseLayer,
size_type BaseFace,
size_type BaseLevel
)
: Storage(Storage)
, Format(Format)
, BaseLevel(BaseLevel)
, Data(compute_data(BaseLayer, BaseFace, BaseLevel))
, Size(compute_size(BaseLevel))
{}
inline image::image
(
image const & Image,
format_type Format
)
: Storage(Image.Storage)
, Format(Format)
, BaseLevel(Image.BaseLevel)
, Data(Image.Data)
, Size(Image.Size)
{
assert(block_size(Format) == block_size(Image.format()));
}
inline bool image::empty() const
{
if(this->Storage.get() == nullptr)
return true;
return this->Storage->empty();
}
inline image::size_type image::size() const
{
assert(!this->empty());
return this->Size;
}
template <typename genType>
inline image::size_type image::size() const
{
assert(sizeof(genType) <= this->Storage->block_size());
return this->size() / sizeof(genType);
}
inline image::format_type image::format() const
{
return this->Format;
}
inline image::dim_type image::dimensions() const
{
assert(!this->empty());
return this->Storage->dimensions(this->BaseLevel);
//return this->Storage->block_count(this->BaseLevel) * block_dimensions(this->format());
}
inline void * image::data()
{
assert(!this->empty());
return this->Data;
}
inline void const * image::data() const
{
assert(!this->empty());
return this->Data;
}
template <typename genType>
inline genType * image::data()
{
assert(!this->empty());
assert(this->Storage->block_size() >= sizeof(genType));
return reinterpret_cast<genType *>(this->data());
}
template <typename genType>
inline genType const * image::data() const
{
assert(!this->empty());
assert(this->Storage->block_size() >= sizeof(genType));
return reinterpret_cast<genType const *>(this->data());
}
inline void image::clear()
{
assert(!this->empty());
memset(this->data<glm::byte>(), 0, this->size<glm::byte>());
}
template <typename genType>
inline void image::clear(genType const & Texel)
{
assert(!this->empty());
assert(this->Storage->block_size() == sizeof(genType));
for(size_type TexelIndex = 0; TexelIndex < this->size<genType>(); ++TexelIndex)
*(this->data<genType>() + TexelIndex) = Texel;
}
inline image::data_type * image::compute_data(size_type BaseLayer, size_type BaseFace, size_type BaseLevel)
{
size_type const Offset = this->Storage->offset(BaseLayer, BaseFace, BaseLevel);
return this->Storage->data() + Offset;
}
inline image::size_type image::compute_size(size_type Level) const
{
assert(!this->empty());
return this->Storage->level_size(Level);
}
template <typename genType>
genType image::load(dim_type const & TexelCoord)
{
assert(!this->empty());
assert(!is_compressed(this->format()));
assert(this->Storage->block_size() == sizeof(genType));
assert(glm::all(glm::lessThan(TexelCoord, this->dimensions())));
return *(this->data<genType>() + detail::texelLinearAdressing(this->dimensions(), TexelCoord));
}
template <typename genType>
void image::store(dim_type const & TexelCoord, genType const & Data)
{
assert(!this->empty());
assert(!is_compressed(this->format()));
assert(this->Storage->block_size() == sizeof(genType));
assert(glm::all(glm::lessThan(TexelCoord, this->dimensions())));
*(this->data<genType>() + detail::texelLinearAdressing(this->dimensions(), TexelCoord)) = Data;
}
}//namespace gli

43
external/gli/gli/core/levels.inl vendored Normal file
View file

@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2014 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/levels.inl
/// @date 2014-12-12 / 2014-12-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/component_wise.hpp>
namespace gli
{
template <template <typename, glm::precision> class dimType>
inline size_t levels(dimType<size_t, glm::defaultp> const & Dimensions)
{
return glm::log2(glm::compMax(Dimensions)) + static_cast<size_t>(1);
}
inline size_t levels(size_t Dimensions)
{
return glm::log2(Dimensions) + static_cast<size_t>(1);
}
}//namespace gli

69
external/gli/gli/core/load.inl vendored Normal file
View file

@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/load.inl
/// @date 2015-08-09 / 2015-08-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../load_dds.hpp"
#include "../load_ktx.hpp"
namespace gli
{
inline texture load(char const * Data, std::size_t Size)
{
{
texture Texture = load_dds(Data, Size);
if(!Texture.empty())
return Texture;
}
{
return load_ktx(Data, Size);
}
}
inline texture load(char const * Filename)
{
FILE* File = std::fopen(Filename, "rb");
if(!File)
return texture();
long Beg = std::ftell(File);
std::fseek(File, 0, SEEK_END);
long End = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::vector<char> Data(static_cast<std::size_t>(End - Beg));
std::fread(&Data[0], 1, Data.size(), File);
std::fclose(File);
return load(&Data[0], Data.size());
}
inline texture load(std::string const & Filename)
{
return load(Filename.c_str());
}
}//namespace gli

302
external/gli/gli/core/load_dds.inl vendored Normal file
View file

@ -0,0 +1,302 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/load_dds.inl
/// @date 2010-09-26 / 2015-06-16
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../dx.hpp"
#include <cstdio>
#include <cassert>
namespace gli{
namespace detail
{
enum ddsCubemapflag
{
DDSCAPS2_CUBEMAP = 0x00000200,
DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400,
DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800,
DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000,
DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000,
DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000,
DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000,
DDSCAPS2_VOLUME = 0x00200000
};
enum
{
DDSCAPS2_CUBEMAP_ALLFACES = DDSCAPS2_CUBEMAP_POSITIVEX | DDSCAPS2_CUBEMAP_NEGATIVEX | DDSCAPS2_CUBEMAP_POSITIVEY | DDSCAPS2_CUBEMAP_NEGATIVEY | DDSCAPS2_CUBEMAP_POSITIVEZ | DDSCAPS2_CUBEMAP_NEGATIVEZ
};
enum ddsFlag
{
DDSD_CAPS = 0x00000001,
DDSD_HEIGHT = 0x00000002,
DDSD_WIDTH = 0x00000004,
DDSD_PITCH = 0x00000008,
DDSD_PIXELFORMAT = 0x00001000,
DDSD_MIPMAPCOUNT = 0x00020000,
DDSD_LINEARSIZE = 0x00080000,
DDSD_DEPTH = 0x00800000
};
enum ddsSurfaceflag
{
DDSCAPS_COMPLEX = 0x00000008,
DDSCAPS_MIPMAP = 0x00400000,
DDSCAPS_TEXTURE = 0x00001000
};
struct ddsPixelFormat
{
std::uint32_t size; // 32
dx::DDPF flags;
dx::D3DFORMAT fourCC;
std::uint32_t bpp;
glm::u32vec4 Mask;
};
struct ddsHeader
{
char Magic[4];
std::uint32_t Size;
std::uint32_t Flags;
std::uint32_t Height;
std::uint32_t Width;
std::uint32_t Pitch;
std::uint32_t Depth;
std::uint32_t MipMapLevels;
std::uint32_t Reserved1[11];
ddsPixelFormat Format;
std::uint32_t SurfaceFlags;
std::uint32_t CubemapFlags;
std::uint32_t Reserved2[3];
};
static_assert(sizeof(ddsHeader) == 128, "DDS Header size mismatch");
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 = 0x01,
D3D10_RESOURCE_MISC_SHARED = 0x02,
D3D10_RESOURCE_MISC_TEXTURECUBE = 0x04,
D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10,
D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20,
};
enum
{
DDS_ALPHA_MODE_UNKNOWN = 0x0,
DDS_ALPHA_MODE_STRAIGHT = 0x1,
DDS_ALPHA_MODE_PREMULTIPLIED = 0x2,
DDS_ALPHA_MODE_OPAQUE = 0x3,
DDS_ALPHA_MODE_CUSTOM = 0x4
};
struct ddsHeader10
{
ddsHeader10() :
Format(dx::DXGI_FORMAT_UNKNOWN),
ResourceDimension(D3D10_RESOURCE_DIMENSION_UNKNOWN),
MiscFlag(0),
ArraySize(0),
Reserved(0)
{}
dx::dxgiFormat Format;
D3D10_RESOURCE_DIMENSION ResourceDimension;
std::uint32_t MiscFlag; // D3D10_RESOURCE_MISC_GENERATE_MIPS
std::uint32_t ArraySize;
std::uint32_t Reserved;
};
static_assert(sizeof(ddsHeader10) == 20, "DDS DX10 Extended Header size mismatch");
inline target getTarget(ddsHeader const & Header, ddsHeader10 const & Header10)
{
if(Header.CubemapFlags & detail::DDSCAPS2_CUBEMAP)
{
if(Header10.ArraySize > 1)
return TARGET_CUBE_ARRAY;
else
return TARGET_CUBE;
}
else if(Header10.ArraySize > 1)
{
if(Header.Flags & detail::DDSD_HEIGHT)
return TARGET_2D_ARRAY;
else
return TARGET_1D_ARRAY;
}
else if(Header10.ResourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE1D)
return TARGET_1D;
else if(Header10.ResourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE3D || Header.Flags & detail::DDSD_DEPTH)
return TARGET_3D;
else
return TARGET_2D;
}
}//namespace detail
inline texture load_dds(char const * Data, std::size_t Size)
{
assert(Data && (Size >= sizeof(detail::ddsHeader)));
detail::ddsHeader const & Header(*reinterpret_cast<detail::ddsHeader const *>(Data));
if(strncmp(Header.Magic, "DDS ", 4) != 0)
return texture();
size_t Offset = sizeof(detail::ddsHeader);
detail::ddsHeader10 Header10;
if(Header.Format.flags & dx::DDPF_FOURCC && Header.Format.fourCC == dx::D3DFMT_DX10)
{
std::memcpy(&Header10, Data + Offset, sizeof(Header10));
Offset += sizeof(detail::ddsHeader10);
}
dx DX;
gli::format Format(static_cast<gli::format>(gli::FORMAT_INVALID));
if((Header.Format.flags & (dx::DDPF_RGB | dx::DDPF_ALPHAPIXELS | dx::DDPF_ALPHA | dx::DDPF_YUV | dx::DDPF_LUMINANCE)) && Format == static_cast<format>(gli::FORMAT_INVALID) && Header.Format.flags != dx::DDPF_FOURCC_ALPHAPIXELS)
{
switch(Header.Format.bpp)
{
case 8:
{
if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_L8_UNORM).Mask)))
Format = FORMAT_L8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_A8_UNORM).Mask)))
Format = FORMAT_A8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R8_UNORM).Mask)))
Format = FORMAT_R8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG3B2_UNORM).Mask)))
Format = FORMAT_RG3B2_UNORM;
break;
}
case 16:
{
if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_LA8_UNORM).Mask)))
Format = FORMAT_LA8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG8_UNORM).Mask)))
Format = FORMAT_RG8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R5G6B5_UNORM).Mask)))
Format = FORMAT_R5G6B5_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_L16_UNORM).Mask)))
Format = FORMAT_L16_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_A16_UNORM).Mask)))
Format = FORMAT_A16_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R16_UNORM).Mask)))
Format = FORMAT_R16_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGB5A1_UNORM).Mask)))
Format = FORMAT_RGB5A1_UNORM;
break;
}
case 24:
{
dx::format const & DXFormat = DX.translate(FORMAT_RGB8_UNORM);
if(glm::all(glm::equal(Header.Format.Mask, DXFormat.Mask)))
Format = FORMAT_RGB8_UNORM;
break;
}
case 32:
{
if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGRX8_UNORM).Mask)))
Format = FORMAT_BGRX8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGRA8_UNORM).Mask)))
Format = FORMAT_BGRA8_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGB10A2_UNORM).Mask)))
Format = FORMAT_RGB10A2_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_LA16_UNORM).Mask)))
Format = FORMAT_LA16_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG16_UNORM).Mask)))
Format = FORMAT_RG16_UNORM;
else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R32_SFLOAT).Mask)))
Format = FORMAT_R32_SFLOAT;
}
break;
}
}
else if((Header.Format.flags & dx::DDPF_FOURCC) && (Header.Format.fourCC != dx::D3DFMT_DX10) && (Format == static_cast<format>(gli::FORMAT_INVALID)))
Format = DX.find(Header.Format.fourCC);
else if((Header.Format.fourCC == dx::D3DFMT_DX10) && (Header10.Format != dx::DXGI_FORMAT_UNKNOWN))
Format = DX.find(Header10.Format);
assert(Format != static_cast<format>(gli::FORMAT_INVALID));
size_t const MipMapCount = (Header.Flags & detail::DDSD_MIPMAPCOUNT) ? Header.MipMapLevels : 1;
size_t FaceCount = 1;
if(Header.CubemapFlags & detail::DDSCAPS2_CUBEMAP)
FaceCount = int(glm::bitCount(Header.CubemapFlags & detail::DDSCAPS2_CUBEMAP_ALLFACES));
size_t DepthCount = 1;
if(Header.CubemapFlags & detail::DDSCAPS2_VOLUME)
DepthCount = Header.Depth;
texture Texture(
getTarget(Header, Header10), Format,
texture::dim_type(Header.Width, Header.Height, DepthCount),
std::max<std::size_t>(Header10.ArraySize, 1), FaceCount, MipMapCount);
assert(Offset + Texture.size() == Size);
std::memcpy(Texture.data(), Data + Offset, Texture.size());
return Texture;
}
inline texture load_dds(char const * Filename)
{
FILE* File = std::fopen(Filename, "rb");
if(!File)
return texture();
long Beg = std::ftell(File);
std::fseek(File, 0, SEEK_END);
long End = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::vector<char> Data(static_cast<std::size_t>(End - Beg));
std::fread(&Data[0], 1, Data.size(), File);
std::fclose(File);
return load_dds(&Data[0], Data.size());
}
inline texture load_dds(std::string const & Filename)
{
return load_dds(Filename.c_str());
}
}//namespace gli

161
external/gli/gli/core/load_ktx.inl vendored Normal file
View file

@ -0,0 +1,161 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/load_ktx.inl
/// @date 2015-08-05 / 2015-08-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../gl.hpp"
#include <cstdio>
#include <cassert>
namespace gli{
namespace detail
{
struct ktxHeader
{
char Identifier[12];
std::uint32_t Endianness;
std::uint32_t GLType;
std::uint32_t GLTypeSize;
std::uint32_t GLFormat;
std::uint32_t GLInternalFormat;
std::uint32_t GLBaseInternalFormat;
std::uint32_t PixelWidth;
std::uint32_t PixelHeight;
std::uint32_t PixelDepth;
std::uint32_t NumberOfArrayElements;
std::uint32_t NumberOfFaces;
std::uint32_t NumberOfMipmapLevels;
std::uint32_t BytesOfKeyValueData;
};
inline target getTarget(ktxHeader const & Header)
{
if(Header.NumberOfFaces > 1)
{
if(Header.NumberOfArrayElements > 0)
return TARGET_CUBE_ARRAY;
else
return TARGET_CUBE;
}
else if(Header.NumberOfArrayElements > 0)
{
if(Header.PixelHeight == 0)
return TARGET_1D_ARRAY;
else
return TARGET_2D_ARRAY;
}
else if(Header.PixelHeight == 0)
return TARGET_1D;
else if(Header.PixelDepth > 0)
return TARGET_3D;
else
return TARGET_2D;
}
}//namespace detail
inline texture load_ktx(char const * Data, std::size_t Size)
{
assert(Data && (Size >= sizeof(detail::ktxHeader)));
detail::ktxHeader const & Header(*reinterpret_cast<detail::ktxHeader const *>(Data));
static unsigned char const Identifier[] =
{
0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
};
if(memcmp(Header.Identifier, Identifier, sizeof(Identifier)) != 0)
return texture();
size_t Offset = sizeof(detail::ktxHeader);
// Skip key value data
Offset += Header.BytesOfKeyValueData;
gl GL;
gli::format const Format = GL.find(
static_cast<gli::gl::internalFormat>(Header.GLInternalFormat),
static_cast<gli::gl::externalFormat>(Header.GLFormat),
static_cast<gli::gl::typeFormat>(Header.GLType));
assert(Format != static_cast<format>(gli::FORMAT_INVALID));
std::uint32_t const BlockSize = block_size(Format);
texture Texture(
detail::getTarget(Header),
Format,
texture::dim_type(
Header.PixelWidth,
std::max<std::uint32_t>(Header.PixelHeight, 1),
std::max<std::uint32_t>(Header.PixelDepth, 1)),
std::max<std::uint32_t>(Header.NumberOfArrayElements, 1),
std::max<std::uint32_t>(Header.NumberOfFaces, 1),
std::max<std::uint32_t>(Header.NumberOfMipmapLevels, 1));
for(std::size_t Level = 0, Levels = Texture.levels(); Level < Levels; ++Level)
{
Offset += sizeof(std::uint32_t);
for(std::size_t Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer)
{
for(std::size_t Face = 0, Faces = Texture.faces(); Face < Faces; ++Face)
{
std::uint32_t const FaceSize = static_cast<std::uint32_t>(Texture.size(Level));
std::memcpy(Texture.data(Layer, Face, Level), Data + Offset, FaceSize);
Offset += std::max(BlockSize, glm::ceilMultiple(FaceSize, static_cast<std::uint32_t>(4)));
}
}
}
return Texture;
}
inline texture load_ktx(char const * Filename)
{
FILE* File = std::fopen(Filename, "rb");
if(!File)
return texture();
long Beg = std::ftell(File);
std::fseek(File, 0, SEEK_END);
long End = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::vector<char> Data(static_cast<std::size_t>(End - Beg));
std::fread(&Data[0], 1, Data.size(), File);
std::fclose(File);
return load_ktx(&Data[0], Data.size());
}
inline texture load_ktx(std::string const & Filename)
{
return load_ktx(Filename.c_str());
}
}//namespace gli

99
external/gli/gli/core/operation.hpp vendored Normal file
View file

@ -0,0 +1,99 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/operation.hpp
/// @date 2008-12-19 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture2d.hpp"
namespace gli
{
/*
texture2D duplicate(texture2D const & Texture);
texture2D flip(texture2D const & Texture);
texture2D mirror(texture2D const & Texture);
texture2D swizzle(
texture2D const & Texture,
glm::uvec4 const & Channel);
texture2D crop(
texture2D const & Texture,
texture2D::dimensions_type const & Position,
texture2D::dimensions_type const & Size);
image2D crop(
image2D const & Image,
image2D::dimensions_type const & Position,
image2D::dimensions_type const & Size);
image2D copy(
image2D const & SrcImage,
image2D::dimensions_type const & SrcPosition,
image2D::dimensions_type const & SrcSize,
image2D & DstImage,
image2D::dimensions_type const & DstPosition);
*/
//image operator+(image const & MipmapA, image const & MipmapB);
//image operator-(image const & MipmapA, image const & MipmapB);
//image operator*(image const & MipmapA, image const & MipmapB);
//image operator/(image const & MipmapA, image const & MipmapB);
//namespace wip
//{
// template <typename GENTYPE, template <typename> class SURFACE>
// GENTYPE fetch(SURFACE<GENTYPE> const & Image)
// {
// return GENTYPE();
// }
// template
// <
// typename GENTYPE,
// template
// <
// typename
// >
// class SURFACE,
// template
// <
// typename,
// template
// <
// typename
// >
// class
// >
// class IMAGE
// >
// GENTYPE fetch(IMAGE<GENTYPE, SURFACE> const & Image)
// {
// return GENTYPE();
// }
//}//namespace wip
}//namespace gli
#include "operation.inl"

254
external/gli/gli/core/operation.inl vendored Normal file
View file

@ -0,0 +1,254 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/operation.inl
/// @date 2008-12-19 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <cstring>
namespace gli
{
namespace detail
{
inline image2D duplicate(image2D const & Mipmap2D)
{
image2D Result(Mipmap2D.format(), Mipmap2D.dimensions());
memcpy(Result.data(), Mipmap2D.data(), Mipmap2D.capacity());
return Result;
}
inline image2D flip(image2D const & Mipmap2D)
{
assert(!Mipmap2D.is_compressed());
image2D Result(Mipmap2D.format(), Mipmap2D.dimensions());
std::size_t TexelSize = Result.texel_size() >> std::size_t(3);
glm::byte * DstPtr = reinterpret_cast<glm::byte *>(Result.data());
glm::byte const * const SrcPtr = reinterpret_cast<glm::byte const * const>(Mipmap2D.data());
for(std::size_t j = 0; j < Result.dimensions().y; ++j)
for(std::size_t i = 0; i < Result.dimensions().x; ++i)
{
std::size_t DstIndex = (i + j * Result.dimensions().y) * TexelSize;
std::size_t SrcIndex = (i + (Result.dimensions().y - j) * Result.dimensions().x) * TexelSize;
memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, TexelSize);
}
return Result;
}
inline image2D mirror(image2D const & Mipmap2D)
{
image2D Result(Mipmap2D.format(), Mipmap2D.dimensions());
std::size_t ValueSize = Mipmap2D.texel_size() >> std::size_t(3);
glm::byte * DstPtr = reinterpret_cast<glm::byte *>(Result.data());
glm::byte const * const SrcPtr = reinterpret_cast<glm::byte const * const>(Mipmap2D.data());
for(std::size_t j = 0; j < Result.dimensions().y; ++j)
for(std::size_t i = 0; i < Result.dimensions().x; ++i)
{
std::size_t DstIndex = (i + j * Result.dimensions().x) * ValueSize;
std::size_t SrcIndex = ((Result.dimensions().x - i) + j * Result.dimensions().x) * ValueSize;
memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize);
}
return Result;
}
inline image2D swizzle
(
image2D const & Mipmap,
glm::uvec4 const & Channel
)
{
image2D Result = gli::detail::duplicate(Mipmap);
glm::byte * DataDst = reinterpret_cast<glm::byte *>(Result.data());
glm::byte const * const DataSrc = reinterpret_cast<glm::byte const * const>(Mipmap.data());
gli::texture2D::size_type CompSize = (Mipmap.texel_size() >> 3) / Mipmap.components();
gli::texture2D::size_type TexelCount = (Mipmap.capacity() / Mipmap.texel_size()) >> 3;
for(gli::texture2D::size_type t = 0; t < TexelCount; ++t)
for(gli::texture2D::size_type c = 0; c < Mipmap.components(); ++c)
{
gli::texture2D::size_type IndexSrc = t * Mipmap.components() + Channel[glm::uvec4::size_type(c)];
gli::texture2D::size_type IndexDst = t * Mipmap.components() + c;
memcpy(DataDst + IndexDst, DataSrc + IndexSrc, CompSize);
}
return Result;
}
inline image2D crop
(
image2D const & Image,
image2D::dimensions_type const & Position,
image2D::dimensions_type const & Size
)
{
assert((Position.x + Size.x) <= Image.dimensions().x && (Position.y + Size.y) <= Image.dimensions().y);
image2D Result(Image.format(), Size);
glm::byte* DstData = reinterpret_cast<glm::byte *>(Result.data());
glm::byte const * const SrcData = reinterpret_cast<glm::byte const * const>(Image.data());
for(std::size_t j = 0; j < Size.y; ++j)
{
std::size_t DstIndex = 0 + (0 + j) * Size.x * (Image.texel_size() >> 3);
std::size_t SrcIndex = Position.x * Image.texel_size() + (Position.y + j) * Image.dimensions().x * (Image.texel_size() >> 3);
memcpy(DstData + DstIndex, SrcData + SrcIndex, Image.texel_size() * Size.x);
}
return Result;
}
inline image2D copy
(
image2D const & SrcMipmap,
image2D::dimensions_type const & SrcPosition,
image2D::dimensions_type const & SrcSize,
image2D & DstMipmap,
image2D::dimensions_type const & DstPosition
)
{
assert((SrcPosition.x + SrcSize.x) <= SrcMipmap.dimensions().x && (SrcPosition.y + SrcSize.y) <= SrcMipmap.dimensions().y);
assert(SrcMipmap.format() == DstMipmap.format());
glm::byte * DstData = reinterpret_cast<glm::byte *>(DstMipmap.data());
glm::byte const * const SrcData = reinterpret_cast<glm::byte const * const>(SrcMipmap.data());
std::size_t SizeX = std::min(std::size_t(SrcSize.x + SrcPosition.x), std::size_t(DstMipmap.dimensions().x + DstPosition.x));
std::size_t SizeY = std::min(std::size_t(SrcSize.y + SrcPosition.y), std::size_t(DstMipmap.dimensions().y + DstPosition.y));
for(std::size_t j = 0; j < SizeY; ++j)
{
std::size_t DstIndex = DstPosition.x * DstMipmap.texel_size() + (DstPosition.y + j) * DstMipmap.dimensions().x * DstMipmap.texel_size();
std::size_t SrcIndex = SrcPosition.x * SrcMipmap.texel_size() + (SrcPosition.y + j) * SrcMipmap.dimensions().x * SrcMipmap.texel_size();
memcpy(DstData + DstIndex, SrcData + SrcIndex, SrcMipmap.texel_size() * SizeX);
}
return DstMipmap;
}
}//namespace detail
/*
inline texture2D duplicate(texture2D const & Texture2D)
{
texture2D Result(Texture2D.levels(), Texture2D.format(), Texture2D.dimensions());
for(texture2D::size_type Level = 0; Level < Texture2D.levels(); ++Level)
Result[Level] = detail::duplicate(Texture2D[Level]);
return Result;
}
inline texture2D flip(texture2D const & Texture2D)
{
texture2D Result(Texture2D.levels(), Texture2D.format(), Texture2D.dimensions());
for(texture2D::size_type Level = 0; Level < Texture2D.levels(); ++Level)
Result[Level] = detail::flip(Texture2D[Level]);
return Result;
}
inline texture2D mirror(texture2D const & Texture2D)
{
texture2D Result(Texture2D.levels(), Texture2D.format(), Texture2D.dimensions());
for(texture2D::size_type Level = 0; Level < Texture2D.levels(); ++Level)
Result[Level] = detail::mirror(Texture2D[Level]);
return Result;
}
inline texture2D crop
(
texture2D const & Texture2D,
texture2D::dimensions_type const & Position,
texture2D::dimensions_type const & Size
)
{
texture2D Result(Texture2D.levels(), Texture2D.format(), Texture2D.dimensions());
for(texture2D::size_type Level = 0; Level < Texture2D.levels(); ++Level)
Result[Level] = detail::crop(
Texture2D[Level],
Position >> texture2D::dimensions_type(Level),
Size >> texture2D::dimensions_type(Level));
return Result;
}
inline texture2D swizzle
(
texture2D const & Texture2D,
glm::uvec4 const & Channel
)
{
texture2D Result(Texture2D.levels(), Texture2D.format(), Texture2D.dimensions());
for(texture2D::size_type Level = 0; Level < Texture2D.levels(); ++Level)
Result[Level] = detail::swizzle(Texture2D[Level], Channel);
return Result;
}
inline texture2D copy
(
texture2D const & SrcImage,
texture2D::size_type const & SrcLevel,
texture2D::dimensions_type const & SrcPosition,
texture2D::dimensions_type const & SrcDimensions,
texture2D & DstMipmap,
texture2D::size_type const & DstLevel,
texture2D::dimensions_type const & DstDimensions
)
{
detail::copy(
SrcImage[SrcLevel],
SrcPosition,
SrcDimensions,
DstMipmap[DstLevel],
DstDimensions);
return DstMipmap;
}
//inline image operator+(image const & MipmapA, image const & MipmapB)
//{
//
//}
//inline image operator-(image const & MipmapA, image const & MipmapB)
//{
//
//}
//inline image operator*(image const & MipmapA, image const & MipmapB)
//{
//
//}
//inline image operator/(image const & MipmapA, image const & MipmapB)
//{
//
//}
*/
}//namespace gli

44
external/gli/gli/core/operator.hpp vendored Normal file
View file

@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/operator.hpp
/// @date 2010-01-19 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture2d.hpp"
namespace gli{
namespace detail
{
}//namespace detail
texture2D operator+(texture2D const & TextureA, texture2D const & TextureB);
texture2D operator-(texture2D const & TextureA, texture2D const & TextureB);
}//namespace gli
#include "operator.inl"

229
external/gli/gli/core/operator.inl vendored Normal file
View file

@ -0,0 +1,229 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/operation.inl
/// @date 2010-01-19 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
namespace detail
{
template <typename T>
void element
(
T & DataDst,
T const & DataSrcA,
T const & DataSrcB,
std::binary_function<T, T, T> const & Func
)
{
*DataDst = Func(DataSrcA, DataSrcB);
}
void op
(
texture2D::value_type * DataDst,
texture2D::value_type const * const DataSrcA,
texture2D::value_type const * const DataSrcB,
format Format
)
{
std::plus<>()
switch(Format)
{
case R8U:
*((glm::u8*)DataDst) = *((glm::u8*)DataSrcA) + *((glm::u8*)DataSrcB);
break;
case RG8U:
*((glm::u8vec2*)DataDst) = *((glm::u8vec2*)DataSrcA) + *((glm::u8vec2*)DataSrcB);
break;
case RGB8U:
*((glm::u8vec3*)DataDst) = *((glm::u8vec3*)DataSrcA) + *((glm::u8vec3*)DataSrcB);
break;
case RGBA8U:
*((glm::u8vec4*)DataDst) = *((glm::u8vec4*)DataSrcA) + *((glm::u8vec4*)DataSrcB);
break;
case R16U:
*((glm::u16*)DataDst) = *((glm::u16*)DataSrcA) + *((glm::u16*)DataSrcB);
break;
case RG16U:
*((glm::u16vec2*)DataDst) = *((glm::u16vec2*)DataSrcA) + *((glm::u16vec2*)DataSrcB);
break;
case RGB16U:
*((glm::u16vec3*)DataDst) = *((glm::u16vec3*)DataSrcA) + *((glm::u16vec3*)DataSrcB);
break;
case RGBA16U:
*((glm::u16vec4*)DataDst) = *((glm::u16vec4*)DataSrcA) + *((glm::u16vec4*)DataSrcB);
break;
case R32U:
*((glm::u32*)DataDst) = *((glm::u32*)DataSrcA) + *((glm::u32*)DataSrcB);
break;
case RG32U:
*((glm::u32vec2*)DataDst) = *((glm::u32vec2*)DataSrcA) + *((glm::u32vec2*)DataSrcB);
break;
case RGB32U:
*((glm::u32vec3*)DataDst) = *((glm::u32vec3*)DataSrcA) + *((glm::u32vec3*)DataSrcB);
break;
case RGBA32U:
*((glm::u32vec4*)DataDst) = *((glm::u32vec4*)DataSrcA) + *((glm::u32vec4*)DataSrcB);
break;
case R8I:
*((glm::i8*)DataDst) = *((glm::i8*)DataSrcA) + *((glm::i8*)DataSrcB);
break;
case RG8I:
*((glm::i8vec2*)DataDst) = *((glm::i8vec2*)DataSrcA) + *((glm::i8vec2*)DataSrcB);
break;
case RGB8I:
*((glm::i8vec3*)DataDst) = *((glm::i8vec3*)DataSrcA) + *((glm::i8vec3*)DataSrcB);
break;
case RGBA8I:
*((glm::i8vec4*)DataDst) = *((glm::i8vec4*)DataSrcA) + *((glm::i8vec4*)DataSrcB);
break;
case R16I:
*((glm::i16*)DataDst) = *((glm::i16*)DataSrcA) + *((glm::i16*)DataSrcB);
break;
case RG16I:
*((glm::i16vec2*)DataDst) = *((glm::i16vec2*)DataSrcA) + *((glm::i16vec2*)DataSrcB);
break;
case RGB16I:
*((glm::i16vec3*)DataDst) = *((glm::i16vec3*)DataSrcA) + *((glm::i16vec3*)DataSrcB);
break;
case RGBA16I:
*((glm::i16vec4*)DataDst) = *((glm::i16vec4*)DataSrcA) + *((glm::i16vec4*)DataSrcB);
break;
case R32I:
*((glm::i32*)DataDst) = *((glm::i32*)DataSrcA) + *((glm::i32*)DataSrcB);
break;
case RG32I:
*((glm::i32vec2*)DataDst) = *((glm::i32vec2*)DataSrcA) + *((glm::i32vec2*)DataSrcB);
break;
case RGB32I:
*((glm::i32vec3*)DataDst) = *((glm::i32vec3*)DataSrcA) + *((glm::i32vec3*)DataSrcB);
break;
case RGBA32I:
*((glm::i32vec4*)DataDst) = *((glm::i32vec4*)DataSrcA) + *((glm::i32vec4*)DataSrcB);
break;
case R16F:
*((glm::f16*)DataDst) = *((glm::f16*)DataSrcA) + *((glm::f16*)DataSrcB);
break;
case RG16F:
*((glm::f16vec2*)DataDst) = *((glm::f16vec2*)DataSrcA) + *((glm::f16vec2*)DataSrcB);
break;
case RGB16F:
*((glm::f16vec3*)DataDst) = *((glm::f16vec3*)DataSrcA) + *((glm::f16vec3*)DataSrcB);
break;
case RGBA16F:
*((glm::f16vec4*)DataDst) = *((glm::f16vec4*)DataSrcA) + *((glm::f16vec4*)DataSrcB);
break;
case R32F:
*((glm::f32*)DataDst) = *((glm::f32*)DataSrcA) + *((glm::f32*)DataSrcB);
break;
case RG32F:
*((glm::f32vec2*)DataDst) = *((glm::f32vec2*)DataSrcA) + *((glm::f32vec2*)DataSrcB);
break;
case RGB32F:
*((glm::f32vec3*)DataDst) = *((glm::f32vec3*)DataSrcA) + *((glm::f32vec3*)DataSrcB);
break;
case RGBA32F:
*((glm::f32vec4*)DataDst) = *((glm::f32vec4*)DataSrcA) + *((glm::f32vec4*)DataSrcB);
break;
default:
assert(0);
}
}
void add
(
texture2D::image & Result,
texture2D::image const & ImageA,
texture2D::image const & ImageB,
)
{
}
}//namespace detail
texture2D operator+
(
texture2D const & ImageA,
texture2D const & ImageB
)
{
assert(ImageA.levels() == ImageB.levels());
texture2D Result[ImageA.levels()];
for(texture2D::level_type Level = 0; Level < Result.levels(); ++Level)
{
assert(ImageA.capacity() == ImageB.capacity());
assert(ImageA.format() == ImageB.format());
Result[Level] = texture2D::image(ImageA[Level].dimensions(), ImageA[Level].format());
add(Result[Level], ImageA[Level], ImageB[Level]);
texture2D::size_type ValueSize = Result.value_size();
texture2D::size_type TexelCount = this->capacity() / ValueSize;
for(texture2D::size_type Texel = 0; Texel < TexelCount; ++Texel)
{
texture2D::value_type * DataDst = Result[Level].data() + Texel * ValueSize;
texture2D::value_type const * const DataSrcA = ImageA[Level].data() + Texel * ValueSize;
texture2D::value_type const * const DataSrcB = ImageB[Level].data() + Texel * ValueSize;
detail::op(DataDst, DataSrcA, DataSrcB, Result.format(), std::plus);
}
}
return Result;
}
texture2D operator-
(
texture2D const & ImageA,
texture2D const & ImageB
)
{
assert(ImageA.levels() == ImageB.levels());
texture2D Result[ImageA.levels()];
for(texture2D::level_type Level = 0; Level < ImageA.levels(); ++Level)
{
assert(ImageA.capacity() == ImageB.capacity());
}
return Result;
}
}//namespace gli

47
external/gli/gli/core/save.inl vendored Normal file
View file

@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/save.inl
/// @date 2015-08-09 / 2015-08-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../save_dds.hpp"
#include "../save_ktx.hpp"
namespace gli
{
inline bool save(texture const & Texture, char const * Path)
{
return save(Texture, std::string(Path));
}
inline bool save(texture const & Texture, std::string const & Path)
{
if(Path.rfind(".dds") != std::string::npos)
return save_dds(Texture, Path);
if(Path.rfind(".ktx") != std::string::npos)
return save_ktx(Texture, Path);
return false;
}
}//namespace gli

149
external/gli/gli/core/save_dds.inl vendored Normal file
View file

@ -0,0 +1,149 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/save_dds.inl
/// @date 2013-01-28 / 2013-01-28
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <cstdio>
namespace gli{
namespace detail
{
inline D3D10_RESOURCE_DIMENSION getDimension(gli::target const & Target)
{
static D3D10_RESOURCE_DIMENSION Table[] = //TARGET_COUNT
{
D3D10_RESOURCE_DIMENSION_TEXTURE1D, //TARGET_1D,
D3D10_RESOURCE_DIMENSION_TEXTURE1D, //TARGET_1D_ARRAY,
D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_2D,
D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_2D_ARRAY,
D3D10_RESOURCE_DIMENSION_TEXTURE3D, //TARGET_3D,
D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_CUBE,
D3D10_RESOURCE_DIMENSION_TEXTURE2D //TARGET_CUBE_ARRAY
};
static_assert(sizeof(Table) / sizeof(Table[0]) == TARGET_COUNT, "Table needs to be updated");
return Table[Target];
}
}
inline bool save_dds(texture const & Texture, std::vector<char> & Memory)
{
if(Texture.empty())
return false;
dx DX;
dx::format const & DXFormat = DX.translate(Texture.format());
dx::D3DFORMAT const FourCC = Texture.layers() > 1 ? dx::D3DFMT_DX10 : DXFormat.D3DFormat;
Memory.resize(Texture.size() + sizeof(detail::ddsHeader) + (FourCC == dx::D3DFMT_DX10 ? sizeof(detail::ddsHeader10) : 0));
detail::ddsHeader & Header = *reinterpret_cast<detail::ddsHeader*>(&Memory[0]);
detail::formatInfo const & Desc = detail::get_format_info(Texture.format());
std::uint32_t Caps = detail::DDSD_CAPS | detail::DDSD_WIDTH | detail::DDSD_PIXELFORMAT | detail::DDSD_MIPMAPCOUNT;
Caps |= !is_target_1d(Texture.target()) ? detail::DDSD_HEIGHT : 0;
Caps |= Texture.target() == TARGET_3D ? detail::DDSD_DEPTH : 0;
//Caps |= Storage.levels() > 1 ? detail::DDSD_MIPMAPCOUNT : 0;
Caps |= (Desc.Flags & detail::CAP_COMPRESSED_BIT) ? detail::DDSD_LINEARSIZE : detail::DDSD_PITCH;
bool const RequireFOURCCDX10 = is_target_array(Texture.target()) || is_target_1d(Texture.target());
memcpy(Header.Magic, "DDS ", sizeof(Header.Magic));
memset(Header.Reserved1, 0, sizeof(Header.Reserved1));
memset(Header.Reserved2, 0, sizeof(Header.Reserved2));
Header.Size = sizeof(detail::ddsHeader) - sizeof(Header.Magic);
Header.Flags = Caps;
assert(Texture.dimensions().x < std::numeric_limits<glm::uint32>::max());
Header.Width = static_cast<std::uint32_t>(Texture.dimensions().x);
assert(Texture.dimensions().y < std::numeric_limits<glm::uint32>::max());
Header.Height = static_cast<std::uint32_t>(Texture.dimensions().y);
Header.Pitch = static_cast<std::uint32_t>((Desc.Flags & detail::CAP_COMPRESSED_BIT) ? Texture.size() / Texture.faces() : 32);
assert(Texture.dimensions().z < std::numeric_limits<glm::uint32>::max());
Header.Depth = static_cast<std::uint32_t>(Texture.dimensions().z > 1 ? Texture.dimensions().z : 0);
Header.MipMapLevels = static_cast<std::uint32_t>(Texture.levels());
Header.Format.size = sizeof(detail::ddsPixelFormat);
Header.Format.flags = RequireFOURCCDX10 ? dx::DDPF_FOURCC : DXFormat.DDPixelFormat;
Header.Format.fourCC = RequireFOURCCDX10 ? dx::D3DFMT_DX10 : DXFormat.D3DFormat;
Header.Format.bpp = static_cast<std::uint32_t>(detail::bits_per_pixel(Texture.format()));
Header.Format.Mask = DXFormat.Mask;
//Header.surfaceFlags = detail::DDSCAPS_TEXTURE | (Storage.levels() > 1 ? detail::DDSCAPS_MIPMAP : 0);
Header.SurfaceFlags = detail::DDSCAPS_TEXTURE | detail::DDSCAPS_MIPMAP;
Header.CubemapFlags = 0;
// Cubemap
if(Texture.faces() > 1)
{
assert(Texture.faces() == 6);
Header.CubemapFlags |= detail::DDSCAPS2_CUBEMAP_ALLFACES | detail::DDSCAPS2_CUBEMAP;
}
// Texture3D
if(Texture.dimensions().z > 1)
Header.CubemapFlags |= detail::DDSCAPS2_VOLUME;
size_t Offset = sizeof(detail::ddsHeader);
if(Header.Format.fourCC == dx::D3DFMT_DX10)
{
detail::ddsHeader10 & Header10 = *reinterpret_cast<detail::ddsHeader10*>(&Memory[0] + sizeof(detail::ddsHeader));
Offset += sizeof(detail::ddsHeader10);
Header10.ArraySize = static_cast<std::uint32_t>(Texture.layers());
Header10.ResourceDimension = detail::getDimension(Texture.target());
Header10.MiscFlag = 0;//Storage.levels() > 0 ? detail::D3D10_RESOURCE_MISC_GENERATE_MIPS : 0;
Header10.Format = static_cast<dx::dxgiFormat>(DXFormat.DXGIFormat);
Header10.Reserved = 0;
}
std::memcpy(&Memory[0] + Offset, Texture.data(), Texture.size());
return true;
}
inline bool save_dds(texture const & Texture, char const * Filename)
{
if(Texture.empty())
return false;
FILE* File = std::fopen(Filename, "wb");
if(!File)
return false;
std::vector<char> Memory;
bool const Result = save_dds(Texture, Memory);
std::fwrite(&Memory[0], 1, Memory.size(), File);
std::fclose(File);
return Result;
}
inline bool save_dds(texture const & Texture, std::string const & Filename)
{
return save_dds(Texture, Filename.c_str());
}
}//namespace gli

148
external/gli/gli/core/save_ktx.inl vendored Normal file
View file

@ -0,0 +1,148 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/save_ktx.inl
/// @date 2015-08-05 / 2015-08-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <cstdio>
#include <glm/gtc/round.hpp>
namespace gli{
namespace detail
{
inline std::size_t compute_ktx_storage_size(texture const & Texture)
{
std::uint32_t const BlockSize = block_size(Texture.format());
std::size_t TotalSize = sizeof(detail::ktxHeader);
for(std::size_t Level = 0, Levels = Texture.levels(); Level < Levels; ++Level)
{
TotalSize += sizeof(std::uint32_t);
for(std::size_t Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer)
{
for(std::size_t Face = 0, Faces = Texture.faces(); Face < Faces; ++Face)
{
std::uint32_t const FaceSize = static_cast<std::uint32_t>(Texture.size(Level));
std::uint32_t const PaddedSize = std::max(BlockSize, glm::ceilMultiple(FaceSize, static_cast<std::uint32_t>(4)));
TotalSize += PaddedSize;
}
}
}
return TotalSize;
}
}//namespace detail
inline bool save_ktx(texture const & Texture, std::vector<char> & Memory)
{
if(Texture.empty())
return false;
gl GL;
gl::format const & Format = GL.translate(Texture.format());
target const Target = Texture.target();
detail::formatInfo const & Desc = detail::get_format_info(Texture.format());
Memory.resize(detail::compute_ktx_storage_size(Texture) + sizeof(detail::ktxHeader));
detail::ktxHeader & Header = *reinterpret_cast<detail::ktxHeader*>(&Memory[0]);
static unsigned char const Identifier[] =
{
0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
};
memcpy(Header.Identifier, Identifier, sizeof(Header.Identifier));
Header.Endianness = 0x04030201;
Header.GLType = Format.Type;
Header.GLTypeSize = Format.Type == gl::TYPE_NONE ? 1 : Desc.BlockSize;
Header.GLFormat = Format.External;
Header.GLInternalFormat = Format.Internal;
Header.GLBaseInternalFormat = Format.External;
Header.PixelWidth = static_cast<std::uint32_t>(Texture.dimensions().x);
Header.PixelHeight = !is_target_1d(Target) ? static_cast<std::uint32_t>(Texture.dimensions().y) : 0;
Header.PixelDepth = Target == TARGET_3D ? static_cast<std::uint32_t>(Texture.dimensions().z) : 0;
Header.NumberOfArrayElements = is_target_array(Target) ? static_cast<std::uint32_t>(Texture.layers()) : 0;
Header.NumberOfFaces = is_target_cube(Target) ? static_cast<std::uint32_t>(Texture.faces()) : 0;
Header.NumberOfMipmapLevels = static_cast<std::uint32_t>(Texture.levels());
Header.BytesOfKeyValueData = 0;
std::size_t Offset = sizeof(detail::ktxHeader);
for(std::size_t Level = 0, Levels = Texture.levels(); Level < Levels; ++Level)
{
std::uint32_t& ImageSize = *reinterpret_cast<std::uint32_t*>(&Memory[0] + Offset);
Offset += sizeof(std::uint32_t);
for(std::size_t Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer)
{
for(std::size_t Face = 0, Faces = Texture.faces(); Face < Faces; ++Face)
{
std::uint32_t const FaceSize = static_cast<std::uint32_t>(Texture.size(Level));
std::memcpy(&Memory[0] + Offset, Texture.data(Layer, Face, Level), FaceSize);
std::uint32_t const PaddedSize = glm::ceilMultiple(FaceSize, static_cast<std::uint32_t>(4));
ImageSize += PaddedSize;
Offset += PaddedSize;
assert(Offset <= Memory.size());
}
}
ImageSize = glm::ceilMultiple(ImageSize, static_cast<std::uint32_t>(4));
}
return true;
}
inline bool save_ktx(texture const & Texture, char const * Filename)
{
if(Texture.empty())
return false;
FILE* File = std::fopen(Filename, "wb");
if(!File)
return false;
std::vector<char> Memory;
bool const Result = save_ktx(Texture, Memory);
std::fwrite(&Memory[0], 1, Memory.size(), File);
std::fclose(File);
return Result;
}
inline bool save_ktx(texture const & Texture, std::string const & Filename)
{
return save_ktx(Texture, Filename.c_str());
}
}//namespace gli

157
external/gli/gli/core/storage.hpp vendored Normal file
View file

@ -0,0 +1,157 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/storage.hpp
/// @date 2012-06-21 / 2015-08-22
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// STD
#include <vector>
#include <queue>
#include <string>
#include <cassert>
#include <cmath>
#include <cstring>
#include <memory>
#include "../type.hpp"
#include "../format.hpp"
// GLM
#include <glm/gtc/round.hpp>
#include <glm/gtx/component_wise.hpp>
#include <glm/gtx/integer.hpp>
#include <glm/gtx/bit.hpp>
#include <glm/gtx/raw_data.hpp>
#include <glm/gtx/wrap.hpp>
static_assert(GLM_VERSION >= 97, "GLI requires at least GLM 0.9.7");
namespace gli
{
class storage
{
public:
typedef dim3_t dim_type;
typedef size_t size_type;
typedef gli::format format_type;
typedef glm::byte data_type;
public:
storage();
storage(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Faces,
size_type Levels);
bool empty() const;
size_type size() const; // Express is bytes
size_type layers() const;
size_type levels() const;
size_type faces() const;
size_type block_size() const;
dim_type block_count(size_type Level) const;
dim_type dimensions(size_type Level) const;
data_type * data();
/// Compute the relative memory offset to access the data for a specific layer, face and level
size_type offset(
size_type Layer,
size_type Face,
size_type Level) const;
size_type level_size(
size_type Level) const;
size_type face_size(
size_type BaseLevel, size_type MaxLevel) const;
size_type layer_size(
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel) const;
private:
size_type const Layers;
size_type const Faces;
size_type const Levels;
size_type const BlockSize;
dim_type const BlockCount;
dim_type const Dimensions;
std::vector<data_type> Data;
};
/*
storage extractLayers(
storage const & Storage,
storage::size_type const & Offset,
storage::size_type const & Size);
*/
/*
storage extractFace(
storage const & Storage,
face const & Face);
*/
/*
storage extractLevels(
storage const & Storage,
storage::size_type const & Offset,
storage::size_type const & Size);
*/
/*
void copy_layers(
storage const & SourceStorage,
storage::size_type const & SourceLayerOffset,
storage::size_type const & SourceLayerSize,
storage & DestinationStorage,
storage::size_type const & DestinationLayerOffset);
void copy_faces(
storage const & SourceStorage,
storage::size_type const & SourceLayerOffset,
storage::size_type const & SourceFaceOffset,
storage::size_type const & SourceLayerSize,
storage & DestinationStorage,
storage::size_type const & DestinationLayerOffset,
storage::size_type const & DestinationFaceOffset);
void copy_levels(
storage const & SourceStorage,
storage::size_type const & SourceLayerOffset,
storage::size_type const & SourceFaceOffset,
storage::size_type const & SourceLevelOffset,
storage::size_type const & SourceLayerSize,
storage & DestinationStorage,
storage::size_type const & DestinationLayerOffset,
storage::size_type const & DestinationFaceOffset,
storage::size_type const & DestinationlevelOffset);
*/
}//namespace gli
#include "storage.inl"

272
external/gli/gli/core/storage.inl vendored Normal file
View file

@ -0,0 +1,272 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/storage.inl
/// @date 2012-06-21 / 2015-08-22
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline storage::storage()
: Layers(0)
, Faces(0)
, Levels(0)
, BlockSize(0)
, BlockCount(0)
, Dimensions(0)
{}
inline storage::storage
(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Faces,
size_type Levels
)
: Layers(Layers)
, Faces(Faces)
, Levels(Levels)
, BlockSize(gli::block_size(Format))
, BlockCount(glm::max(Dimensions / block_dimensions(Format), gli::dim3_t(1)))
, Dimensions(Dimensions)
{
assert(Layers > 0);
assert(Faces > 0);
assert(Levels > 0);
assert(glm::all(glm::greaterThan(Dimensions, dim_type(0))));
this->Data.resize(this->layer_size(0, Faces - 1, 0, Levels - 1) * Layers, 0);
}
inline bool storage::empty() const
{
return this->Data.empty();
}
inline storage::size_type storage::layers() const
{
return this->Layers;
}
inline storage::size_type storage::faces() const
{
return this->Faces;
}
inline storage::size_type storage::levels() const
{
return this->Levels;
}
inline storage::size_type storage::block_size() const
{
return this->BlockSize;
}
inline storage::dim_type storage::block_count(size_type Level) const
{
assert(Level < this->Levels);
return glm::max(this->BlockCount >> storage::dim_type(static_cast<glm::uint>(Level)), storage::dim_type(static_cast<glm::uint>(1)));
}
inline storage::dim_type storage::dimensions(size_type Level) const
{
return glm::max(this->Dimensions >> Level, storage::dim_type(1));
}
inline storage::size_type storage::size() const
{
assert(!this->empty());
return this->Data.size();
}
inline storage::data_type * storage::data()
{
assert(!this->empty());
return &this->Data[0];
}
inline storage::size_type storage::offset
(
size_type Layer,
size_type Face,
size_type Level
) const
{
assert(Layer < this->layers());
assert(Face < this->faces());
assert(Level < this->levels());
size_t const LayerSize = this->layer_size(0, this->faces() - 1, 0, this->levels() - 1);
size_t const FaceSize = this->face_size(0, this->levels() - 1);
size_t BaseOffset = LayerSize * Layer + FaceSize * Face;
for(size_t LevelIndex = 0, LevelCount = Level; LevelIndex < LevelCount; ++LevelIndex)
BaseOffset += this->level_size(LevelIndex);
return BaseOffset;
}
inline storage::size_type storage::level_size(size_type Level) const
{
assert(Level < this->levels());
return this->BlockSize * glm::compMul(this->block_count(Level));
}
inline storage::size_type storage::face_size(
size_type BaseLevel,
size_type MaxLevel) const
{
assert(MaxLevel < this->levels());
size_type FaceSize(0);
// The size of a face is the sum of the size of each level.
for(storage::size_type Level(BaseLevel); Level <= MaxLevel; ++Level)
FaceSize += this->level_size(Level);
return FaceSize;
}
inline storage::size_type storage::layer_size(
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel) const
{
assert(MaxFace < this->faces());
assert(MaxLevel < this->levels());
// The size of a layer is the sum of the size of each face.
// All the faces have the same size.
return this->face_size(BaseLevel, MaxLevel) * (MaxFace - BaseFace + 1);
}
/*
inline storage extractLayers
(
storage const & Storage,
storage::size_type const & Offset,
storage::size_type const & Size
)
{
assert(Storage.layers() > 1);
assert(Storage.layers() >= Size);
assert(Storage.faces() > 0);
assert(Storage.levels() > 0);
storage SubStorage(
Size,
Storage.faces(),
Storage.levels(),
Storage.dimensions(0),
Storage.blockSize());
memcpy(
SubStorage.data(),
Storage.data() + Storage.imageAddressing(Offset, 0, 0),
Storage.layerSize() * Size);
return SubStorage;
}
*/
/*
inline storage extractFace
(
storage const & Storage,
face const & Face
)
{
assert(Storage.faces() > 1);
assert(Storage.levels() > 0);
storage SubStorage(
Storage.layers(),
Face,
Storage.levels(),
Storage.dimensions(0),
Storage.blockSize());
memcpy(
SubStorage.data(),
Storage.data() + Storage.imageAddressing(0, storage::size_type(Face), 0),
Storage.faceSize());
return SubStorage;
}
*/
/*
inline storage extractLevel
(
storage const & Storage,
storage::size_type const & Level
)
{
assert(Storage.layers() == 1);
assert(Storage.faces() == 1);
assert(Storage.levels() >= 1);
storage SubStorage(
1, // layer
glm::uint(FACE_DEFAULT),
1, // level
Storage.dimensions(0),
Storage.blockSize());
memcpy(
SubStorage.data(),
Storage.data() + Storage.imageAddressing(0, 0, Level),
Storage.levelSize(Level));
return SubStorage;
}
*/
/*
inline void copy_layers
(
storage const & SourceStorage,
storage::size_type const & SourceLayerOffset,
storage::size_type const & SourceLayerSize,
storage & DestinationStorage,
storage::size_type const & DestinationLayerOffset
)
{
assert(DestinationStorage.blockSize() == SourceStorage.blockSize());
assert(DestinationStorage.layers() <= SourceStorage.layers());
assert(SourceStorage.layers() <= SourceLayerOffset + SourceLayerSize);
assert(DestinationStorage.layers() <= DestinationLayerOffset + SourceLayerSize);
std::size_t OffsetSrc = SourceStorage.imageAddressing(SourceLayerOffset, 0, 0);
std::size_t OffsetDst = DestinationStorage.imageAddressing(DestinationLayerOffset, 0, 0);
memcpy(
DestinationStorage.data() + OffsetDst * DestinationStorage.blockSize(),
SourceStorage.data() + OffsetSrc * SourceStorage.blockSize(),
SourceStorage.layerSize() * SourceLayerSize * SourceStorage.blockSize());
}
*/
}//namespace gli

332
external/gli/gli/core/texture.inl vendored Normal file
View file

@ -0,0 +1,332 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture.inl
/// @date 2015-08-20 / 2015-08-20
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
namespace gli
{
inline texture::texture()
: Storage(nullptr)
, Target(static_cast<gli::target>(TARGET_INVALID))
, Format(static_cast<gli::format>(FORMAT_INVALID))
, BaseLayer(0), MaxLayer(0)
, BaseFace(0), MaxFace(0)
, BaseLevel(0), MaxLevel(0)
{}
inline texture::texture
(
target_type Target,
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Faces,
size_type Levels
)
: Storage(std::make_shared<storage>(Format, Dimensions, Layers, Faces, Levels))
, Target(Target)
, Format(Format)
, BaseLayer(0), MaxLayer(Layers - 1)
, BaseFace(0), MaxFace(Faces - 1)
, BaseLevel(0), MaxLevel(Levels - 1)
{
assert(Target != TARGET_CUBE || (Target == TARGET_CUBE && Dimensions.x == Dimensions.y));
assert(Target != TARGET_CUBE_ARRAY || (Target == TARGET_CUBE_ARRAY && Dimensions.x == Dimensions.y));
this->build_cache();
}
inline texture::texture
(
texture const & Texture,
target_type Target,
format_type Format
)
: Storage(Texture.Storage)
, Target(Target)
, Format(Format)
, BaseLayer(Texture.base_layer()), MaxLayer(Texture.max_layer())
, BaseFace(Texture.base_face()), MaxFace(Texture.max_face())
, BaseLevel(Texture.base_level()), MaxLevel(Texture.max_level())
{
if(this->empty())
return;
assert(Target != TARGET_1D || (Target == TARGET_1D && this->layers() == 1 && this->faces() == 1 && this->dimensions().y == 1 && this->dimensions().z == 1));
assert(Target != TARGET_1D_ARRAY || (Target == TARGET_1D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->dimensions().y == 1 && this->dimensions().z == 1));
assert(Target != TARGET_2D || (Target == TARGET_2D && this->layers() == 1 && this->faces() == 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
assert(Target != TARGET_2D_ARRAY || (Target == TARGET_2D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
assert(Target != TARGET_3D || (Target == TARGET_3D && this->layers() == 1 && this->faces() == 1 && this->dimensions().y >= 1 && this->dimensions().z >= 1));
assert(Target != TARGET_CUBE || (Target == TARGET_CUBE && this->layers() == 1 && this->faces() >= 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
assert(Target != TARGET_CUBE_ARRAY || (Target == TARGET_CUBE_ARRAY && this->layers() >= 1 && this->faces() >= 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
this->build_cache();
}
inline texture::texture
(
texture const & Texture,
target_type Target,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: Storage(Texture.Storage)
, Target(Target)
, Format(Format)
, BaseLayer(BaseLayer), MaxLayer(MaxLayer)
, BaseFace(BaseFace), MaxFace(MaxFace)
, BaseLevel(BaseLevel), MaxLevel(MaxLevel)
{
assert(block_size(Format) == block_size(Texture.format()));
assert(Target != TARGET_1D || (Target == TARGET_1D && this->layers() == 1 && this->faces() == 1 && this->dimensions().y == 1 && this->dimensions().z == 1));
assert(Target != TARGET_1D_ARRAY || (Target == TARGET_1D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->dimensions().y == 1 && this->dimensions().z == 1));
assert(Target != TARGET_2D || (Target == TARGET_2D && this->layers() == 1 && this->faces() == 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
assert(Target != TARGET_2D_ARRAY || (Target == TARGET_2D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
assert(Target != TARGET_3D || (Target == TARGET_3D && this->layers() == 1 && this->faces() == 1 && this->dimensions().y >= 1 && this->dimensions().z >= 1));
assert(Target != TARGET_CUBE || (Target == TARGET_CUBE && this->layers() == 1 && this->faces() >= 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
assert(Target != TARGET_CUBE_ARRAY || (Target == TARGET_CUBE_ARRAY && this->layers() >= 1 && this->faces() >= 1 && this->dimensions().y >= 1 && this->dimensions().z == 1));
this->build_cache();
}
inline texture::size_type texture::size() const
{
assert(!this->empty());
return this->Cache.Size;
}
template <typename genType>
inline texture::size_type texture::size() const
{
assert(!this->empty());
assert(block_size(this->format()) == sizeof(genType));
return this->size() / sizeof(genType);
}
inline texture::size_type texture::size(size_type Level) const
{
assert(!this->empty());
assert(Level >= BaseLevel && Level <= MaxLevel);
return this->Storage->level_size(Level);
}
template <typename genType>
inline texture::size_type texture::size(size_type Level) const
{
assert(!this->empty());
assert(block_size(this->format()) == sizeof(genType));
assert(Level >= BaseLevel && Level <= MaxLevel);
return this->Storage->level_size(Level) / sizeof(genType);
}
inline void * texture::data()
{
return this->Cache.Data;
}
inline void const * texture::data() const
{
return this->Cache.Data;
}
template <typename genType>
inline genType * texture::data()
{
assert(!this->empty());
assert(block_size(this->format()) >= sizeof(genType));
return reinterpret_cast<genType *>(this->data());
}
template <typename genType>
inline genType const * texture::data() const
{
assert(!this->empty());
assert(block_size(this->format()) >= sizeof(genType));
return reinterpret_cast<genType const *>(this->data());
}
inline void * texture::data(size_type Layer, size_type Face, size_type Level)
{
size_type const Offset = this->Storage->offset(
this->base_layer() + Layer, this->base_face() + Face, this->base_level() + Level);
return this->Storage->data() + Offset;
}
inline void const * texture::data(size_type Layer, size_type Face, size_type Level) const
{
size_type const Offset = this->Storage->offset(
this->base_layer() + Layer, this->base_face() + Face, this->base_level() + Level);
return this->Storage->data() + Offset;
}
template <typename genType>
inline genType * texture::data(size_type Layer, size_type Face, size_type Level)
{
assert(!this->empty());
assert(block_size(this->format()) >= sizeof(genType));
return reinterpret_cast<genType *>(this->data(Layer, Face, Level));
}
template <typename genType>
inline genType const * texture::data(size_type Layer, size_type Face, size_type Level) const
{
assert(!this->empty());
assert(block_size(this->format()) >= sizeof(genType));
return reinterpret_cast<genType const *>(this->data(Layer, Face, Level));
}
inline bool texture::empty() const
{
if(this->Storage.get() == nullptr)
return true;
return this->Storage->empty();
}
inline texture::format_type texture::format() const
{
return this->Format;
}
inline texture::dim_type texture::dimensions(size_type Level) const
{
assert(!this->empty());
return this->Storage->dimensions(this->base_level() + Level);
//return this->Storage->block_count(this->base_level() + Level) * block_dimensions(this->format());
}
inline texture::size_type texture::base_layer() const
{
return this->BaseLayer;
}
inline texture::size_type texture::max_layer() const
{
return this->MaxLayer;
}
inline texture::size_type texture::layers() const
{
return this->max_layer() - this->base_layer() + 1;
}
inline texture::size_type texture::base_face() const
{
return this->BaseFace;
}
inline texture::size_type texture::max_face() const
{
return this->MaxFace;
}
inline texture::size_type texture::faces() const
{
//assert(this->max_face() - this->base_face() + 1 == 1);
return this->max_face() - this->base_face() + 1;
}
inline texture::size_type texture::base_level() const
{
return this->BaseLevel;
}
inline texture::size_type texture::max_level() const
{
return this->MaxLevel;
}
inline texture::size_type texture::levels() const
{
return this->max_level() - this->base_level() + 1;
}
inline void texture::clear()
{
memset(this->data(), 0, this->size());
}
template <typename genType>
inline void texture::clear(genType const & Texel)
{
assert(!this->empty());
assert(block_size(this->format()) == sizeof(genType));
genType* Data = this->data<genType>();
size_type const TexelCount = this->size<genType>();
for(size_type TexelIndex = 0; TexelIndex < TexelCount; ++TexelIndex)
*(Data + TexelIndex) = Texel;
}
inline void texture::build_cache()
{
size_type const Offset = this->Storage->offset(
this->base_layer(), this->base_face(), this->base_level());
size_type const Size = this->Storage->layer_size(
this->base_face(), this->max_face(),
this->base_level(), this->max_level()) * this->layers();
this->Cache.Data = this->Storage->data() + Offset;
this->Cache.Size = Size;
}
inline texture::size_type texture::offset
(
size_type Layer,
size_type Face,
size_type Level
) const
{
assert(Layer >= BaseLayer && Layer <= MaxLayer);
assert(Face >= BaseFace && Face <= MaxFace);
assert(Level >= BaseLevel && Level <= MaxLevel);
//return this->Storage->offset(Layer, Face, Level);
return this->Storage->offset(
this->base_layer() + Layer,
this->base_face() + Face,
this->base_level() + Level);
}
}//namespace gli

105
external/gli/gli/core/texture1d.inl vendored Normal file
View file

@ -0,0 +1,105 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture1d.inl
/// @date 2013-01-12 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../levels.hpp"
namespace gli
{
inline texture1D::texture1D()
{}
inline texture1D::texture1D
(
format_type Format,
dim_type const & Dimensions,
size_type Levels
)
: texture(gli::TARGET_1D, Format, texture::dim_type(Dimensions.x, 1, 1), 1, 1, Levels)
{}
inline texture1D::texture1D
(
format_type Format,
dim_type const & Dimensions
)
: texture(gli::TARGET_1D, Format, texture::dim_type(Dimensions.x, 1, 1), 1, 1, gli::levels(Dimensions))
{}
inline texture1D::texture1D(texture const & Texture)
: texture(Texture, gli::TARGET_1D, Texture.format())
{}
inline texture1D::texture1D
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_1D,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline texture1D::texture1D
(
texture1D const & Texture,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_1D,
Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline image texture1D::operator[](texture1D::size_type Level) const
{
assert(Level < this->levels());
return image(
this->Storage,
this->format(),
this->base_layer(),
this->base_face(),
this->base_level() + Level);
}
inline texture1D::dim_type texture1D::dimensions() const
{
assert(!this->empty());
return texture1D::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
}
}//namespace gli

View file

@ -0,0 +1,110 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture1d_array.inl
/// @date 2012-06-27 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../levels.hpp"
namespace gli
{
inline texture1DArray::texture1DArray()
{}
inline texture1DArray::texture1DArray
(
format_type Format,
dim_type const & Dimensions,
size_type Layers
)
: texture(gli::TARGET_1D_ARRAY, Format, texture::dim_type(Dimensions.x, 1, 1), Layers, 1, gli::levels(Dimensions))
{}
inline texture1DArray::texture1DArray
(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Levels
)
: texture(gli::TARGET_1D_ARRAY, Format, texture::dim_type(Dimensions.x, 1, 1), Layers, 1, Levels)
{}
inline texture1DArray::texture1DArray(texture const & Texture)
: texture(Texture, gli::TARGET_1D_ARRAY, Texture.format())
{}
inline texture1DArray::texture1DArray
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_1D_ARRAY,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline texture1DArray::texture1DArray
(
texture1DArray const & Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_1D_ARRAY,
Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline texture1D texture1DArray::operator[](size_type Layer) const
{
assert(!this->empty());
assert(Layer < this->layers());
return texture1D(
*this, this->format(),
this->base_layer() + Layer, this->base_layer() + Layer,
this->base_face(), this->max_face(),
this->base_level(), this->max_level());
}
inline texture1DArray::dim_type texture1DArray::dimensions() const
{
assert(!this->empty());
return texture1DArray::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
}
}//namespace gli

219
external/gli/gli/core/texture2d.inl vendored Normal file
View file

@ -0,0 +1,219 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture2d.inl
/// @date 2010-09-27 / 2012-10-16
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../levels.hpp"
namespace gli
{
inline texture2D::texture2D()
{}
inline texture2D::texture2D(format_type Format, dim_type const & Dimensions)
: texture(gli::TARGET_2D, Format, texture::dim_type(Dimensions, 1), 1, 1, gli::levels(Dimensions))
{}
inline texture2D::texture2D(format_type Format, dim_type const & Dimensions, size_type Levels)
: texture(gli::TARGET_2D, Format, texture::dim_type(Dimensions, 1), 1, 1, Levels)
{}
inline texture2D::texture2D(texture const & Texture)
: texture(Texture, gli::TARGET_2D, Texture.format())
{}
inline texture2D::texture2D
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_2D, Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline texture2D::texture2D
(
texture2D const & Texture,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_2D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline image texture2D::operator[](texture2D::size_type Level) const
{
assert(Level < this->levels());
return image(
this->Storage,
this->format(),
this->base_layer(),
this->base_face(),
this->base_level() + Level);
}
inline texture2D::dim_type texture2D::dimensions() const
{
assert(!this->empty());
return texture2D::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
}
template <typename genType>
inline genType texture2D::fetch(texture2D::dim_type const & TexelCoord, texture2D::size_type Level)
{
assert(!this->empty());
assert(!is_compressed(this->format()));
assert(block_size(this->format()) == sizeof(genType));
image Image = this->operator[](Level);
genType const * const Data = Image.data<genType>();
std::size_t const Index = TexelCoord.x + TexelCoord.y * Image.dimensions().x;
assert(Index < Image.size());
return reinterpret_cast<genType const * const>(Data)[Index];
}
template <typename genType>
void texture2D::write(texture2D::dim_type const & TexelCoord, texture2D::size_type Level, genType const & Color)
{
assert(!this->empty());
assert(!is_compressed(this->format()));
assert(block_size(this->format()) == sizeof(genType));
image Image = this->operator[](Level);
genType * Data = Image.data<genType>();
std::size_t const Index = TexelCoord.x + TexelCoord.y * Image.dimensions().x;
assert(Index < Image.size());
*(Data + Index) = Color;
}
/*
template <typename genType>
inline void texture2D::swizzle(glm::comp X, glm::comp Y, glm::comp Z, glm::comp W)
{
for(texture2D::level_type Level = 0; Level < this->levels(); ++Level)
{
genType * Data = reinterpret_cast<genType*>(this->Images[Level].data());
texture2D::size_type Components = this->Images[Level].components();
//gli::detail::getComponents(this->Images[Level].format());
texture2D::size_type Size = (glm::compMul(this->Images[Level].dimensions()) * Components) / sizeof(genType);
for(texture2D::size_type i = 0; i < Size; ++i)
{
genType Copy = Data[i];
if(Components > 0)
Data[i][0] = Copy[X];
if(Components > 1)
Data[i][1] = Copy[Y];
if(Components > 2)
Data[i][2] = Copy[Z];
if(Components > 3)
Data[i][3] = Copy[W];
}
}
}
*/
/*
template <typename T>
inline T texture<T>::texture(float x, float y) const
{
size_type x_below = size_type(std::floor(x * (_width - 1)));
size_type x_above = size_type(std::ceil(x * (_width - 1)));
size_type y_below = size_type(std::floor(y * (_height - 1)));
size_type y_above = size_type(std::ceil(y * (_height - 1)));
float x_step = 1.0f / float(_width);
float y_step = 1.0f / float(_height);
float x_below_normalized = float(x_below) / float(_width - 1);
float x_above_normalized = float(x_above) / float(_width - 1);
float y_below_normalized = float(y_below) / float(_height - 1);
float y_above_normalized = float(y_above) / float(_height - 1);
T value1 = _data[x_below + y_below * _width];
T value2 = _data[x_above + y_below * _width];
T value3 = _data[x_above + y_above * _width];
T value4 = _data[x_below + y_above * _width];
T valueA = glm::mix(value1, value2, x - x_below_normalized);
T valueB = glm::mix(value4, value3, x - x_below_normalized);
T valueC = glm::mix(valueA, valueB, y - y_below_normalized);
return valueC;
}
*/
/*
template <typename T>
inline T texture(const texture2D<T>& Image2D, const glm::vec2& TexCoord)
{
texture2D<T>::size_type s_below = texture2D<T>::size_type(std::floor(TexCoord.s * (Image2D.width() - 1)));
texture2D<T>::size_type s_above = texture2D<T>::size_type(std::ceil(TexCoord.s * (Image2D.width() - 1)));
texture2D<T>::size_type t_below = texture2D<T>::size_type(std::floor(TexCoord.t * (Image2D.height() - 1)));
texture2D<T>::size_type t_above = texture2D<T>::size_type(std::ceil(TexCoord.t * (Image2D.height() - 1)));
glm::vec2::value_type s_step = 1.0f / glm::vec2::value_type(Image2D.width());
glm::vec2::value_type t_step = 1.0f / glm::vec2::value_type(Image2D.height());
glm::vec2::value_type s_below_normalized = glm::vec2::value_type(s_below) / glm::vec2::value_type(Image2D.width() - 1);
glm::vec2::value_type s_above_normalized = glm::vec2::value_type(s_above) / glm::vec2::value_type(Image2D.width() - 1);
glm::vec2::value_type t_below_normalized = glm::vec2::value_type(t_below) / glm::vec2::value_type(Image2D.height() - 1);
glm::vec2::value_type t_above_normalized = glm::vec2::value_type(t_above) / glm::vec2::value_type(Image2D.height() - 1);
T value1 = Image2D[s_below + t_below * Image2D.width()];
T value2 = Image2D[s_above + t_below * Image2D.width()];
T value3 = Image2D[s_above + t_above * Image2D.width()];
T value4 = Image2D[s_below + t_above * Image2D.width()];
T valueA = glm::mix(value1, value2, TexCoord.s - s_below_normalized);
T valueB = glm::mix(value4, value3, TexCoord.s - s_below_normalized);
T valueC = glm::mix(valueA, valueB, TexCoord.t - t_below_normalized);
return valueC;
}
template <typename T>
inline T textureNearest(const texture2D<T>& Image2D, const glm::vec2& TexCoord)
{
texture2D<T>::size_type s = texture2D<T>::size_type(glm::roundGTX(TexCoord.s * (Image2D.width() - 1)));
texture2D<T>::size_type t = texture2D<T>::size_type(std::roundGTX(TexCoord.t * (Image2D.height() - 1)));
return Image2D[s + t * Image2D.width()];
}
*/
}//namespace gli

View file

@ -0,0 +1,109 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture2d_array.inl
/// @date 2013-01-12 / 2013-01-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../levels.hpp"
namespace gli
{
inline texture2DArray::texture2DArray()
{}
inline texture2DArray::texture2DArray
(
format_type Format,
dim_type const & Dimensions,
size_type Layers
)
: texture(gli::TARGET_2D_ARRAY, Format, texture::dim_type(Dimensions, 1), Layers, 1, gli::levels(Dimensions))
{}
inline texture2DArray::texture2DArray
(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Levels
)
: texture(gli::TARGET_2D_ARRAY, Format, texture::dim_type(Dimensions, 1), Layers, 1, Levels)
{}
inline texture2DArray::texture2DArray(texture const & Texture)
: texture(Texture, gli::TARGET_2D_ARRAY, Texture.format())
{}
inline texture2DArray::texture2DArray
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_2D_ARRAY,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline texture2DArray::texture2DArray
(
texture2DArray const & Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_2D_ARRAY,
Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline texture2D texture2DArray::operator[](size_type Layer) const
{
assert(Layer < this->layers());
return texture2D(
*this, this->format(),
this->base_layer() + Layer, this->base_layer() + Layer,
this->base_face(), this->max_face(),
this->base_level(), this->max_level());
}
inline texture2DArray::dim_type texture2DArray::dimensions() const
{
assert(!this->empty());
return texture2DArray::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
//return texture2DArray::dim_type(this->Storage.dimensions(this->base_level()));
}
}//namespace gli

98
external/gli/gli/core/texture3d.inl vendored Normal file
View file

@ -0,0 +1,98 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture3d.inl
/// @date 2013-01-13 / 2013-01-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../levels.hpp"
namespace gli
{
inline texture3D::texture3D()
{}
inline texture3D::texture3D(format_type Format, dim_type const & Dimensions)
: texture(gli::TARGET_3D, Format, Dimensions, 1, 1, gli::levels(Dimensions))
{}
inline texture3D::texture3D(format_type Format, dim_type const & Dimensions, size_type Levels)
: texture(gli::TARGET_3D, Format, Dimensions, 1, 1, Levels)
{}
inline texture3D::texture3D(texture const & Texture)
: texture(Texture, gli::TARGET_3D, Texture.format())
{}
inline texture3D::texture3D
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_3D,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline texture3D::texture3D
(
texture3D const & Texture,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_3D,
Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline image texture3D::operator[](texture3D::size_type Level) const
{
assert(Level < this->levels());
return image(
this->Storage,
this->format(),
this->base_layer(),
this->base_face(),
this->base_level() + Level);
}
inline texture3D::dim_type texture3D::dimensions() const
{
assert(!this->empty());
return texture3D::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
//return texture3D::dim_type(this->Storage.dimensions(this->base_level()));
}
}//namespace gli

105
external/gli/gli/core/texture_cube.inl vendored Normal file
View file

@ -0,0 +1,105 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture_cube.inl
/// @date 2011-04-06 / 2012-12-12
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline textureCube::textureCube()
{}
inline textureCube::textureCube
(
format_type Format,
dim_type const & Dimensions
)
: texture(gli::TARGET_CUBE, Format, texture::dim_type(Dimensions, 1), 1, 6, gli::levels(Dimensions))
{}
inline textureCube::textureCube
(
format_type Format,
dim_type const & Dimensions,
size_type Levels
)
: texture(gli::TARGET_CUBE, Format, texture::dim_type(Dimensions, 1), 1, 6, Levels)
{}
inline textureCube::textureCube(texture const & Texture)
: texture(Texture, gli::TARGET_CUBE, Texture.format())
{}
inline textureCube::textureCube
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_CUBE,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline textureCube::textureCube
(
textureCube const & Texture,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_CUBE,
Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline texture2D textureCube::operator[](size_type Face) const
{
assert(Face < this->faces());
return texture2D(
*this, this->format(),
this->base_layer(), this->max_layer(),
this->base_face() + Face, this->base_face() + Face,
this->base_level(), this->max_level());
}
inline textureCube::dim_type textureCube::dimensions() const
{
assert(!this->empty());
return textureCube::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
//return textureCube::dim_type(this->Storage.dimensions(this->base_level()));
}
}//namespace gli

View file

@ -0,0 +1,107 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/texture_cube_array.inl
/// @date 2013-01-10 / 2013-01-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline textureCubeArray::textureCubeArray()
{}
inline textureCubeArray::textureCubeArray
(
format_type Format,
dim_type const & Dimensions,
size_type Layers
)
: texture(gli::TARGET_CUBE_ARRAY, Format, texture::dim_type(Dimensions, 1), Layers, 6, gli::levels(Dimensions))
{}
inline textureCubeArray::textureCubeArray
(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Levels
)
: texture(gli::TARGET_CUBE_ARRAY, Format, texture::dim_type(Dimensions, 1), Layers, 6, Levels)
{}
inline textureCubeArray::textureCubeArray(texture const & Texture)
: texture(Texture, gli::TARGET_CUBE_ARRAY, Texture.format())
{}
inline textureCubeArray::textureCubeArray
(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_CUBE_ARRAY,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel)
{}
inline textureCubeArray::textureCubeArray
(
textureCubeArray const & Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, gli::TARGET_CUBE_ARRAY, Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline textureCube textureCubeArray::operator[](size_type Layer) const
{
assert(Layer < this->layers());
return textureCube(
*this, this->format(),
this->base_layer() + Layer, this->base_layer() + Layer,
this->base_face(), this->max_face(),
this->base_level(), this->max_level());
}
inline textureCubeArray::dim_type textureCubeArray::dimensions() const
{
assert(!this->empty());
return textureCubeArray::dim_type(
this->Storage->block_count(this->base_level()) * block_dimensions(this->format()));
//return textureCubeArray::dim_type(this->Storage.dimensions(this->base_level()));
}
}//namespace gli

194
external/gli/gli/core/view.inl vendored Normal file
View file

@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/core/view.inl
/// @date 2013-02-07 / 2013-02-07
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline image view(image const & Image)
{
return Image;
}
inline texture view(texture const & Texture)
{
return Texture;
}
template <typename texType>
inline texture view(texType const & Texture)
{
return Texture;
}
template <typename texType>
inline texture view(texType const & Texture, format Format)
{
if(block_size(Texture.format()) != block_size(Format))
return texture();
return texture(Texture, Texture.target(), Format);
}
inline texture view
(
texture1D const & Texture,
texture1D::size_type BaseLevel, texture1D::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
return texture(
Texture, TARGET_1D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
texture1DArray const & Texture,
texture1DArray::size_type BaseLayer, texture1DArray::size_type MaxLayer,
texture1DArray::size_type BaseLevel, texture1DArray::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseLayer <= MaxLayer);
assert(BaseLayer < Texture.layers());
assert(MaxLayer < Texture.layers());
return texture(
Texture, TARGET_1D_ARRAY, Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
texture2D const & Texture,
texture2D::size_type BaseLevel, texture2D::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
return texture(
Texture, TARGET_2D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
texture2DArray const & Texture,
texture2DArray::size_type BaseLayer, texture2DArray::size_type MaxLayer,
texture2DArray::size_type BaseLevel, texture2DArray::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseLayer <= MaxLayer);
assert(BaseLayer < Texture.layers());
assert(MaxLayer < Texture.layers());
return texture(
Texture, TARGET_2D_ARRAY, Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
texture3D const & Texture,
texture3D::size_type BaseLevel, texture3D::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
return texture(
Texture, TARGET_3D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
textureCube const & Texture,
textureCube::size_type BaseFace, textureCube::size_type MaxFace,
textureCube::size_type BaseLevel, textureCube::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseFace <= MaxFace);
assert(BaseFace < Texture.faces());
assert(MaxFace < Texture.faces());
return texture(
Texture, TARGET_CUBE, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
textureCubeArray const & Texture,
textureCubeArray::size_type BaseLayer, textureCubeArray::size_type MaxLayer,
textureCubeArray::size_type BaseFace, textureCubeArray::size_type MaxFace,
textureCubeArray::size_type BaseLevel, textureCubeArray::size_type MaxLevel
)
{
assert(BaseLevel <= MaxLevel);
assert(BaseLevel < Texture.levels());
assert(MaxLevel < Texture.levels());
assert(BaseFace <= MaxFace);
assert(BaseFace < Texture.faces());
assert(MaxFace < Texture.faces());
assert(BaseLayer <= MaxLayer);
assert(BaseLayer < Texture.layers());
assert(MaxLayer < Texture.layers());
return texture(
Texture, TARGET_CUBE_ARRAY, Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
}//namespace gli

345
external/gli/gli/dx.hpp vendored Normal file
View file

@ -0,0 +1,345 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/gl.hpp
/// @date 2013-11-09 / 2013-11-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "format.hpp"
#include <array>
namespace gli
{
class dx
{
public:
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
(std::uint32_t)( \
(((std::uint32_t)(std::uint8_t)(ch3) << 24) & 0xFF000000) | \
(((std::uint32_t)(std::uint8_t)(ch2) << 16) & 0x00FF0000) | \
(((std::uint32_t)(std::uint8_t)(ch1) << 8) & 0x0000FF00) | \
((std::uint32_t)(std::uint8_t)(ch0) & 0x000000FF) )
enum D3DFORMAT
{
D3DFMT_UNKNOWN = 0,
D3DFMT_R8G8B8 = 20,
D3DFMT_A8R8G8B8 = 21,
D3DFMT_X8R8G8B8 = 22,
D3DFMT_R5G6B5 = 23,
D3DFMT_X1R5G5B5 = 24,
D3DFMT_A1R5G5B5 = 25,
D3DFMT_A4R4G4B4 = 26,
D3DFMT_R3G3B2 = 27,
D3DFMT_A8 = 28,
D3DFMT_A8R3G3B2 = 29,
D3DFMT_X4R4G4B4 = 30,
D3DFMT_A2B10G10R10 = 31,
D3DFMT_A8B8G8R8 = 32,
D3DFMT_X8B8G8R8 = 33,
D3DFMT_G16R16 = 34,
D3DFMT_A2R10G10B10 = 35,
D3DFMT_A16B16G16R16 = 36,
D3DFMT_A8P8 = 40,
D3DFMT_P8 = 41,
D3DFMT_L8 = 50,
D3DFMT_A8L8 = 51,
D3DFMT_A4L4 = 52,
D3DFMT_V8U8 = 60,
D3DFMT_L6V5U5 = 61,
D3DFMT_X8L8V8U8 = 62,
D3DFMT_Q8W8V8U8 = 63,
D3DFMT_V16U16 = 64,
D3DFMT_A2W10V10U10 = 67,
D3DFMT_UYVY = GLI_MAKEFOURCC('U', 'Y', 'V', 'Y'),
D3DFMT_R8G8_B8G8 = GLI_MAKEFOURCC('R', 'G', 'B', 'G'),
D3DFMT_YUY2 = GLI_MAKEFOURCC('Y', 'U', 'Y', '2'),
D3DFMT_G8R8_G8B8 = GLI_MAKEFOURCC('G', 'R', 'G', 'B'),
D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
D3DFMT_ATI1 = GLI_MAKEFOURCC('A', 'T', 'I', '1'),
D3DFMT_AT1N = GLI_MAKEFOURCC('A', 'T', '1', 'N'),
D3DFMT_ATI2 = GLI_MAKEFOURCC('A', 'T', 'I', '2'),
D3DFMT_AT2N = GLI_MAKEFOURCC('A', 'T', '2', 'N'),
D3DFMT_ETC = GLI_MAKEFOURCC('E', 'T', 'C', ' '),
D3DFMT_ETC1 = GLI_MAKEFOURCC('E', 'T', 'C', '1'),
D3DFMT_ATC = GLI_MAKEFOURCC('A', 'T', 'C', ' '),
D3DFMT_ATCA = GLI_MAKEFOURCC('A', 'T', 'C', 'A'),
D3DFMT_ATCI = GLI_MAKEFOURCC('A', 'T', 'C', 'I'),
D3DFMT_POWERVR_2BPP = GLI_MAKEFOURCC('P', 'T', 'C', '2'),
D3DFMT_POWERVR_4BPP = GLI_MAKEFOURCC('P', 'T', 'C', '4'),
D3DFMT_D16_LOCKABLE = 70,
D3DFMT_D32 = 71,
D3DFMT_D15S1 = 73,
D3DFMT_D24S8 = 75,
D3DFMT_D24X8 = 77,
D3DFMT_D24X4S4 = 79,
D3DFMT_D16 = 80,
D3DFMT_D32F_LOCKABLE = 82,
D3DFMT_D24FS8 = 83,
D3DFMT_L16 = 81,
D3DFMT_VERTEXDATA =100,
D3DFMT_INDEX16 =101,
D3DFMT_INDEX32 =102,
D3DFMT_Q16W16V16U16 =110,
D3DFMT_MULTI2_ARGB8 = GLI_MAKEFOURCC('M','E','T','1'),
D3DFMT_R16F = 111,
D3DFMT_G16R16F = 112,
D3DFMT_A16B16G16R16F = 113,
D3DFMT_R32F = 114,
D3DFMT_G32R32F = 115,
D3DFMT_A32B32G32R32F = 116,
D3DFMT_CxV8U8 = 117,
D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
D3DFMT_FORCE_DWORD = 0x7fffffff
};
enum dxgiFormat
{
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_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_P208 = 130,
DXGI_FORMAT_V208 = 131,
DXGI_FORMAT_V408 = 132,
DXGI_FORMAT_ASTC_4X4_TYPELESS = 133,
DXGI_FORMAT_ASTC_4X4_UNORM = 134,
DXGI_FORMAT_ASTC_4X4_UNORM_SRGB = 135,
DXGI_FORMAT_ASTC_5X4_TYPELESS = 137,
DXGI_FORMAT_ASTC_5X4_UNORM = 138,
DXGI_FORMAT_ASTC_5X4_UNORM_SRGB = 139,
DXGI_FORMAT_ASTC_5X5_TYPELESS = 141,
DXGI_FORMAT_ASTC_5X5_UNORM = 142,
DXGI_FORMAT_ASTC_5X5_UNORM_SRGB = 143,
DXGI_FORMAT_ASTC_6X5_TYPELESS = 145,
DXGI_FORMAT_ASTC_6X5_UNORM = 146,
DXGI_FORMAT_ASTC_6X5_UNORM_SRGB = 147,
DXGI_FORMAT_ASTC_6X6_TYPELESS = 149,
DXGI_FORMAT_ASTC_6X6_UNORM = 150,
DXGI_FORMAT_ASTC_6X6_UNORM_SRGB = 151,
DXGI_FORMAT_ASTC_8X5_TYPELESS = 153,
DXGI_FORMAT_ASTC_8X5_UNORM = 154,
DXGI_FORMAT_ASTC_8X5_UNORM_SRGB = 155,
DXGI_FORMAT_ASTC_8X6_TYPELESS = 157,
DXGI_FORMAT_ASTC_8X6_UNORM = 158,
DXGI_FORMAT_ASTC_8X6_UNORM_SRGB = 159,
DXGI_FORMAT_ASTC_8X8_TYPELESS = 161,
DXGI_FORMAT_ASTC_8X8_UNORM = 162,
DXGI_FORMAT_ASTC_8X8_UNORM_SRGB = 163,
DXGI_FORMAT_ASTC_10X5_TYPELESS = 165,
DXGI_FORMAT_ASTC_10X5_UNORM = 166,
DXGI_FORMAT_ASTC_10X5_UNORM_SRGB = 167,
DXGI_FORMAT_ASTC_10X6_TYPELESS = 169,
DXGI_FORMAT_ASTC_10X6_UNORM = 170,
DXGI_FORMAT_ASTC_10X6_UNORM_SRGB = 171,
DXGI_FORMAT_ASTC_10X8_TYPELESS = 173,
DXGI_FORMAT_ASTC_10X8_UNORM = 174,
DXGI_FORMAT_ASTC_10X8_UNORM_SRGB = 175,
DXGI_FORMAT_ASTC_10X10_TYPELESS = 177,
DXGI_FORMAT_ASTC_10X10_UNORM = 178,
DXGI_FORMAT_ASTC_10X10_UNORM_SRGB = 179,
DXGI_FORMAT_ASTC_12X10_TYPELESS = 181,
DXGI_FORMAT_ASTC_12X10_UNORM = 182,
DXGI_FORMAT_ASTC_12X10_UNORM_SRGB = 183,
DXGI_FORMAT_ASTC_12X12_TYPELESS = 185,
DXGI_FORMAT_ASTC_12X12_UNORM = 186,
DXGI_FORMAT_ASTC_12X12_UNORM_SRGB = 187, DXGI_FORMAT_LAST = DXGI_FORMAT_ASTC_12X12_UNORM_SRGB,
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
};
enum DDPF
{
DDPF_ALPHAPIXELS = 0x1,
DDPF_ALPHA = 0x2,
DDPF_FOURCC = 0x4,
DDPF_RGB = 0x40,
DDPF_YUV = 0x200,
DDPF_LUMINANCE = 0x20000,
DDPF_LUMINANCE_ALPHA = DDPF_LUMINANCE | DDPF_ALPHA,
DDPF_FOURCC_ALPHAPIXELS = DDPF_FOURCC | DDPF_ALPHAPIXELS,
DDPF_RGBAPIXELS = DDPF_RGB | DDPF_ALPHAPIXELS,
DDPF_RGBA = DDPF_RGB | DDPF_ALPHA,
DDPF_LUMINANCE_ALPHAPIXELS = DDPF_LUMINANCE | DDPF_ALPHAPIXELS,
};
struct format
{
DDPF DDPixelFormat;
D3DFORMAT D3DFormat;
dxgiFormat DXGIFormat;
glm::u32vec4 Mask;
};
public:
dx();
format const & translate(gli::format const & Format) const;
gli::format find(D3DFORMAT FourCC);
gli::format find(dxgiFormat Format);
private:
std::array<format, FORMAT_COUNT> Translation;
};
}//namespace gli
#include "./core/dx.inl"

237
external/gli/gli/format.hpp vendored Normal file
View file

@ -0,0 +1,237 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2012 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/format.hpp
/// @date 2012-10-16 / 2015-06-16
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "type.hpp"
#include <cstdint>
namespace gli
{
enum format
{
// unorm formats
FORMAT_R8_UNORM = 0, FORMAT_FIRST = FORMAT_R8_UNORM,
FORMAT_RG8_UNORM,
FORMAT_RGB8_UNORM,
FORMAT_RGBA8_UNORM,
FORMAT_R16_UNORM,
FORMAT_RG16_UNORM,
FORMAT_RGB16_UNORM,
FORMAT_RGBA16_UNORM,
// snorm formats
FORMAT_R8_SNORM,
FORMAT_RG8_SNORM,
FORMAT_RGB8_SNORM,
FORMAT_RGBA8_SNORM,
FORMAT_R16_SNORM,
FORMAT_RG16_SNORM,
FORMAT_RGB16_SNORM,
FORMAT_RGBA16_SNORM,
// Unsigned integer formats
FORMAT_R8_UINT,
FORMAT_RG8_UINT,
FORMAT_RGB8_UINT,
FORMAT_RGBA8_UINT,
FORMAT_R16_UINT,
FORMAT_RG16_UINT,
FORMAT_RGB16_UINT,
FORMAT_RGBA16_UINT,
FORMAT_R32_UINT,
FORMAT_RG32_UINT,
FORMAT_RGB32_UINT,
FORMAT_RGBA32_UINT,
// Signed integer formats
FORMAT_R8_SINT,
FORMAT_RG8_SINT,
FORMAT_RGB8_SINT,
FORMAT_RGBA8_SINT,
FORMAT_R16_SINT,
FORMAT_RG16_SINT,
FORMAT_RGB16_SINT,
FORMAT_RGBA16_SINT,
FORMAT_R32_SINT,
FORMAT_RG32_SINT,
FORMAT_RGB32_SINT,
FORMAT_RGBA32_SINT,
// Floating formats
FORMAT_R16_SFLOAT,
FORMAT_RG16_SFLOAT,
FORMAT_RGB16_SFLOAT,
FORMAT_RGBA16_SFLOAT,
FORMAT_R32_SFLOAT,
FORMAT_RG32_SFLOAT,
FORMAT_RGB32_SFLOAT,
FORMAT_RGBA32_SFLOAT,
// sRGB formats
FORMAT_R8_SRGB,
FORMAT_RG8_SRGB,
FORMAT_RGB8_SRGB,
FORMAT_RGBA8_SRGB,
// Packed formats
FORMAT_RGB10A2_UNORM,
FORMAT_RGB10A2_UINT,
FORMAT_RGB9E5_UFLOAT,
FORMAT_RG11B10_UFLOAT,
FORMAT_RG3B2_UNORM,
FORMAT_R5G6B5_UNORM,
FORMAT_RGB5A1_UNORM,
FORMAT_RGBA4_UNORM,
// Swizzle formats
FORMAT_BGRX8_UNORM,
FORMAT_BGRA8_UNORM,
FORMAT_BGRX8_SRGB,
FORMAT_BGRA8_SRGB,
// Luminance Alpha formats
FORMAT_L8_UNORM,
FORMAT_A8_UNORM,
FORMAT_LA8_UNORM,
FORMAT_L16_UNORM,
FORMAT_A16_UNORM,
FORMAT_LA16_UNORM,
// Depth formats
FORMAT_D16_UNORM,
FORMAT_D24_UNORM,
FORMAT_D24S8_UNORM,
FORMAT_D32_UFLOAT,
FORMAT_D32_UFLOAT_S8_UNORM,
// Compressed formats
FORMAT_RGB_DXT1_UNORM, FORMAT_COMPRESSED_FIRST = FORMAT_RGB_DXT1_UNORM,
FORMAT_RGBA_DXT1_UNORM,
FORMAT_RGBA_DXT3_UNORM,
FORMAT_RGBA_DXT5_UNORM,
FORMAT_R_ATI1N_UNORM,
FORMAT_R_ATI1N_SNORM,
FORMAT_RG_ATI2N_UNORM,
FORMAT_RG_ATI2N_SNORM,
FORMAT_RGB_BP_UFLOAT,
FORMAT_RGB_BP_SFLOAT,
FORMAT_RGB_BP_UNORM,
FORMAT_RGB_PVRTC_8X8_UNORM,
FORMAT_RGB_PVRTC_16X8_UNORM,
FORMAT_RGBA_PVRTC_8X8_UNORM,
FORMAT_RGBA_PVRTC_16X8_UNORM,
FORMAT_RGBA_PVRTC2_8X8_UNORM,
FORMAT_RGBA_PVRTC2_16X8_UNORM,
FORMAT_RGB_ATC_UNORM,
FORMAT_RGBA_ATC_EXPLICIT_UNORM,
FORMAT_RGBA_ATC_INTERPOLATED_UNORM,
FORMAT_RGB_ETC_UNORM,
FORMAT_RGB_ETC2_UNORM,
FORMAT_RGBA_ETC2_PUNCHTHROUGH_UNORM,
FORMAT_RGBA_ETC2_UNORM,
FORMAT_R11_EAC_UNORM,
FORMAT_R11_EAC_SNORM,
FORMAT_RG11_EAC_UNORM,
FORMAT_RG11_EAC_SNORM,
FORMAT_RGBA_ASTC_4X4_UNORM,
FORMAT_RGBA_ASTC_5X4_UNORM,
FORMAT_RGBA_ASTC_5X5_UNORM,
FORMAT_RGBA_ASTC_6X5_UNORM,
FORMAT_RGBA_ASTC_6X6_UNORM,
FORMAT_RGBA_ASTC_8X5_UNORM,
FORMAT_RGBA_ASTC_8X6_UNORM,
FORMAT_RGBA_ASTC_8X8_UNORM,
FORMAT_RGBA_ASTC_10X5_UNORM,
FORMAT_RGBA_ASTC_10X6_UNORM,
FORMAT_RGBA_ASTC_10X8_UNORM,
FORMAT_RGBA_ASTC_10X10_UNORM,
FORMAT_RGBA_ASTC_12X10_UNORM,
FORMAT_RGBA_ASTC_12X12_UNORM,
// Compressed sRGB formats
FORMAT_RGB_DXT1_SRGB,
FORMAT_RGBA_DXT1_SRGB,
FORMAT_RGBA_DXT3_SRGB,
FORMAT_RGBA_DXT5_SRGB,
FORMAT_RGB_BP_SRGB,
FORMAT_RGB_PVRTC_8X8_SRGB,
FORMAT_RGB_PVRTC_16X8_SRGB,
FORMAT_RGBA_PVRTC_8X8_SRGB,
FORMAT_RGBA_PVRTC_16X8_SRGB,
FORMAT_RGBA_PVRTC2_8X8_SRGB,
FORMAT_RGBA_PVRTC2_16X8_SRGB,
FORMAT_RGB_ETC_SRGB,
FORMAT_RGBA_ETC2_PUNCHTHROUGH_SRGB,
FORMAT_RGBA_ETC2_SRGB,
FORMAT_RGBA_ASTC_4X4_SRGB,
FORMAT_RGBA_ASTC_5X4_SRGB,
FORMAT_RGBA_ASTC_5X5_SRGB,
FORMAT_RGBA_ASTC_6X5_SRGB,
FORMAT_RGBA_ASTC_6X6_SRGB,
FORMAT_RGBA_ASTC_8X5_SRGB,
FORMAT_RGBA_ASTC_8X6_SRGB,
FORMAT_RGBA_ASTC_8X8_SRGB,
FORMAT_RGBA_ASTC_10X5_SRGB,
FORMAT_RGBA_ASTC_10X6_SRGB,
FORMAT_RGBA_ASTC_10X8_SRGB,
FORMAT_RGBA_ASTC_10X10_SRGB,
FORMAT_RGBA_ASTC_12X10_SRGB,
FORMAT_RGBA_ASTC_12X12_SRGB, FORMAT_COMPRESSED_LAST = FORMAT_RGBA_ASTC_12X12_SRGB, FORMAT_LAST = FORMAT_RGBA_ASTC_12X12_SRGB
};
enum
{
FORMAT_INVALID = -1,
FORMAT_COUNT = FORMAT_LAST - FORMAT_FIRST + 1,
FORMAT_COMPRESSED_COUNT = FORMAT_COMPRESSED_LAST - FORMAT_COMPRESSED_FIRST + 1
};
inline bool is_compressed(format Format)
{
return Format >= FORMAT_COMPRESSED_FIRST && Format <= FORMAT_COMPRESSED_LAST;
}
inline bool is_valid(format Format)
{
return Format >= FORMAT_FIRST && Format <= FORMAT_LAST;
}
std::uint32_t block_size(format Format);
gli::dim3_t block_dimensions(format Format);
std::uint32_t component_count(format Format);
}//namespace gli
#include "./core/format.inl"

307
external/gli/gli/gl.hpp vendored Normal file
View file

@ -0,0 +1,307 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/gl.hpp
/// @date 2013-11-09 / 2013-11-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "format.hpp"
#include "target.hpp"
#include <array>
namespace gli
{
class gl
{
public:
enum internalFormat
{
// unorm formats
INTERNAL_R8_UNORM = 0x8229, //GL_R8
INTERNAL_RG8_UNORM = 0x822B, //GL_RG8
INTERNAL_RGB8_UNORM = 0x8051, //GL_RGB8
INTERNAL_RGBA8_UNORM = 0x8058, //GL_RGBA8
INTERNAL_R16_UNORM = 0x822A, //GL_R16
INTERNAL_RG16_UNORM = 0x822C, //GL_RG16
INTERNAL_RGB16_UNORM = 0x8054, //GL_RGB16
INTERNAL_RGBA16_UNORM = 0x805B, //GL_RGBA16
INTERNAL_RGB10A2_UNORM = 0x8059, //GL_RGB10_A2
// snorm formats
INTERNAL_R8_SNORM = 0x8F94, //GL_R8_SNORM
INTERNAL_RG8_SNORM = 0x8F95, //GL_RG8_SNORM
INTERNAL_RGB8_SNORM = 0x8F96, //GL_RGB8_SNORM
INTERNAL_RGBA8_SNORM = 0x8F97, //GL_RGBA8_SNORM
INTERNAL_R16_SNORM = 0x8F98, //GL_R16_SNORM
INTERNAL_RG16_SNORM= 0x8F99, //GL_RG16_SNORM
INTERNAL_RGB16_SNORM= 0x8F9A, //GL_RGB16_SNORM
INTERNAL_RGBA16_SNORM = 0x8F9B, //GL_RGBA16_SNORM
// unsigned integer formats
INTERNAL_R8U = 0x8232, //GL_R8UI
INTERNAL_RG8U = 0x8238, //GL_RG8UI
INTERNAL_RGB8U = 0x8D7D, //GL_RGB8UI
INTERNAL_RGBA8U = 0x8D7C, //GL_RGBA8UI
INTERNAL_R16U = 0x8234, //GL_R16UI
INTERNAL_RG16U = 0x823A, //GL_RG16UI
INTERNAL_RGB16U = 0x8D77, //GL_RGB16UI
INTERNAL_RGBA16U = 0x8D76, //GL_RGBA16UI
INTERNAL_R32U = 0x8236, //GL_R32UI
INTERNAL_RG32U = 0x823C, //GL_RG32UI
INTERNAL_RGB32U = 0x8D71, //GL_RGB32UI
INTERNAL_RGBA32U = 0x8D70, //GL_RGBA32UI
INTERNAL_RGB10A2U = 0x906F, //GL_RGB10_A2UI
// signed integer formats
INTERNAL_R8I = 0x8231, //GL_R8I
INTERNAL_RG8I = 0x8237, //GL_RG8I
INTERNAL_RGB8I = 0x8D8F, //GL_RGB8I
INTERNAL_RGBA8I = 0x8D8E, //GL_RGBA8I
INTERNAL_R16I = 0x8233, //GL_R16I
INTERNAL_RG16I = 0x8239, //GL_RG16I
INTERNAL_RGB16I = 0x8D89, //GL_RGB16I
INTERNAL_RGBA16I = 0x8D88, //GL_RGBA16I
INTERNAL_R32I = 0x8235, //GL_R32I
INTERNAL_RG32I = 0x823B, //GL_RG32I
INTERNAL_RGB32I = 0x8D83, //GL_RGB32I
INTERNAL_RGBA32I = 0x8D82, //GL_RGBA32I
// Floating formats
INTERNAL_R16F = 0x822D, //GL_R16F
INTERNAL_RG16F = 0x822F, //GL_RG16F
INTERNAL_RGB16F = 0x881B, //GL_RGB16F
INTERNAL_RGBA16F = 0x881A, //GL_RGBA16F
INTERNAL_R32F = 0x822E, //GL_R32F
INTERNAL_RG32F = 0x8230, //GL_RG32F
INTERNAL_RGB32F = 0x8815, //GL_RGB32F
INTERNAL_RGBA32F = 0x8814, //GL_RGBA32F
// sRGB formats
INTERNAL_SR8 = 0x8FBD, //GL_SR8_EXT
INTERNAL_SRG8 = 0x8FBE, //GL_SRG8_EXT
INTERNAL_SRGB8 = 0x8C41, //GL_SRGB8
INTERNAL_SRGB8_ALPHA8 = 0x8C43, //GL_SRGB8_ALPHA8
// Packed formats
INTERNAL_RGB9E5 = 0x8C3D, //GL_RGB9_E5
INTERNAL_RG11B10F = 0x8C3A, //GL_R11F_G11F_B10F
INTERNAL_RG3B2 = 0x2A10, //GL_R3_G3_B2
INTERNAL_R5G6B5 = 0x8D62, //GL_RGB565
INTERNAL_RGB5A1 = 0x8057, //GL_RGB5_A1
INTERNAL_RGBA4 = 0x8056, //GL_RGBA4
// Luminance Alpha formats
INTERNAL_LA4 = 0x8043, //GL_LUMINANCE4_ALPHA4
INTERNAL_L8 = 0x8040, //GL_LUMINANCE8
INTERNAL_A8 = 0x803C, //GL_ALPHA8
INTERNAL_LA8 = 0x8045, //GL_LUMINANCE8_ALPHA8
INTERNAL_L16 = 0x8042, //GL_LUMINANCE16
INTERNAL_A16 = 0x803E, //GL_ALPHA16
INTERNAL_LA16 = 0x8048, //GL_LUMINANCE16_ALPHA16
// Depth formats
INTERNAL_D16 = 0x81A5, //GL_DEPTH_COMPONENT16
INTERNAL_D24 = 0x81A6, //GL_DEPTH_COMPONENT24
INTERNAL_D24S8 = 0x88F0, //GL_DEPTH24_STENCIL8
INTERNAL_D32 = 0x81A7, //GL_DEPTH_COMPONENT32
INTERNAL_D32F = 0x8CAC, //GL_DEPTH_COMPONENT32F
INTERNAL_D32FS8X24 = 0x8CAD, //GL_DEPTH32F_STENCIL8
// Compressed formats
INTERNAL_RGB_DXT1 = 0x83F0, //GL_COMPRESSED_RGB_S3TC_DXT1_EXT
INTERNAL_RGBA_DXT1 = 0x83F1, //GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
INTERNAL_RGBA_DXT3 = 0x83F2, //GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
INTERNAL_RGBA_DXT5 = 0x83F3, //GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
INTERNAL_R_ATI1N_UNORM = 0x8DBB, //GL_COMPRESSED_RED_RGTC1
INTERNAL_R_ATI1N_SNORM = 0x8DBC, //GL_COMPRESSED_SIGNED_RED_RGTC1
INTERNAL_RG_ATI2N_UNORM = 0x8DBD, //GL_COMPRESSED_RG_RGTC2
INTERNAL_RG_ATI2N_SNORM = 0x8DBE, //GL_COMPRESSED_SIGNED_RG_RGTC2
INTERNAL_RGB_BP_UNSIGNED_FLOAT = 0x8E8F, //GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT
INTERNAL_RGB_BP_SIGNED_FLOAT = 0x8E8E, //GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT
INTERNAL_RGB_BP_UNORM = 0x8E8C, //GL_COMPRESSED_RGBA_BPTC_UNORM
INTERNAL_RGB_PVRTC_4BPPV1 = 0x8C00, //GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
INTERNAL_RGB_PVRTC_2BPPV1 = 0x8C01, //GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
INTERNAL_RGBA_PVRTC_4BPPV1 = 0x8C02, //GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
INTERNAL_RGBA_PVRTC_2BPPV1 = 0x8C03, //GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
INTERNAL_RGBA_PVRTC_4BPPV2 = 0x9137, //GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
INTERNAL_RGBA_PVRTC_2BPPV2 = 0x9138, //GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG
INTERNAL_ATC_RGB = 0x8C92, //GL_ATC_RGB_AMD
INTERNAL_ATC_RGBA_EXPLICIT_ALPHA = 0x8C93, //GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
INTERNAL_ATC_RGBA_INTERPOLATED_ALPHA = 0x87EE, //GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
INTERNAL_RGB_ETC = 0x8D64, //GL_COMPRESSED_RGB8_ETC1
INTERNAL_RGB_ETC2 = 0x9274, //GL_COMPRESSED_RGB8_ETC2
INTERNAL_RGBA_PUNCHTHROUGH_ETC2 = 0x9276, //GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
INTERNAL_RGBA_ETC2 = 0x9278, //GL_COMPRESSED_RGBA8_ETC2_EAC
INTERNAL_R11_EAC = 0x9270, //GL_COMPRESSED_R11_EAC
INTERNAL_SIGNED_R11_EAC = 0x9271, //GL_COMPRESSED_SIGNED_R11_EAC
INTERNAL_RG11_EAC = 0x9272, //GL_COMPRESSED_RG11_EAC
INTERNAL_SIGNED_RG11_EAC = 0x9273, //GL_COMPRESSED_SIGNED_RG11_EAC
INTERNAL_RGBA_ASTC_4x4 = 0x93B0, //GL_COMPRESSED_RGBA_ASTC_4x4_KHR
INTERNAL_RGBA_ASTC_5x4 = 0x93B1, //GL_COMPRESSED_RGBA_ASTC_5x4_KHR
INTERNAL_RGBA_ASTC_5x5 = 0x93B2, //GL_COMPRESSED_RGBA_ASTC_5x5_KHR
INTERNAL_RGBA_ASTC_6x5 = 0x93B3, //GL_COMPRESSED_RGBA_ASTC_6x5_KHR
INTERNAL_RGBA_ASTC_6x6 = 0x93B4, //GL_COMPRESSED_RGBA_ASTC_6x6_KHR
INTERNAL_RGBA_ASTC_8x5 = 0x93B5, //GL_COMPRESSED_RGBA_ASTC_8x5_KHR
INTERNAL_RGBA_ASTC_8x6 = 0x93B6, //GL_COMPRESSED_RGBA_ASTC_8x6_KHR
INTERNAL_RGBA_ASTC_8x8 = 0x93B7, //GL_COMPRESSED_RGBA_ASTC_8x8_KHR
INTERNAL_RGBA_ASTC_10x5 = 0x93B8, //GL_COMPRESSED_RGBA_ASTC_10x5_KHR
INTERNAL_RGBA_ASTC_10x6 = 0x93B9, //GL_COMPRESSED_RGBA_ASTC_10x6_KHR
INTERNAL_RGBA_ASTC_10x8 = 0x93BA, //GL_COMPRESSED_RGBA_ASTC_10x8_KHR
INTERNAL_RGBA_ASTC_10x10 = 0x93BB, //GL_COMPRESSED_RGBA_ASTC_10x10_KHR
INTERNAL_RGBA_ASTC_12x10 = 0x93BC, //GL_COMPRESSED_RGBA_ASTC_12x10_KHR
INTERNAL_RGBA_ASTC_12x12 = 0x93BD, //GL_COMPRESSED_RGBA_ASTC_12x12_KHR
// sRGB formats
INTERNAL_SRGB_DXT1 = 0x8C4C, //GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
INTERNAL_SRGB_ALPHA_DXT1 = 0x8C4C, //GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
INTERNAL_SRGB_ALPHA_DXT3 = 0x8C4E, //GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
INTERNAL_SRGB_ALPHA_DXT5 = 0x8C4F, //GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
INTERNAL_SRGB_BP_UNORM = 0x8E8D, //GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM
INTERNAL_SRGB_PVRTC_2BPPV1 = 0x8A54, //GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT
INTERNAL_SRGB_PVRTC_4BPPV1 = 0x8A55, //GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT
INTERNAL_SRGB_ALPHA_PVRTC_2BPPV1 = 0x8A56, //GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT
INTERNAL_SRGB_ALPHA_PVRTC_4BPPV1 = 0x8A57, //GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT
INTERNAL_SRGB_ALPHA_PVRTC_2BPPV2 = 0x93F0, //COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG
INTERNAL_SRGB_ALPHA_PVRTC_4BPPV2 = 0x93F1, //GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG
INTERNAL_SRGB8_ETC2 = 0x9275, //GL_COMPRESSED_SRGB8_ETC2
INTERNAL_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277, //GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
INTERNAL_SRGB8_ALPHA8_ETC2_EAC = 0x9279, //GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
INTERNAL_SRGB8_ALPHA8_ASTC_4x4 = 0x93D0, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_5x4 = 0x93D1, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_5x5 = 0x93D2, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_6x5 = 0x93D3, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_6x6 = 0x93D4, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_8x5 = 0x93D5, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_8x6 = 0x93D6, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_8x8 = 0x93D7, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x5 = 0x93D8, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x6 = 0x93D9, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x8 = 0x93DA, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x10 = 0x93DB, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_12x10 = 0x93DC, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_12x12 = 0x93DD //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
};
enum externalFormat
{
EXTERNAL_NONE = 0, //GL_NONE
EXTERNAL_RED = 0x1903, //GL_RED
EXTERNAL_RG = 0x8227, //GL_RG
EXTERNAL_RGB= 0x1907, //GL_RGB
EXTERNAL_BGR = 0x80E0, //GL_BGR
EXTERNAL_RGBA = 0x1908, //GL_RGBA
EXTERNAL_BGRA = 0x80E1, //GL_BGRA
EXTERNAL_RED_INTEGER = 0x8D94, //GL_RED_INTEGER
EXTERNAL_RG_INTEGER = 0x8228, //GL_RG_INTEGER
EXTERNAL_RGB_INTEGER = 0x8D98, //GL_RGB_INTEGER
EXTERNAL_BGR_INTEGER = 0x8D9A, //GL_BGR_INTEGER
EXTERNAL_RGBA_INTEGER = 0x8D99, //GL_RGBA_INTEGER
EXTERNAL_BGRA_INTEGER = 0x8D9B, //GL_BGRA_INTEGER
EXTERNAL_DEPTH = 0x1902, //GL_DEPTH_COMPONENT
EXTERNAL_DEPTH_STENCIL = 0x84F9, //GL_DEPTH_STENCIL
EXTERNAL_LUMINANCE = 0x1909, //GL_LUMINANCE
EXTERNAL_ALPHA = 0x1906, //GL_ALPHA
EXTERNAL_LUMINANCE_ALPHA = 0x190A, //GL_LUMINANCE_ALPHA
};
enum typeFormat
{
TYPE_NONE = 0, //GL_NONE
TYPE_I8 = 0x1400, //GL_BYTE
TYPE_U8 = 0x1401, //GL_UNSIGNED_BYTE
TYPE_I16 = 0x1402, //GL_SHORT
TYPE_U16 = 0x1403, //GL_UNSIGNED_SHORT
TYPE_I32 = 0x1404, //GL_INT
TYPE_U32 = 0x1405, //GL_UNSIGNED_INT
TYPE_F16 = 0x140B, //GL_HALF_FLOAT
TYPE_F32 = 0x1406, //GL_FLOAT
TYPE_UINT32_RGB9_E5 = 0x8C3E, //GL_UNSIGNED_INT_5_9_9_9_REV
TYPE_UINT32_RG11B10F = 0x8C3B, //GL_UNSIGNED_INT_10F_11F_11F_REV
TYPE_UINT8_RG3B2 = 0x8032, //GL_UNSIGNED_BYTE_3_3_2
TYPE_UINT8_RG3B2_REV = 0x8362, //GL_UNSIGNED_BYTE_2_3_3_REV
TYPE_UINT16_RGB5A1 = 0x8034, //GL_UNSIGNED_SHORT_5_5_5_1
TYPE_UINT16_RGB5A1_REV = 0x8366, //GL_UNSIGNED_SHORT_1_5_5_5_REV
TYPE_UINT16_R5G6B5 = 0x8363, //GL_UNSIGNED_SHORT_5_6_5
TYPE_UINT16_R5G6B5_REV = 0x8364, //GL_UNSIGNED_SHORT_5_6_5_REV
TYPE_UINT16_RGBA4 = 0x8033, //GL_UNSIGNED_SHORT_4_4_4_4
TYPE_UINT16_RGBA4_REV = 0x8365, //GL_UNSIGNED_SHORT_4_4_4_4_REV
TYPE_UINT32_RGB10A2 = 0x8036, //GL_UNSIGNED_INT_10_10_10_2
TYPE_UINT32_RGB10A2_REV = 0x8368 //GL_UNSIGNED_INT_2_10_10_10_REV
};
enum target
{
TARGET_1D = 0x0DE0,
TARGET_1D_ARRAY = 0x8C18,
TARGET_2D = 0x0DE1,
TARGET_2D_ARRAY = 0x8C1A,
TARGET_3D = 0x806F,
TARGET_CUBE = 0x8513,
TARGET_CUBE_ARRAY = 0x9009
};
enum swizzle
{
SWIZZLE_RED = 0x1903, //GL_RED
SWIZZLE_GREEN = 0x1904, //GL_GREEN
SWIZZLE_BLUE = 0x1905, //GL_BLUE
SWIZZLE_ALPHA = 0x1906, //GL_ALPHA
SWIZZLE_ZERO = 0x0000, //GL_ZERO
SWIZZLE_ONE = 0x0001, //GL_ONE
};
struct format
{
internalFormat Internal;
externalFormat External;
typeFormat Type;
swizzle Swizzle[4];
};
gl();
target const & translate(gli::target Target) const;
format const & translate(gli::format Format) const;
gli::format find(internalFormat internalFormat, externalFormat externalFormat, typeFormat type);
private:
std::array<format, FORMAT_COUNT> Translation;
};
}//namespace gli
#include "./core/gl.inl"

69
external/gli/gli/gli.hpp vendored Normal file
View file

@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/gli.hpp
/// @date 2008-12-19 / 2015-08-08
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
/*! @mainpage OpenGL Image
*
*/
#pragma once
#define GLI_VERSION 70
#define GLI_VERSION_MAJOR 0
#define GLI_VERSION_MINOR 7
#define GLI_VERSION_PATCH 0
#define GLI_VERSION_REVISION 0
#include "format.hpp"
#include "target.hpp"
#include "levels.hpp"
#include "image.hpp"
#include "texture.hpp"
#include "texture1d.hpp"
#include "texture1d_array.hpp"
#include "texture2d.hpp"
#include "texture2d_array.hpp"
#include "texture3d.hpp"
#include "texture_cube.hpp"
#include "texture_cube_array.hpp"
#include "copy.hpp"
#include "view.hpp"
#include "comparison.hpp"
#include "load.hpp"
#include "save.hpp"
#include "gl.hpp"
#include "dx.hpp"
#include "./core/flip.hpp"
#include "./core/fetch.hpp"

143
external/gli/gli/image.hpp vendored Normal file
View file

@ -0,0 +1,143 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/image.hpp
/// @date 2011-10-06 / 2013-01-12
/// @author Christophe Riccio
///
/// @defgroup core_image Image
/// @ingroup core
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "./core/storage.hpp"
namespace gli
{
/// Image
class image
{
private:
friend class texture1D;
friend class texture2D;
friend class texture3D;
public:
typedef size_t size_type;
typedef gli::format format_type;
typedef storage::dim_type dim_type;
typedef storage::data_type data_type;
/// Create an empty image instance
image();
/// Create an image object and allocate an image storoge for it.
explicit image(
format_type Format,
dim_type const & Dimensions);
/// Create an image object by sharing an existing image storage from another image instance.
/// This image object is effectively an image view where format can be reinterpreted
/// with a different compatible image format.
/// For formats to be compatible, the block size of source and destination must match.
explicit image(
image const & Image,
format_type Format);
/// Return whether the image instance is empty, no storage or description have been assigned to the instance.
bool empty() const;
/// Return the image instance format.
format_type format() const;
/// Return the dimensions of an image instance: width, height and depth.
dim_type dimensions() const;
/// Return the memory size of an image instance storage in bytes.
size_type size() const;
/// Return the number of blocks contained in an image instance storage.
/// genType size must match the block size conresponding to the image format.
template <typename genType>
size_type size() const;
/// Return a pointer to the beginning of the image instance data.
void * data();
/// Return a pointer to the beginning of the image instance data.
void const * data() const;
/// Return a pointer of type genType which size must match the image format block size.
template <typename genType>
genType * data();
/// Return a pointer of type genType which size must match the image format block size.
template <typename genType>
genType const * data() const;
/// Clear the entire image storage with zeros
void clear();
/// Clear the entire image storage with Texel which type must match the image storage format block size
/// If the type of genType doesn't match the type of the image format, no conversion is performed and the data will be reinterpreted as if is was of the image format.
template <typename genType>
void clear(genType const & Texel);
/// Load the texel located at TexelCoord coordinates.
/// It's an error to call this function if the format is compressed.
/// It's an error if TexelCoord values aren't between [0, dimensions].
template <typename genType>
genType load(dim_type const & TexelCoord);
/// Store the texel located at TexelCoord coordinates.
/// It's an error to call this function if the format is compressed.
/// It's an error if TexelCoord values aren't between [0, dimensions].
template <typename genType>
void store(dim_type const & TexelCoord, genType const & Data);
private:
/// Create an image object by sharing an existing image storage from another image instance.
/// This image object is effectively an image view where the layer, the face and the level allows identifying
/// a specific subset of the image storage source.
/// This image object is effectively a image view where the format can be reinterpreted
/// with a different compatible image format.
explicit image(
std::shared_ptr<storage> Storage,
format_type Format,
size_type BaseLayer,
size_type BaseFace,
size_type BaseLevel);
std::shared_ptr<storage> Storage;
format_type const Format;
size_type const BaseLevel;
data_type * Data;
size_type const Size;
data_type * compute_data(size_type BaseLayer, size_type BaseFace, size_type BaseLevel);
size_type compute_size(size_type Level) const;
};
}//namespace gli
#include "./core/image.inl"

65
external/gli/gli/levels.hpp vendored Normal file
View file

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2014 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/levels.hpp
/// @date 2014-12-12 / 2014-12-12
/// @author Christophe Riccio
///
/// @defgroup core_image Image
/// @ingroup core
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "type.hpp"
namespace gli
{
/// Compute the number of mipmaps levels necessary to create a mipmap complete texture
///
/// @param Dimensions Dimensions of the texture base level mipmap
/// @tparam dimType Vector type used to express the dimentions of a texture of any kind.
/// @code
/// #include <gli/gli.hpp>
/// #include <gli/levels.hpp>
/// ...
/// gli::size2_t Dimensions(32, 10);
/// gli::texture2D Texture(gli::levels(Dimensions));
/// @endcode
template <template <typename, glm::precision> class dimType>
size_t levels(dimType<size_t, glm::defaultp> const & Dimensions);
/// Compute the number of mipmaps levels necessary to create a mipmap complete texture
///
/// @param Dimensions Dimensions of the texture base level mipmap
/// @tparam dimType Vector type used to express the dimentions of a texture of any kind.
/// @code
/// #include <gli/gli.hpp>
/// #include <gli/levels.hpp>
/// ...
/// gli::texture2D Texture(32);
/// @endcode
size_t levels(size_t Dimension);
}//namespace gli
#include "./core/levels.inl"

51
external/gli/gli/load.hpp vendored Normal file
View file

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/load.hpp
/// @date 2015-08-09 / 2015-08-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage from file. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load(char const * Path);
/// Loads a texture storage from file. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load(std::string const & Filename);
/// Loads a texture storage from memory. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load(char const * Data, std::size_t Size);
}//namespace gli
#include "./core/load.inl"

51
external/gli/gli/load_dds.hpp vendored Normal file
View file

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/load_dds.hpp
/// @date 2010-09-08 / 2013-01-28
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage from DDS file. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_dds(char const * Path);
/// Loads a texture storage from DDS file. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_dds(std::string const & Filename);
/// Loads a texture storage from DDS memory. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_dds(char const * Data, std::size_t Size);
}//namespace gli
#include "./core/load_dds.inl"

51
external/gli/gli/load_ktx.hpp vendored Normal file
View file

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/load_ktx.hpp
/// @date 2015-08-05 / 2015-08-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage from KTX file. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_ktx(char const * Path);
/// Loads a texture storage from KTX file. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_ktx(std::string const & Filename);
/// Loads a texture storage from KTX memory. Returns an empty storage in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_ktx(char const * Data, std::size_t Size);
}//namespace gli
#include "./core/load_ktx.inl"

51
external/gli/gli/save.hpp vendored Normal file
View file

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/save.hpp
/// @date 2015-08-09 / 2015-08-09
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "save_dds.hpp"
#include "save_ktx.hpp"
namespace gli
{
/// Save a texture storage to file.
///
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// The function use the filename extension included in the path to figure out the file container to use.
/// @return Returns false if the function fails to save the file.
bool save(texture const & Texture, char const * Path);
/// Save a texture storage to file.
///
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// The function use the filename extension included in the path to figure out the file container to use.
/// @return Returns false if the function fails to save the file.
bool save(texture const & Texture, std::string const & Path);
}//namespace gli
#include "./core/save.inl"

56
external/gli/gli/save_dds.hpp vendored Normal file
View file

@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/save_dds.hpp
/// @date 2013-01-28 / 2013-01-28
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "load_dds.hpp"
namespace gli
{
/// Save a texture storage to a DDS file.
///
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to DDS anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_dds(texture const & Texture, char const * Filename);
/// Save a texture storage to a DDS file.
///
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to DDS anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_dds(texture const & Texture, std::string const & Filename);
/// Save a texture storage to a DDS file.
///
/// @param Memory Storage for the DDS container. The function resizes the containers to fit the necessary storage.
/// @return Returns false if the function fails to save the file.
bool save_dds(texture const & Texture, std::vector<char> & Memory);
}//namespace gli
#include "./core/save_dds.inl"

56
external/gli/gli/save_ktx.hpp vendored Normal file
View file

@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/save_ktx.hpp
/// @date 2015-08-05 / 2015-08-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "load_ktx.hpp"
namespace gli
{
/// Save a texture storage to a KTX file.
///
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to KTX anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_ktx(texture const & Texture, char const * Path);
/// Save a texture storage to a KTX file.
///
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to KTX anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_ktx(texture const & Texture, std::string const & Path);
/// Save a texture storage to a KTX file.
///
/// @param Memory Storage for the KTX container. The function resizes the containers to fit the necessary storage.
/// @return Returns false if the function fails to save the file.
bool save_ktx(texture const & Texture, std::vector<char> & Memory);
}//namespace gli
#include "./core/save_ktx.inl"

67
external/gli/gli/target.hpp vendored Normal file
View file

@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/target.hpp
/// @date 2015-08-21 / 2015-08-21
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
namespace gli
{
enum target
{
TARGET_1D = 0, TARGET_FIRST = TARGET_1D,
TARGET_1D_ARRAY,
TARGET_2D,
TARGET_2D_ARRAY,
TARGET_3D,
TARGET_CUBE,
TARGET_CUBE_ARRAY, TARGET_LAST = TARGET_CUBE_ARRAY
};
enum
{
TARGET_COUNT = TARGET_LAST - TARGET_FIRST + 1,
TARGET_INVALID = -1
};
/// Check whether a target is a 1D target
inline bool is_target_1d(target Target)
{
return Target == TARGET_1D || Target == TARGET_1D_ARRAY;
}
/// Check whether a target is an array target
inline bool is_target_array(target Target)
{
return Target == TARGET_1D_ARRAY || Target == TARGET_2D_ARRAY || Target == TARGET_CUBE_ARRAY;
}
/// Check whether a target is a cube map target
inline bool is_target_cube(target Target)
{
return Target == TARGET_CUBE || Target == TARGET_CUBE_ARRAY;
}
}//namespace gli

200
external/gli/gli/texture.hpp vendored Normal file
View file

@ -0,0 +1,200 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture.hpp
/// @date 2013-02-05 / 2013-02-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "image.hpp"
#include "target.hpp"
namespace gli
{
/// Genetic texture class. It can support any target.
class texture
{
public:
typedef size_t size_type;
typedef gli::format format_type;
typedef gli::target target_type;
typedef storage::dim_type dim_type;
typedef storage::data_type data_type;
/// Create an empty texture instance
texture();
/// Create a texture object and allocate a texture storoge for it
texture(
target_type Target,
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Faces,
size_type Levels);
/// Create a texture object by sharing an existing texture storage from another texture instance.
/// This texture object is effectively a texture view where the layer, the face and the level allows identifying
/// a specific subset of the texture storage source.
/// This texture object is effectively a texture view where the target and format can be reinterpreted
/// with a different compatible texture target and texture format.
texture(
texture const & Texture,
target_type Target,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture object by sharing an existing texture storage from another texture instance.
/// This texture object is effectively a texture view where the target and format can be reinterpreted
/// with a different compatible texture target and texture format.
texture(
texture const & Texture,
target_type Target,
format_type Format);
virtual ~texture(){}
/// Return whether the texture instance is empty, no storage or description have been assigned to the instance.
bool empty() const;
/// Return the target of a texture instance.
target_type target() const{return this->Target;}
/// Return the texture instance format
format_type format() const;
/// Return the base layer of the texture instance, effectively a memory offset in the actual texture storage to identify where to start reading the layers.
size_type base_layer() const;
/// Return the max layer of the texture instance, effectively a memory offset to the beginning of the last layer in the actual texture storage that the texture instance can access.
size_type max_layer() const;
/// Return max_layer() - base_layer() + 1
size_type layers() const;
/// Return the base face of the texture instance, effectively a memory offset in the actual texture storage to identify where to start reading the faces.
size_type base_face() const;
/// Return the max face of the texture instance, effectively a memory offset to the beginning of the last face in the actual texture storage that the texture instance can access.
size_type max_face() const;
/// Return max_face() - base_face() + 1
size_type faces() const;
/// Return the base level of the texture instance, effectively a memory offset in the actual texture storage to identify where to start reading the levels.
size_type base_level() const;
/// Return the max level of the texture instance, effectively a memory offset to the beginning of the last level in the actual texture storage that the texture instance can access.
size_type max_level() const;
/// Return max_level() - base_level() + 1.
size_type levels() const;
/// Return the dimensions of a texture instance: width, height and depth.
dim_type dimensions(size_type Level = 0) const;
/// Return the memory size of a texture instance storage in bytes.
size_type size() const;
/// Return the number of blocks contained in a texture instance storage.
/// genType size must match the block size conresponding to the texture format.
template <typename genType>
size_type size() const;
/// Return the memory size of a specific level identified by Level.
size_type size(size_type Level) const;
/// Return the memory size of a specific level identified by Level.
/// genType size must match the block size conresponding to the texture format.
template <typename genType>
size_type size(size_type Level) const;
/// Return a pointer to the beginning of the texture instance data.
void * data();
/// Return a pointer of type genType which size must match the texture format block size
template <typename genType>
genType * data();
/// Return a pointer to the beginning of the texture instance data.
void const * data() const;
/// Return a pointer of type genType which size must match the texture format block size
template <typename genType>
genType const * data() const;
/// Return a pointer to the beginning of the texture instance data.
void * data(size_type Layer, size_type Face, size_type Level);
/// Return a pointer to the beginning of the texture instance data.
void const * data(size_type Layer, size_type Face, size_type Level) const;
/// Return a pointer of type genType which size must match the texture format block size
template <typename genType>
genType * data(size_type Layer, size_type Face, size_type Level);
/// Return a pointer of type genType which size must match the texture format block size
template <typename genType>
genType const * data(size_type Layer, size_type Face, size_type Level) const;
/// Clear the entire texture storage with zeros
void clear();
/// Clear the entire texture storage with Texel which type must match the texture storage format block size
/// If the type of genType doesn't match the type of the texture format, no conversion is performed and the data will be reinterpreted as if is was of the texture format.
template <typename genType>
void clear(genType const & Texel);
protected:
/// Compute the relative memory offset to access the data for a specific layer, face and level
size_type offset(size_type Layer, size_type Face, size_type Level) const;
struct cache
{
data_type * Data;
size_type Size;
};
std::shared_ptr<storage> Storage;
target_type const Target;
format_type const Format;
size_type const BaseLayer;
size_type const MaxLayer;
size_type const BaseFace;
size_type const MaxFace;
size_type const BaseLevel;
size_type const MaxLevel;
cache Cache;
private:
void build_cache();
};
}//namespace gli
#include "./core/texture.inl"

83
external/gli/gli/texture1d.hpp vendored Normal file
View file

@ -0,0 +1,83 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture1d.hpp
/// @date 2012-06-25 / 2013-01-11
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture.hpp"
#include "image.hpp"
namespace gli
{
/// texture1D
class texture1D : public texture
{
public:
typedef dim1_t dim_type;
typedef vec1 texcoord_type;
public:
/// Create an empty texture 1D
texture1D();
/// Create a texture1D and allocate a new storage
explicit texture1D(
format_type Format,
dim_type const & Dimensions,
size_type Levels);
/// Create a texture1D and allocate a new storage with a complete mipmap chain
explicit texture1D(
format_type Format,
dim_type const & Dimensions);
/// Create a texture1D view with an existing storage
explicit texture1D(
texture const & Texture);
/// Create a texture1D view with an existing storage
explicit texture1D(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture1D view, reference a subset of an existing texture1D instance
explicit texture1D(
texture1D const & Texture,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the image identified by Level in the mipmap chain of the texture
image operator[](size_type Level) const;
/// Return the width of a texture instance
dim_type dimensions() const;
};
}//namespace gli
#include "./core/texture1d.inl"

85
external/gli/gli/texture1d_array.hpp vendored Normal file
View file

@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture1d_array.hpp
/// @date 2012-06-25 / 2013-01-11
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture1d.hpp"
namespace gli
{
/// texture1DArray
class texture1DArray : public texture
{
public:
typedef dim1_t dim_type;
typedef vec1 texcoord_type;
public:
/// Create an empty texture 1D array
texture1DArray();
/// Create a texture1DArray and allocate a new storage
explicit texture1DArray(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Levels);
/// Create a texture1DArray and allocate a new storage with a complete mipmap chain
explicit texture1DArray(
format_type Format,
dim_type const & Dimensions,
size_type Layers);
/// Create a texture1DArray view with an existing storage
explicit texture1DArray(
texture const & Texture);
/// Create a texture1DArray view with an existing storage
explicit texture1DArray(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture view, reference a subset of an exiting storage
explicit texture1DArray(
texture1DArray const & Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Layer in the texture array
texture1D operator[](size_type Layer) const;
/// Return the width of a texture instance
dim_type dimensions() const;
};
}//namespace gli
#include "./core/texture1d_array.inl"

89
external/gli/gli/texture2d.hpp vendored Normal file
View file

@ -0,0 +1,89 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture2d.hpp
/// @date 2010-01-09 / 2015-08-29
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture.hpp"
#include "image.hpp"
namespace gli
{
/// texture2D
class texture2D : public texture
{
public:
typedef dim2_t dim_type;
typedef vec2 texcoord_type;
public:
/// Create an empty texture 2D.
texture2D();
/// Create a texture2D and allocate a new storage.
explicit texture2D(
format_type Format,
dim_type const & Dimensions,
size_type Levels);
/// Create a texture2D and allocate a new storage with a complete mipmap chain.
explicit texture2D(
format_type Format,
dim_type const & Dimensions);
/// Create a texture2D view with an existing storage.
explicit texture2D(
texture const & Texture);
/// Create a texture2D view with an existing storage.
explicit texture2D(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture2D view, reference a subset of an existing texture2D instance.
explicit texture2D(
texture2D const & Texture,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the image identified by Level in the mipmap chain of the texture.
image operator[](size_type Level) const;
/// Return the dimensions of a texture instance: width and height.
dim_type dimensions() const;
template <typename genType>
genType fetch(texture2D::dim_type const & TexelCoord, texture2D::size_type Level);
template <typename genType>
void write(texture2D::dim_type const & TexelCoord, texture2D::size_type Level, genType const & Color);
};
}//namespace gli
#include "./core/texture2d.inl"

85
external/gli/gli/texture2d_array.hpp vendored Normal file
View file

@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture2d_array.hpp
/// @date 2011-04-06 / 2013-01-11
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture2d.hpp"
namespace gli
{
/// texture2DArray
class texture2DArray : public texture
{
public:
typedef dim2_t dim_type;
typedef vec3 texcoord_type;
public:
/// Create an empty texture 2D array
texture2DArray();
/// Create a texture2DArray and allocate a new storage
explicit texture2DArray(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Levels);
/// Create a texture2DArray and allocate a new storage with a complete mipmap chain
explicit texture2DArray(
format_type Format,
dim_type const & Dimensions,
size_type Layers);
/// Create a texture2DArray view with an existing storage
explicit texture2DArray(
texture const & Texture);
/// Create a texture2DArray view with an existing storage
explicit texture2DArray(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture view, reference a subset of an exiting texture2DArray instance
explicit texture2DArray(
texture2DArray const & Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Layer in the texture array
texture2D operator[](size_type Layer) const;
/// Return the dimensions of a texture instance: width and height
dim_type dimensions() const;
};
}//namespace gli
#include "./core/texture2d_array.inl"

83
external/gli/gli/texture3d.hpp vendored Normal file
View file

@ -0,0 +1,83 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture3d.hpp
/// @date 2010-01-09 / 2013-01-11
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture.hpp"
#include "image.hpp"
namespace gli
{
/// texture3D
class texture3D : public texture
{
public:
typedef dim3_t dim_type;
typedef vec3 texcoord_type;
public:
/// Create an empty texture 3D
texture3D();
/// Create a texture3D and allocate a new storage
explicit texture3D(
format_type Format,
dim_type const & Dimensions,
size_type Levels);
/// Create a texture3D and allocate a new storage with a complete mipmap chain
explicit texture3D(
format_type Format,
dim_type const & Dimensions);
/// Create a texture3D view with an existing storage
explicit texture3D(
texture const & Texture);
/// Create a texture3D view with an existing storage
explicit texture3D(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture3D view, reference a subset of an existing texture3D instance
explicit texture3D(
texture3D const & Texture,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the image identified by Level in the mipmap chain of the texture
image operator[](size_type Level) const;
/// Return the dimensions of a texture instance: width, height and depth
dim_type dimensions() const;
};
}//namespace gli
#include "./core/texture3d.inl"

83
external/gli/gli/texture_cube.hpp vendored Normal file
View file

@ -0,0 +1,83 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture_cube.hpp
/// @date 2011-04-06 / 2013-01-11
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture2d.hpp"
namespace gli
{
/// textureCube
class textureCube : public texture
{
public:
typedef dim2_t dim_type;
typedef vec3 texcoord_type;
public:
/// Create an empty texture cube
textureCube();
/// Create a textureCube and allocate a new storage
explicit textureCube(
format_type Format,
dim_type const & Dimensions,
size_type Levels);
/// Create a textureCube and allocate a new storage with a complete mipmap chain
explicit textureCube(
format_type Format,
dim_type const & Dimensions);
/// Create a textureCube view with an existing storage
explicit textureCube(
texture const & Texture);
/// Create a textureCube view with an existing storage
explicit textureCube(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a textureCube view, reference a subset of an existing textureCube instance
explicit textureCube(
textureCube const & Texture,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Face in the texture cube
texture2D operator[](size_type Face) const;
/// Return the dimensions of a texture instance: width and height where both should be equal.
dim_type dimensions() const;
};
}//namespace gli
#include "./core/texture_cube.inl"

87
external/gli/gli/texture_cube_array.hpp vendored Normal file
View file

@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/texture_cube_array.hpp
/// @date 2011-04-06 / 2013-01-11
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "texture_cube.hpp"
namespace gli
{
/// textureCubeArray
class textureCubeArray : public texture
{
public:
typedef dim2_t dim_type;
typedef vec4 texcoord_type;
public:
/// Create an empty texture cube array
textureCubeArray();
/// Create a textureCubeArray and allocate a new storage
explicit textureCubeArray(
format_type Format,
dim_type const & Dimensions,
size_type Layers,
size_type Levels);
/// Create a textureCubeArray and allocate a new storage with a complete mipmap chain
explicit textureCubeArray(
format_type Format,
dim_type const & Dimensions,
size_type Layers);
/// Create a textureCubeArray view with an existing storage
explicit textureCubeArray(
texture const & Texture);
/// Reference a subset of an exiting storage constructor
explicit textureCubeArray(
texture const & Texture,
format_type Format,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a texture view, reference a subset of an exiting textureCubeArray instance
explicit textureCubeArray(
textureCubeArray const & Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Layer in the texture array
textureCube operator[](size_type Layer) const;
/// Return the dimensions of a texture instance: width and height where both should be equal.
dim_type dimensions() const;
};
}//namespace gli
#include "./core/texture_cube_array.inl"

54
external/gli/gli/type.hpp vendored Normal file
View file

@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2014 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/type.hpp
/// @date 2014-07-28 / 2015-08-29
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// STD
#include <cstddef>
// GLM
#define GLM_FORCE_EXPLICIT_CTOR
#include <glm/glm.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtx/std_based_type.hpp>
namespace gli
{
using std::size_t;
typedef glm::tvec1<size_t> dim1_t;
typedef glm::tvec2<size_t> dim2_t;
typedef glm::tvec3<size_t> dim3_t;
typedef glm::tvec4<size_t> dim4_t;
typedef glm::vec1 vec1;
typedef glm::vec2 vec2;
typedef glm::vec3 vec3;
typedef glm::vec4 vec4;
typedef glm::ivec4 ivec4;
}//namespace gli

99
external/gli/gli/view.hpp vendored Normal file
View file

@ -0,0 +1,99 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Image (gli.g-truc.net)
///
/// Copyright (c) 2008 - 2015 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
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file gli/view.hpp
/// @date 2013-02-07 / 2013-02-07
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "image.hpp"
#include "texture.hpp"
#include "texture1d.hpp"
#include "texture1d_array.hpp"
#include "texture2d.hpp"
#include "texture2d_array.hpp"
#include "texture3d.hpp"
#include "texture_cube.hpp"
#include "texture_cube_array.hpp"
namespace gli
{
/// Create an image view of an existing image, sharing the same memory storage.
image view(image const & Image);
/// Create a texture view of an existing texture, sharing the same memory storage.
texture view(texture const & Texture);
/// Create a texture view of an existing texture, sharing the same memory storage.
template <typename texType>
texture view(texType const & Texture);
/// Create a texture view of an existing texture, sharing the same memory storage but a different format.
/// The format must be a compatible format, a format which block size match the original format.
template <typename texType>
texture view(texType const & Texture, format Format);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of levels.
texture view(
texture1D const & Texture,
texture1D::size_type BaseLevel, texture1D::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of levels and layers.
texture view(
texture1DArray const & Texture,
texture1DArray::size_type BaseLayer, texture1DArray::size_type MaxLayer,
texture1DArray::size_type BaseLevel, texture1DArray::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of levels.
texture view(
texture2D const & Texture,
texture2D::size_type BaseLevel, texture2D::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of levels and layers.
texture view(
texture2DArray const & Texture,
texture2DArray::size_type BaseLayer, texture2DArray::size_type MaxLayer,
texture2DArray::size_type BaseLevel, texture2DArray::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of levels.
texture view(
texture3D const & Texture,
texture3D::size_type BaseLevel, texture3D::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of levels and faces.
texture view(
textureCube const & Texture,
textureCube::size_type BaseFace, textureCube::size_type MaxFace,
textureCube::size_type BaseLevel, textureCube::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage but giving access only to a subset of layers, levels and faces.
texture view(
textureCubeArray const & Texture,
textureCubeArray::size_type BaseLayer, textureCubeArray::size_type MaxLayer,
textureCubeArray::size_type BaseFace, textureCubeArray::size_type MaxFace,
textureCubeArray::size_type BaseLevel, textureCubeArray::size_type MaxLevel);
}//namespace gli
#include "./core/view.inl"