Added GLI for GLM tests
This commit is contained in:
4
test/external/gli/core/dummy.cpp
vendored
Normal file
4
test/external/gli/core/dummy.cpp
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
int main()
|
||||
{
|
||||
|
||||
}
|
||||
25
test/external/gli/core/generate_mipmaps.hpp
vendored
Normal file
25
test/external/gli/core/generate_mipmaps.hpp
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/generate_mipmaps.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GENERATE_MIPMAPS_INCLUDED
|
||||
#define GLI_GENERATE_MIPMAPS_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
texture2D generateMipmaps(
|
||||
texture2D const & Texture,
|
||||
texture2D::level_type const & BaseLevel);
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "generate_mipmaps.inl"
|
||||
|
||||
#endif//GLI_GENERATE_MIPMAPS_INCLUDED
|
||||
69
test/external/gli/core/generate_mipmaps.inl
vendored
Normal file
69
test/external/gli/core/generate_mipmaps.inl
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/generate_mipmaps.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline texture2D generateMipmaps
|
||||
(
|
||||
texture2D const & Image,
|
||||
texture2D::level_type const & BaseLevel
|
||||
)
|
||||
{
|
||||
assert(BaseLevel < Image.levels());
|
||||
texture2D::format_type Format = Image[BaseLevel].format();
|
||||
|
||||
assert(Format == R8U || Format == RG8U || Format == RGB8U || Format == RGBA8U);
|
||||
texture2D::level_type Levels = std::size_t(glm::log2(float(glm::compMax(Image[0].dimensions())))) + 1;
|
||||
|
||||
texture2D Result(Levels);
|
||||
for(texture2D::level_type Level = 0; Level <= BaseLevel; ++Level)
|
||||
Result[Level] = detail::duplicate(Image[Level]);
|
||||
|
||||
for(texture2D::level_type Level = BaseLevel; Level < Levels - 1; ++Level)
|
||||
{
|
||||
std::size_t BaseWidth = Result[Level + 0].dimensions().x;
|
||||
texture2D::value_type * DataSrc = Result[Level + 0].data();
|
||||
|
||||
texture2D::dimensions_type LevelDimensions = Result[Level + 0].dimensions() >> texture2D::dimensions_type(1);
|
||||
LevelDimensions = glm::max(LevelDimensions, texture2D::dimensions_type(1));
|
||||
texture2D::size_type ValueSize = Result[Level + 0].value_size();
|
||||
texture2D::size_type Components = Result[Level + 0].components();
|
||||
|
||||
texture2D::data_type DataDst(glm::compMul(LevelDimensions) * Components);
|
||||
|
||||
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<texture2D::value_type*>(DataSrc)[Index00];
|
||||
glm::u32 Data01 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index01];
|
||||
glm::u32 Data11 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index11];
|
||||
glm::u32 Data10 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index10];
|
||||
|
||||
texture2D::value_type Result = (Data00 + Data01 + Data11 + Data10) >> 2;
|
||||
texture2D::value_type * Data = reinterpret_cast<texture2D::value_type*>(DataDst.data());
|
||||
|
||||
*(Data + ((i + j * LevelDimensions.x) * Components + c)) = Result;
|
||||
}
|
||||
|
||||
Result[Level + 1] = image2D(LevelDimensions, Format, DataDst);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
}//namespace gli
|
||||
169
test/external/gli/core/image2d.hpp
vendored
Normal file
169
test/external/gli/core/image2d.hpp
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-05
|
||||
// Updated : 2011-04-05
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/image2d.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_IMAGE2D_INCLUDED
|
||||
#define GLI_CORE_IMAGE2D_INCLUDED
|
||||
|
||||
// STD
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
// GLM
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/number_precision.hpp>
|
||||
#include <glm/gtx/raw_data.hpp>
|
||||
#include <glm/gtx/gradient_paint.hpp>
|
||||
#include <glm/gtx/component_wise.hpp>
|
||||
|
||||
namespace gli
|
||||
{
|
||||
enum format
|
||||
{
|
||||
FORMAT_NULL,
|
||||
|
||||
// Unsigned integer formats
|
||||
R8U,
|
||||
RG8U,
|
||||
RGB8U,
|
||||
RGBA8U,
|
||||
|
||||
R16U,
|
||||
RG16U,
|
||||
RGB16U,
|
||||
RGBA16U,
|
||||
|
||||
R32U,
|
||||
RG32U,
|
||||
RGB32U,
|
||||
RGBA32U,
|
||||
|
||||
// Signed integer formats
|
||||
R8I,
|
||||
RG8I,
|
||||
RGB8I,
|
||||
RGBA8I,
|
||||
|
||||
R16I,
|
||||
RG16I,
|
||||
RGB16I,
|
||||
RGBA16I,
|
||||
|
||||
R32I,
|
||||
RG32I,
|
||||
RGB32I,
|
||||
RGBA32I,
|
||||
|
||||
// Floating formats
|
||||
R16F,
|
||||
RG16F,
|
||||
RGB16F,
|
||||
RGBA16F,
|
||||
|
||||
R32F,
|
||||
RG32F,
|
||||
RGB32F,
|
||||
RGBA32F,
|
||||
|
||||
// Packed formats
|
||||
RGBE8,
|
||||
RGB9E5,
|
||||
RG11B10F,
|
||||
R5G6B5,
|
||||
RGBA4,
|
||||
RGB10A2,
|
||||
|
||||
// Depth formats
|
||||
D16,
|
||||
D24X8,
|
||||
D24S8,
|
||||
D32F,
|
||||
D32FS8X24,
|
||||
|
||||
// Compressed formats
|
||||
DXT1,
|
||||
DXT3,
|
||||
DXT5,
|
||||
ATI1N_UNORM,
|
||||
ATI1N_SNORM,
|
||||
ATI2N_UNORM,
|
||||
ATI2N_SNORM,
|
||||
BP_UF16,
|
||||
BP_SF16,
|
||||
BP,
|
||||
|
||||
FORMAT_MAX
|
||||
};
|
||||
|
||||
enum size_type
|
||||
{
|
||||
LINEAR_SIZE,
|
||||
BLOCK_SIZE,
|
||||
BIT_PER_PIXEL,
|
||||
COMPONENT
|
||||
};
|
||||
|
||||
class image2D
|
||||
{
|
||||
public:
|
||||
typedef glm::uvec2 dimensions_type;
|
||||
typedef glm::vec2 texcoord_type;
|
||||
typedef glm::uint32 size_type;
|
||||
typedef glm::byte value_type;
|
||||
typedef gli::format format_type;
|
||||
typedef std::vector<value_type> data_type;
|
||||
|
||||
public:
|
||||
image2D();
|
||||
image2D(
|
||||
image2D const & Image);
|
||||
|
||||
explicit image2D(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format);
|
||||
|
||||
template <typename genType>
|
||||
explicit image2D(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format,
|
||||
genType const & Value);
|
||||
|
||||
explicit image2D(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format,
|
||||
std::vector<value_type> const & Data);
|
||||
|
||||
~image2D();
|
||||
|
||||
template <typename genType>
|
||||
void setPixel(
|
||||
dimensions_type const & TexelCoord,
|
||||
genType const & TexelData);
|
||||
|
||||
size_type value_size() const;
|
||||
size_type capacity() const;
|
||||
dimensions_type dimensions() const;
|
||||
size_type components() const;
|
||||
format_type format() const;
|
||||
|
||||
value_type * data();
|
||||
value_type const * const data() const;
|
||||
|
||||
private:
|
||||
data_type Data;
|
||||
dimensions_type Dimensions;
|
||||
format_type Format;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "image2d.inl"
|
||||
|
||||
#endif//GLI_CORE_IMAGE2D_INCLUDED
|
||||
231
test/external/gli/core/image2d.inl
vendored
Normal file
231
test/external/gli/core/image2d.inl
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-05
|
||||
// Updated : 2011-04-05
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/image2d.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct format_desc
|
||||
{
|
||||
image2D::size_type BlockSize;
|
||||
image2D::size_type BBP;
|
||||
image2D::size_type Component;
|
||||
};
|
||||
|
||||
inline format_desc getFormatInfo(format const & Format)
|
||||
{
|
||||
format_desc Desc[FORMAT_MAX] =
|
||||
{
|
||||
{ 0, 0, 0}, //FORMAT_NULL
|
||||
|
||||
// Unsigned integer formats
|
||||
{ 1, 8, 1}, //R8U,
|
||||
{ 2, 16, 2}, //RG8U,
|
||||
{ 3, 24, 3}, //RGB8U,
|
||||
{ 4, 32, 4}, //RGBA8U,
|
||||
|
||||
{ 2, 16, 1}, //R16U,
|
||||
{ 4, 32, 2}, //RG16U,
|
||||
{ 6, 48, 3}, //RGB16U,
|
||||
{ 8, 64, 4}, //RGBA16U,
|
||||
|
||||
{ 4, 32, 1}, //R32U,
|
||||
{ 8, 64, 2}, //RG32U,
|
||||
{ 12, 96, 3}, //RGB32U,
|
||||
{ 16, 128, 4}, //RGBA32U,
|
||||
|
||||
//// Signed integer formats
|
||||
{ 4, 32, 1}, //R8I,
|
||||
{ 8, 64, 2}, //RG8I,
|
||||
{ 12, 96, 3}, //RGB8I,
|
||||
{ 16, 128, 4}, //RGBA8I,
|
||||
|
||||
{ 2, 16, 1}, //R16I,
|
||||
{ 4, 32, 2}, //RG16I,
|
||||
{ 6, 48, 3}, //RGB16I,
|
||||
{ 8, 64, 4}, //RGBA16I,
|
||||
|
||||
{ 4, 32, 1}, //R32I,
|
||||
{ 8, 64, 2}, //RG32I,
|
||||
{ 12, 96, 3}, //RGB32I,
|
||||
{ 16, 128, 4}, //RGBA32I,
|
||||
|
||||
//// Floating formats
|
||||
{ 2, 16, 1}, //R16F,
|
||||
{ 4, 32, 2}, //RG16F,
|
||||
{ 6, 48, 3}, //RGB16F,
|
||||
{ 8, 64, 4}, //RGBA16F,
|
||||
|
||||
{ 4, 32, 1}, //R32F,
|
||||
{ 8, 64, 2}, //RG32F,
|
||||
{ 12, 96, 3}, //RGB32F,
|
||||
{ 16, 128, 4}, //RGBA32F,
|
||||
|
||||
//// Packed formats
|
||||
{ 4, 32, 3}, //RGBE8,
|
||||
{ 4, 32, 3}, //RGB9E5,
|
||||
{ 4, 32, 3}, //RG11B10F,
|
||||
{ 2, 16, 3}, //R5G6B5,
|
||||
{ 2, 16, 4}, //RGBA4,
|
||||
{ 4, 32, 3}, //RGB10A2,
|
||||
|
||||
//// Depth formats
|
||||
{ 2, 16, 1}, //D16,
|
||||
{ 4, 32, 1}, //D24X8,
|
||||
{ 4, 32, 2}, //D24S8,
|
||||
{ 4, 32, 1}, //D32F,
|
||||
{ 8, 64, 2}, //D32FS8X24,
|
||||
|
||||
//// Compressed formats
|
||||
{ 8, 4, 4}, //DXT1,
|
||||
{ 16, 8, 4}, //DXT3,
|
||||
{ 16, 8, 4}, //DXT5,
|
||||
{ 8, 4, 1}, //ATI1N_UNORM,
|
||||
{ 8, 4, 1}, //ATI1N_SNORM,
|
||||
{ 16, 8, 2}, //ATI2N_UNORM,
|
||||
{ 16, 8, 2}, //ATI2N_SNORM,
|
||||
{ 16, 8, 3}, //BP_UF16,
|
||||
{ 16, 8, 3}, //BP_SF16,
|
||||
{ 16, 8, 4}, //BP,
|
||||
};
|
||||
|
||||
return Desc[Format];
|
||||
};
|
||||
|
||||
inline image2D::size_type sizeBlock
|
||||
(
|
||||
format const & Format
|
||||
)
|
||||
{
|
||||
return getFormatInfo(Format).BlockSize;
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeBitPerPixel
|
||||
(
|
||||
format const & Format
|
||||
)
|
||||
{
|
||||
return getFormatInfo(Format).BBP;
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeComponent
|
||||
(
|
||||
format const & Format
|
||||
)
|
||||
{
|
||||
return getFormatInfo(Format).Component;
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeLinear
|
||||
(
|
||||
image2D const & Image
|
||||
)
|
||||
{
|
||||
image2D::dimensions_type Dimension = Image.dimensions();
|
||||
Dimension = glm::max(Dimension, image2D::dimensions_type(1));
|
||||
|
||||
image2D::size_type BlockSize = sizeBlock(Image.format());
|
||||
image2D::size_type BPP = sizeBitPerPixel(Image.format());
|
||||
image2D::size_type BlockCount = 0;
|
||||
if((BlockSize << 3) == BPP)
|
||||
BlockCount = Dimension.x * Dimension.y;
|
||||
else
|
||||
BlockCount = ((Dimension.x + 3) >> 2) * ((Dimension.y + 3) >> 2);
|
||||
|
||||
return BlockCount * BlockSize;
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
inline image2D::image2D() :
|
||||
Data(0),
|
||||
Dimensions(0),
|
||||
Format(FORMAT_NULL)
|
||||
{}
|
||||
|
||||
inline image2D::image2D
|
||||
(
|
||||
image2D const & Image
|
||||
) :
|
||||
Data(Image.Data),
|
||||
Dimensions(Image.Dimensions),
|
||||
Format(Image.Format)
|
||||
{}
|
||||
|
||||
inline image2D::image2D
|
||||
(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format
|
||||
) :
|
||||
Data((glm::compMul(Dimensions) * detail::sizeBitPerPixel(Format)) >> 3),
|
||||
Dimensions(Dimensions),
|
||||
Format(Format)
|
||||
{
|
||||
std::size_t Size = (glm::compMul(Dimensions) * detail::sizeBitPerPixel(Format)) >> 3;
|
||||
}
|
||||
|
||||
inline image2D::image2D
|
||||
(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format,
|
||||
std::vector<value_type> const & Data
|
||||
) :
|
||||
Data(Data),
|
||||
Dimensions(Dimensions),
|
||||
Format(Format)
|
||||
{}
|
||||
|
||||
inline image2D::~image2D()
|
||||
{}
|
||||
|
||||
template <typename genType>
|
||||
inline void image2D::setPixel
|
||||
(
|
||||
dimensions_type const & TexelCoord,
|
||||
genType const & TexelData
|
||||
)
|
||||
{
|
||||
size_type Index = this->dimensions().x * sizeof(genType) * TexelCoord.y + sizeof(genType) * TexelCoord.x;
|
||||
memcpy(this->data() + Index, &TexelData[0], sizeof(genType));
|
||||
}
|
||||
|
||||
inline image2D::size_type image2D::value_size() const
|
||||
{
|
||||
return detail::sizeBitPerPixel(this->format());
|
||||
}
|
||||
|
||||
inline image2D::size_type image2D::capacity() const
|
||||
{
|
||||
return detail::sizeLinear(*this);
|
||||
}
|
||||
|
||||
inline image2D::dimensions_type image2D::dimensions() const
|
||||
{
|
||||
return this->Dimensions;
|
||||
}
|
||||
|
||||
inline image2D::size_type image2D::components() const
|
||||
{
|
||||
return detail::sizeComponent(this->format());
|
||||
}
|
||||
|
||||
inline image2D::format_type image2D::format() const
|
||||
{
|
||||
return this->Format;
|
||||
}
|
||||
|
||||
inline image2D::value_type * image2D::data()
|
||||
{
|
||||
return &this->Data[0];
|
||||
}
|
||||
|
||||
inline image2D::value_type const * const image2D::data() const
|
||||
{
|
||||
return &this->Data[0];
|
||||
}
|
||||
}//namespace gli
|
||||
82
test/external/gli/core/operation.hpp
vendored
Normal file
82
test/external/gli/core/operation.hpp
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/operation.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_OPERATION_INCLUDED
|
||||
#define GLI_OPERATION_INCLUDED
|
||||
|
||||
#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,
|
||||
texture2D::dimensions_type const & Position,
|
||||
texture2D::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"
|
||||
|
||||
#endif//GLI_OPERATION_INCLUDED
|
||||
233
test/external/gli/core/operation.inl
vendored
Normal file
233
test/external/gli/core/operation.inl
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-08
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/operation.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
inline image2D duplicate(image2D const & Mipmap2D)
|
||||
{
|
||||
image2D Result(Mipmap2D.dimensions(), Mipmap2D.format());
|
||||
memcpy(Result.data(), Mipmap2D.data(), Mipmap2D.capacity());
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D flip(image2D const & Mipmap2D)
|
||||
{
|
||||
image2D Result(Mipmap2D.dimensions(), Mipmap2D.format());
|
||||
|
||||
std::size_t ValueSize = Result.value_size();
|
||||
glm::byte * DstPtr = Result.data();
|
||||
glm::byte const * const SrcPtr = 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) * ValueSize;
|
||||
std::size_t SrcIndex = (i + (Result.dimensions().y - j) * Result.dimensions().x) * ValueSize;
|
||||
memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D mirror(image2D const & Mipmap2D)
|
||||
{
|
||||
image2D Result(Mipmap2D.dimensions(), Mipmap2D.format());
|
||||
|
||||
std::size_t ValueSize = Mipmap2D.value_size();
|
||||
glm::byte * DstPtr = Result.data();
|
||||
glm::byte const * const SrcPtr = 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 = detail::duplicate(Mipmap);
|
||||
|
||||
glm::byte * DataDst = Result.data();
|
||||
glm::byte const * const DataSrc = Mipmap.data();
|
||||
|
||||
gli::texture2D::size_type CompSize = Mipmap.value_size() / Mipmap.components();
|
||||
gli::texture2D::size_type TexelCount = Mipmap.capacity() / Mipmap.value_size();
|
||||
|
||||
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(Size, Image.format());
|
||||
|
||||
glm::byte* DstData = Result.data();
|
||||
glm::byte const * const SrcData = Image.data();
|
||||
|
||||
for(std::size_t j = 0; j < Size.y; ++j)
|
||||
{
|
||||
std::size_t DstIndex = 0 + (0 + j) * Size.x * Image.value_size();
|
||||
std::size_t SrcIndex = Position.x * Image.value_size() + (Position.y + j) * Image.dimensions().x * Image.value_size();
|
||||
memcpy(DstData + DstIndex, SrcData + SrcIndex, Image.value_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 = DstMipmap.data();
|
||||
glm::byte const * const SrcData = 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.value_size() + (DstPosition.y + j) * DstMipmap.dimensions().x * DstMipmap.value_size();
|
||||
std::size_t SrcIndex = SrcPosition.x * SrcMipmap.value_size() + (SrcPosition.y + j) * SrcMipmap.dimensions().x * SrcMipmap.value_size();
|
||||
memcpy(DstData + DstIndex, SrcData + SrcIndex, SrcMipmap.value_size() * SizeX);
|
||||
}
|
||||
|
||||
return DstMipmap;
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D duplicate(texture2D const & Texture2D)
|
||||
{
|
||||
texture2D Result(Texture2D.levels());
|
||||
for(texture2D::level_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());
|
||||
for(texture2D::level_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());
|
||||
for(texture2D::level_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());
|
||||
for(texture2D::level_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());
|
||||
for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level)
|
||||
Result[Level] = detail::swizzle(Texture2D[Level], Channel);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline texture2D copy
|
||||
(
|
||||
texture2D const & SrcImage,
|
||||
texture2D::level_type const & SrcLevel,
|
||||
texture2D::dimensions_type const & SrcPosition,
|
||||
texture2D::dimensions_type const & SrcDimensions,
|
||||
texture2D & DstMipmap,
|
||||
texture2D::level_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
|
||||
28
test/external/gli/core/operator.hpp
vendored
Normal file
28
test/external/gli/core/operator.hpp
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-19
|
||||
// Updated : 2010-01-19
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/operator.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_OPERATOR_INCLUDED
|
||||
#define GLI_OPERATOR_INCLUDED
|
||||
|
||||
#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"
|
||||
|
||||
#endif//GLI_OPERATOR_INCLUDED
|
||||
210
test/external/gli/core/operator.inl
vendored
Normal file
210
test/external/gli/core/operator.inl
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-19
|
||||
// Updated : 2010-01-19
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/operator.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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
|
||||
48
test/external/gli/core/shared_array.hpp
vendored
Normal file
48
test/external/gli/core/shared_array.hpp
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2005-06-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/shared_array.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_SHARED_ARRAY_INCLUDED
|
||||
#define GLI_SHARED_ARRAY_INCLUDED
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
class shared_array
|
||||
{
|
||||
public:
|
||||
|
||||
shared_array();
|
||||
shared_array(shared_array const & SharedArray);
|
||||
shared_array(T * Pointer);
|
||||
virtual ~shared_array();
|
||||
|
||||
void reset();
|
||||
void reset(T * Pointer);
|
||||
|
||||
T & operator*();
|
||||
T * operator->();
|
||||
T const & operator*() const;
|
||||
T const * const operator->() const;
|
||||
|
||||
T * get();
|
||||
T const * const get() const;
|
||||
|
||||
shared_array & operator=(shared_array const & SharedArray);
|
||||
bool operator==(shared_array const & SharedArray) const;
|
||||
bool operator!=(shared_array const & SharedArray) const;
|
||||
|
||||
private:
|
||||
int * Counter;
|
||||
T * Pointer;
|
||||
};
|
||||
}//namespace gli
|
||||
|
||||
#include "shared_array.inl"
|
||||
|
||||
#endif //GLI_SHARED_ARRAY_INCLUDED
|
||||
151
test/external/gli/core/shared_array.inl
vendored
Normal file
151
test/external/gli/core/shared_array.inl
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2005-06-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/shared_array.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
shared_array<T>::shared_array() :
|
||||
Counter(0),
|
||||
Pointer(0)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>::shared_array
|
||||
(
|
||||
shared_array<T> const & SharedArray
|
||||
)
|
||||
{
|
||||
this->Counter = SharedArray.Counter;
|
||||
this->Pointer = SharedArray.Pointer;
|
||||
(*this->Counter)++;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>::shared_array
|
||||
(
|
||||
T * Pointer
|
||||
)
|
||||
{
|
||||
this->reset(Pointer);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>::~shared_array()
|
||||
{
|
||||
this->reset();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void shared_array<T>::reset()
|
||||
{
|
||||
if(this->Pointer)
|
||||
{
|
||||
(*this->Counter)--;
|
||||
if(*this->Counter <= 0)
|
||||
{
|
||||
delete this->Counter;
|
||||
this->Counter = 0;
|
||||
delete[] this->Pointer;
|
||||
this->Pointer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void shared_array<T>::reset(T * Pointer)
|
||||
{
|
||||
this->Counter = new int;
|
||||
this->Pointer = Pointer;
|
||||
*this->Counter = 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>& shared_array<T>::operator=
|
||||
(
|
||||
shared_array<T> const & SharedArray
|
||||
)
|
||||
{
|
||||
this->reset();
|
||||
|
||||
this->Counter = SharedArray.Counter;
|
||||
this->Pointer = SharedArray.Pointer;
|
||||
(*this->Counter)++;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//template <typename T>
|
||||
//shared_array<T> & shared_array<T>::operator=(T * Pointer)
|
||||
//{
|
||||
// if(this->Pointer)
|
||||
// {
|
||||
// (*this->Counter)--;
|
||||
// if(*this->Counter <= 0)
|
||||
// {
|
||||
// delete this->Counter;
|
||||
// delete[] this->Pointer;
|
||||
// }
|
||||
// }
|
||||
|
||||
// this->Counter = new int;
|
||||
// this->Pointer = this->Pointer;
|
||||
// (*this->Counter) = 1;
|
||||
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
template <typename T>
|
||||
bool shared_array<T>::operator==(shared_array<T> const & SharedArray) const
|
||||
{
|
||||
return this->Pointer == SharedArray.Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool shared_array<T>::operator!=(shared_array<T> const & SharedArray) const
|
||||
{
|
||||
return this->Pointer != SharedArray.Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T & shared_array<T>::operator*()
|
||||
{
|
||||
return *this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T * shared_array<T>::operator->()
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const & shared_array<T>::operator*() const
|
||||
{
|
||||
return * this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const * const shared_array<T>::operator->() const
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T * shared_array<T>::get()
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const * const shared_array<T>::get() const
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
}//namespace gli
|
||||
41
test/external/gli/core/shared_ptr.hpp
vendored
Normal file
41
test/external/gli/core/shared_ptr.hpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2005-06-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/fetch.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_SHARED_PTR_INCLUDED
|
||||
#define GLI_SHARED_PTR_INCLUDED
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
class shared_ptr
|
||||
{
|
||||
public:
|
||||
shared_ptr();
|
||||
shared_ptr(shared_ptr const & SmartPtr);
|
||||
shared_ptr(T* pPointer);
|
||||
~shared_ptr();
|
||||
|
||||
T& operator*();
|
||||
T* operator->();
|
||||
const T& operator*() const;
|
||||
const T* operator->() const;
|
||||
shared_ptr& operator=(shared_ptr const & SmartPtr);
|
||||
shared_ptr& operator=(T* pPointer);
|
||||
bool operator==(shared_ptr const & SmartPtr) const;
|
||||
bool operator!=(shared_ptr const & SmartPtr) const;
|
||||
|
||||
private:
|
||||
int* m_pReference;
|
||||
T* m_pPointer;
|
||||
};
|
||||
}//namespace gli
|
||||
|
||||
#include "shared_ptr.inl"
|
||||
|
||||
#endif //GLI_SHARED_PTR_INCLUDED
|
||||
125
test/external/gli/core/shared_ptr.inl
vendored
Normal file
125
test/external/gli/core/shared_ptr.inl
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Interstate Gangs : smart_ptr.inl
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is under GPL licence
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CHANGELOG
|
||||
// Groove - 13/06/2005 :
|
||||
// - Create file
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::CSmartPtr()
|
||||
{
|
||||
m_pPointer = 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::CSmartPtr(const util::CSmartPtr<T> & SmartPtr)
|
||||
{
|
||||
m_pReference = SmartPtr.m_pReference;
|
||||
m_pPointer = SmartPtr.m_pPointer;
|
||||
(*m_pReference)++;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::CSmartPtr(T* pPointer)
|
||||
{
|
||||
m_pReference = new int;
|
||||
m_pPointer = pPointer;
|
||||
(*m_pReference) = 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::~CSmartPtr()
|
||||
{
|
||||
if(!m_pPointer)
|
||||
return;
|
||||
|
||||
(*m_pReference)--;
|
||||
if(*m_pReference <= 0)
|
||||
{
|
||||
delete m_pReference;
|
||||
delete m_pPointer;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>& util::CSmartPtr<T>::operator=(const util::CSmartPtr<T> & SmartPtr)
|
||||
{
|
||||
if(m_pPointer)
|
||||
{
|
||||
(*m_pReference)--;
|
||||
if(*m_pReference <= 0)
|
||||
{
|
||||
delete m_pReference;
|
||||
delete m_pPointer;
|
||||
}
|
||||
}
|
||||
|
||||
m_pReference = SmartPtr.m_pReference;
|
||||
m_pPointer = SmartPtr.m_pPointer;
|
||||
(*m_pReference)++;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>& util::CSmartPtr<T>::operator=(T* pPointer)
|
||||
{
|
||||
if(m_pPointer)
|
||||
{
|
||||
(*m_pReference)--;
|
||||
if(*m_pReference <= 0)
|
||||
{
|
||||
delete m_pReference;
|
||||
delete m_pPointer;
|
||||
}
|
||||
}
|
||||
|
||||
m_pReference = new int;
|
||||
m_pPointer = pPointer;
|
||||
(*m_pReference) = 1;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool util::CSmartPtr<T>::operator==(const util::CSmartPtr<T> & SmartPtr) const
|
||||
{
|
||||
return m_pPointer == SmartPtr.m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool util::CSmartPtr<T>::operator!=(const util::CSmartPtr<T> & SmartPtr) const
|
||||
{
|
||||
return m_pPointer != SmartPtr.m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& util::CSmartPtr<T>::operator*()
|
||||
{
|
||||
return *m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* util::CSmartPtr<T>::operator->()
|
||||
{
|
||||
return m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& util::CSmartPtr<T>::operator*() const
|
||||
{
|
||||
return *m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* util::CSmartPtr<T>::operator->() const
|
||||
{
|
||||
return m_pPointer;
|
||||
}
|
||||
|
||||
}//namespace gli
|
||||
31
test/external/gli/core/size.hpp
vendored
Normal file
31
test/external/gli/core/size.hpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-08
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/size.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_SIZE_INCLUDED
|
||||
#define GLI_CORE_SIZE_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
//template <size_type sizeType>
|
||||
image2D::size_type size(
|
||||
image2D const & Image,
|
||||
image2D::size_type const & SizeType);
|
||||
|
||||
//template <size_type sizeType>
|
||||
texture2D::size_type size(
|
||||
texture2D const & Texture,
|
||||
texture2D::size_type const & SizeType);
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "size.inl"
|
||||
|
||||
#endif//GLI_CORE_SIZE_INCLUDED
|
||||
47
test/external/gli/core/size.inl
vendored
Normal file
47
test/external/gli/core/size.inl
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-08
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/size.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline image2D::size_type size
|
||||
(
|
||||
image2D const & Image,
|
||||
image2D::size_type const & SizeType
|
||||
)
|
||||
{
|
||||
switch(SizeType)
|
||||
{
|
||||
case LINEAR_SIZE:
|
||||
return detail::sizeLinear(Image);
|
||||
case BLOCK_SIZE:
|
||||
return detail::sizeBlock(Image.format());
|
||||
case BIT_PER_PIXEL:
|
||||
return detail::sizeBitPerPixel(Image.format());
|
||||
case COMPONENT:
|
||||
return detail::sizeComponent(Image.format());
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
inline texture2D::size_type size
|
||||
(
|
||||
texture2D const & Texture,
|
||||
texture2D::size_type const & SizeType
|
||||
)
|
||||
{
|
||||
texture2D::size_type Size = 0;
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
Size += size(Texture[Level], SizeType);
|
||||
|
||||
return Size;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
106
test/external/gli/core/texture2d.hpp
vendored
Normal file
106
test/external/gli/core/texture2d.hpp
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-09
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture2d.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE2D_INCLUDED
|
||||
#define GLI_CORE_TEXTURE2D_INCLUDED
|
||||
|
||||
#include "image2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
//template <template <typename> class mem>
|
||||
class texture2D
|
||||
{
|
||||
public:
|
||||
typedef image2D::dimensions_type dimensions_type;
|
||||
typedef image2D::texcoord_type texcoord_type;
|
||||
typedef image2D::size_type size_type;
|
||||
typedef image2D::value_type value_type;
|
||||
typedef image2D::format_type format_type;
|
||||
typedef image2D::data_type data_type;
|
||||
typedef std::size_t level_type;
|
||||
|
||||
public:
|
||||
texture2D();
|
||||
|
||||
explicit texture2D(level_type const & Levels);
|
||||
//texture2D(image const & Mipmap, bool GenerateMipmaps = false);
|
||||
|
||||
~texture2D();
|
||||
|
||||
image2D & operator[] (
|
||||
level_type const & Level);
|
||||
image2D const & operator[] (
|
||||
level_type const & Level) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
level_type levels() const;
|
||||
void resize(level_type const & Levels);
|
||||
|
||||
template <typename genType>
|
||||
void swizzle(glm::comp X, glm::comp Y, glm::comp Z, glm::comp W);
|
||||
|
||||
private:
|
||||
std::vector<image2D> Images;
|
||||
};
|
||||
|
||||
//namespace wip
|
||||
//{
|
||||
// // plain
|
||||
// template <typename genType>
|
||||
// class plain
|
||||
// {
|
||||
// public:
|
||||
//
|
||||
// private:
|
||||
// boost::shared_array<genType> Data;
|
||||
// };
|
||||
//
|
||||
// // texture2D
|
||||
// template
|
||||
// <
|
||||
// typename genType,
|
||||
// template <typename> class surface = plain
|
||||
// >
|
||||
// class texture2D
|
||||
// {
|
||||
// public:
|
||||
// typedef genType value_type;
|
||||
//
|
||||
// private:
|
||||
// class image_impl
|
||||
// {
|
||||
// public:
|
||||
// template <typename coordType>
|
||||
// value_type const & operator() (coordType const & Coord) const;
|
||||
//
|
||||
// private:
|
||||
// surface<value_type> Surface;
|
||||
// };
|
||||
//
|
||||
// public:
|
||||
// typedef image_impl image;
|
||||
// typedef std::vector<image> mipmaps;
|
||||
// typedef typename mipmaps::size_type level_type;
|
||||
//
|
||||
// level_type levels() const;
|
||||
// image & operator[] (level_type Level);
|
||||
// image const & operator[] (level_type Level) const;
|
||||
//
|
||||
// private:
|
||||
// mipmaps Mipmaps;
|
||||
// };
|
||||
//
|
||||
//}//namespace wip
|
||||
}//namespace gli
|
||||
|
||||
#include "texture2d.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE2D_INCLUDED
|
||||
304
test/external/gli/core/texture2d.inl
vendored
Normal file
304
test/external/gli/core/texture2d.inl
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture2D.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
inline texture2D::size_type sizeLinear
|
||||
(
|
||||
texture2D const & Texture
|
||||
)
|
||||
{
|
||||
texture2D::size_type Result = 0;
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
Result += sizeLinear(Texture[Level]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D::texture2D()
|
||||
{}
|
||||
|
||||
inline texture2D::texture2D
|
||||
(
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Images.resize(Levels);
|
||||
}
|
||||
|
||||
//inline texture2D::texture2D
|
||||
//(
|
||||
// image const & Mipmap,
|
||||
// bool GenerateMipmaps // ToDo
|
||||
//)
|
||||
//{
|
||||
// //std::size_t Levels = !GenerateMipmaps ? 1 : std::size_t(glm::log2(float(glm::max(Mipmap.width(), Mipmap.height()))));
|
||||
// texture2D::level_type Levels = !GenerateMipmaps ? 1 : std::size_t(glm::log2(float(glm::compMax(Mipmap.dimensions()))));
|
||||
// this->Mipmaps.resize(Levels);
|
||||
// this->Mipmaps[0] = Mipmap;
|
||||
|
||||
// if(GenerateMipmaps)
|
||||
// this->generateMipmaps(0);
|
||||
//}
|
||||
|
||||
inline texture2D::~texture2D()
|
||||
{}
|
||||
|
||||
inline image2D & texture2D::operator[] (level_type const & Level)
|
||||
{
|
||||
return this->Images[Level];
|
||||
}
|
||||
|
||||
inline image2D const & texture2D::operator[] (level_type const & Level) const
|
||||
{
|
||||
return this->Images[Level];
|
||||
}
|
||||
|
||||
inline bool texture2D::empty() const
|
||||
{
|
||||
return this->Images.size() == 0;
|
||||
}
|
||||
|
||||
inline texture2D::format_type texture2D::format() const
|
||||
{
|
||||
return this->Images.empty() ? FORMAT_NULL : this->Images[0].format();
|
||||
}
|
||||
|
||||
inline texture2D::level_type texture2D::levels() const
|
||||
{
|
||||
return this->Images.size();
|
||||
}
|
||||
|
||||
inline void texture2D::resize
|
||||
(
|
||||
texture2D::level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Images.resize(Levels);
|
||||
}
|
||||
|
||||
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 wip
|
||||
{
|
||||
////////////////
|
||||
// image
|
||||
/*
|
||||
//
|
||||
template
|
||||
<
|
||||
typename coordType
|
||||
>
|
||||
template
|
||||
<
|
||||
typename genType,
|
||||
template <typename> class surface
|
||||
>
|
||||
typename texture2D<genType, surface>::value_type &
|
||||
texture2D<genType, surface>::image_impl<coordType>::operator()
|
||||
(
|
||||
coordType const & Coord
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//
|
||||
template
|
||||
<
|
||||
typename coordType
|
||||
>
|
||||
template
|
||||
<
|
||||
typename genType,
|
||||
template <typename> class surface
|
||||
>
|
||||
typename texture2D<genType, surface>::value_type const &
|
||||
texture2D<genType, surface>::image_impl::operator()
|
||||
(
|
||||
coordType const & Coord
|
||||
) const
|
||||
{
|
||||
return value_type(0);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//
|
||||
template
|
||||
<
|
||||
typename coordType
|
||||
>
|
||||
template
|
||||
<
|
||||
typename genType,
|
||||
template <typename> class surface
|
||||
>
|
||||
void texture2D<genType, surface>::image_impl::operator()
|
||||
(
|
||||
coordType const & Coord
|
||||
) const
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//template
|
||||
//<
|
||||
// typename coordType
|
||||
//>
|
||||
//typename texture2D<genType, surface>::value_type const &
|
||||
//texture2D<genType, surface>::image_impl::operator()
|
||||
//(
|
||||
// coordType const & Coord
|
||||
//) const
|
||||
//{
|
||||
// return value_type(0);
|
||||
//}
|
||||
|
||||
//////////////////
|
||||
//// texture2D
|
||||
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//typename texture2D<genType, surface>::level_type texture2D<genType, surface>::levels() const
|
||||
//{
|
||||
// return this->Mipmaps.size();
|
||||
//}
|
||||
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//typename texture2D<genType, surface>::image & texture2D<genType, surface>::operator[]
|
||||
//(
|
||||
// typename texture2D<genType, surface>::level_type Level
|
||||
//)
|
||||
//{
|
||||
// return this->Mipmaps[Level];
|
||||
//}
|
||||
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//typename texture2D<genType, surface>::image const & texture2D<genType, surface>::operator[]
|
||||
//(
|
||||
// typename texture2D<genType, surface>::level_type Level
|
||||
//) const
|
||||
//{
|
||||
// return this->Mipmaps[Level];
|
||||
//}
|
||||
|
||||
}//namespace wip
|
||||
}//namespace gli
|
||||
59
test/external/gli/core/texture2d_array.hpp
vendored
Normal file
59
test/external/gli/core/texture2d_array.hpp
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture2d_array.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
|
||||
#define GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
class texture2DArray
|
||||
{
|
||||
public:
|
||||
typedef texture2D::dimensions_type dimensions_type;
|
||||
typedef texture2D::texcoord_type texcoord_type;
|
||||
typedef texture2D::size_type size_type;
|
||||
typedef texture2D::value_type value_type;
|
||||
typedef texture2D::format_type format_type;
|
||||
typedef texture2D::data_type data_type;
|
||||
typedef texture2D::level_type level_type;
|
||||
typedef std::vector<texture2D>::size_type layer_type;
|
||||
|
||||
public:
|
||||
texture2DArray();
|
||||
|
||||
explicit texture2DArray(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
~texture2DArray();
|
||||
|
||||
texture2D & operator[] (
|
||||
layer_type const & Layer);
|
||||
texture2D const & operator[] (
|
||||
layer_type const & Layer) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
layer_type layers() const;
|
||||
level_type levels() const;
|
||||
void resize(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
private:
|
||||
std::vector<texture2D> Arrays;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "texture2d_array.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
|
||||
78
test/external/gli/core/texture2d_array.inl
vendored
Normal file
78
test/external/gli/core/texture2d_array.inl
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline texture2DArray::texture2DArray()
|
||||
{}
|
||||
|
||||
inline texture2DArray::texture2DArray
|
||||
(
|
||||
texture2DArray::layer_type const & Layers,
|
||||
texture2DArray::level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Arrays.resize(Layers);
|
||||
for(texture2DArray::size_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
}
|
||||
|
||||
inline texture2DArray::~texture2DArray()
|
||||
{}
|
||||
|
||||
inline texture2D & texture2DArray::operator[]
|
||||
(
|
||||
layer_type const & Layer
|
||||
)
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
|
||||
inline texture2D const & texture2DArray::operator[]
|
||||
(
|
||||
layer_type const & Layer
|
||||
) const
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
|
||||
inline bool texture2DArray::empty() const
|
||||
{
|
||||
return this->Arrays.empty();
|
||||
}
|
||||
|
||||
inline texture2DArray::format_type texture2DArray::format() const
|
||||
{
|
||||
return this->Arrays.empty() ? FORMAT_NULL : this->Arrays[0].format();
|
||||
}
|
||||
|
||||
inline texture2DArray::layer_type texture2DArray::layers() const
|
||||
{
|
||||
return this->Arrays.size();
|
||||
}
|
||||
|
||||
inline texture2DArray::level_type texture2DArray::levels() const
|
||||
{
|
||||
if(this->empty())
|
||||
return 0;
|
||||
return this->Arrays[0].levels();
|
||||
}
|
||||
|
||||
inline void texture2DArray::resize
|
||||
(
|
||||
texture2DArray::layer_type const & Layers,
|
||||
texture2DArray::level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Arrays.resize(Layers);
|
||||
for(texture2DArray::layer_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
}
|
||||
|
||||
}//namespace gli
|
||||
65
test/external/gli/core/texture_cube.hpp
vendored
Normal file
65
test/external/gli/core/texture_cube.hpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE_CUBE_INCLUDED
|
||||
#define GLI_CORE_TEXTURE_CUBE_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
enum face
|
||||
{
|
||||
POSITIVE_X,
|
||||
NEGATIVE_X,
|
||||
POSITIVE_Y,
|
||||
NEGATIVE_Y,
|
||||
POSITIVE_Z,
|
||||
NEGATIVE_Z,
|
||||
FACE_MAX
|
||||
};
|
||||
|
||||
class textureCube
|
||||
{
|
||||
public:
|
||||
typedef texture2D::dimensions_type dimensions_type;
|
||||
typedef texture2D::texcoord_type texcoord_type;
|
||||
typedef texture2D::size_type size_type;
|
||||
typedef texture2D::value_type value_type;
|
||||
typedef texture2D::format_type format_type;
|
||||
typedef texture2D::data_type data_type;
|
||||
typedef texture2D::level_type level_type;
|
||||
typedef face face_type;
|
||||
|
||||
public:
|
||||
textureCube();
|
||||
|
||||
explicit textureCube(level_type const & Levels);
|
||||
|
||||
~textureCube();
|
||||
|
||||
texture2D & operator[] (
|
||||
face_type const & Face);
|
||||
texture2D const & operator[] (
|
||||
face_type const & Face) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
level_type levels() const;
|
||||
void resize(level_type const & Levels);
|
||||
|
||||
private:
|
||||
std::vector<texture2D> Faces;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "texture_cube.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE_CUBE_INCLUDED
|
||||
70
test/external/gli/core/texture_cube.inl
vendored
Normal file
70
test/external/gli/core/texture_cube.inl
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline textureCube::textureCube()
|
||||
{}
|
||||
|
||||
inline textureCube::textureCube
|
||||
(
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Faces.resize(FACE_MAX);
|
||||
for(textureCube::size_type i = 0; i < FACE_MAX; ++i)
|
||||
this->Faces[i].resize(Levels);
|
||||
}
|
||||
|
||||
inline textureCube::~textureCube()
|
||||
{}
|
||||
|
||||
inline texture2D & textureCube::operator[]
|
||||
(
|
||||
face_type const & Face
|
||||
)
|
||||
{
|
||||
return this->Faces[Face];
|
||||
}
|
||||
|
||||
inline texture2D const & textureCube::operator[]
|
||||
(
|
||||
face_type const & Face
|
||||
) const
|
||||
{
|
||||
return this->Faces[Face];
|
||||
}
|
||||
|
||||
inline bool textureCube::empty() const
|
||||
{
|
||||
return this->Faces.size() == 0;
|
||||
}
|
||||
|
||||
inline textureCube::format_type textureCube::format() const
|
||||
{
|
||||
return this->Faces.empty() ? FORMAT_NULL : this->Faces[0].format();
|
||||
}
|
||||
|
||||
inline textureCube::level_type textureCube::levels() const
|
||||
{
|
||||
if(this->empty())
|
||||
return 0;
|
||||
return this->Faces[POSITIVE_X].levels();
|
||||
}
|
||||
|
||||
inline void textureCube::resize
|
||||
(
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
for(textureCube::size_type i = 0; i < FACE_MAX; ++i)
|
||||
this->Faces[i].resize(Levels);
|
||||
}
|
||||
|
||||
}//namespace gli
|
||||
59
test/external/gli/core/texture_cube_array.hpp
vendored
Normal file
59
test/external/gli/core/texture_cube_array.hpp
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube_array.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
|
||||
#define GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
|
||||
|
||||
#include "texture_cube.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
class textureCubeArray
|
||||
{
|
||||
public:
|
||||
typedef textureCube::dimensions_type dimensions_type;
|
||||
typedef textureCube::texcoord_type texcoord_type;
|
||||
typedef textureCube::size_type size_type;
|
||||
typedef textureCube::value_type value_type;
|
||||
typedef textureCube::format_type format_type;
|
||||
typedef std::vector<textureCube> data_type;
|
||||
typedef textureCube::level_type level_type;
|
||||
typedef data_type::size_type layer_type;
|
||||
|
||||
public:
|
||||
textureCubeArray();
|
||||
|
||||
explicit textureCubeArray(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
~textureCubeArray();
|
||||
|
||||
textureCube & operator[] (
|
||||
layer_type const & Layer);
|
||||
textureCube const & operator[] (
|
||||
layer_type const & Layer) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
layer_type layers() const;
|
||||
level_type levels() const;
|
||||
void resize(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
private:
|
||||
data_type Arrays;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "texture_cube_array.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
|
||||
72
test/external/gli/core/texture_cube_array.inl
vendored
Normal file
72
test/external/gli/core/texture_cube_array.inl
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube_array.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline textureCubeArray::textureCubeArray()
|
||||
{}
|
||||
|
||||
inline textureCubeArray::textureCubeArray
|
||||
(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Arrays.resize(Layers);
|
||||
for(textureCubeArray::size_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
}
|
||||
|
||||
inline textureCubeArray::~textureCubeArray()
|
||||
{}
|
||||
|
||||
inline textureCube & textureCubeArray::operator[]
|
||||
(
|
||||
layer_type const & Layer
|
||||
)
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
|
||||
inline textureCube const & textureCubeArray::operator[]
|
||||
(
|
||||
layer_type const & Layer
|
||||
) const
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
|
||||
inline bool textureCubeArray::empty() const
|
||||
{
|
||||
return this->Arrays.empty();
|
||||
}
|
||||
|
||||
inline textureCubeArray::format_type textureCubeArray::format() const
|
||||
{
|
||||
return this->Arrays.empty() ? FORMAT_NULL : this->Arrays[0].format();
|
||||
}
|
||||
|
||||
inline textureCubeArray::level_type textureCubeArray::levels() const
|
||||
{
|
||||
if(this->empty())
|
||||
return 0;
|
||||
return this->Arrays[0].levels();
|
||||
}
|
||||
|
||||
inline void textureCubeArray::resize
|
||||
(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
for(textureCubeArray::size_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
}
|
||||
|
||||
}//namespace gli
|
||||
Reference in New Issue
Block a user