Libraries upgraded to VC12. Except for OpenAL. OpenAL is special. Also broken.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
@@ -19,14 +19,14 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@@ -40,17 +40,17 @@
|
|||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-12.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
||||||
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.3;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.3;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-12.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
||||||
|
|||||||
@@ -1,183 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{FE405CFA-8FCE-4867-92CF-797E73B36482}</ProjectGuid>
|
|
||||||
<RootNamespace>EscapetheDawn</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
|
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
|
||||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
|
||||||
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
|
|
||||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
|
||||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>GLEW_STATIC;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32sd.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent />
|
|
||||||
<PostBuildEvent />
|
|
||||||
<Lib>
|
|
||||||
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32sd.lib;glfw3.lib</AdditionalDependencies>
|
|
||||||
<ForceSymbolReferences>
|
|
||||||
</ForceSymbolReferences>
|
|
||||||
</Lib>
|
|
||||||
<ProjectReference />
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>GLEW_STATIC;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
<Lib>
|
|
||||||
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;</AdditionalDependencies>
|
|
||||||
</Lib>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Camera.cpp" />
|
|
||||||
<ClCompile Include="Engine.h" />
|
|
||||||
<ClCompile Include="Frame.cpp" />
|
|
||||||
<ClCompile Include="GameFrame.cpp" />
|
|
||||||
<ClCompile Include="GameWorld.cpp" />
|
|
||||||
<ClCompile Include="GUIManager.cpp" />
|
|
||||||
<ClCompile Include="main.cpp" />
|
|
||||||
<ClCompile Include="MenuFrame.cpp" />
|
|
||||||
<ClCompile Include="Model.cpp" />
|
|
||||||
<ClCompile Include="OBJ.cpp" />
|
|
||||||
<ClCompile Include="Renderer.cpp" />
|
|
||||||
<ClCompile Include="ShaderProgram.cpp" />
|
|
||||||
<ClCompile Include="Systems\CollisionSystem.cpp" />
|
|
||||||
<ClCompile Include="Texture.cpp" />
|
|
||||||
<ClCompile Include="TextFrame.cpp" />
|
|
||||||
<ClCompile Include="World.cpp" />
|
|
||||||
<ClCompile Include="Systems\InputSystem.cpp" />
|
|
||||||
<ClCompile Include="Systems\LevelGenerationSystem.cpp" />
|
|
||||||
<ClCompile Include="Systems\ParticleSystem.cpp" />
|
|
||||||
<ClCompile Include="Systems\PlayerSystem.cpp" />
|
|
||||||
<ClCompile Include="Systems\RenderSystem.cpp" />
|
|
||||||
<ClCompile Include="Systems\SoundsSystem.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Camera.h" />
|
|
||||||
<ClInclude Include="Color.h" />
|
|
||||||
<ClInclude Include="Component.h" />
|
|
||||||
<ClInclude Include="Components\Camera.h" />
|
|
||||||
<ClInclude Include="Factory.h" />
|
|
||||||
<ClInclude Include="Components\Bounds.h" />
|
|
||||||
<ClInclude Include="Components\Collision.h" />
|
|
||||||
<ClInclude Include="Components\DirectionalLight.h" />
|
|
||||||
<ClInclude Include="Components\Input.h" />
|
|
||||||
<ClInclude Include="Components\Model.h" />
|
|
||||||
<ClInclude Include="Components\ParticleEmitter.h" />
|
|
||||||
<ClInclude Include="Components\PointLight.h" />
|
|
||||||
<ClInclude Include="Components\PowerUp.h" />
|
|
||||||
<ClInclude Include="Components\SoundEmitter.h" />
|
|
||||||
<ClInclude Include="Components\Sprite.h" />
|
|
||||||
<ClInclude Include="Components\Stat.h" />
|
|
||||||
<ClInclude Include="Components\Template.h" />
|
|
||||||
<ClInclude Include="Components\Transform.h" />
|
|
||||||
<ClInclude Include="Entity.h" />
|
|
||||||
<ClInclude Include="Frame.h" />
|
|
||||||
<ClInclude Include="GameFrame.h" />
|
|
||||||
<ClInclude Include="GameWorld.h" />
|
|
||||||
<ClInclude Include="GUIManager.h" />
|
|
||||||
<ClInclude Include="logging.h" />
|
|
||||||
<ClInclude Include="glerror.h" />
|
|
||||||
<ClInclude Include="MenuFrame.h" />
|
|
||||||
<ClInclude Include="Model.h" />
|
|
||||||
<ClInclude Include="Rectangle.h" />
|
|
||||||
<ClInclude Include="OBJ.h" />
|
|
||||||
<ClInclude Include="OpenGL.h" />
|
|
||||||
<ClInclude Include="Renderer.h" />
|
|
||||||
<ClInclude Include="ShaderProgram.h" />
|
|
||||||
<ClInclude Include="Systems\InputSystem.h" />
|
|
||||||
<ClInclude Include="System.h" />
|
|
||||||
<ClInclude Include="Systems\CollisionSystem.h" />
|
|
||||||
<ClInclude Include="Systems\LevelGenerationSystem.h" />
|
|
||||||
<ClInclude Include="Systems\ParticleSystem.h" />
|
|
||||||
<ClInclude Include="Systems\PlayerSystem.h" />
|
|
||||||
<ClInclude Include="Systems\RenderSystem.h" />
|
|
||||||
<ClInclude Include="Systems\SoundSystem.h" />
|
|
||||||
<ClInclude Include="Texture.h" />
|
|
||||||
<ClInclude Include="TextFrame.h" />
|
|
||||||
<ClInclude Include="World.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Fragment2.glsl" />
|
|
||||||
<None Include="Shaders\AABB.frag.glsl" />
|
|
||||||
<None Include="Shaders\Fragment.glsl" />
|
|
||||||
<None Include="Shaders\Normals.frag.glsl" />
|
|
||||||
<None Include="Shaders\Normals.geo.glsl" />
|
|
||||||
<None Include="Shaders\VisualizeDepth.frag.glsl" />
|
|
||||||
<None Include="Shaders\VisualizeDepth.vert.glsl" />
|
|
||||||
<None Include="Shaders\ShadowMap.frag.glsl" />
|
|
||||||
<None Include="Shaders\ShadowMap.vert.glsl" />
|
|
||||||
<None Include="Shaders\Vertex.glsl" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
#include "GameWorld.h"
|
|
||||||
|
|
||||||
|
|
||||||
void GameWorld::Initialize()
|
|
||||||
{
|
|
||||||
World::Initialize();
|
|
||||||
|
|
||||||
AddSystem("LevelGenerationSystem");
|
|
||||||
AddSystem("InputSystem");
|
|
||||||
AddSystem("CollisionSystem");
|
|
||||||
//AddSystem("ParticleSystem");
|
|
||||||
AddSystem("PlayerSystem");
|
|
||||||
AddSystem("SoundSystem");
|
|
||||||
AddSystem("RenderSystem");
|
|
||||||
|
|
||||||
std::shared_ptr<Components::Transform> transform;
|
|
||||||
std::shared_ptr<Components::Model> model;
|
|
||||||
std::shared_ptr<Components::PointLight> pointLight;
|
|
||||||
std::shared_ptr<Components::Camera> camera;
|
|
||||||
std::shared_ptr<Components::Bounds> bounds;
|
|
||||||
std::shared_ptr<Components::Collision> collision;
|
|
||||||
std::shared_ptr<Components::SoundEmitter> soundEmitter;
|
|
||||||
EntityID ent;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Fucking lights
|
|
||||||
ent = CreateEntity();
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
transform->Position = glm::vec3(0.f, 7.f, 0.f);
|
|
||||||
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
|
||||||
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
|
||||||
pointLight->Diffuse = glm::vec3(0.0, 0.0, 5.0);
|
|
||||||
pointLight->constantAttenuation = 0.f;
|
|
||||||
pointLight->linearAttenuation = 1.f;
|
|
||||||
pointLight->quadraticAttenuation = 0.f;
|
|
||||||
pointLight->spotExponent = 0.0f;
|
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
|
||||||
model->ModelFile = "Models/sphere.obj";
|
|
||||||
ent = CreateEntity();
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
transform->Position = glm::vec3(10.f, 7.f, 0.f);
|
|
||||||
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
|
||||||
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
|
||||||
pointLight->Diffuse = glm::vec3(0.0, 5.0, 0.0);
|
|
||||||
pointLight->constantAttenuation = 0.f;
|
|
||||||
pointLight->linearAttenuation = 1.f;
|
|
||||||
pointLight->quadraticAttenuation = 0.f;
|
|
||||||
pointLight->spotExponent = 0.0f;
|
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
|
||||||
model->ModelFile = "Models/sphere.obj";
|
|
||||||
ent = CreateEntity();
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
transform->Position = glm::vec3(-10.f, 7.f, 0.f);
|
|
||||||
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
|
|
||||||
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
|
||||||
pointLight->Diffuse = glm::vec3(5.0, 0.0, 0.0);
|
|
||||||
pointLight->constantAttenuation = 0.f;
|
|
||||||
pointLight->linearAttenuation = 1.f;
|
|
||||||
pointLight->quadraticAttenuation = 0.f;
|
|
||||||
pointLight->spotExponent = 0.0f;
|
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
|
||||||
model->ModelFile = "Models/sphere.obj";
|
|
||||||
|
|
||||||
//ground
|
|
||||||
ent = CreateEntity();
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
|
||||||
model->ModelFile = "Models/plane.obj";
|
|
||||||
|
|
||||||
// Player
|
|
||||||
m_Player = CreateEntity();
|
|
||||||
SetProperty(m_Player, "Name", std::string("PlayerShip"));
|
|
||||||
transform = AddComponent<Components::Transform>(m_Player, "Transform");
|
|
||||||
transform->Position = glm::vec3(0.f, 2.f, -5.f);
|
|
||||||
transform->Scale = glm::vec3(1.0f);
|
|
||||||
model = AddComponent<Components::Model>(m_Player, "Model");
|
|
||||||
model->ModelFile = "Models/ship.obj";
|
|
||||||
pointLight = AddComponent<Components::PointLight>(m_Player, "PointLight");
|
|
||||||
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
|
||||||
pointLight->Diffuse = glm::vec3(0.4, 0.4, 1.0);
|
|
||||||
pointLight->constantAttenuation = 0.f;
|
|
||||||
pointLight->linearAttenuation = 1.f;
|
|
||||||
pointLight->quadraticAttenuation = 0.f;
|
|
||||||
pointLight->spotExponent = 0.0f;
|
|
||||||
AddComponent<Components::Input>(m_Player, "Input");
|
|
||||||
collision = AddComponent<Components::Collision>(m_Player, "Collision");
|
|
||||||
collision->Phantom = false;
|
|
||||||
collision->Interested = true;
|
|
||||||
bounds = AddComponent<Components::Bounds>(m_Player, "Bounds");
|
|
||||||
<<<<<<< HEAD
|
|
||||||
bounds->Origin = glm::vec3(transform->Position.x, transform->Position.y - 4, transform->Position.z + 3);
|
|
||||||
bounds->VolumeVector = glm::vec3(4.f,0.7f,4);
|
|
||||||
soundEmitter = AddComponent<Components::SoundEmitter>(m_Player, "SoundEmitter");
|
|
||||||
soundEmitter->Loop = true;
|
|
||||||
soundEmitter->MaxDistance = FLT_MAX;
|
|
||||||
soundEmitter->ReferenceDistance = 10;
|
|
||||||
soundEmitter->Gain = 1;
|
|
||||||
soundEmitter->Pitch = 1;
|
|
||||||
soundEmitter->Path = "Sounds/hallelujah.wav";
|
|
||||||
GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter);
|
|
||||||
=======
|
|
||||||
bounds->Origin = glm::vec3(0, 0, 2.f);
|
|
||||||
bounds->VolumeVector = glm::vec3(4.f, 0.7f, 1);
|
|
||||||
>>>>>>> f76c0b336f87a259a7eabf3c532fc885f155a605
|
|
||||||
|
|
||||||
|
|
||||||
// Camera
|
|
||||||
entcamera = CreateEntity(m_Player);
|
|
||||||
SetProperty(entcamera, "Name", std::string("Camera"));
|
|
||||||
transform = AddComponent<Components::Transform>(entcamera, "Transform");
|
|
||||||
AddComponent<Components::Input>(entcamera, "Input");
|
|
||||||
transform->Position = glm::vec3(0.f, 10.f, 14.f);
|
|
||||||
camera = AddComponent<Components::Camera>(entcamera, "Camera");
|
|
||||||
camera->FOV = 45.f;
|
|
||||||
camera->FarClip = 1000.f;
|
|
||||||
camera->NearClip = 0.01f;
|
|
||||||
transform->Orientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*ent = CreateEntity();
|
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
|
||||||
transform->Position = glm::vec3(10.f, 4.f, 0.f);
|
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
|
||||||
model->ModelFile = "Models/ship.obj";
|
|
||||||
collision = AddComponent<Components::Collision>(player2, "Collision");
|
|
||||||
collision->Phantom = false;
|
|
||||||
bounds = AddComponent<Components::Bounds>(player2, "Bounds");
|
|
||||||
bounds->Origin = transform->Position;
|
|
||||||
bounds->VolumeVector = glm::vec3(2.f,2.f,2.f);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::Update(double dt)
|
|
||||||
{
|
|
||||||
World::Update(dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::RegisterComponents()
|
|
||||||
{
|
|
||||||
m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); });
|
|
||||||
m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); });
|
|
||||||
m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); });
|
|
||||||
m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); });
|
|
||||||
m_ComponentFactory.Register("Input", []() { return new Components::Input(); });
|
|
||||||
m_ComponentFactory.Register("Model", []() { return new Components::Model(); });
|
|
||||||
m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
|
|
||||||
m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); });
|
|
||||||
m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); });
|
|
||||||
m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); });
|
|
||||||
m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); });
|
|
||||||
m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); });
|
|
||||||
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
|
|
||||||
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::RegisterSystems()
|
|
||||||
{
|
|
||||||
m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
|
||||||
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
|
||||||
m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
|
||||||
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
|
||||||
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
|
|
||||||
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
|
|
||||||
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,133 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
|
||||||
cmake_policy(VERSION 2.6)
|
|
||||||
|
|
||||||
project(glm)
|
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
|
|
||||||
option(GLM_TEST_ENABLE "GLM test" OFF)
|
|
||||||
if(NOT GLM_TEST_ENABLE)
|
|
||||||
message(FATAL_ERROR "GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND UNIX))
|
|
||||||
option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_CXX_0X "Enable C++ 0x" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_CXX_1Y "Enable C++ 1y" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_CXX_PEDANTIC "Pedantic" ON)
|
|
||||||
|
|
||||||
if(GLM_TEST_ENABLE_CXX_PEDANTIC)
|
|
||||||
add_definitions(-pedantic)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(GLM_TEST_ENABLE_CXX_1Y)
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++1y")
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++1y")
|
|
||||||
elseif(GLM_TEST_ENABLE_CXX_11)
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11")
|
|
||||||
elseif(GLM_TEST_ENABLE_CXX_0X)
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x")
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++0x")
|
|
||||||
elseif(GLM_TEST_ENABLE_CXX_98)
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++98")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32))
|
|
||||||
option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF)
|
|
||||||
|
|
||||||
if(NOT GLM_TEST_ENABLE_MS_EXTENSIONS)
|
|
||||||
add_definitions(/Za)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(GLM_TEST_ENABLE_SIMD_SSE2 "Enable SSE2 optimizations" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_SIMD_SSE3 "Enable SSE3 optimizations" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_SIMD_AVX "Enable AVX optimizations" OFF)
|
|
||||||
option(GLM_TEST_ENABLE_SIMD_AVX2 "Enable AVX2 optimizations" OFF)
|
|
||||||
option(GLM_TEST_FORCE_PURE "Force 'pure' instructions" OFF)
|
|
||||||
|
|
||||||
if(GLM_TEST_FORCE_PURE)
|
|
||||||
add_definitions(-DGLM_FORCE_PURE)
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-mfpmath=387)
|
|
||||||
elseif(MSVC)
|
|
||||||
add_definitions(/arch:IA32)
|
|
||||||
endif()
|
|
||||||
elseif(GLM_TEST_ENABLE_AVX2)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-mavx2)
|
|
||||||
elseif(GLM_USE_INTEL)
|
|
||||||
add_definitions(/QxAVX2)
|
|
||||||
elseif(MSVC)
|
|
||||||
add_definitions(/arch:AVX2)
|
|
||||||
endif()
|
|
||||||
elseif(GLM_TEST_ENABLE_AVX)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-mavx)
|
|
||||||
elseif(GLM_USE_INTEL)
|
|
||||||
add_definitions(/QxAVX)
|
|
||||||
elseif(MSVC)
|
|
||||||
add_definitions(/arch:AVX)
|
|
||||||
endif()
|
|
||||||
elseif(GLM_TEST_ENABLE_SSE3)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-msse3)
|
|
||||||
elseif(GLM_USE_INTEL)
|
|
||||||
add_definitions(/QxSSE3)
|
|
||||||
elseif(MSVC)
|
|
||||||
add_definitions(/arch:SSE2) # VC doesn't support /arch:SSE3
|
|
||||||
endif()
|
|
||||||
elseif(GLM_TEST_ENABLE_SSE2)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-msse2)
|
|
||||||
elseif(GLM_USE_INTEL)
|
|
||||||
add_definitions(/QxSSE2)
|
|
||||||
elseif(MSVC)
|
|
||||||
if(NOT CMAKE_CL_64)
|
|
||||||
add_definitions(/arch:SSE2)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)
|
|
||||||
if(GLM_TEST_ENABLE_FAST_MATH)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
add_definitions(-ffast-math)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
add_definitions(/fp:fast)
|
|
||||||
endif()
|
|
||||||
elseif(NOT GLM_TEST_ENABLE_FAST_MATH)
|
|
||||||
if(MSVC)
|
|
||||||
add_definitions(/fp:precise)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
#add_definitions(-S)
|
|
||||||
#add_definitions(-s)
|
|
||||||
#add_definitions(-m32)
|
|
||||||
#add_definitions(-O3)
|
|
||||||
|
|
||||||
#add_definitions(-fprofile-arcs -ftest-coverage) gcov
|
|
||||||
#ctest_enable_coverage()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(".")
|
|
||||||
include_directories("./test/external")
|
|
||||||
|
|
||||||
add_subdirectory(glm)
|
|
||||||
add_subdirectory(test)
|
|
||||||
|
|
||||||
install(DIRECTORY glm DESTINATION include)
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
## This file should be placed in the root directory of your project.
|
|
||||||
## Then modify the CMakeLists.txt file in the root directory of your
|
|
||||||
## project to incorporate the testing dashboard.
|
|
||||||
## # The following are required to uses Dart and the Cdash dashboard
|
|
||||||
## ENABLE_TESTING()
|
|
||||||
## INCLUDE(CTest)
|
|
||||||
set(CTEST_PROJECT_NAME "GLM")
|
|
||||||
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
|
|
||||||
|
|
||||||
set(CTEST_DROP_METHOD "http")
|
|
||||||
set(CTEST_DROP_SITE "my.cdash.org")
|
|
||||||
set(CTEST_DROP_LOCATION "/submit.php?project=GLM")
|
|
||||||
set(CTEST_DROP_SITE_CDASH TRUE)
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// OpenGL Mathematics (glm.g-truc.net)
|
|
||||||
///
|
|
||||||
/// Copyright (c) 2005 - 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 glm/core/dummy.cpp
|
|
||||||
/// @date 2011-01-19 / 2011-06-15
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///
|
|
||||||
/// GLM is a header only library. There is nothing to compile.
|
|
||||||
/// dummy.cpp exist only a wordaround for CMake file.
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#define GLM_MESSAGES
|
|
||||||
#include "../glm.hpp"
|
|
||||||
#include <limits>
|
|
||||||
/*
|
|
||||||
#if(GLM_ARCH & GLM_ARCH_SSE2)
|
|
||||||
struct float4
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct {float r, g, b, a;};
|
|
||||||
struct {float s, t, p, q;};
|
|
||||||
struct {float x, y, z, w;};
|
|
||||||
__m128 data;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
int test_simd()
|
|
||||||
{
|
|
||||||
float4 f;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif//GLM_ARCH
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class T = int>
|
|
||||||
class C;
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class C
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
T value;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
# if(GLM_ARCH & GLM_ARCH_SSE2)
|
|
||||||
test_simd();
|
|
||||||
# endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
C<> c;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Vendored
BIN
Binary file not shown.
@@ -1,15 +0,0 @@
|
|||||||
function(glmCreateTestGTC NAME)
|
|
||||||
set(SAMPLE_NAME test-${NAME})
|
|
||||||
add_executable(${SAMPLE_NAME} ${NAME}.cpp)
|
|
||||||
|
|
||||||
add_test(
|
|
||||||
NAME ${SAMPLE_NAME}
|
|
||||||
COMMAND $<TARGET_FILE:${SAMPLE_NAME}> )
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
add_subdirectory(bug)
|
|
||||||
add_subdirectory(core)
|
|
||||||
add_subdirectory(gtc)
|
|
||||||
add_subdirectory(gtx)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
glmCreateTestGTC(core_type_cast)
|
|
||||||
glmCreateTestGTC(core_type_float)
|
|
||||||
glmCreateTestGTC(core_type_int)
|
|
||||||
glmCreateTestGTC(core_type_length)
|
|
||||||
glmCreateTestGTC(core_type_mat2x2)
|
|
||||||
glmCreateTestGTC(core_type_mat2x3)
|
|
||||||
glmCreateTestGTC(core_type_mat2x4)
|
|
||||||
glmCreateTestGTC(core_type_mat3x2)
|
|
||||||
glmCreateTestGTC(core_type_mat3x3)
|
|
||||||
glmCreateTestGTC(core_type_mat3x4)
|
|
||||||
glmCreateTestGTC(core_type_mat4x2)
|
|
||||||
glmCreateTestGTC(core_type_mat4x3)
|
|
||||||
glmCreateTestGTC(core_type_mat4x4)
|
|
||||||
glmCreateTestGTC(core_type_vec1)
|
|
||||||
glmCreateTestGTC(core_type_vec2)
|
|
||||||
glmCreateTestGTC(core_type_vec3)
|
|
||||||
glmCreateTestGTC(core_type_vec4)
|
|
||||||
glmCreateTestGTC(core_func_common)
|
|
||||||
glmCreateTestGTC(core_func_exponential)
|
|
||||||
glmCreateTestGTC(core_func_geometric)
|
|
||||||
glmCreateTestGTC(core_func_integer)
|
|
||||||
glmCreateTestGTC(core_func_matrix)
|
|
||||||
glmCreateTestGTC(core_func_noise)
|
|
||||||
glmCreateTestGTC(core_func_packing)
|
|
||||||
glmCreateTestGTC(core_func_trigonometric)
|
|
||||||
glmCreateTestGTC(core_func_vector_relational)
|
|
||||||
glmCreateTestGTC(core_func_swizzle)
|
|
||||||
glmCreateTestGTC(core_setup_message)
|
|
||||||
glmCreateTestGTC(core_setup_precision)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,645 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-09-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_common.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//#include <boost/array.hpp>
|
|
||||||
//#include <boost/date_time/posix_time/posix_time.hpp>
|
|
||||||
//#include <boost/thread/thread.hpp>
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
int test_modf()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
float X(1.5f);
|
|
||||||
float I(0.0f);
|
|
||||||
float A = glm::modf(X, I);
|
|
||||||
|
|
||||||
Error += I == 1.0f ? 0 : 1;
|
|
||||||
Error += A == 0.5f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f);
|
|
||||||
glm::vec4 I(0.0f);
|
|
||||||
glm::vec4 A = glm::modf(X, I);
|
|
||||||
|
|
||||||
Error += I == glm::vec4(1.0f) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec4 X(1.1, 1.2, 1.5, 1.7);
|
|
||||||
glm::dvec4 I(0.0);
|
|
||||||
glm::dvec4 A = glm::modf(X, I);
|
|
||||||
|
|
||||||
Error += I == glm::dvec4(1.0) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
double X(1.5);
|
|
||||||
double I(0.0);
|
|
||||||
double A = glm::modf(X, I);
|
|
||||||
|
|
||||||
Error += I == 1.0 ? 0 : 1;
|
|
||||||
Error += A == 0.5 ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_floatBitsToInt()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = 1.0f;
|
|
||||||
int B = glm::floatBitsToInt(A);
|
|
||||||
float C = glm::intBitsToFloat(B);
|
|
||||||
int D = *(int*)&A;
|
|
||||||
Error += B == D ? 0 : 1;
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::ivec2 B = glm::floatBitsToInt(A);
|
|
||||||
glm::vec2 C = glm::intBitsToFloat(B);
|
|
||||||
Error += B.x == *(int*)&(A.x) ? 0 : 1;
|
|
||||||
Error += B.y == *(int*)&(A.y) ? 0 : 1;
|
|
||||||
Error += A == C? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::ivec3 B = glm::floatBitsToInt(A);
|
|
||||||
glm::vec3 C = glm::intBitsToFloat(B);
|
|
||||||
Error += B.x == *(int*)&(A.x) ? 0 : 1;
|
|
||||||
Error += B.y == *(int*)&(A.y) ? 0 : 1;
|
|
||||||
Error += B.z == *(int*)&(A.z) ? 0 : 1;
|
|
||||||
Error += A == C? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::ivec4 B = glm::floatBitsToInt(A);
|
|
||||||
glm::vec4 C = glm::intBitsToFloat(B);
|
|
||||||
Error += B.x == *(int*)&(A.x) ? 0 : 1;
|
|
||||||
Error += B.y == *(int*)&(A.y) ? 0 : 1;
|
|
||||||
Error += B.z == *(int*)&(A.z) ? 0 : 1;
|
|
||||||
Error += B.w == *(int*)&(A.w) ? 0 : 1;
|
|
||||||
Error += A == C? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_floatBitsToUint()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = 1.0f;
|
|
||||||
glm::uint B = glm::floatBitsToUint(A);
|
|
||||||
float C = glm::intBitsToFloat(B);
|
|
||||||
Error += B == *(glm::uint*)&A ? 0 : 1;
|
|
||||||
Error += A == C? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::uvec2 B = glm::floatBitsToUint(A);
|
|
||||||
glm::vec2 C = glm::uintBitsToFloat(B);
|
|
||||||
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
|
|
||||||
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::uvec3 B = glm::floatBitsToUint(A);
|
|
||||||
glm::vec3 C = glm::uintBitsToFloat(B);
|
|
||||||
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
|
|
||||||
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
|
|
||||||
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
|
|
||||||
Error += A == C? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::uvec4 B = glm::floatBitsToUint(A);
|
|
||||||
glm::vec4 C = glm::uintBitsToFloat(B);
|
|
||||||
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
|
|
||||||
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
|
|
||||||
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
|
|
||||||
Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1;
|
|
||||||
Error += A == C? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace test_mix
|
|
||||||
{
|
|
||||||
template <typename T, typename B>
|
|
||||||
struct test
|
|
||||||
{
|
|
||||||
T x;
|
|
||||||
T y;
|
|
||||||
B a;
|
|
||||||
T Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
test<float, bool> TestBool[] =
|
|
||||||
{
|
|
||||||
{0.0f, 1.0f, false, 0.0f},
|
|
||||||
{0.0f, 1.0f, true, 1.0f},
|
|
||||||
{-1.0f, 1.0f, false, -1.0f},
|
|
||||||
{-1.0f, 1.0f, true, 1.0f}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<float, float> TestFloat[] =
|
|
||||||
{
|
|
||||||
{0.0f, 1.0f, 0.0f, 0.0f},
|
|
||||||
{0.0f, 1.0f, 1.0f, 1.0f},
|
|
||||||
{-1.0f, 1.0f, 0.0f, -1.0f},
|
|
||||||
{-1.0f, 1.0f, 1.0f, 1.0f}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec2, bool> TestVec2Bool[] =
|
|
||||||
{
|
|
||||||
{glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)},
|
|
||||||
{glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)},
|
|
||||||
{glm::vec2(-1.0f), glm::vec2(1.0f), false, glm::vec2(-1.0f)},
|
|
||||||
{glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec2, glm::bvec2> TestBVec2[] =
|
|
||||||
{
|
|
||||||
{glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)},
|
|
||||||
{glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
|
|
||||||
{glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(-1.0f)},
|
|
||||||
{glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
|
|
||||||
{glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec3, bool> TestVec3Bool[] =
|
|
||||||
{
|
|
||||||
{glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)},
|
|
||||||
{glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)},
|
|
||||||
{glm::vec3(-1.0f), glm::vec3(1.0f), false, glm::vec3(-1.0f)},
|
|
||||||
{glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec3, glm::bvec3> TestBVec3[] =
|
|
||||||
{
|
|
||||||
{glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)},
|
|
||||||
{glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
|
|
||||||
{glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(-1.0f)},
|
|
||||||
{glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
|
|
||||||
{glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec4, bool> TestVec4Bool[] =
|
|
||||||
{
|
|
||||||
{glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)},
|
|
||||||
{glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)},
|
|
||||||
{glm::vec4(-1.0f), glm::vec4(1.0f), false, glm::vec4(-1.0f)},
|
|
||||||
{glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec4, glm::bvec4> TestBVec4[] =
|
|
||||||
{
|
|
||||||
{glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(0.0f)},
|
|
||||||
{glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
|
|
||||||
{glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(-1.0f)},
|
|
||||||
{glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
|
|
||||||
{glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f), glm::bvec4(true, false, true, false), glm::vec4(5.0f, 2.0f, 7.0f, 4.0f)}
|
|
||||||
};
|
|
||||||
|
|
||||||
int run()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
// Float with bool
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(test<float, bool>); ++i)
|
|
||||||
{
|
|
||||||
float Result = glm::mix(TestBool[i].x, TestBool[i].y, TestBool[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result, TestBool[i].Result, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float with float
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(test<float, float>); ++i)
|
|
||||||
{
|
|
||||||
float Result = glm::mix(TestFloat[i].x, TestFloat[i].y, TestFloat[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result, TestFloat[i].Result, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec2 with bool
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(test<glm::vec2, bool>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec2 Result = glm::mix(TestVec2Bool[i].x, TestVec2Bool[i].y, TestVec2Bool[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result.x, TestVec2Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.y, TestVec2Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec2 with bvec2
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(test<glm::vec2, glm::bvec2>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec2 Result = glm::mix(TestBVec2[i].x, TestBVec2[i].y, TestBVec2[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result.x, TestBVec2[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.y, TestBVec2[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec3 with bool
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(test<glm::vec3, bool>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec3 Result = glm::mix(TestVec3Bool[i].x, TestVec3Bool[i].y, TestVec3Bool[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result.x, TestVec3Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.y, TestVec3Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.z, TestVec3Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec3 with bvec3
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(test<glm::vec3, glm::bvec3>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec3 Result = glm::mix(TestBVec3[i].x, TestBVec3[i].y, TestBVec3[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.y, TestBVec3[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.z, TestBVec3[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec4 with bool
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(test<glm::vec4, bool>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec4 Result = glm::mix(TestVec4Bool[i].x, TestVec4Bool[i].y, TestVec4Bool[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result.x, TestVec4Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.y, TestVec4Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.z, TestVec4Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.w, TestVec4Bool[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec4 with bvec4
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(test<glm::vec4, glm::bvec4>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec4 Result = glm::mix(TestBVec4[i].x, TestBVec4[i].y, TestBVec4[i].a);
|
|
||||||
Error += glm::epsilonEqual(Result.x, TestBVec4[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.y, TestBVec4[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.z, TestBVec4[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Result.w, TestBVec4[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//namespace test_mix
|
|
||||||
|
|
||||||
namespace test_step
|
|
||||||
{
|
|
||||||
template <typename EDGE, typename VEC>
|
|
||||||
struct test
|
|
||||||
{
|
|
||||||
EDGE edge;
|
|
||||||
VEC x;
|
|
||||||
VEC result;
|
|
||||||
};
|
|
||||||
|
|
||||||
test<float, glm::vec4> TestVec4Scalar [] =
|
|
||||||
{
|
|
||||||
{ 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
|
|
||||||
{ 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
|
|
||||||
{ 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) }
|
|
||||||
};
|
|
||||||
|
|
||||||
test<glm::vec4, glm::vec4> TestVec4Vector [] =
|
|
||||||
{
|
|
||||||
{ glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) },
|
|
||||||
{ glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
|
|
||||||
{ glm::vec4( 2.0f, 3.0f, 4.0f, 5.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(0.0f) },
|
|
||||||
{ glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) }
|
|
||||||
};
|
|
||||||
|
|
||||||
int run()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
// vec4 and float
|
|
||||||
{
|
|
||||||
for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(test<float, glm::vec4>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec4 Result = glm::step(TestVec4Scalar[i].edge, TestVec4Scalar[i].x);
|
|
||||||
Error += glm::all(glm::epsilonEqual(Result, TestVec4Scalar[i].result, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vec4 and vec4
|
|
||||||
{
|
|
||||||
for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(test<glm::vec4, glm::vec4>); ++i)
|
|
||||||
{
|
|
||||||
glm::vec4 Result = glm::step(TestVec4Vector[i].edge, TestVec4Vector[i].x);
|
|
||||||
Error += glm::all(glm::epsilonEqual(Result, TestVec4Vector[i].result, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//namespace test_step
|
|
||||||
|
|
||||||
int test_round()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::round(0.0f);
|
|
||||||
Error += A == 0.0f ? 0 : 1;
|
|
||||||
float B = glm::round(0.5f);
|
|
||||||
Error += B == 1.0f ? 0 : 1;
|
|
||||||
float C = glm::round(1.0f);
|
|
||||||
Error += C == 1.0f ? 0 : 1;
|
|
||||||
float D = glm::round(0.1f);
|
|
||||||
Error += D == 0.0f ? 0 : 1;
|
|
||||||
float E = glm::round(0.9f);
|
|
||||||
Error += E == 1.0f ? 0 : 1;
|
|
||||||
float F = glm::round(1.5f);
|
|
||||||
Error += F == 2.0f ? 0 : 1;
|
|
||||||
float G = glm::round(1.9f);
|
|
||||||
Error += G == 2.0f ? 0 : 1;
|
|
||||||
|
|
||||||
#if GLM_LANG >= GLM_LANG_CXX11
|
|
||||||
float A1 = glm::round(0.0f);
|
|
||||||
Error += A1 == A ? 0 : 1;
|
|
||||||
float B1 = glm::round(0.5f);
|
|
||||||
Error += B1 == B ? 0 : 1;
|
|
||||||
float C1 = glm::round(1.0f);
|
|
||||||
Error += C1 == C ? 0 : 1;
|
|
||||||
float D1 = glm::round(0.1f);
|
|
||||||
Error += D1 == D ? 0 : 1;
|
|
||||||
float E1 = glm::round(0.9f);
|
|
||||||
Error += E1 == E ? 0 : 1;
|
|
||||||
float F1 = glm::round(1.5f);
|
|
||||||
Error += F == F ? 0 : 1;
|
|
||||||
float G1 = glm::round(1.9f);
|
|
||||||
Error += G1 == G ? 0 : 1;
|
|
||||||
#endif // GLM_LANG >= GLM_CXX0X
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::round(-0.0f);
|
|
||||||
Error += A == 0.0f ? 0 : 1;
|
|
||||||
float B = glm::round(-0.5f);
|
|
||||||
Error += B == -1.0f ? 0 : 1;
|
|
||||||
float C = glm::round(-1.0f);
|
|
||||||
Error += C == -1.0f ? 0 : 1;
|
|
||||||
float D = glm::round(-0.1f);
|
|
||||||
Error += D == 0.0f ? 0 : 1;
|
|
||||||
float E = glm::round(-0.9f);
|
|
||||||
Error += E == -1.0f ? 0 : 1;
|
|
||||||
float F = glm::round(-1.5f);
|
|
||||||
Error += F == -2.0f ? 0 : 1;
|
|
||||||
float G = glm::round(-1.9f);
|
|
||||||
Error += G == -2.0f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_roundEven()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-1.5f);
|
|
||||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(1.5f);
|
|
||||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-3.5f);
|
|
||||||
Error += glm::epsilonEqual(A, -4.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(3.5f);
|
|
||||||
Error += glm::epsilonEqual(A, 4.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-2.5f);
|
|
||||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(2.5f);
|
|
||||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-2.4f);
|
|
||||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(2.4f);
|
|
||||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-2.6f);
|
|
||||||
Error += glm::epsilonEqual(A, -3.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(2.6f);
|
|
||||||
Error += glm::epsilonEqual(A, 3.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-2.0f);
|
|
||||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(2.0f);
|
|
||||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
|
||||||
Error += 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(0.0f);
|
|
||||||
Error += A == 0.0f ? 0 : 1;
|
|
||||||
float B = glm::roundEven(0.5f);
|
|
||||||
Error += B == 0.0f ? 0 : 1;
|
|
||||||
float C = glm::roundEven(1.0f);
|
|
||||||
Error += C == 1.0f ? 0 : 1;
|
|
||||||
float D = glm::roundEven(0.1f);
|
|
||||||
Error += D == 0.0f ? 0 : 1;
|
|
||||||
float E = glm::roundEven(0.9f);
|
|
||||||
Error += E == 1.0f ? 0 : 1;
|
|
||||||
float F = glm::roundEven(1.5f);
|
|
||||||
Error += F == 2.0f ? 0 : 1;
|
|
||||||
float G = glm::roundEven(1.9f);
|
|
||||||
Error += G == 2.0f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-0.0f);
|
|
||||||
Error += A == 0.0f ? 0 : 1;
|
|
||||||
float B = glm::roundEven(-0.5f);
|
|
||||||
Error += B == -0.0f ? 0 : 1;
|
|
||||||
float C = glm::roundEven(-1.0f);
|
|
||||||
Error += C == -1.0f ? 0 : 1;
|
|
||||||
float D = glm::roundEven(-0.1f);
|
|
||||||
Error += D == 0.0f ? 0 : 1;
|
|
||||||
float E = glm::roundEven(-0.9f);
|
|
||||||
Error += E == -1.0f ? 0 : 1;
|
|
||||||
float F = glm::roundEven(-1.5f);
|
|
||||||
Error += F == -2.0f ? 0 : 1;
|
|
||||||
float G = glm::roundEven(-1.9f);
|
|
||||||
Error += G == -2.0f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(1.5f);
|
|
||||||
Error += A == 2.0f ? 0 : 1;
|
|
||||||
float B = glm::roundEven(2.5f);
|
|
||||||
Error += B == 2.0f ? 0 : 1;
|
|
||||||
float C = glm::roundEven(3.5f);
|
|
||||||
Error += C == 4.0f ? 0 : 1;
|
|
||||||
float D = glm::roundEven(4.5f);
|
|
||||||
Error += D == 4.0f ? 0 : 1;
|
|
||||||
float E = glm::roundEven(5.5f);
|
|
||||||
Error += E == 6.0f ? 0 : 1;
|
|
||||||
float F = glm::roundEven(6.5f);
|
|
||||||
Error += F == 6.0f ? 0 : 1;
|
|
||||||
float G = glm::roundEven(7.5f);
|
|
||||||
Error += G == 8.0f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
float A = glm::roundEven(-1.5f);
|
|
||||||
Error += A == -2.0f ? 0 : 1;
|
|
||||||
float B = glm::roundEven(-2.5f);
|
|
||||||
Error += B == -2.0f ? 0 : 1;
|
|
||||||
float C = glm::roundEven(-3.5f);
|
|
||||||
Error += C == -4.0f ? 0 : 1;
|
|
||||||
float D = glm::roundEven(-4.5f);
|
|
||||||
Error += D == -4.0f ? 0 : 1;
|
|
||||||
float E = glm::roundEven(-5.5f);
|
|
||||||
Error += E == -6.0f ? 0 : 1;
|
|
||||||
float F = glm::roundEven(-6.5f);
|
|
||||||
Error += F == -6.0f ? 0 : 1;
|
|
||||||
float G = glm::roundEven(-7.5f);
|
|
||||||
Error += G == -8.0f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_isnan()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
float Zero_f = 0.0;
|
|
||||||
double Zero_d = 0.0;
|
|
||||||
|
|
||||||
{
|
|
||||||
Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_isinf()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
float Zero_f = 0.0;
|
|
||||||
double Zero_d = 0.0;
|
|
||||||
|
|
||||||
{
|
|
||||||
Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
|
|
||||||
Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
|
|
||||||
Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
|
|
||||||
Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += test_modf();
|
|
||||||
Error += test_floatBitsToInt();
|
|
||||||
Error += test_floatBitsToUint();
|
|
||||||
Error += test_step::run();
|
|
||||||
Error += test_mix::run();
|
|
||||||
Error += test_round();
|
|
||||||
Error += test_roundEven();
|
|
||||||
Error += test_isnan();
|
|
||||||
//Error += test_isinf();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-09-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_exponential.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/common.hpp>
|
|
||||||
#include <glm/exponential.hpp>
|
|
||||||
#include <glm/gtc/ulp.hpp>
|
|
||||||
|
|
||||||
namespace inversesqrt
|
|
||||||
{
|
|
||||||
int test()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::uint ulp(0);
|
|
||||||
float diff(0.0f);
|
|
||||||
|
|
||||||
for(float f = 0.001f; f < 10.f; f *= 1.001f)
|
|
||||||
{
|
|
||||||
glm::lowp_fvec1 lowp_v = glm::inversesqrt(glm::lowp_fvec1(f));
|
|
||||||
float defaultp_v = glm::inversesqrt(f);
|
|
||||||
|
|
||||||
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
|
|
||||||
diff = glm::abs(lowp_v.x - defaultp_v);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//namespace inversesqrt
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += inversesqrt::test();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-11-14
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_geometric.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/geometric.hpp>
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
|
|
||||||
int test_reflect()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f,-1.0f);
|
|
||||||
glm::vec2 B(0.0f, 1.0f);
|
|
||||||
glm::vec2 C = glm::reflect(A, B);
|
|
||||||
Error += C == glm::vec2(1.0, 1.0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec2 A(1.0f,-1.0f);
|
|
||||||
glm::dvec2 B(0.0f, 1.0f);
|
|
||||||
glm::dvec2 C = glm::reflect(A, B);
|
|
||||||
Error += C == glm::dvec2(1.0, 1.0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_refract()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float A(-1.0f);
|
|
||||||
float B(1.0f);
|
|
||||||
float C = glm::refract(A, B, 0.5f);
|
|
||||||
Error += C == -1.0f ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(0.0f,-1.0f);
|
|
||||||
glm::vec2 B(0.0f, 1.0f);
|
|
||||||
glm::vec2 C = glm::refract(A, B, 0.5f);
|
|
||||||
Error += glm::all(glm::epsilonEqual(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec2 A(0.0f,-1.0f);
|
|
||||||
glm::dvec2 B(0.0f, 1.0f);
|
|
||||||
glm::dvec2 C = glm::refract(A, B, 0.5);
|
|
||||||
Error += C == glm::dvec2(0.0, -1.0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += test_reflect();
|
|
||||||
Error += test_refract();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-05-03
|
|
||||||
// Updated : 2011-05-03
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_integer.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/integer.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
enum result
|
|
||||||
{
|
|
||||||
SUCCESS,
|
|
||||||
FAIL,
|
|
||||||
ASSERT,
|
|
||||||
STATIC_ASSERT
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace bitfieldExtract
|
|
||||||
{
|
|
||||||
template <typename genType, typename sizeType>
|
|
||||||
struct type
|
|
||||||
{
|
|
||||||
genType Value;
|
|
||||||
sizeType BitFirst;
|
|
||||||
sizeType BitCount;
|
|
||||||
genType Return;
|
|
||||||
result Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef type<glm::uint, glm::uint> typeU32;
|
|
||||||
|
|
||||||
typeU32 const Data32[] =
|
|
||||||
{
|
|
||||||
{0xffffffff, 8, 0, 0x00000000, SUCCESS},
|
|
||||||
{0x00000000, 0,32, 0x00000000, SUCCESS},
|
|
||||||
{0xffffffff, 0,32, 0xffffffff, SUCCESS},
|
|
||||||
{0x0f0f0f0f, 0,32, 0x0f0f0f0f, SUCCESS},
|
|
||||||
{0x00000000, 8, 0, 0x00000000, SUCCESS},
|
|
||||||
{0x80000000,31, 1, 0x00000001, SUCCESS},
|
|
||||||
{0x7fffffff,31, 1, 0x00000000, SUCCESS},
|
|
||||||
{0x00000300, 8, 8, 0x00000003, SUCCESS},
|
|
||||||
{0x0000ff00, 8, 8, 0x000000ff, SUCCESS},
|
|
||||||
{0xfffffff0, 0, 5, 0x00000010, SUCCESS},
|
|
||||||
{0x000000ff, 1, 3, 0x00000007, SUCCESS},
|
|
||||||
{0x000000ff, 0, 3, 0x00000007, SUCCESS},
|
|
||||||
{0x00000000, 0, 2, 0x00000000, SUCCESS},
|
|
||||||
{0xffffffff, 0, 8, 0x000000ff, SUCCESS},
|
|
||||||
{0xffff0000,16,16, 0x0000ffff, SUCCESS},
|
|
||||||
{0xfffffff0, 0, 8, 0x00000000, FAIL},
|
|
||||||
{0xffffffff,16,16, 0x00000000, FAIL},
|
|
||||||
//{0xffffffff,32, 1, 0x00000000, ASSERT}, // Throw an assert
|
|
||||||
//{0xffffffff, 0,33, 0x00000000, ASSERT}, // Throw an assert
|
|
||||||
//{0xffffffff,16,16, 0x00000000, ASSERT}, // Throw an assert
|
|
||||||
};
|
|
||||||
|
|
||||||
int test()
|
|
||||||
{
|
|
||||||
glm::uint count = sizeof(Data32) / sizeof(typeU32);
|
|
||||||
|
|
||||||
for(glm::uint i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
glm::uint Return = glm::bitfieldExtract(
|
|
||||||
Data32[i].Value,
|
|
||||||
Data32[i].BitFirst,
|
|
||||||
Data32[i].BitCount);
|
|
||||||
|
|
||||||
bool Compare = Data32[i].Return == Return;
|
|
||||||
|
|
||||||
if(Data32[i].Result == SUCCESS && Compare)
|
|
||||||
continue;
|
|
||||||
else if(Data32[i].Result == FAIL && !Compare)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
std::cout << "glm::bitfieldExtract test fail on test " << i << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}//extractField
|
|
||||||
|
|
||||||
namespace bitfieldReverse
|
|
||||||
{
|
|
||||||
template <typename genType>
|
|
||||||
struct type
|
|
||||||
{
|
|
||||||
genType Value;
|
|
||||||
genType Return;
|
|
||||||
result Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef type<glm::uint> typeU32;
|
|
||||||
|
|
||||||
typeU32 const Data32[] =
|
|
||||||
{
|
|
||||||
{0xffffffff, 0xffffffff, SUCCESS},
|
|
||||||
{0x00000000, 0x00000000, SUCCESS},
|
|
||||||
{0xf0000000, 0x0000000f, SUCCESS},
|
|
||||||
};
|
|
||||||
|
|
||||||
int test()
|
|
||||||
{
|
|
||||||
glm::uint count = sizeof(Data32) / sizeof(typeU32);
|
|
||||||
|
|
||||||
for(glm::uint i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
glm::uint Return = glm::bitfieldReverse(
|
|
||||||
Data32[i].Value);
|
|
||||||
|
|
||||||
bool Compare = Data32[i].Return == Return;
|
|
||||||
|
|
||||||
if(Data32[i].Result == SUCCESS && Compare)
|
|
||||||
continue;
|
|
||||||
else if(Data32[i].Result == FAIL && !Compare)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
std::cout << "glm::bitfieldReverse test fail on test " << i << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}//bitRevert
|
|
||||||
|
|
||||||
namespace findMSB
|
|
||||||
{
|
|
||||||
template <typename genType>
|
|
||||||
struct type
|
|
||||||
{
|
|
||||||
genType Value;
|
|
||||||
genType Return;
|
|
||||||
};
|
|
||||||
|
|
||||||
type<int> const DataI32[] =
|
|
||||||
{
|
|
||||||
{0x00000000, -1},
|
|
||||||
{0x00000001, 0},
|
|
||||||
{0x00000002, 1},
|
|
||||||
{0x00000003, 1},
|
|
||||||
{0x00000004, 2},
|
|
||||||
{0x00000005, 2},
|
|
||||||
{0x00000007, 2},
|
|
||||||
{0x00000008, 3},
|
|
||||||
{0x00000010, 4},
|
|
||||||
{0x00000020, 5},
|
|
||||||
{0x00000040, 6},
|
|
||||||
{0x00000080, 7},
|
|
||||||
{0x00000100, 8},
|
|
||||||
{0x00000200, 9},
|
|
||||||
{0x00000400, 10},
|
|
||||||
{0x00000800, 11},
|
|
||||||
{0x00001000, 12},
|
|
||||||
{0x00002000, 13},
|
|
||||||
{0x00004000, 14},
|
|
||||||
{0x00008000, 15},
|
|
||||||
{0x00010000, 16},
|
|
||||||
{0x00020000, 17},
|
|
||||||
{0x00040000, 18},
|
|
||||||
{0x00080000, 19},
|
|
||||||
{0x00100000, 20},
|
|
||||||
{0x00200000, 21},
|
|
||||||
{0x00400000, 22},
|
|
||||||
{0x00800000, 23},
|
|
||||||
{0x01000000, 24},
|
|
||||||
{0x02000000, 25},
|
|
||||||
{0x04000000, 26},
|
|
||||||
{0x08000000, 27},
|
|
||||||
{0x10000000, 28},
|
|
||||||
{0x20000000, 29},
|
|
||||||
{0x40000000, 30}
|
|
||||||
};
|
|
||||||
|
|
||||||
int test()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(type<int>); ++i)
|
|
||||||
{
|
|
||||||
int Result = glm::findMSB(DataI32[i].Value);
|
|
||||||
Error += DataI32[i].Return == Result ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//findMSB
|
|
||||||
|
|
||||||
namespace findLSB
|
|
||||||
{
|
|
||||||
template <typename genType>
|
|
||||||
struct type
|
|
||||||
{
|
|
||||||
genType Value;
|
|
||||||
genType Return;
|
|
||||||
};
|
|
||||||
|
|
||||||
type<int> const DataI32[] =
|
|
||||||
{
|
|
||||||
{0x00000001, 0},
|
|
||||||
{0x00000003, 0},
|
|
||||||
{0x00000002, 1}
|
|
||||||
};
|
|
||||||
|
|
||||||
int test()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(type<int>); ++i)
|
|
||||||
{
|
|
||||||
int Result = glm::findLSB(DataI32[i].Value);
|
|
||||||
Error += DataI32[i].Return == Result ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//findLSB
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::cout << "sizeof(glm::uint64): " << sizeof(glm::detail::uint64) << std::endl;
|
|
||||||
|
|
||||||
Error += ::bitfieldExtract::test();
|
|
||||||
Error += ::bitfieldReverse::test();
|
|
||||||
Error += ::findMSB::test();
|
|
||||||
Error += ::findLSB::test();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2012-05-02
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_matrix.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/matrix.hpp>
|
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
|
||||||
#include <glm/gtc/ulp.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
using namespace glm;
|
|
||||||
|
|
||||||
int test_matrixCompMult()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
mat2 m(0, 1, 2, 3);
|
|
||||||
mat2 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat2(0, 1, 4, 9) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat2x3 m(0, 1, 2, 3, 4, 5);
|
|
||||||
mat2x3 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat2x3(0, 1, 4, 9, 16, 25) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
|
|
||||||
mat2x4 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat2x4(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
|
||||||
mat3 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat3(0, 1, 4, 9, 16, 25, 36, 49, 64) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat3x2 m(0, 1, 2, 3, 4, 5);
|
|
||||||
mat3x2 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat3x2(0, 1, 4, 9, 16, 25) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
|
||||||
mat3x4 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
|
||||||
mat4 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
|
|
||||||
mat4x2 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat4x2(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
|
||||||
mat4x3 n = matrixCompMult(m, m);
|
|
||||||
Error += n == mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_outerProduct()
|
|
||||||
{
|
|
||||||
glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_transpose()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
mat2 m(0, 1, 2, 3);
|
|
||||||
mat2 t = transpose(m);
|
|
||||||
Error += t == mat2(0, 2, 1, 3) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat2x3 m(0, 1, 2, 3, 4, 5);
|
|
||||||
mat3x2 t = transpose(m);
|
|
||||||
Error += t == mat3x2(0, 3, 1, 4, 2, 5) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
|
|
||||||
mat4x2 t = transpose(m);
|
|
||||||
Error += t == mat4x2(0, 4, 1, 5, 2, 6, 3, 7) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
|
||||||
mat3 t = transpose(m);
|
|
||||||
Error += t == mat3(0, 3, 6, 1, 4, 7, 2, 5, 8) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat3x2 m(0, 1, 2, 3, 4, 5);
|
|
||||||
mat2x3 t = transpose(m);
|
|
||||||
Error += t == mat2x3(0, 2, 4, 1, 3, 5) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
|
||||||
mat4x3 t = transpose(m);
|
|
||||||
Error += t == mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
|
||||||
mat4 t = transpose(m);
|
|
||||||
Error += t == mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
|
|
||||||
mat2x4 t = transpose(m);
|
|
||||||
Error += t == mat2x4(0, 2, 4, 6, 1, 3, 5, 7) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
|
||||||
mat3x4 t = transpose(m);
|
|
||||||
Error += t == mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_determinant()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_inverse()
|
|
||||||
{
|
|
||||||
int Failed(0);
|
|
||||||
|
|
||||||
glm::mat4x4 A4x4(
|
|
||||||
glm::vec4(1, 0, 1, 0),
|
|
||||||
glm::vec4(0, 1, 0, 0),
|
|
||||||
glm::vec4(0, 0, 1, 0),
|
|
||||||
glm::vec4(0, 0, 0, 1));
|
|
||||||
glm::mat4x4 B4x4 = inverse(A4x4);
|
|
||||||
glm::mat4x4 I4x4 = A4x4 * B4x4;
|
|
||||||
Failed += I4x4 == glm::mat4x4(1) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::mat3x3 A3x3(
|
|
||||||
glm::vec3(1, 0, 1),
|
|
||||||
glm::vec3(0, 1, 0),
|
|
||||||
glm::vec3(0, 0, 1));
|
|
||||||
glm::mat3x3 B3x3 = glm::inverse(A3x3);
|
|
||||||
glm::mat3x3 I3x3 = A3x3 * B3x3;
|
|
||||||
Failed += I3x3 == glm::mat3x3(1) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::mat2x2 A2x2(
|
|
||||||
glm::vec2(1, 1),
|
|
||||||
glm::vec2(0, 1));
|
|
||||||
glm::mat2x2 B2x2 = glm::inverse(A2x2);
|
|
||||||
glm::mat2x2 I2x2 = A2x2 * B2x2;
|
|
||||||
Failed += I2x2 == glm::mat2x2(1) ? 0 : 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t const Count(10000000);
|
|
||||||
|
|
||||||
template <typename VEC3, typename MAT4>
|
|
||||||
int test_inverse_perf(std::size_t Instance, char const * Message)
|
|
||||||
{
|
|
||||||
std::vector<MAT4> TestInputs;
|
|
||||||
TestInputs.resize(Count);
|
|
||||||
std::vector<MAT4> TestOutputs;
|
|
||||||
TestOutputs.resize(TestInputs.size());
|
|
||||||
|
|
||||||
VEC3 Axis(glm::normalize(VEC3(1.0f, 2.0f, 3.0f)));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < TestInputs.size(); ++i)
|
|
||||||
{
|
|
||||||
typename MAT4::value_type f = static_cast<typename MAT4::value_type>(i + Instance) * typename MAT4::value_type(0.1) + typename MAT4::value_type(0.1);
|
|
||||||
TestInputs[i] = glm::rotate(glm::translate(MAT4(1), Axis * f), f, Axis);
|
|
||||||
//TestInputs[i] = glm::translate(MAT4(1), Axis * f);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::clock_t StartTime = std::clock();
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < TestInputs.size(); ++i)
|
|
||||||
TestOutputs[i] = glm::inverse(TestInputs[i]);
|
|
||||||
|
|
||||||
std::clock_t EndTime = std::clock();
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < TestInputs.size(); ++i)
|
|
||||||
TestOutputs[i] = TestOutputs[i] * TestInputs[i];
|
|
||||||
|
|
||||||
typename MAT4::value_type Diff(0);
|
|
||||||
for(std::size_t Entry = 0; Entry < TestOutputs.size(); ++Entry)
|
|
||||||
{
|
|
||||||
MAT4 i(1.0);
|
|
||||||
MAT4 m(TestOutputs[Entry]);
|
|
||||||
for(glm::length_t y = 0; y < m.length(); ++y)
|
|
||||||
for(glm::length_t x = 0; x < m[y].length(); ++x)
|
|
||||||
Diff = glm::max(m[y][x], i[y][x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//glm::uint Ulp = 0;
|
|
||||||
//Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp);
|
|
||||||
|
|
||||||
printf("inverse<%s>(%f): %d\n", Message, Diff, EndTime - StartTime);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += test_matrixCompMult();
|
|
||||||
Error += test_outerProduct();
|
|
||||||
Error += test_transpose();
|
|
||||||
Error += test_determinant();
|
|
||||||
Error += test_inverse();
|
|
||||||
for(std::size_t i = 0; i < 1; ++i)
|
|
||||||
{
|
|
||||||
Error += test_inverse_perf<glm::vec3, glm::mat4>(i, "mat4");
|
|
||||||
Error += test_inverse_perf<glm::dvec3, glm::dmat4>(i, "dmat4");
|
|
||||||
}
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-09-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_noise.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Failed = 0;
|
|
||||||
|
|
||||||
return Failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-09-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_packing.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/type_precision.hpp>
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/packing.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int test_packUnorm2x16()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
/*
|
|
||||||
std::vector<glm::hvec2> A;
|
|
||||||
A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 0.0f)));
|
|
||||||
A.push_back(glm::hvec2(glm::half( 0.5f), glm::half( 0.7f)));
|
|
||||||
A.push_back(glm::hvec2(glm::half( 0.1f), glm::half( 0.2f)));
|
|
||||||
*/
|
|
||||||
std::vector<glm::vec2> A;
|
|
||||||
A.push_back(glm::vec2(1.0f, 0.0f));
|
|
||||||
A.push_back(glm::vec2(0.5f, 0.7f));
|
|
||||||
A.push_back(glm::vec2(0.1f, 0.2f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < A.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::vec2 B(A[i]);
|
|
||||||
glm::uint32 C = glm::packUnorm2x16(B);
|
|
||||||
glm::vec2 D = glm::unpackUnorm2x16(C);
|
|
||||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_packSnorm2x16()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec2> A;
|
|
||||||
A.push_back(glm::vec2( 1.0f, 0.0f));
|
|
||||||
A.push_back(glm::vec2(-0.5f,-0.7f));
|
|
||||||
A.push_back(glm::vec2(-0.1f, 0.1f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < A.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::vec2 B(A[i]);
|
|
||||||
glm::uint32 C = glm::packSnorm2x16(B);
|
|
||||||
glm::vec2 D = glm::unpackSnorm2x16(C);
|
|
||||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_packUnorm4x8()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec4> A;
|
|
||||||
A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f));
|
|
||||||
A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < A.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::vec4 B(A[i]);
|
|
||||||
glm::uint32 C = glm::packUnorm4x8(B);
|
|
||||||
glm::vec4 D = glm::unpackUnorm4x8(C);
|
|
||||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_packSnorm4x8()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec4> A;
|
|
||||||
A.push_back(glm::vec4( 1.0f, 0.0f,-0.5f,-1.0f));
|
|
||||||
A.push_back(glm::vec4(-0.7f,-0.1f, 0.1f, 0.7f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < A.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::vec4 B(A[i]);
|
|
||||||
glm::uint32 C = glm::packSnorm4x8(B);
|
|
||||||
glm::vec4 D = glm::unpackSnorm4x8(C);
|
|
||||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_packHalf2x16()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
/*
|
|
||||||
std::vector<glm::hvec2> A;
|
|
||||||
A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 2.0f)));
|
|
||||||
A.push_back(glm::hvec2(glm::half(-1.0f), glm::half(-2.0f)));
|
|
||||||
A.push_back(glm::hvec2(glm::half(-1.1f), glm::half( 1.1f)));
|
|
||||||
*/
|
|
||||||
std::vector<glm::vec2> A;
|
|
||||||
A.push_back(glm::vec2( 1.0f, 2.0f));
|
|
||||||
A.push_back(glm::vec2(-1.0f,-2.0f));
|
|
||||||
A.push_back(glm::vec2(-1.1f, 1.1f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < A.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::vec2 B(A[i]);
|
|
||||||
glm::uint C = glm::packHalf2x16(B);
|
|
||||||
glm::vec2 D = glm::unpackHalf2x16(C);
|
|
||||||
//Error += B == D ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_packDouble2x32()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::uvec2> A;
|
|
||||||
A.push_back(glm::uvec2( 1, 2));
|
|
||||||
A.push_back(glm::uvec2(-1,-2));
|
|
||||||
A.push_back(glm::uvec2(-1000, 1100));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < A.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uvec2 B(A[i]);
|
|
||||||
double C = glm::packDouble2x32(B);
|
|
||||||
glm::uvec2 D = glm::unpackDouble2x32(C);
|
|
||||||
Error += B == D ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_packSnorm4x8();
|
|
||||||
Error += test_packUnorm4x8();
|
|
||||||
Error += test_packSnorm2x16();
|
|
||||||
Error += test_packUnorm2x16();
|
|
||||||
Error += test_packHalf2x16();
|
|
||||||
Error += test_packDouble2x32();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-10-16
|
|
||||||
// Updated : 2011-10-16
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/core_func_swizzle.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#define GLM_MESSAGES
|
|
||||||
#define GLM_SWIZZLE
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
int test_ivec2_swizzle()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::ivec2 A(1, 2);
|
|
||||||
glm::ivec2 B = A.yx();
|
|
||||||
glm::ivec2 C = B.yx();
|
|
||||||
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ivec3_swizzle()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::ivec3 A(1, 2, 3);
|
|
||||||
glm::ivec3 B = A.zyx();
|
|
||||||
glm::ivec3 C = B.zyx();
|
|
||||||
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ivec4_swizzle()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::ivec4 A(1, 2, 3, 4);
|
|
||||||
glm::ivec4 B = A.wzyx();
|
|
||||||
glm::ivec4 C = B.wzyx();
|
|
||||||
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec4_swizzle()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec4 A(1, 2, 3, 4);
|
|
||||||
glm::vec4 B = A.wzyx();
|
|
||||||
glm::vec4 C = B.wzyx();
|
|
||||||
|
|
||||||
float f = glm::dot(C.wzyx(), C.xyzw());
|
|
||||||
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ivec2_swizzle();
|
|
||||||
Error += test_ivec3_swizzle();
|
|
||||||
Error += test_ivec4_swizzle();
|
|
||||||
|
|
||||||
Error += test_vec4_swizzle();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-09-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/func_trigonometric.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Failed = 0;
|
|
||||||
|
|
||||||
return Failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-01-15
|
|
||||||
// Updated : 2011-09-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/core/vector_relational.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,260 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-05-31
|
|
||||||
// Updated : 2013-08-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/setup_message.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_MESSAGES
|
|
||||||
#include <glm/vec3.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int test_compiler()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
if(GLM_COMPILER & GLM_COMPILER_VC)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_VC" << std::endl;
|
|
||||||
|
|
||||||
switch(GLM_COMPILER)
|
|
||||||
{
|
|
||||||
case GLM_COMPILER_VC8:
|
|
||||||
std::cout << "GLM_COMPILER_VC8" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_VC9:
|
|
||||||
std::cout << "GLM_COMPILER_VC9" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_VC10:
|
|
||||||
std::cout << "GLM_COMPILER_VC10" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_VC11:
|
|
||||||
std::cout << "GLM_COMPILER_VC11" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_VC12:
|
|
||||||
std::cout << "GLM_COMPILER_VC12" << std::endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cout << "Visual C++ version not detected" << std::endl;
|
|
||||||
Error += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_GCC)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_GCC" << std::endl;
|
|
||||||
|
|
||||||
switch(GLM_COMPILER)
|
|
||||||
{
|
|
||||||
case GLM_COMPILER_GCC34:
|
|
||||||
std::cout << "GLM_COMPILER_GCC34" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC35:
|
|
||||||
std::cout << "GLM_COMPILER_GCC35" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC40:
|
|
||||||
std::cout << "GLM_COMPILER_GCC40" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC41:
|
|
||||||
std::cout << "GLM_COMPILER_GCC41" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC42:
|
|
||||||
std::cout << "GLM_COMPILER_GCC42" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC43:
|
|
||||||
std::cout << "GLM_COMPILER_GCC43" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC44:
|
|
||||||
std::cout << "GLM_COMPILER_GCC44" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC45:
|
|
||||||
std::cout << "GLM_COMPILER_GCC45" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC46:
|
|
||||||
std::cout << "GLM_COMPILER_GCC46" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC47:
|
|
||||||
std::cout << "GLM_COMPILER_GCC47" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC48:
|
|
||||||
std::cout << "GLM_COMPILER_GCC48" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_GCC49:
|
|
||||||
std::cout << "GLM_COMPILER_GCC49" << std::endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cout << "GCC version not detected" << std::endl;
|
|
||||||
Error += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_BC)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_BC" << std::endl;
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_CODEWARRIOR)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_CODEWARRIOR" << std::endl;
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_CUDA)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_CUDA" << std::endl;
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_CLANG)
|
|
||||||
{
|
|
||||||
# ifdef __clang_major__
|
|
||||||
std::cout << "GLM_COMPILER_CLANG " << __clang_major__ << "." << __clang_minor__ << std::endl;
|
|
||||||
# endif
|
|
||||||
switch(GLM_COMPILER)
|
|
||||||
{
|
|
||||||
case GLM_COMPILER_CLANG26:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG26" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG27:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG27" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG28:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG28" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG29:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG29" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG30:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG30" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG31:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG31" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG32:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG32" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG33:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG33" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG40:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG40" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG41:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG41" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG42:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG42" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_CLANG43:
|
|
||||||
std::cout << "GLM_COMPILER_CLANG43" << std::endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cout << "Clang version not detected" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_LLVM_GCC)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_LLVM_GCC" << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(GLM_COMPILER & GLM_COMPILER_INTEL)
|
|
||||||
{
|
|
||||||
std::cout << "GLM_COMPILER_INTEL" << std::endl;
|
|
||||||
switch(GLM_COMPILER)
|
|
||||||
{
|
|
||||||
case GLM_COMPILER_INTEL9:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL9" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_INTEL10_0:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL10_0" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_INTEL10_1:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL10_1" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_INTEL11_0:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL11_0" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_INTEL11_1:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL11_1" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_INTEL12_1:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL12_1" << std::endl;
|
|
||||||
break;
|
|
||||||
case GLM_COMPILER_INTEL13_0:
|
|
||||||
std::cout << "GLM_COMPILER_INTEL13_0" << std::endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cout << "Intel compiler version not detected" << std::endl;
|
|
||||||
Error += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "Undetected compiler" << std::endl;
|
|
||||||
Error += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_model()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += ((sizeof(void*) == 4) && (GLM_MODEL == GLM_MODEL_32)) || ((sizeof(void*) == 8) && (GLM_MODEL == GLM_MODEL_64)) ? 0 : 1;
|
|
||||||
|
|
||||||
if(GLM_MODEL == GLM_MODEL_32)
|
|
||||||
std::cout << "GLM_MODEL_32" << std::endl;
|
|
||||||
else if(GLM_MODEL == GLM_MODEL_64)
|
|
||||||
std::cout << "GLM_MODEL_64" << std::endl;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_cpp_version()
|
|
||||||
{
|
|
||||||
std::cout << "__cplusplus: " << __cplusplus << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_operators()
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f);
|
|
||||||
glm::vec3 B(1.0f);
|
|
||||||
bool R = A != B;
|
|
||||||
bool S = A == B;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct vec
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <template <typename> class C, typename T>
|
|
||||||
struct Class
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct Class<vec, T>
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
//Class<vec, float> C;
|
|
||||||
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_cpp_version();
|
|
||||||
Error += test_compiler();
|
|
||||||
Error += test_model();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-05-31
|
|
||||||
// Updated : 2011-05-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/setup_precision_highp.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_INLINE
|
|
||||||
#define GLM_PRECISION_HIGHP_FLOAT
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <glm/ext.hpp>
|
|
||||||
|
|
||||||
static int test_mat()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mat2) == sizeof(glm::highp_mat2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat3) == sizeof(glm::highp_mat3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat4) == sizeof(glm::highp_mat4) ? 0 : 1;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mat2x2) == sizeof(glm::highp_mat2x2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat2x3) == sizeof(glm::highp_mat2x3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat2x4) == sizeof(glm::highp_mat2x4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat3x2) == sizeof(glm::highp_mat3x2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat3x3) == sizeof(glm::highp_mat3x3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat3x4) == sizeof(glm::highp_mat3x4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat4x2) == sizeof(glm::highp_mat4x2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat4x3) == sizeof(glm::highp_mat4x3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mat4x4) == sizeof(glm::highp_mat4x4) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_vec()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::vec2) == sizeof(glm::highp_vec2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::vec3) == sizeof(glm::highp_vec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_dvec()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_mat();
|
|
||||||
Error += test_vec();
|
|
||||||
Error += test_dvec();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2013-05-06
|
|
||||||
// Updated : 2013-05-06
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_cast.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
struct my_vec2
|
|
||||||
{
|
|
||||||
operator glm::vec2() { return glm::vec2(x, y); }
|
|
||||||
float x, y;
|
|
||||||
};
|
|
||||||
|
|
||||||
int test_vec2_cast()
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::lowp_vec2 B(A);
|
|
||||||
glm::mediump_vec2 C(A);
|
|
||||||
glm::highp_vec2 D(A);
|
|
||||||
|
|
||||||
glm::vec2 E = static_cast<glm::vec2>(A);
|
|
||||||
glm::lowp_vec2 F = static_cast<glm::lowp_vec2>(A);
|
|
||||||
glm::mediump_vec2 G = static_cast<glm::mediump_vec2>(A);
|
|
||||||
glm::highp_vec2 H = static_cast<glm::highp_vec2>(A);
|
|
||||||
|
|
||||||
my_vec2 I;
|
|
||||||
glm::vec2 J = static_cast<glm::vec2>(I);
|
|
||||||
glm::vec2 K(7.8f);
|
|
||||||
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_cast()
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::lowp_vec3 B(A);
|
|
||||||
glm::mediump_vec3 C(A);
|
|
||||||
glm::highp_vec3 D(A);
|
|
||||||
|
|
||||||
glm::vec3 E = static_cast<glm::vec3>(A);
|
|
||||||
glm::lowp_vec3 F = static_cast<glm::lowp_vec3>(A);
|
|
||||||
glm::mediump_vec3 G = static_cast<glm::mediump_vec3>(A);
|
|
||||||
glm::highp_vec3 H = static_cast<glm::highp_vec3>(A);
|
|
||||||
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec4_cast()
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::lowp_vec4 B(A);
|
|
||||||
glm::mediump_vec4 C(A);
|
|
||||||
glm::highp_vec4 D(A);
|
|
||||||
|
|
||||||
glm::vec4 E = static_cast<glm::vec4>(A);
|
|
||||||
glm::lowp_vec4 F = static_cast<glm::lowp_vec4>(A);
|
|
||||||
glm::mediump_vec4 G = static_cast<glm::mediump_vec4>(A);
|
|
||||||
glm::highp_vec4 H = static_cast<glm::highp_vec4>(A);
|
|
||||||
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_vec2_cast();
|
|
||||||
Error += test_vec3_cast();
|
|
||||||
Error += test_vec4_cast();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2011-05-06
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_float.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
int test_float_size()
|
|
||||||
{
|
|
||||||
return
|
|
||||||
sizeof(glm::float_t) != sizeof(glm::lowp_float) &&
|
|
||||||
sizeof(glm::float_t) != sizeof(glm::mediump_float) &&
|
|
||||||
sizeof(glm::float_t) != sizeof(glm::highp_float);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_float_precision()
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
sizeof(glm::lowp_float) <= sizeof(glm::mediump_float) &&
|
|
||||||
sizeof(glm::mediump_float) <= sizeof(glm::highp_float)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec2()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_float_size();
|
|
||||||
Error += test_float_precision();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2011-05-06
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_int.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
int test_int_size()
|
|
||||||
{
|
|
||||||
return
|
|
||||||
sizeof(glm::int_t) != sizeof(glm::lowp_int) &&
|
|
||||||
sizeof(glm::int_t) != sizeof(glm::mediump_int) &&
|
|
||||||
sizeof(glm::int_t) != sizeof(glm::highp_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_uint_size()
|
|
||||||
{
|
|
||||||
return
|
|
||||||
sizeof(glm::uint_t) != sizeof(glm::lowp_uint) &&
|
|
||||||
sizeof(glm::uint_t) != sizeof(glm::mediump_uint) &&
|
|
||||||
sizeof(glm::uint_t) != sizeof(glm::highp_uint);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_int_precision()
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
sizeof(glm::lowp_int) <= sizeof(glm::mediump_int) &&
|
|
||||||
sizeof(glm::mediump_int) <= sizeof(glm::highp_int)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_uint_precision()
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
sizeof(glm::lowp_uint) <= sizeof(glm::mediump_uint) &&
|
|
||||||
sizeof(glm::mediump_uint) <= sizeof(glm::highp_uint)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_int_size();
|
|
||||||
Error += test_int_precision();
|
|
||||||
Error += test_uint_size();
|
|
||||||
Error += test_uint_precision();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-05-25
|
|
||||||
// Updated : 2011-05-25
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_length.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
int test_length_mat_non_squared()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += glm::mat2x3().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::mat2x4().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::mat3x2().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::mat3x4().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::mat4x2().length() == 4 ? 0 : 1;
|
|
||||||
Error += glm::mat4x3().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
Error += glm::dmat2x3().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::dmat2x4().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::dmat3x2().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::dmat3x4().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::dmat4x2().length() == 4 ? 0 : 1;
|
|
||||||
Error += glm::dmat4x3().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_length_mat()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += glm::mat2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::mat3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::mat4().length() == 4 ? 0 : 1;
|
|
||||||
Error += glm::mat2x2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::mat3x3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::mat4x4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
Error += glm::dmat2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::dmat3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::dmat4().length() == 4 ? 0 : 1;
|
|
||||||
Error += glm::dmat2x2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::dmat3x3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::dmat4x4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_length_vec()
|
|
||||||
{
|
|
||||||
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += glm::vec2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::vec3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::vec4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
Error += glm::ivec2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::ivec3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::ivec4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
Error += glm::uvec2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::uvec3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::uvec4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
Error += glm::dvec2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::dvec3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::dvec4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_length_vec();
|
|
||||||
Error += test_length_mat();
|
|
||||||
Error += test_length_mat_non_squared();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat2x2.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/matrix.hpp>
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat2x2.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int test_operators()
|
|
||||||
{
|
|
||||||
glm::mat2x2 l(1.0f);
|
|
||||||
glm::mat2x2 m(1.0f);
|
|
||||||
glm::vec2 u(1.0f);
|
|
||||||
glm::vec2 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec2 a = m * u;
|
|
||||||
glm::vec2 b = v * m;
|
|
||||||
glm::mat2x2 n = x / m;
|
|
||||||
glm::mat2x2 o = m / x;
|
|
||||||
glm::mat2x2 p = x * m;
|
|
||||||
glm::mat2x2 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_inverse()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat2 const Matrix(1, 2, 3, 4);
|
|
||||||
glm::mat2 const Inverse = glm::inverse(Matrix);
|
|
||||||
glm::mat2 const Identity = Matrix * Inverse;
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat2 const Matrix(1, 2, 3, 4);
|
|
||||||
glm::mat2 const Identity = Matrix / Matrix;
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat2x2 m0(
|
|
||||||
glm::vec2(0, 1),
|
|
||||||
glm::vec2(2, 3));
|
|
||||||
|
|
||||||
glm::mat2x2 m1{0, 1, 2, 3};
|
|
||||||
|
|
||||||
glm::mat2x2 m2{
|
|
||||||
{0, 1},
|
|
||||||
{2, 3}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat2x2> v1{
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{0, 1, 2, 3}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat2x2> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1},
|
|
||||||
{ 4, 5}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1},
|
|
||||||
{ 4, 5}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
Error += test_inverse();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2013-10-04
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat2x3.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat2x3.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
glm::mat2x3 l(1.0f);
|
|
||||||
glm::mat2x3 m(1.0f);
|
|
||||||
glm::vec2 u(1.0f);
|
|
||||||
glm::vec3 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec3 a = m * u;
|
|
||||||
glm::vec2 b = v * m;
|
|
||||||
glm::mat2x3 n = x / m;
|
|
||||||
glm::mat2x3 o = m / x;
|
|
||||||
glm::mat2x3 p = x * m;
|
|
||||||
glm::mat2x3 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat2x3 m0(
|
|
||||||
glm::vec3(0, 1, 2),
|
|
||||||
glm::vec3(3, 4, 5));
|
|
||||||
|
|
||||||
glm::mat2x3 m1{0, 1, 2, 3, 4, 5};
|
|
||||||
|
|
||||||
glm::mat2x3 m2{
|
|
||||||
{0, 1, 2},
|
|
||||||
{3, 4, 5}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat2x3> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5},
|
|
||||||
{0, 1, 2, 3, 4, 5}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat2x3> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1, 2},
|
|
||||||
{ 4, 5, 6}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1, 2},
|
|
||||||
{ 4, 5, 6}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat2x4.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat2x4.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
glm::mat2x4 l(1.0f);
|
|
||||||
glm::mat2x4 m(1.0f);
|
|
||||||
glm::vec2 u(1.0f);
|
|
||||||
glm::vec4 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec4 a = m * u;
|
|
||||||
glm::vec2 b = v * m;
|
|
||||||
glm::mat2x4 n = x / m;
|
|
||||||
glm::mat2x4 o = m / x;
|
|
||||||
glm::mat2x4 p = x * m;
|
|
||||||
glm::mat2x4 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat2x4 m0(
|
|
||||||
glm::vec4(0, 1, 2, 3),
|
|
||||||
glm::vec4(4, 5, 6, 7));
|
|
||||||
|
|
||||||
glm::mat2x4 m1{0, 1, 2, 3, 4, 5, 6, 7};
|
|
||||||
|
|
||||||
glm::mat2x4 m2{
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{4, 5, 6, 7}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat2x4> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat2x4> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3},
|
|
||||||
{ 4, 5, 6, 7}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3},
|
|
||||||
{ 4, 5, 6, 7}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat3x2.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat3x2.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static bool test_operators()
|
|
||||||
{
|
|
||||||
glm::mat3x2 l(1.0f);
|
|
||||||
glm::mat3x2 m(1.0f);
|
|
||||||
glm::vec3 u(1.0f);
|
|
||||||
glm::vec2 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec2 a = m * u;
|
|
||||||
glm::vec3 b = v * m;
|
|
||||||
glm::mat3x2 n = x / m;
|
|
||||||
glm::mat3x2 o = m / x;
|
|
||||||
glm::mat3x2 p = x * m;
|
|
||||||
glm::mat3x2 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat3x2 m0(
|
|
||||||
glm::vec2(0, 1),
|
|
||||||
glm::vec2(2, 3),
|
|
||||||
glm::vec2(4, 5));
|
|
||||||
|
|
||||||
glm::mat3x2 m1{0, 1, 2, 3, 4, 5};
|
|
||||||
|
|
||||||
glm::mat3x2 m2{
|
|
||||||
{0, 1},
|
|
||||||
{2, 3},
|
|
||||||
{4, 5}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat3x2> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5},
|
|
||||||
{0, 1, 2, 3, 4, 5}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat3x2> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1},
|
|
||||||
{ 2, 3},
|
|
||||||
{ 4, 5}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1},
|
|
||||||
{ 2, 3},
|
|
||||||
{ 4, 5}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat3x3.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/matrix.hpp>
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat3x3.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void print(glm::dmat3 const & Mat0)
|
|
||||||
{
|
|
||||||
printf("mat3(\n");
|
|
||||||
printf("\tvec3(%2.3f, %2.3f, %2.3f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2]);
|
|
||||||
printf("\tvec3(%2.3f, %2.3f, %2.3f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2]);
|
|
||||||
printf("\tvec3(%2.3f, %2.3f, %2.3f))\n\n", Mat0[2][0], Mat0[2][1], Mat0[2][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x3()
|
|
||||||
{
|
|
||||||
glm::dmat3 Mat0(
|
|
||||||
glm::dvec3(0.6f, 0.2f, 0.3f),
|
|
||||||
glm::dvec3(0.2f, 0.7f, 0.5f),
|
|
||||||
glm::dvec3(0.3f, 0.5f, 0.7f));
|
|
||||||
glm::dmat3 Inv0 = glm::inverse(Mat0);
|
|
||||||
glm::dmat3 Res0 = Mat0 * Inv0;
|
|
||||||
|
|
||||||
print(Mat0);
|
|
||||||
print(Inv0);
|
|
||||||
print(Res0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
glm::mat3x3 l(1.0f);
|
|
||||||
glm::mat3x3 m(1.0f);
|
|
||||||
glm::vec3 u(1.0f);
|
|
||||||
glm::vec3 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec3 a = m * u;
|
|
||||||
glm::vec3 b = v * m;
|
|
||||||
glm::mat3x3 n = x / m;
|
|
||||||
glm::mat3x3 o = m / x;
|
|
||||||
glm::mat3x3 p = x * m;
|
|
||||||
glm::mat3x3 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_inverse()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat3 const Matrix(
|
|
||||||
glm::vec3(0.6f, 0.2f, 0.3f),
|
|
||||||
glm::vec3(0.2f, 0.7f, 0.5f),
|
|
||||||
glm::vec3(0.3f, 0.5f, 0.7f));
|
|
||||||
glm::mat3 const Inverse = glm::inverse(Matrix);
|
|
||||||
glm::mat3 const Identity = Matrix * Inverse;
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat3 const Matrix(
|
|
||||||
glm::vec3(0.6f, 0.2f, 0.3f),
|
|
||||||
glm::vec3(0.2f, 0.7f, 0.5f),
|
|
||||||
glm::vec3(0.3f, 0.5f, 0.7f));
|
|
||||||
glm::mat3 const Identity = Matrix / Matrix;
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat3x3 m0(
|
|
||||||
glm::vec3(0, 1, 2),
|
|
||||||
glm::vec3(3, 4, 5),
|
|
||||||
glm::vec3(6, 7, 8));
|
|
||||||
|
|
||||||
glm::mat3x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8};
|
|
||||||
|
|
||||||
glm::mat3x3 m2{
|
|
||||||
{0, 1, 2},
|
|
||||||
{3, 4, 5},
|
|
||||||
{6, 7, 8}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat3x3> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat3x3> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1, 2},
|
|
||||||
{ 3, 4, 5},
|
|
||||||
{ 6, 7, 8}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1, 2},
|
|
||||||
{ 3, 4, 5},
|
|
||||||
{ 6, 7, 8}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_mat3x3();
|
|
||||||
Error += test_operators();
|
|
||||||
Error += test_inverse();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat3x4.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat3x4.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static bool test_operators()
|
|
||||||
{
|
|
||||||
glm::mat3x4 l(1.0f);
|
|
||||||
glm::mat3x4 m(1.0f);
|
|
||||||
glm::vec3 u(1.0f);
|
|
||||||
glm::vec4 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec4 a = m * u;
|
|
||||||
glm::vec3 b = v * m;
|
|
||||||
glm::mat3x4 n = x / m;
|
|
||||||
glm::mat3x4 o = m / x;
|
|
||||||
glm::mat3x4 p = x * m;
|
|
||||||
glm::mat3x4 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat3x4 m0(
|
|
||||||
glm::vec4(0, 1, 2, 3),
|
|
||||||
glm::vec4(4, 5, 6, 7),
|
|
||||||
glm::vec4(8, 9, 10, 11));
|
|
||||||
|
|
||||||
glm::mat3x4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
|
|
||||||
|
|
||||||
glm::mat3x4 m2{
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{4, 5, 6, 7},
|
|
||||||
{8, 9, 10, 11}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat3x4> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat3x4> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3},
|
|
||||||
{ 4, 5, 6, 7},
|
|
||||||
{ 8, 9, 10, 11}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3},
|
|
||||||
{ 4, 5, 6, 7},
|
|
||||||
{ 8, 9, 10, 11}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat4x2.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat4x2.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
glm::mat4x2 l(1.0f);
|
|
||||||
glm::mat4x2 m(1.0f);
|
|
||||||
glm::vec4 u(1.0f);
|
|
||||||
glm::vec2 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec2 a = m * u;
|
|
||||||
glm::vec4 b = v * m;
|
|
||||||
glm::mat4x2 n = x / m;
|
|
||||||
glm::mat4x2 o = m / x;
|
|
||||||
glm::mat4x2 p = x * m;
|
|
||||||
glm::mat4x2 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat4x2 m0(
|
|
||||||
glm::vec2(0, 1),
|
|
||||||
glm::vec2(2, 3),
|
|
||||||
glm::vec2(4, 5),
|
|
||||||
glm::vec2(6, 7));
|
|
||||||
|
|
||||||
glm::mat4x2 m1{0, 1, 2, 3, 4, 5, 6, 7};
|
|
||||||
|
|
||||||
glm::mat4x2 m2{
|
|
||||||
{0, 1},
|
|
||||||
{2, 3},
|
|
||||||
{4, 5},
|
|
||||||
{6, 7}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat4x2> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat4x2> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1},
|
|
||||||
{ 4, 5},
|
|
||||||
{ 8, 9},
|
|
||||||
{ 12, 13}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1},
|
|
||||||
{ 4, 5},
|
|
||||||
{ 8, 9},
|
|
||||||
{ 12, 13}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat4x3.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/mat4x3.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
glm::mat4x3 l(1.0f);
|
|
||||||
glm::mat4x3 m(1.0f);
|
|
||||||
glm::vec4 u(1.0f);
|
|
||||||
glm::vec3 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec3 a = m * u;
|
|
||||||
glm::vec4 b = v * m;
|
|
||||||
glm::mat4x3 n = x / m;
|
|
||||||
glm::mat4x3 o = m / x;
|
|
||||||
glm::mat4x3 p = x * m;
|
|
||||||
glm::mat4x3 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat4x3 m0(
|
|
||||||
glm::vec3(0, 1, 2),
|
|
||||||
glm::vec3(3, 4, 5),
|
|
||||||
glm::vec3(6, 7, 8),
|
|
||||||
glm::vec3(9, 10, 11));
|
|
||||||
|
|
||||||
glm::mat4x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
|
|
||||||
|
|
||||||
glm::mat4x3 m2{
|
|
||||||
{0, 1, 2},
|
|
||||||
{3, 4, 5},
|
|
||||||
{6, 7, 8},
|
|
||||||
{9, 10, 11}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat4x3> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<glm::mat4x3> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1, 2 },
|
|
||||||
{ 4, 5, 6 },
|
|
||||||
{ 8, 9, 10 },
|
|
||||||
{ 12, 13, 14 }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1, 2 },
|
|
||||||
{ 4, 5, 6 },
|
|
||||||
{ 8, 9, 10 },
|
|
||||||
{ 12, 13, 14 }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_operators();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,257 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_mat4x4.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/matrix.hpp>
|
|
||||||
#include <glm/mat4x4.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void print(glm::dmat4 const & Mat0)
|
|
||||||
{
|
|
||||||
printf("mat4(\n");
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]);
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]);
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]);
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(glm::mat4 const & Mat0)
|
|
||||||
{
|
|
||||||
printf("mat4(\n");
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]);
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]);
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]);
|
|
||||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_inverse_mat4x4()
|
|
||||||
{
|
|
||||||
glm::mat4 Mat0(
|
|
||||||
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::mat4 Inv0 = glm::inverse(Mat0);
|
|
||||||
glm::mat4 Res0 = Mat0 * Inv0;
|
|
||||||
|
|
||||||
print(Mat0);
|
|
||||||
print(Inv0);
|
|
||||||
print(Res0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_inverse_dmat4x4()
|
|
||||||
{
|
|
||||||
glm::dmat4 Mat0(
|
|
||||||
glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::dvec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::dvec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::dvec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::dmat4 Inv0 = glm::inverse(Mat0);
|
|
||||||
glm::dmat4 Res0 = Mat0 * Inv0;
|
|
||||||
|
|
||||||
print(Mat0);
|
|
||||||
print(Inv0);
|
|
||||||
print(Res0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool test_operators()
|
|
||||||
{
|
|
||||||
glm::mat4x4 l(1.0f);
|
|
||||||
glm::mat4x4 m(1.0f);
|
|
||||||
glm::vec4 u(1.0f);
|
|
||||||
glm::vec4 v(1.0f);
|
|
||||||
float x = 1.0f;
|
|
||||||
glm::vec4 a = m * u;
|
|
||||||
glm::vec4 b = v * m;
|
|
||||||
glm::mat4x4 n = x / m;
|
|
||||||
glm::mat4x4 o = m / x;
|
|
||||||
glm::mat4x4 p = x * m;
|
|
||||||
glm::mat4x4 q = m * x;
|
|
||||||
bool R = m != q;
|
|
||||||
bool S = m == l;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_inverse()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat4 const Matrix(
|
|
||||||
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::mat4 const Inverse = glm::inverse(Matrix);
|
|
||||||
glm::mat4 const Identity = Matrix * Inverse;
|
|
||||||
|
|
||||||
print(Matrix);
|
|
||||||
print(Inverse);
|
|
||||||
print(Identity);
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::highp_mat4 const Matrix(
|
|
||||||
glm::highp_vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::highp_vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::highp_vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::highp_vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::highp_mat4 const Inverse = glm::inverse(Matrix);
|
|
||||||
glm::highp_mat4 const Identity = Matrix * Inverse;
|
|
||||||
|
|
||||||
printf("highp_mat4 inverse\n");
|
|
||||||
print(Matrix);
|
|
||||||
print(Inverse);
|
|
||||||
print(Identity);
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::highp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::highp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::highp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::highp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mediump_mat4 const Matrix(
|
|
||||||
glm::mediump_vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::mediump_vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::mediump_vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::mediump_vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::mediump_mat4 const Inverse = glm::inverse(Matrix);
|
|
||||||
glm::mediump_mat4 const Identity = Matrix * Inverse;
|
|
||||||
|
|
||||||
printf("mediump_mat4 inverse\n");
|
|
||||||
print(Matrix);
|
|
||||||
print(Inverse);
|
|
||||||
print(Identity);
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::mediump_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::mediump_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::mediump_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::mediump_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::lowp_mat4 const Matrix(
|
|
||||||
glm::lowp_vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::lowp_vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::lowp_vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::lowp_vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::lowp_mat4 const Inverse = glm::inverse(Matrix);
|
|
||||||
glm::lowp_mat4 const Identity = Matrix * Inverse;
|
|
||||||
|
|
||||||
printf("lowp_mat4 inverse\n");
|
|
||||||
print(Matrix);
|
|
||||||
print(Inverse);
|
|
||||||
print(Identity);
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::lowp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::lowp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::lowp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::lowp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat4 const Matrix(
|
|
||||||
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
|
||||||
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
|
||||||
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
|
||||||
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
|
||||||
glm::mat4 const Identity = Matrix / Matrix;
|
|
||||||
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
glm::mat4 m0(
|
|
||||||
glm::vec4(0, 1, 2, 3),
|
|
||||||
glm::vec4(4, 5, 6, 7),
|
|
||||||
glm::vec4(8, 9, 10, 11),
|
|
||||||
glm::vec4(12, 13, 14, 15));
|
|
||||||
|
|
||||||
assert(sizeof(m0) == 4 * 4 * 4);
|
|
||||||
|
|
||||||
glm::vec4 V{0, 1, 2, 3};
|
|
||||||
|
|
||||||
glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
||||||
|
|
||||||
glm::mat4 m2{
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{4, 5, 6, 7},
|
|
||||||
{8, 9, 10, 11},
|
|
||||||
{12, 13, 14, 15}};
|
|
||||||
|
|
||||||
for(int i = 0; i < m0.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
for(int i = 0; i < m1.length(); ++i)
|
|
||||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
|
||||||
|
|
||||||
std::vector<glm::mat4> m3{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
|
|
||||||
|
|
||||||
std::vector<glm::mat4> v1{
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
|
||||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
|
|
||||||
|
|
||||||
std::vector<glm::mat4> v2{
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3 },
|
|
||||||
{ 4, 5, 6, 7 },
|
|
||||||
{ 8, 9, 10, 11 },
|
|
||||||
{ 12, 13, 14, 15 }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3 },
|
|
||||||
{ 4, 5, 6, 7 },
|
|
||||||
{ 8, 9, 10, 11 },
|
|
||||||
{ 12, 13, 14, 15 }
|
|
||||||
}};
|
|
||||||
|
|
||||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_ctr();
|
|
||||||
Error += test_inverse_dmat4x4();
|
|
||||||
Error += test_inverse_mat4x4();
|
|
||||||
Error += test_operators();
|
|
||||||
Error += test_inverse();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2008-08-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_vec1.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtx/vec1.hpp>
|
|
||||||
|
|
||||||
int test_operators()
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f);
|
|
||||||
glm::vec4 B(1.0f);
|
|
||||||
bool R = A != B;
|
|
||||||
bool S = A == B;
|
|
||||||
|
|
||||||
return (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_operator_increment()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::ivec1 v0(1);
|
|
||||||
glm::ivec1 v1(v0);
|
|
||||||
glm::ivec1 v2(v0);
|
|
||||||
glm::ivec1 v3 = ++v1;
|
|
||||||
glm::ivec1 v4 = v2++;
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
|
||||||
|
|
||||||
int i0(1);
|
|
||||||
int i1(i0);
|
|
||||||
int i2(i0);
|
|
||||||
int i3 = ++i1;
|
|
||||||
int i4 = i2++;
|
|
||||||
|
|
||||||
Error += i0 == i4 ? 0 : 1;
|
|
||||||
Error += i1 == i2 ? 0 : 1;
|
|
||||||
Error += i1 == i3 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_operators();
|
|
||||||
Error += test_operator_increment();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2011-05-31
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_vec2.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/vec2.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int test_vec2_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f);
|
|
||||||
glm::vec2 B(1.0f);
|
|
||||||
Error += A != B ? 1 : 0;
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f);
|
|
||||||
glm::vec2 C = A + 1.0f;
|
|
||||||
A += 1.0f;
|
|
||||||
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1;
|
|
||||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f);
|
|
||||||
glm::vec2 B(2.0f,-1.0f);
|
|
||||||
glm::vec2 C = A + B;
|
|
||||||
A += B;
|
|
||||||
Error += A.x == 3.0f && A.y == 0.0f ? 0 : 1;
|
|
||||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f);
|
|
||||||
glm::vec2 C = A - 1.0f;
|
|
||||||
A -= 1.0f;
|
|
||||||
Error += A.x == 0.0f && A.y == 0.0f ? 0 : 1;
|
|
||||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f);
|
|
||||||
glm::vec2 B(2.0f,-1.0f);
|
|
||||||
glm::vec2 C = A - B;
|
|
||||||
A -= B;
|
|
||||||
Error += A.x == -1.0f && A.y == 2.0f ? 0 : 1;
|
|
||||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f);
|
|
||||||
glm::vec2 C = A * 2.0f;
|
|
||||||
A *= 2.0f;
|
|
||||||
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1;
|
|
||||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(2.0f);
|
|
||||||
glm::vec2 B(2.0f);
|
|
||||||
glm::vec2 C = A / B;
|
|
||||||
A /= B;
|
|
||||||
Error += A.x == 1.0f && A.y == 1.0f ? 0 : 1;
|
|
||||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B(4.0f, 5.0f);
|
|
||||||
|
|
||||||
glm::vec2 C = A + B;
|
|
||||||
Error += C == glm::vec2(5, 7) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 D = B - A;
|
|
||||||
Error += D == glm::vec2(3, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 E = A * B;
|
|
||||||
Error += E == glm::vec2(4, 10) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 F = B / A;
|
|
||||||
Error += F == glm::vec2(4, 2.5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 G = A + 1.0f;
|
|
||||||
Error += G == glm::vec2(2, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 H = B - 1.0f;
|
|
||||||
Error += H == glm::vec2(3, 4) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 I = A * 2.0f;
|
|
||||||
Error += I == glm::vec2(2, 4) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 J = B / 2.0f;
|
|
||||||
Error += J == glm::vec2(2, 2.5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 K = 1.0f + A;
|
|
||||||
Error += K == glm::vec2(2, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 L = 1.0f - B;
|
|
||||||
Error += L == glm::vec2(-3, -4) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 M = 2.0f * A;
|
|
||||||
Error += M == glm::vec2(2, 4) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec2 N = 2.0f / B;
|
|
||||||
Error += N == glm::vec2(0.5, 2.0 / 5.0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B(4.0f, 5.0f);
|
|
||||||
|
|
||||||
A += B;
|
|
||||||
Error += A == glm::vec2(5, 7) ? 0 : 1;
|
|
||||||
|
|
||||||
A += 1.0f;
|
|
||||||
Error += A == glm::vec2(6, 8) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B(4.0f, 5.0f);
|
|
||||||
|
|
||||||
B -= A;
|
|
||||||
Error += B == glm::vec2(3, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
B -= 1.0f;
|
|
||||||
Error += B == glm::vec2(2, 2) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B(4.0f, 5.0f);
|
|
||||||
|
|
||||||
A *= B;
|
|
||||||
Error += A == glm::vec2(4, 10) ? 0 : 1;
|
|
||||||
|
|
||||||
A *= 2.0f;
|
|
||||||
Error += A == glm::vec2(8, 20) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B(4.0f, 5.0f);
|
|
||||||
|
|
||||||
B /= A;
|
|
||||||
Error += B == glm::vec2(4, 2.5) ? 0 : 1;
|
|
||||||
|
|
||||||
B /= 2.0f;
|
|
||||||
Error += B == glm::vec2(2, 1.25) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec2 B(2.0f);
|
|
||||||
|
|
||||||
B /= B.y;
|
|
||||||
Error += B == glm::vec2(1.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B = -A;
|
|
||||||
Error += B == glm::vec2(-1.0f, -2.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B = --A;
|
|
||||||
Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B = A--;
|
|
||||||
Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1;
|
|
||||||
Error += A == glm::vec2(0.0f, 1.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B = ++A;
|
|
||||||
Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A(1.0f, 2.0f);
|
|
||||||
glm::vec2 B = A++;
|
|
||||||
Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1;
|
|
||||||
Error += A == glm::vec2(2.0f, 3.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec2_ctor()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
{
|
|
||||||
glm::vec2 a{ 0, 1 };
|
|
||||||
std::vector<glm::vec2> v = {
|
|
||||||
{0, 1},
|
|
||||||
{4, 5},
|
|
||||||
{8, 9}};
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec2 a{ 0, 1 };
|
|
||||||
std::vector<glm::dvec2> v = {
|
|
||||||
{0, 1},
|
|
||||||
{4, 5},
|
|
||||||
{8, 9}};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 A = glm::vec2(2.0f);
|
|
||||||
glm::vec2 B = glm::vec2(2.0f, 3.0f);
|
|
||||||
glm::vec2 C = glm::vec2(2.0f, 3.0);
|
|
||||||
//glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says?
|
|
||||||
glm::vec2 E(glm::dvec2(2.0));
|
|
||||||
glm::vec2 F(glm::ivec2(2));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec2_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::vec2) == sizeof(glm::mediump_vec2) ? 0 : 1;
|
|
||||||
Error += 8 == sizeof(glm::mediump_vec2) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1;
|
|
||||||
Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1;
|
|
||||||
Error += glm::vec2().length() == 2 ? 0 : 1;
|
|
||||||
Error += glm::dvec2().length() == 2 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_operator_increment()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::ivec2 v0(1);
|
|
||||||
glm::ivec2 v1(v0);
|
|
||||||
glm::ivec2 v2(v0);
|
|
||||||
glm::ivec2 v3 = ++v1;
|
|
||||||
glm::ivec2 v4 = v2++;
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
|
||||||
|
|
||||||
int i0(1);
|
|
||||||
int i1(i0);
|
|
||||||
int i2(i0);
|
|
||||||
int i3 = ++i1;
|
|
||||||
int i4 = i2++;
|
|
||||||
|
|
||||||
Error += i0 == i4 ? 0 : 1;
|
|
||||||
Error += i1 == i2 ? 0 : 1;
|
|
||||||
Error += i1 == i3 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_vec2_size();
|
|
||||||
Error += test_vec2_ctor();
|
|
||||||
Error += test_vec2_operators();
|
|
||||||
Error += test_operator_increment();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,455 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2013-08-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_vec3.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#define GLM_SWIZZLE
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/geometric.hpp>
|
|
||||||
#include <glm/vec2.hpp>
|
|
||||||
#include <glm/vec3.hpp>
|
|
||||||
#include <glm/vec4.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int test_vec3_ctor()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
{
|
|
||||||
glm::vec3 a{ 0, 1, 2 };
|
|
||||||
std::vector<glm::vec3> v = {
|
|
||||||
{0, 1, 2},
|
|
||||||
{4, 5, 6},
|
|
||||||
{8, 9, 0}};
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec3 a{ 0, 1, 2 };
|
|
||||||
std::vector<glm::dvec3> v = {
|
|
||||||
{0, 1, 2},
|
|
||||||
{4, 5, 6},
|
|
||||||
{8, 9, 0}};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1);
|
|
||||||
glm::vec3 B(1, 1, 1);
|
|
||||||
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::vec3> Tests;
|
|
||||||
Tests.push_back(glm::vec3(glm::vec2(1, 2), 3));
|
|
||||||
Tests.push_back(glm::vec3(1, glm::vec2(2, 3)));
|
|
||||||
Tests.push_back(glm::vec3(1, 2, 3));
|
|
||||||
Tests.push_back(glm::vec3(glm::vec4(1, 2, 3, 4)));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
Error += Tests[i] == glm::vec3(1, 2, 3) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f);
|
|
||||||
glm::vec3 B(1.0f);
|
|
||||||
bool R = A != B;
|
|
||||||
bool S = A == B;
|
|
||||||
|
|
||||||
Error += (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
|
||||||
|
|
||||||
glm::vec3 C = A + B;
|
|
||||||
Error += C == glm::vec3(5, 7, 9) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 D = B - A;
|
|
||||||
Error += D == glm::vec3(3, 3, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 E = A * B;
|
|
||||||
Error += E == glm::vec3(4, 10, 18) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 F = B / A;
|
|
||||||
Error += F == glm::vec3(4, 2.5, 2) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 G = A + 1.0f;
|
|
||||||
Error += G == glm::vec3(2, 3, 4) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 H = B - 1.0f;
|
|
||||||
Error += H == glm::vec3(3, 4, 5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 I = A * 2.0f;
|
|
||||||
Error += I == glm::vec3(2, 4, 6) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 J = B / 2.0f;
|
|
||||||
Error += J == glm::vec3(2, 2.5, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 K = 1.0f + A;
|
|
||||||
Error += K == glm::vec3(2, 3, 4) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 L = 1.0f - B;
|
|
||||||
Error += L == glm::vec3(-3, -4, -5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 M = 2.0f * A;
|
|
||||||
Error += M == glm::vec3(2, 4, 6) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec3 N = 2.0f / B;
|
|
||||||
Error += N == glm::vec3(0.5, 2.0 / 5.0, 2.0 / 6.0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
|
||||||
|
|
||||||
A += B;
|
|
||||||
Error += A == glm::vec3(5, 7, 9) ? 0 : 1;
|
|
||||||
|
|
||||||
A += 1.0f;
|
|
||||||
Error += A == glm::vec3(6, 8, 10) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
|
||||||
|
|
||||||
B -= A;
|
|
||||||
Error += B == glm::vec3(3, 3, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
B -= 1.0f;
|
|
||||||
Error += B == glm::vec3(2, 2, 2) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
|
||||||
|
|
||||||
A *= B;
|
|
||||||
Error += A == glm::vec3(4, 10, 18) ? 0 : 1;
|
|
||||||
|
|
||||||
A *= 2.0f;
|
|
||||||
Error += A == glm::vec3(8, 20, 36) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
|
||||||
|
|
||||||
B /= A;
|
|
||||||
Error += B == glm::vec3(4, 2.5, 2) ? 0 : 1;
|
|
||||||
|
|
||||||
B /= 2.0f;
|
|
||||||
Error += B == glm::vec3(2, 1.25, 1) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec3 B(2.0f);
|
|
||||||
|
|
||||||
B /= B.y;
|
|
||||||
Error += B == glm::vec3(1.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B = -A;
|
|
||||||
Error += B == glm::vec3(-1.0f, -2.0f, -3.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B = --A;
|
|
||||||
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B = A--;
|
|
||||||
Error += B == glm::vec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
|
|
||||||
Error += A == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B = ++A;
|
|
||||||
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
|
||||||
glm::vec3 B = A++;
|
|
||||||
Error += B == glm::vec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
|
|
||||||
Error += A == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::vec3) == sizeof(glm::lowp_vec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::vec3) == sizeof(glm::mediump_vec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::vec3) == sizeof(glm::highp_vec3) ? 0 : 1;
|
|
||||||
Error += 12 == sizeof(glm::mediump_vec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec3) == sizeof(glm::lowp_dvec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec3) == sizeof(glm::mediump_dvec3) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1;
|
|
||||||
Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1;
|
|
||||||
Error += glm::vec3().length() == 3 ? 0 : 1;
|
|
||||||
Error += glm::dvec3().length() == 3 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_swizzle3_2()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec3 v(1, 2, 3);
|
|
||||||
glm::vec2 u;
|
|
||||||
|
|
||||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
|
||||||
// Can not assign a vec3 swizzle to a vec2
|
|
||||||
//u = v.xyz; //Illegal
|
|
||||||
//u = v.rgb; //Illegal
|
|
||||||
//u = v.stp; //Illegal
|
|
||||||
|
|
||||||
u = v.xx; Error += (u.x == 1.0f && u.y == 1.0f) ? 0 : 1;
|
|
||||||
u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1;
|
|
||||||
u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1;
|
|
||||||
u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1;
|
|
||||||
u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1;
|
|
||||||
u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1;
|
|
||||||
u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1;
|
|
||||||
u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1;
|
|
||||||
u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1;
|
|
||||||
u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1;
|
|
||||||
u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1;
|
|
||||||
u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1;
|
|
||||||
u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1;
|
|
||||||
u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1;
|
|
||||||
u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1;
|
|
||||||
u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1;
|
|
||||||
u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1;
|
|
||||||
u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1;
|
|
||||||
u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1;
|
|
||||||
u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1;
|
|
||||||
u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1;
|
|
||||||
u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1;
|
|
||||||
u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1;
|
|
||||||
u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1;
|
|
||||||
u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1;
|
|
||||||
// Mixed member aliases are not valid
|
|
||||||
//u = v.rx; //Illegal
|
|
||||||
//u = v.sy; //Illegal
|
|
||||||
|
|
||||||
u = glm::vec2(1, 2);
|
|
||||||
v = glm::vec3(1, 2, 3);
|
|
||||||
//v.xx = u; //Illegal
|
|
||||||
v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1;
|
|
||||||
v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1;
|
|
||||||
v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
|
|
||||||
//v.yy = u; //Illegal
|
|
||||||
v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
|
|
||||||
v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1;
|
|
||||||
v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1;
|
|
||||||
//v.zz = u; //Illegal
|
|
||||||
|
|
||||||
# endif//GLM_LANG
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_swizzle3_3()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec3 v(1, 2, 3);
|
|
||||||
glm::vec3 u;
|
|
||||||
|
|
||||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
|
||||||
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
|
||||||
u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
|
||||||
u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
|
||||||
u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
|
||||||
u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
|
||||||
u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
|
||||||
u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
|
||||||
# endif//GLM_LANG
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_swizzle_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec3 q, u, v;
|
|
||||||
|
|
||||||
u = glm::vec3(1, 2, 3);
|
|
||||||
v = glm::vec3(10, 20, 30);
|
|
||||||
|
|
||||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
|
||||||
// Swizzle, swizzle binary operators
|
|
||||||
q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1;
|
|
||||||
q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1;
|
|
||||||
q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1;
|
|
||||||
q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1;
|
|
||||||
q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1;
|
|
||||||
q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1;
|
|
||||||
|
|
||||||
// vec, swizzle binary operators
|
|
||||||
q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1;
|
|
||||||
q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1;
|
|
||||||
q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1;
|
|
||||||
q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1;
|
|
||||||
q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1;
|
|
||||||
|
|
||||||
// swizzle,vec binary operators
|
|
||||||
q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1;
|
|
||||||
q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1;
|
|
||||||
q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1;
|
|
||||||
q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1;
|
|
||||||
q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1;
|
|
||||||
# endif//GLM_LANG
|
|
||||||
|
|
||||||
// Compile errors
|
|
||||||
//q = (u.yz * v.xyz);
|
|
||||||
//q = (u * v.xy);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_swizzle_functions()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
// NOTE: template functions cannot pick up the implicit conversion from
|
|
||||||
// a swizzle to the unswizzled type, therefore the operator() must be
|
|
||||||
// used. E.g.:
|
|
||||||
//
|
|
||||||
// glm::dot(u.xy, v.xy); <--- Compile error
|
|
||||||
// glm::dot(u.xy(), v.xy()); <--- Compiles correctly
|
|
||||||
|
|
||||||
float r;
|
|
||||||
|
|
||||||
// vec2
|
|
||||||
glm::vec2 a(1, 2);
|
|
||||||
glm::vec2 b(10, 20);
|
|
||||||
r = glm::dot(a, b); Error += (int(r) == 50) ? 0 : 1;
|
|
||||||
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.xy())); Error += (int(r) == 50) ? 0 : 1;
|
|
||||||
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.yy())); Error += (int(r) == 60) ? 0 : 1;
|
|
||||||
|
|
||||||
// vec3
|
|
||||||
glm::vec3 q, u, v;
|
|
||||||
u = glm::vec3(1, 2, 3);
|
|
||||||
v = glm::vec3(10, 20, 30);
|
|
||||||
r = glm::dot(u, v); Error += (int(r) == 140) ? 0 : 1;
|
|
||||||
r = glm::dot(u.xyz(), v.zyz()); Error += (int(r) == 160) ? 0 : 1;
|
|
||||||
r = glm::dot(u, v.zyx()); Error += (int(r) == 100) ? 0 : 1;
|
|
||||||
r = glm::dot(u.xyz(), v); Error += (int(r) == 140) ? 0 : 1;
|
|
||||||
r = glm::dot(u.xy(), v.xy()); Error += (int(r) == 50) ? 0 : 1;
|
|
||||||
|
|
||||||
// vec4
|
|
||||||
glm::vec4 s, t;
|
|
||||||
s = glm::vec4(1, 2, 3, 4);
|
|
||||||
t = glm::vec4(10, 20, 30, 40);
|
|
||||||
r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1;
|
|
||||||
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
|
|
||||||
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec3_swizzle_partial()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec3 A(1, 2, 3);
|
|
||||||
|
|
||||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
|
||||||
{
|
|
||||||
glm::vec3 B(A.xy, 3.0f);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 B(1.0f, A.yz);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec3 B(A.xyz);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
# endif//GLM_LANG
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_operator_increment()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::ivec3 v0(1);
|
|
||||||
glm::ivec3 v1(v0);
|
|
||||||
glm::ivec3 v2(v0);
|
|
||||||
glm::ivec3 v3 = ++v1;
|
|
||||||
glm::ivec3 v4 = v2++;
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
|
||||||
|
|
||||||
int i0(1);
|
|
||||||
int i1(i0);
|
|
||||||
int i2(i0);
|
|
||||||
int i3 = ++i1;
|
|
||||||
int i4 = i2++;
|
|
||||||
|
|
||||||
Error += i0 == i4 ? 0 : 1;
|
|
||||||
Error += i1 == i2 ? 0 : 1;
|
|
||||||
Error += i1 == i3 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_vec3_ctor();
|
|
||||||
Error += test_vec3_operators();
|
|
||||||
Error += test_vec3_size();
|
|
||||||
Error += test_vec3_swizzle3_2();
|
|
||||||
Error += test_vec3_swizzle3_3();
|
|
||||||
Error += test_vec3_swizzle_partial();
|
|
||||||
Error += test_vec3_swizzle_operators();
|
|
||||||
Error += test_vec3_swizzle_functions();
|
|
||||||
Error += test_operator_increment();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,390 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-08-31
|
|
||||||
// Updated : 2013-12-24
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : test/core/type_vec4.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <glm/vec2.hpp>
|
|
||||||
#include <glm/vec3.hpp>
|
|
||||||
#include <glm/vec4.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <ctime>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
template <int Value>
|
|
||||||
struct mask
|
|
||||||
{
|
|
||||||
enum{value = Value};
|
|
||||||
};
|
|
||||||
|
|
||||||
enum comp
|
|
||||||
{
|
|
||||||
X,
|
|
||||||
Y,
|
|
||||||
Z,
|
|
||||||
W
|
|
||||||
};
|
|
||||||
|
|
||||||
//template<comp X, comp Y, comp Z, comp W>
|
|
||||||
//__m128 swizzle(glm::vec4 const & v)
|
|
||||||
//{
|
|
||||||
// __m128 Src = _mm_set_ps(v.w, v.z, v.y, v.x);
|
|
||||||
// return _mm_shuffle_ps(Src, Src, mask<(int(W) << 6) | (int(Z) << 4) | (int(Y) << 2) | (int(X) << 0)>::value);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
int test_vec4_ctor()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
{
|
|
||||||
glm::vec4 a{ 0, 1, 2, 3 };
|
|
||||||
std::vector<glm::vec4> v = {
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{4, 5, 6, 7},
|
|
||||||
{8, 9, 0, 1}};
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec4 a{ 0, 1, 2, 3 };
|
|
||||||
std::vector<glm::dvec4> v = {
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{4, 5, 6, 7},
|
|
||||||
{8, 9, 0, 1}};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1);
|
|
||||||
glm::vec4 B(1, 1, 1, 1);
|
|
||||||
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::vec4> Tests;
|
|
||||||
Tests.push_back(glm::vec4(glm::vec2(1, 2), 3, 4));
|
|
||||||
Tests.push_back(glm::vec4(1, glm::vec2(2, 3), 4));
|
|
||||||
Tests.push_back(glm::vec4(1, 2, glm::vec2(3, 4)));
|
|
||||||
Tests.push_back(glm::vec4(glm::vec3(1, 2, 3), 4));
|
|
||||||
Tests.push_back(glm::vec4(1, glm::vec3(2, 3, 4)));
|
|
||||||
Tests.push_back(glm::vec4(glm::vec2(1, 2), glm::vec2(3, 4)));
|
|
||||||
Tests.push_back(glm::vec4(1, 2, 3, 4));
|
|
||||||
Tests.push_back(glm::vec4(glm::vec4(1, 2, 3, 4)));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec4_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f);
|
|
||||||
glm::vec4 B(1.0f);
|
|
||||||
bool R = A != B;
|
|
||||||
bool S = A == B;
|
|
||||||
|
|
||||||
Error += (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
|
||||||
|
|
||||||
glm::vec4 C = A + B;
|
|
||||||
Error += C == glm::vec4(5, 7, 9, 11) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 D = B - A;
|
|
||||||
Error += D == glm::vec4(3, 3, 3, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 E = A * B;
|
|
||||||
Error += E == glm::vec4(4, 10, 18, 28) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 F = B / A;
|
|
||||||
Error += F == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 G = A + 1.0f;
|
|
||||||
Error += G == glm::vec4(2, 3, 4, 5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 H = B - 1.0f;
|
|
||||||
Error += H == glm::vec4(3, 4, 5, 6) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 I = A * 2.0f;
|
|
||||||
Error += I == glm::vec4(2, 4, 6, 8) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 J = B / 2.0f;
|
|
||||||
Error += J == glm::vec4(2, 2.5, 3, 3.5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 K = 1.0f + A;
|
|
||||||
Error += K == glm::vec4(2, 3, 4, 5) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 L = 1.0f - B;
|
|
||||||
Error += L == glm::vec4(-3, -4, -5, -6) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 M = 2.0f * A;
|
|
||||||
Error += M == glm::vec4(2, 4, 6, 8) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec4 N = 2.0f / B;
|
|
||||||
Error += N == glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
|
||||||
|
|
||||||
A += B;
|
|
||||||
Error += A == glm::vec4(5, 7, 9, 11) ? 0 : 1;
|
|
||||||
|
|
||||||
A += 1.0f;
|
|
||||||
Error += A == glm::vec4(6, 8, 10, 12) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
|
||||||
|
|
||||||
B -= A;
|
|
||||||
Error += B == glm::vec4(3, 3, 3, 3) ? 0 : 1;
|
|
||||||
|
|
||||||
B -= 1.0f;
|
|
||||||
Error += B == glm::vec4(2, 2, 2, 2) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
|
||||||
|
|
||||||
A *= B;
|
|
||||||
Error += A == glm::vec4(4, 10, 18, 28) ? 0 : 1;
|
|
||||||
|
|
||||||
A *= 2.0f;
|
|
||||||
Error += A == glm::vec4(8, 20, 36, 56) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
|
||||||
|
|
||||||
B /= A;
|
|
||||||
Error += B == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
|
|
||||||
|
|
||||||
B /= 2.0f;
|
|
||||||
Error += B == glm::vec4(2, 1.25, 1, 7.0f / 4.0f / 2.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 B(2.0f);
|
|
||||||
|
|
||||||
B /= B.y;
|
|
||||||
Error += B == glm::vec4(1.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B = -A;
|
|
||||||
Error += B == glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B = --A;
|
|
||||||
Error += B == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B = A--;
|
|
||||||
Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
|
||||||
Error += A == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B = ++A;
|
|
||||||
Error += B == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
|
||||||
glm::vec4 B = A++;
|
|
||||||
Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
|
||||||
Error += A == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec4_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::vec4) == sizeof(glm::lowp_vec4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::vec4) == sizeof(glm::mediump_vec4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
|
|
||||||
Error += 16 == sizeof(glm::mediump_vec4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec4) == sizeof(glm::lowp_dvec4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec4) == sizeof(glm::mediump_dvec4) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
|
|
||||||
Error += 32 == sizeof(glm::highp_dvec4) ? 0 : 1;
|
|
||||||
Error += glm::vec4().length() == 4 ? 0 : 1;
|
|
||||||
Error += glm::dvec4().length() == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec4_swizzle_partial()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec4 A(1, 2, 3, 4);
|
|
||||||
|
|
||||||
# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE_RELAX))
|
|
||||||
{
|
|
||||||
glm::vec4 B(A.xy, A.zw);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 B(A.xy, 3.0f, 4.0f);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 B(1.0f, A.yz, 4.0f);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 B(1.0f, 2.0f, A.zw);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 B(A.xyz, 4.0f);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 B(1.0f, A.yzw);
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_operator_increment()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::ivec4 v0(1);
|
|
||||||
glm::ivec4 v1(v0);
|
|
||||||
glm::ivec4 v2(v0);
|
|
||||||
glm::ivec4 v3 = ++v1;
|
|
||||||
glm::ivec4 v4 = v2++;
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
|
||||||
|
|
||||||
int i0(1);
|
|
||||||
int i1(i0);
|
|
||||||
int i2(i0);
|
|
||||||
int i3 = ++i1;
|
|
||||||
int i4 = i2++;
|
|
||||||
|
|
||||||
Error += i0 == i4 ? 0 : 1;
|
|
||||||
Error += i1 == i2 ? 0 : 1;
|
|
||||||
Error += i1 == i3 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AoS
|
|
||||||
{
|
|
||||||
glm::vec4 A;
|
|
||||||
glm::vec3 B;
|
|
||||||
glm::vec3 C;
|
|
||||||
glm::vec2 D;
|
|
||||||
};
|
|
||||||
|
|
||||||
int test_vec4_perf_AoS(std::size_t Size)
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
std::vector<AoS> In;
|
|
||||||
std::vector<AoS> Out;
|
|
||||||
In.resize(Size);
|
|
||||||
Out.resize(Size);
|
|
||||||
|
|
||||||
std::clock_t StartTime = std::clock();
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < In.size(); ++i)
|
|
||||||
Out[i] = In[i];
|
|
||||||
|
|
||||||
std::clock_t EndTime = std::clock();
|
|
||||||
|
|
||||||
std::printf("AoS: %d\n", EndTime - StartTime);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_vec4_perf_SoA(std::size_t Size)
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
std::vector<glm::vec4> InA;
|
|
||||||
std::vector<glm::vec3> InB;
|
|
||||||
std::vector<glm::vec3> InC;
|
|
||||||
std::vector<glm::vec2> InD;
|
|
||||||
std::vector<glm::vec4> OutA;
|
|
||||||
std::vector<glm::vec3> OutB;
|
|
||||||
std::vector<glm::vec3> OutC;
|
|
||||||
std::vector<glm::vec2> OutD;
|
|
||||||
|
|
||||||
InA.resize(Size);
|
|
||||||
InB.resize(Size);
|
|
||||||
InC.resize(Size);
|
|
||||||
InD.resize(Size);
|
|
||||||
OutA.resize(Size);
|
|
||||||
OutB.resize(Size);
|
|
||||||
OutC.resize(Size);
|
|
||||||
OutD.resize(Size);
|
|
||||||
|
|
||||||
std::clock_t StartTime = std::clock();
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < InA.size(); ++i)
|
|
||||||
{
|
|
||||||
OutA[i] = InA[i];
|
|
||||||
OutB[i] = InB[i];
|
|
||||||
OutC[i] = InC[i];
|
|
||||||
OutD[i] = InD[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::clock_t EndTime = std::clock();
|
|
||||||
|
|
||||||
std::printf("SoA: %d\n", EndTime - StartTime);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
std::size_t const Size(1000000);
|
|
||||||
|
|
||||||
Error += test_vec4_perf_AoS(Size);
|
|
||||||
Error += test_vec4_perf_SoA(Size);
|
|
||||||
Error += test_vec4_ctor();
|
|
||||||
Error += test_vec4_size();
|
|
||||||
Error += test_vec4_operators();
|
|
||||||
Error += test_vec4_swizzle_partial();
|
|
||||||
Error += test_operator_increment();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
set(NAME gli)
|
|
||||||
|
|
||||||
file(GLOB ROOT_SOURCE *.cpp)
|
|
||||||
file(GLOB ROOT_INLINE *.inl)
|
|
||||||
file(GLOB ROOT_HEADER *.hpp)
|
|
||||||
|
|
||||||
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("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_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
|
|
||||||
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
|
|
||||||
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER} )
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
int main()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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 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
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,229 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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)
|
|
||||||
{}
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,233 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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[static_cast<int>(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 = glm::min(std::size_t(SrcSize.x + SrcPosition.x), std::size_t(DstMipmap.dimensions().x + DstPosition.x));
|
|
||||||
std::size_t SizeY = glm::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
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
{
|
|
||||||
enum comp
|
|
||||||
{
|
|
||||||
X = 0,
|
|
||||||
R = 0,
|
|
||||||
S = 0,
|
|
||||||
Y = 1,
|
|
||||||
G = 1,
|
|
||||||
T = 1,
|
|
||||||
Z = 2,
|
|
||||||
B = 2,
|
|
||||||
P = 2,
|
|
||||||
W = 3,
|
|
||||||
A = 3,
|
|
||||||
Q = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
//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(gli::comp X, gli::comp Y, gli::comp Z, gli::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
|
|
||||||
@@ -1,304 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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(gli::comp X, gli::comp Y, gli::comp Z, gli::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
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-09-29
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gli.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/*! \mainpage OpenGL Image
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GLI_GLI_INCLUDED
|
|
||||||
#define GLI_GLI_INCLUDED
|
|
||||||
|
|
||||||
#define GLI_VERSION 31
|
|
||||||
#define GLI_VERSION_MAJOR 0
|
|
||||||
#define GLI_VERSION_MINOR 3
|
|
||||||
#define GLI_VERSION_PATCH 1
|
|
||||||
#define GLI_VERSION_REVISION 0
|
|
||||||
|
|
||||||
#include "./core/texture2d.hpp"
|
|
||||||
#include "./core/texture2d_array.hpp"
|
|
||||||
#include "./core/texture_cube.hpp"
|
|
||||||
#include "./core/texture_cube_array.hpp"
|
|
||||||
#include "./core/size.hpp"
|
|
||||||
#include "./core/operation.hpp"
|
|
||||||
#include "./core/generate_mipmaps.hpp"
|
|
||||||
|
|
||||||
#endif//GLI_GLI_INCLUDED
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-01-09
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/compression.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_COMPRESSION_INCLUDED
|
|
||||||
#define GLI_GTX_COMPRESSION_INCLUDED
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace compression
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}//namespace compression
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::compression;}
|
|
||||||
|
|
||||||
#include "compression.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_COMPRESSION_INCLUDED
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-01-09
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/compression.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/fetch.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_FETCH_INCLUDED
|
|
||||||
#define GLI_GTX_FETCH_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace fetch
|
|
||||||
{
|
|
||||||
template <typename genType>
|
|
||||||
genType texelFetch(
|
|
||||||
texture2D const & Texture,
|
|
||||||
texture2D::dimensions_type const & Texcoord,
|
|
||||||
texture2D::level_type const & Level);
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
genType textureLod(
|
|
||||||
texture2D const & Texture,
|
|
||||||
texture2D::texcoord_type const & Texcoord,
|
|
||||||
texture2D::level_type const & Level);
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
void texelWrite(
|
|
||||||
texture2D & Texture,
|
|
||||||
texture2D::dimensions_type const & Texcoord,
|
|
||||||
texture2D::level_type const & Level,
|
|
||||||
genType const & Color);
|
|
||||||
|
|
||||||
}//namespace fetch
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::fetch;}
|
|
||||||
|
|
||||||
#include "fetch.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_FETCH_INCLUDED
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/fetch.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace fetch
|
|
||||||
{
|
|
||||||
template <typename genType>
|
|
||||||
inline genType texelFetch
|
|
||||||
(
|
|
||||||
texture2D const & Image,
|
|
||||||
texture2D::dimensions_type const & TexCoord,
|
|
||||||
texture2D::level_type const & Level
|
|
||||||
)
|
|
||||||
{
|
|
||||||
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
|
|
||||||
|
|
||||||
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
|
|
||||||
texture2D::value_type const * const Data = Image[Level].data();
|
|
||||||
|
|
||||||
return reinterpret_cast<genType const * const>(Data)[TexCoord.x + TexCoord.y * Dimensions.x];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
inline genType textureLod
|
|
||||||
(
|
|
||||||
texture2D const & Image,
|
|
||||||
texture2D::texcoord_type const & TexCoord,
|
|
||||||
texture2D::level_type const & Level
|
|
||||||
)
|
|
||||||
{
|
|
||||||
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
|
|
||||||
|
|
||||||
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
|
|
||||||
texture2D::value_type const * const Data = Image[Level].data();
|
|
||||||
|
|
||||||
std::size_t s_below = std::size_t(glm::floor(TexCoord.s * float(Dimensions.x - 1)));
|
|
||||||
std::size_t s_above = std::size_t(glm::ceil( TexCoord.s * float(Dimensions.x - 1)));
|
|
||||||
std::size_t t_below = std::size_t(glm::floor(TexCoord.t * float(Dimensions.y - 1)));
|
|
||||||
std::size_t t_above = std::size_t(glm::ceil( TexCoord.t * float(Dimensions.y - 1)));
|
|
||||||
|
|
||||||
float s_step = 1.0f / float(Dimensions.x);
|
|
||||||
float t_step = 1.0f / float(Dimensions.y);
|
|
||||||
|
|
||||||
float s_below_normalized = s_below / float(Dimensions.x);
|
|
||||||
float s_above_normalized = s_above / float(Dimensions.x);
|
|
||||||
float t_below_normalized = t_below / float(Dimensions.y);
|
|
||||||
float t_above_normalized = t_above / float(Dimensions.y);
|
|
||||||
|
|
||||||
genType Value1 = reinterpret_cast<genType const * const>(Data)[s_below + t_below * Dimensions.x];
|
|
||||||
genType Value2 = reinterpret_cast<genType const * const>(Data)[s_above + t_below * Dimensions.x];
|
|
||||||
genType Value3 = reinterpret_cast<genType const * const>(Data)[s_above + t_above * Dimensions.x];
|
|
||||||
genType Value4 = reinterpret_cast<genType const * const>(Data)[s_below + t_above * Dimensions.x];
|
|
||||||
|
|
||||||
float BlendA = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
|
|
||||||
float BlendB = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
|
|
||||||
float BlendC = float(TexCoord.t - t_below_normalized) * float(Dimensions.y - 1);
|
|
||||||
|
|
||||||
genType ValueA(glm::mix(Value1, Value2, BlendA));
|
|
||||||
genType ValueB(glm::mix(Value4, Value3, BlendB));
|
|
||||||
|
|
||||||
return genType(glm::mix(ValueA, ValueB, BlendC));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
void texelWrite
|
|
||||||
(
|
|
||||||
texture2D & Image,
|
|
||||||
texture2D::dimensions_type const & Texcoord,
|
|
||||||
texture2D::level_type const & Level,
|
|
||||||
genType const & Color
|
|
||||||
)
|
|
||||||
{
|
|
||||||
genType * Data = (genType*)Image[Level].data();
|
|
||||||
std::size_t Index = Texcoord.x + Texcoord.y * Image[Level].dimensions().x;
|
|
||||||
|
|
||||||
std::size_t Capacity = Image[Level].capacity();
|
|
||||||
assert(Index < Capacity);
|
|
||||||
|
|
||||||
*(Data + Index) = Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace fetch
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-27
|
|
||||||
// Updated : 2010-10-01
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/gl_texture2d.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_GL_TEXTURE2D_INCLUDED
|
|
||||||
#define GLI_GTX_GL_TEXTURE2D_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
#include "../gtx/loader.hpp"
|
|
||||||
|
|
||||||
#ifndef GL_VERSION_1_1
|
|
||||||
#error "ERROR: OpenGL must be included before GLI_GTX_gl_texture2d"
|
|
||||||
#endif//GL_VERSION_1_1
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace gl_texture2d
|
|
||||||
{
|
|
||||||
GLuint createTexture2D(std::string const & Filename);
|
|
||||||
}//namespace gl_texture2d
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::gl_texture2d;}
|
|
||||||
|
|
||||||
#include "gl_texture2d.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_GL_TEXTURE2D_INCLUDED
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-27
|
|
||||||
// Updated : 2010-10-01
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/gl_texture2d.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace gl_texture2d{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
//GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, GL_COMPRESSED_RGBA, GL_COMPRESSED_SRGB, GL_COMPRESSED_SRGB_ALPHA,
|
|
||||||
//GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or GL_SRGB8_ALPHA8
|
|
||||||
struct texture_desc
|
|
||||||
{
|
|
||||||
GLint InternalFormat;
|
|
||||||
GLint InternalFormatCompressed;
|
|
||||||
GLint InternalFormatSRGB;
|
|
||||||
GLint InternalFormatCompressedSRGB;
|
|
||||||
GLenum ExternalFormat;
|
|
||||||
GLenum ExternalFormatRev;
|
|
||||||
GLenum Type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA.
|
|
||||||
//GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT,
|
|
||||||
//GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
|
|
||||||
//GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4,
|
|
||||||
//GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
|
||||||
//GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
|
|
||||||
//GL_UNSIGNED_INT_2_10_10_10_REV
|
|
||||||
|
|
||||||
# ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
|
|
||||||
# define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
|
|
||||||
# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
|
|
||||||
# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
|
|
||||||
# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
|
|
||||||
# endif
|
|
||||||
|
|
||||||
inline texture_desc gli2ogl_cast(format const & Format)
|
|
||||||
{
|
|
||||||
texture_desc Cast[] =
|
|
||||||
{
|
|
||||||
{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
|
|
||||||
//// Normalized
|
|
||||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
|
|
||||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
|
|
||||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
|
|
||||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
|
|
||||||
|
|
||||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
|
|
||||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
|
|
||||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
|
|
||||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
|
|
||||||
|
|
||||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
|
|
||||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
|
|
||||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
|
|
||||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
|
|
||||||
|
|
||||||
// Unsigned
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
|
|
||||||
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
|
|
||||||
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
|
|
||||||
|
|
||||||
// Signed
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_BYTE},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_BYTE},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_BYTE},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_BYTE},
|
|
||||||
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_SHORT},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_SHORT},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_SHORT},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_SHORT},
|
|
||||||
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_INT},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_INT},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_INT},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_INT},
|
|
||||||
|
|
||||||
// Float
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_HALF_FLOAT},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_HALF_FLOAT},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_HALF_FLOAT},
|
|
||||||
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_FLOAT},
|
|
||||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_FLOAT},
|
|
||||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_FLOAT},
|
|
||||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_FLOAT},
|
|
||||||
|
|
||||||
// Packed
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
{GL_RGB9_E5, GL_RGB9_E5, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
{GL_R11F_G11F_B10F, GL_R11F_G11F_B10F, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
{GL_RGBA4, GL_RGBA4, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
{GL_RGB10_A2, GL_RGB10_A2, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
|
||||||
|
|
||||||
// Depth
|
|
||||||
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT},
|
|
||||||
{GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
|
|
||||||
{GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
|
|
||||||
{GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT},
|
|
||||||
{GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
|
|
||||||
|
|
||||||
// Compressed formats
|
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_NONE, GL_NONE, GL_NONE},
|
|
||||||
};
|
|
||||||
|
|
||||||
return Cast[Format];
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace detail
|
|
||||||
|
|
||||||
inline GLuint createTexture2D(std::string const & Filename)
|
|
||||||
{
|
|
||||||
gli::texture2D Texture = gli::load(Filename);
|
|
||||||
if(Texture.empty())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
detail::texture_desc TextureDesc = detail::gli2ogl_cast(Texture.format());
|
|
||||||
|
|
||||||
GLint Alignment = 0;
|
|
||||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &Alignment);
|
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
|
|
||||||
GLuint Name = 0;
|
|
||||||
glGenTextures(1, &Name);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, Name);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Texture.levels() > 1 ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
|
|
||||||
if(size(Texture, BIT_PER_PIXEL) == size(Texture, BLOCK_SIZE) << 3)
|
|
||||||
{
|
|
||||||
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
|
||||||
{
|
|
||||||
glTexImage2D(
|
|
||||||
GL_TEXTURE_2D,
|
|
||||||
GLint(Level),
|
|
||||||
TextureDesc.InternalFormat,
|
|
||||||
GLsizei(Texture[Level].dimensions().x),
|
|
||||||
GLsizei(Texture[Level].dimensions().y),
|
|
||||||
0,
|
|
||||||
TextureDesc.ExternalFormatRev,
|
|
||||||
TextureDesc.Type,
|
|
||||||
Texture[Level].data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
|
||||||
{
|
|
||||||
glCompressedTexImage2D(
|
|
||||||
GL_TEXTURE_2D,
|
|
||||||
GLint(Level),
|
|
||||||
TextureDesc.InternalFormat,
|
|
||||||
GLsizei(Texture[Level].dimensions().x),
|
|
||||||
GLsizei(Texture[Level].dimensions().y),
|
|
||||||
0,
|
|
||||||
GLsizei(Texture[Level].capacity()),
|
|
||||||
Texture[Level].data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, Alignment);
|
|
||||||
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace gl_texture_2d
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-01-09
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/gradient.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_GRADIENT_INCLUDED
|
|
||||||
#define GLI_GTX_GRADIENT_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace gradient
|
|
||||||
{
|
|
||||||
texture2D radial(
|
|
||||||
texture2D::dimensions_type const & Size,
|
|
||||||
texture2D::texcoord_type const & Center,
|
|
||||||
float const & Radius,
|
|
||||||
texture2D::texcoord_type const & Focal);
|
|
||||||
|
|
||||||
texture2D linear(
|
|
||||||
texture2D::dimensions_type const & Size,
|
|
||||||
texture2D::texcoord_type const & Point0,
|
|
||||||
texture2D::texcoord_type const & Point1);
|
|
||||||
|
|
||||||
}//namespace gradient
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::gradient;}
|
|
||||||
|
|
||||||
#include "gradient.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_GRADIENT_INCLUDED
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2008-12-19
|
|
||||||
// Updated : 2010-01-09
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/gradient.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace gradient
|
|
||||||
{
|
|
||||||
inline texture2D radial
|
|
||||||
(
|
|
||||||
texture2D::dimensions_type const & Size,
|
|
||||||
texture2D::texcoord_type const & Center,
|
|
||||||
float const & Radius,
|
|
||||||
texture2D::texcoord_type const & Focal
|
|
||||||
)
|
|
||||||
{
|
|
||||||
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
|
|
||||||
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
|
|
||||||
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
|
|
||||||
{
|
|
||||||
float Value = glm::radialGradient(
|
|
||||||
Center * glm::vec2(Size),
|
|
||||||
Radius,
|
|
||||||
Focal * glm::vec2(Size),
|
|
||||||
glm::vec2(x, y));
|
|
||||||
|
|
||||||
std::size_t Index = x + y * Result.dimensions().x;
|
|
||||||
|
|
||||||
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Image(1);
|
|
||||||
Image[0] = Result;
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline texture2D linear
|
|
||||||
(
|
|
||||||
texture2D::dimensions_type const & Size,
|
|
||||||
texture2D::texcoord_type const & Point0,
|
|
||||||
texture2D::texcoord_type const & Point1
|
|
||||||
)
|
|
||||||
{
|
|
||||||
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
|
|
||||||
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
|
|
||||||
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
|
|
||||||
{
|
|
||||||
float Value = glm::linearGradient(
|
|
||||||
Point0 * glm::vec2(Size),
|
|
||||||
Point1 * glm::vec2(Size),
|
|
||||||
texture2D::texcoord_type(x, y));
|
|
||||||
|
|
||||||
std::size_t Index = x + y * Result.dimensions().x;
|
|
||||||
|
|
||||||
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Image(1);
|
|
||||||
Image[0] = Result;
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace gradient
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-08
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_LOADER_INCLUDED
|
|
||||||
#define GLI_GTX_LOADER_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
#include "../gtx/loader_dds9.hpp"
|
|
||||||
#include "../gtx/loader_dds10.hpp"
|
|
||||||
#include "../gtx/loader_tga.hpp"
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader
|
|
||||||
{
|
|
||||||
inline texture2D load(
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
inline void save(
|
|
||||||
texture2D const & Image,
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
}//namespace loader
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::loader;}
|
|
||||||
|
|
||||||
#include "loader.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_LOADER_INCLUDED
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-08
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader
|
|
||||||
{
|
|
||||||
inline texture2D load
|
|
||||||
(
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if(Filename.find(".dds") != std::string::npos)
|
|
||||||
return loadDDS10(Filename);
|
|
||||||
else if(Filename.find(".tga") != std::string::npos)
|
|
||||||
return loadTGA(Filename);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(0); // File format not supported
|
|
||||||
return texture2D();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void save
|
|
||||||
(
|
|
||||||
texture2D const & Image,
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if(Filename.find(".dds") != std::string::npos)
|
|
||||||
saveDDS10(Image, Filename);
|
|
||||||
else if(Filename.find(".tga") != std::string::npos)
|
|
||||||
saveTGA(Image, Filename);
|
|
||||||
else
|
|
||||||
assert(0); // File format not supported
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace loader
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-26
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader_dds10.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_LOADER_DDS10_INCLUDED
|
|
||||||
#define GLI_GTX_LOADER_DDS10_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader_dds10
|
|
||||||
{
|
|
||||||
texture2D loadDDS10(
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
void saveDDS10(
|
|
||||||
texture2D const & Image,
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
}//namespace loader_dds10
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::loader_dds10;}
|
|
||||||
|
|
||||||
#include "loader_dds10.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_LOADER_DDS10_INCLUDED
|
|
||||||
@@ -1,595 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-26
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader_dds10.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader_dds10{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
// DDS Documentation
|
|
||||||
/*
|
|
||||||
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
|
|
||||||
http://msdn.microsoft.com/en-us/library/bb943992.aspx
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
|
||||||
(glm::uint32)( \
|
|
||||||
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
|
|
||||||
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
|
|
||||||
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
|
|
||||||
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
|
|
||||||
|
|
||||||
enum DXGI_FORMAT
|
|
||||||
{
|
|
||||||
DXGI_FORMAT_UNKNOWN = 0,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
|
||||||
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
|
||||||
DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
|
||||||
DXGI_FORMAT_R32G32B32_UINT = 7,
|
|
||||||
DXGI_FORMAT_R32G32B32_SINT = 8,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
|
||||||
DXGI_FORMAT_R32G32_TYPELESS = 15,
|
|
||||||
DXGI_FORMAT_R32G32_FLOAT = 16,
|
|
||||||
DXGI_FORMAT_R32G32_UINT = 17,
|
|
||||||
DXGI_FORMAT_R32G32_SINT = 18,
|
|
||||||
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
|
||||||
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
|
||||||
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
|
||||||
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
|
||||||
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
|
||||||
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
|
||||||
DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
|
||||||
DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
|
||||||
DXGI_FORMAT_R16G16_TYPELESS = 33,
|
|
||||||
DXGI_FORMAT_R16G16_FLOAT = 34,
|
|
||||||
DXGI_FORMAT_R16G16_UNORM = 35,
|
|
||||||
DXGI_FORMAT_R16G16_UINT = 36,
|
|
||||||
DXGI_FORMAT_R16G16_SNORM = 37,
|
|
||||||
DXGI_FORMAT_R16G16_SINT = 38,
|
|
||||||
DXGI_FORMAT_R32_TYPELESS = 39,
|
|
||||||
DXGI_FORMAT_D32_FLOAT = 40,
|
|
||||||
DXGI_FORMAT_R32_FLOAT = 41,
|
|
||||||
DXGI_FORMAT_R32_UINT = 42,
|
|
||||||
DXGI_FORMAT_R32_SINT = 43,
|
|
||||||
DXGI_FORMAT_R24G8_TYPELESS = 44,
|
|
||||||
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
|
||||||
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
|
||||||
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
|
||||||
DXGI_FORMAT_R8G8_TYPELESS = 48,
|
|
||||||
DXGI_FORMAT_R8G8_UNORM = 49,
|
|
||||||
DXGI_FORMAT_R8G8_UINT = 50,
|
|
||||||
DXGI_FORMAT_R8G8_SNORM = 51,
|
|
||||||
DXGI_FORMAT_R8G8_SINT = 52,
|
|
||||||
DXGI_FORMAT_R16_TYPELESS = 53,
|
|
||||||
DXGI_FORMAT_R16_FLOAT = 54,
|
|
||||||
DXGI_FORMAT_D16_UNORM = 55,
|
|
||||||
DXGI_FORMAT_R16_UNORM = 56,
|
|
||||||
DXGI_FORMAT_R16_UINT = 57,
|
|
||||||
DXGI_FORMAT_R16_SNORM = 58,
|
|
||||||
DXGI_FORMAT_R16_SINT = 59,
|
|
||||||
DXGI_FORMAT_R8_TYPELESS = 60,
|
|
||||||
DXGI_FORMAT_R8_UNORM = 61,
|
|
||||||
DXGI_FORMAT_R8_UINT = 62,
|
|
||||||
DXGI_FORMAT_R8_SNORM = 63,
|
|
||||||
DXGI_FORMAT_R8_SINT = 64,
|
|
||||||
DXGI_FORMAT_A8_UNORM = 65,
|
|
||||||
DXGI_FORMAT_R1_UNORM = 66,
|
|
||||||
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
|
||||||
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
|
||||||
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
|
||||||
DXGI_FORMAT_BC1_TYPELESS = 70,
|
|
||||||
DXGI_FORMAT_BC1_UNORM = 71,
|
|
||||||
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
|
||||||
DXGI_FORMAT_BC2_TYPELESS = 73,
|
|
||||||
DXGI_FORMAT_BC2_UNORM = 74,
|
|
||||||
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
|
||||||
DXGI_FORMAT_BC3_TYPELESS = 76,
|
|
||||||
DXGI_FORMAT_BC3_UNORM = 77,
|
|
||||||
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
|
||||||
DXGI_FORMAT_BC4_TYPELESS = 79,
|
|
||||||
DXGI_FORMAT_BC4_UNORM = 80,
|
|
||||||
DXGI_FORMAT_BC4_SNORM = 81,
|
|
||||||
DXGI_FORMAT_BC5_TYPELESS = 82,
|
|
||||||
DXGI_FORMAT_BC5_UNORM = 83,
|
|
||||||
DXGI_FORMAT_BC5_SNORM = 84,
|
|
||||||
DXGI_FORMAT_B5G6R5_UNORM = 85,
|
|
||||||
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
|
||||||
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
|
||||||
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
|
||||||
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
|
||||||
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
|
||||||
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
|
||||||
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
|
||||||
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
|
||||||
DXGI_FORMAT_BC6H_TYPELESS = 94,
|
|
||||||
DXGI_FORMAT_BC6H_UF16 = 95,
|
|
||||||
DXGI_FORMAT_BC6H_SF16 = 96,
|
|
||||||
DXGI_FORMAT_BC7_TYPELESS = 97,
|
|
||||||
DXGI_FORMAT_BC7_UNORM = 98,
|
|
||||||
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
|
||||||
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum D3D10_RESOURCE_DIMENSION
|
|
||||||
{
|
|
||||||
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
|
|
||||||
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
|
|
||||||
D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
|
|
||||||
D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
|
|
||||||
D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
enum D3D10_RESOURCE_MISC_FLAG
|
|
||||||
{
|
|
||||||
D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1L,
|
|
||||||
D3D10_RESOURCE_MISC_SHARED = 0x2L,
|
|
||||||
D3D10_RESOURCE_MISC_TEXTURECUBE = 0x4L,
|
|
||||||
D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10L,
|
|
||||||
D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20L
|
|
||||||
};
|
|
||||||
|
|
||||||
enum dds_format
|
|
||||||
{
|
|
||||||
GLI_D3DFMT_R8G8B8 = 20,
|
|
||||||
GLI_D3DFMT_A8R8G8B8 = 21,
|
|
||||||
GLI_D3DFMT_X8R8G8B8 = 22,
|
|
||||||
GLI_D3DFMT_A8 = 28,
|
|
||||||
GLI_D3DFMT_A2B10G10R10 = 31,
|
|
||||||
GLI_D3DFMT_A8B8G8R8 = 32,
|
|
||||||
GLI_D3DFMT_X8B8G8R8 = 33,
|
|
||||||
GLI_D3DFMT_G16R16 = 34,
|
|
||||||
GLI_D3DFMT_A2R10G10B10 = 35,
|
|
||||||
GLI_D3DFMT_A16B16G16R16 = 36,
|
|
||||||
|
|
||||||
GLI_D3DFMT_L8 = 50,
|
|
||||||
GLI_D3DFMT_A8L8 = 51,
|
|
||||||
|
|
||||||
GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
|
|
||||||
GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
|
|
||||||
GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
|
|
||||||
GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
|
|
||||||
GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
|
|
||||||
GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
|
|
||||||
|
|
||||||
GLI_D3DFMT_D32 = 71,
|
|
||||||
GLI_D3DFMT_D24S8 = 75,
|
|
||||||
GLI_D3DFMT_D24X8 = 77,
|
|
||||||
GLI_D3DFMT_D16 = 80,
|
|
||||||
GLI_D3DFMT_L16 = 81,
|
|
||||||
GLI_D3DFMT_D32F_LOCKABLE = 82,
|
|
||||||
GLI_D3DFMT_D24FS8 = 83,
|
|
||||||
|
|
||||||
GLI_D3DFMT_R16F = 111,
|
|
||||||
GLI_D3DFMT_G16R16F = 112,
|
|
||||||
GLI_D3DFMT_A16B16G16R16F = 113,
|
|
||||||
|
|
||||||
GLI_D3DFMT_R32F = 114,
|
|
||||||
GLI_D3DFMT_G32R32F = 115,
|
|
||||||
GLI_D3DFMT_A32B32G32R32F = 116
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ddsHeader10
|
|
||||||
{
|
|
||||||
DXGI_FORMAT dxgiFormat;
|
|
||||||
D3D10_RESOURCE_DIMENSION resourceDimension;
|
|
||||||
glm::uint32 miscFlag; // D3D10_RESOURCE_MISC_GENERATE_MIPS
|
|
||||||
glm::uint32 arraySize;
|
|
||||||
glm::uint32 reserved;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
inline gli::format format_fourcc2gli_cast(glm::uint32 const & FourCC)
|
|
||||||
{
|
|
||||||
switch(FourCC)
|
|
||||||
{
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_DXT1:
|
|
||||||
return DXT1;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_DXT2:
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_DXT3:
|
|
||||||
return DXT3;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_DXT4:
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_DXT5:
|
|
||||||
return DXT5;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_R16F:
|
|
||||||
return R16F;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_G16R16F:
|
|
||||||
return RG16F;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_A16B16G16R16F:
|
|
||||||
return RGBA16F;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_R32F:
|
|
||||||
return R32F;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_G32R32F:
|
|
||||||
return RG32F;
|
|
||||||
case loader_dds9::detail::GLI_FOURCC_A32B32G32R32F:
|
|
||||||
return RGBA32F;
|
|
||||||
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_R8G8B8:
|
|
||||||
return RGB8U;
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_A8R8G8B8:
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_X8R8G8B8:
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_A8B8G8R8:
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_X8B8G8R8:
|
|
||||||
return RGBA8U;
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_R5G6B5:
|
|
||||||
return R5G6B5;
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_A4R4G4B4:
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_X4R4G4B4:
|
|
||||||
return RGBA4;
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_G16R16:
|
|
||||||
return RG16U;
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_A16B16G16R16:
|
|
||||||
return RGBA16U;
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_A2R10G10B10:
|
|
||||||
case loader_dds9::detail::GLI_D3DFMT_A2B10G10R10:
|
|
||||||
return RGB10A2;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return FORMAT_NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline DXGI_FORMAT format_gli2dds_cast(gli::format const & Format)
|
|
||||||
{
|
|
||||||
DXGI_FORMAT Cast[] =
|
|
||||||
{
|
|
||||||
DXGI_FORMAT_UNKNOWN, //FORMAT_NULL,
|
|
||||||
|
|
||||||
// Unsigned integer formats
|
|
||||||
DXGI_FORMAT_R8_UINT, //R8U,
|
|
||||||
DXGI_FORMAT_R8G8_UINT, //RG8U,
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGB8U,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_UINT, //RGBA8U,
|
|
||||||
|
|
||||||
DXGI_FORMAT_R16_UINT, //R16U,
|
|
||||||
DXGI_FORMAT_R16G16_UINT, //RG16U,
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGB16U,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_UINT, //RGBA16U,
|
|
||||||
|
|
||||||
DXGI_FORMAT_R32_UINT, //R32U,
|
|
||||||
DXGI_FORMAT_R32G32_UINT, //RG32U,
|
|
||||||
DXGI_FORMAT_R32G32B32_UINT, //RGB32U,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_UINT, //RGBA32U,
|
|
||||||
|
|
||||||
// Signed integer formats
|
|
||||||
DXGI_FORMAT_R8_SINT, //R8I,
|
|
||||||
DXGI_FORMAT_R8G8_SINT, //RG8I,
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGB8I,
|
|
||||||
DXGI_FORMAT_R8G8B8A8_SINT, //RGBA8I,
|
|
||||||
|
|
||||||
DXGI_FORMAT_R16_SINT, //R16I,
|
|
||||||
DXGI_FORMAT_R16G16_SINT, //RG16I,
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGB16I,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_SINT, //RGBA16I,
|
|
||||||
|
|
||||||
DXGI_FORMAT_R32_SINT, //R32I,
|
|
||||||
DXGI_FORMAT_R32G32_SINT, //RG32I,
|
|
||||||
DXGI_FORMAT_R32G32B32_SINT, //RGB32I,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_SINT, //RGBA32I,
|
|
||||||
|
|
||||||
// Floating formats
|
|
||||||
DXGI_FORMAT_R16_FLOAT, //R16F,
|
|
||||||
DXGI_FORMAT_R16G16_FLOAT, //RG16F,
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGB16F,
|
|
||||||
DXGI_FORMAT_R16G16B16A16_FLOAT, //RGBA16F,
|
|
||||||
|
|
||||||
DXGI_FORMAT_R32_FLOAT, //R32F,
|
|
||||||
DXGI_FORMAT_R32G32_FLOAT, //RG32F,
|
|
||||||
DXGI_FORMAT_R32G32B32_FLOAT, //RGB32F,
|
|
||||||
DXGI_FORMAT_R32G32B32A32_FLOAT, //RGBA32F,
|
|
||||||
|
|
||||||
// Packed formats
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGBE8,
|
|
||||||
DXGI_FORMAT_R9G9B9E5_SHAREDEXP, //RGB9E5,
|
|
||||||
DXGI_FORMAT_R11G11B10_FLOAT,
|
|
||||||
DXGI_FORMAT_B5G6R5_UNORM, //R5G6B5,
|
|
||||||
DXGI_FORMAT_UNKNOWN, //RGBA4,
|
|
||||||
DXGI_FORMAT_R10G10B10A2_TYPELESS, //RGB10A2,
|
|
||||||
|
|
||||||
// Depth formats
|
|
||||||
DXGI_FORMAT_D16_UNORM, //D16,
|
|
||||||
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24X8,
|
|
||||||
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24S8,
|
|
||||||
DXGI_FORMAT_D32_FLOAT, //D32F,
|
|
||||||
DXGI_FORMAT_D32_FLOAT_S8X24_UINT, //D32FS8X24,
|
|
||||||
|
|
||||||
// Compressed formats
|
|
||||||
DXGI_FORMAT_BC1_UNORM, //DXT1,
|
|
||||||
DXGI_FORMAT_BC2_UNORM, //DXT3,
|
|
||||||
DXGI_FORMAT_BC3_UNORM, //DXT5,
|
|
||||||
DXGI_FORMAT_BC4_UNORM, //ATI1N_UNORM,
|
|
||||||
DXGI_FORMAT_BC4_SNORM, //ATI1N_SNORM,
|
|
||||||
DXGI_FORMAT_BC5_UNORM, //ATI2N_UNORM,
|
|
||||||
DXGI_FORMAT_BC5_SNORM, //ATI2N_SNORM,
|
|
||||||
DXGI_FORMAT_BC6H_UF16, //BP_FLOAT,
|
|
||||||
DXGI_FORMAT_BC6H_SF16, //BP_FLOAT,
|
|
||||||
DXGI_FORMAT_BC7_UNORM //BP,
|
|
||||||
};
|
|
||||||
|
|
||||||
return Cast[Format];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline gli::format format_dds2gli_cast(DXGI_FORMAT const & Format)
|
|
||||||
{
|
|
||||||
gli::format Cast[] =
|
|
||||||
{
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_UNKNOWN = 0,
|
|
||||||
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
|
||||||
gli::RGBA32F, //DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
|
||||||
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
|
||||||
gli::RGBA32I, //DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
|
||||||
gli::RGB32U, //DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
|
||||||
gli::RGB32F, //DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
|
||||||
gli::RGB32U, //DXGI_FORMAT_R32G32B32_UINT = 7,
|
|
||||||
gli::RGB32I, //DXGI_FORMAT_R32G32B32_SINT = 8,
|
|
||||||
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
|
||||||
gli::RGBA16F, //DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
|
||||||
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
|
||||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
|
||||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
|
||||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
|
||||||
gli::RG32U, //DXGI_FORMAT_R32G32_TYPELESS = 15,
|
|
||||||
gli::RG32F, //DXGI_FORMAT_R32G32_FLOAT = 16,
|
|
||||||
gli::RG32U, //DXGI_FORMAT_R32G32_UINT = 17,
|
|
||||||
gli::RG32I, //DXGI_FORMAT_R32G32_SINT = 18,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
|
||||||
gli::D32FS8X24, //DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
|
||||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
|
||||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
|
||||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
|
||||||
gli::RG11B10F, //DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
|
||||||
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
|
||||||
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
|
||||||
gli::RG16U, //DXGI_FORMAT_R16G16_TYPELESS = 33,
|
|
||||||
gli::RG16F, //DXGI_FORMAT_R16G16_FLOAT = 34,
|
|
||||||
gli::RG16U, //DXGI_FORMAT_R16G16_UNORM = 35,
|
|
||||||
gli::RG16U, //DXGI_FORMAT_R16G16_UINT = 36,
|
|
||||||
gli::RG16I, //DXGI_FORMAT_R16G16_SNORM = 37,
|
|
||||||
gli::RG16I, //DXGI_FORMAT_R16G16_SINT = 38,
|
|
||||||
gli::R32F, //DXGI_FORMAT_R32_TYPELESS = 39,
|
|
||||||
gli::D32F, //DXGI_FORMAT_D32_FLOAT = 40,
|
|
||||||
gli::R32F, //DXGI_FORMAT_R32_FLOAT = 41,
|
|
||||||
gli::R32U, //DXGI_FORMAT_R32_UINT = 42,
|
|
||||||
gli::R32I, //DXGI_FORMAT_R32_SINT = 43,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R24G8_TYPELESS = 44,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
|
||||||
gli::RG8U, //DXGI_FORMAT_R8G8_TYPELESS = 48,
|
|
||||||
gli::RG8U, //DXGI_FORMAT_R8G8_UNORM = 49,
|
|
||||||
gli::RG8U, //DXGI_FORMAT_R8G8_UINT = 50,
|
|
||||||
gli::RG8I, //DXGI_FORMAT_R8G8_SNORM = 51,
|
|
||||||
gli::RG8I, //DXGI_FORMAT_R8G8_SINT = 52,
|
|
||||||
gli::R16U, //DXGI_FORMAT_R16_TYPELESS = 53,
|
|
||||||
gli::R16F, //DXGI_FORMAT_R16_FLOAT = 54,
|
|
||||||
gli::D16, //DXGI_FORMAT_D16_UNORM = 55,
|
|
||||||
gli::R16U, //DXGI_FORMAT_R16_UNORM = 56,
|
|
||||||
gli::R16U, //DXGI_FORMAT_R16_UINT = 57,
|
|
||||||
gli::R16I, //DXGI_FORMAT_R16_SNORM = 58,
|
|
||||||
gli::R16I, //DXGI_FORMAT_R16_SINT = 59,
|
|
||||||
gli::R8U, //DXGI_FORMAT_R8_TYPELESS = 60,
|
|
||||||
gli::R8U, //DXGI_FORMAT_R8_UNORM = 61,
|
|
||||||
gli::R8U, //DXGI_FORMAT_R8_UINT = 62,
|
|
||||||
gli::R8I, //DXGI_FORMAT_R8_SNORM = 63,
|
|
||||||
gli::R8I, //DXGI_FORMAT_R8_SINT = 64,
|
|
||||||
gli::R8U, //DXGI_FORMAT_A8_UNORM = 65,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R1_UNORM = 66,
|
|
||||||
gli::RGB9E5, //DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
|
||||||
gli::DXT1, //DXGI_FORMAT_BC1_TYPELESS = 70,
|
|
||||||
gli::DXT1, //DXGI_FORMAT_BC1_UNORM = 71,
|
|
||||||
gli::DXT1, //DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
|
||||||
gli::DXT3, //DXGI_FORMAT_BC2_TYPELESS = 73,
|
|
||||||
gli::DXT3, //DXGI_FORMAT_BC2_UNORM = 74,
|
|
||||||
gli::DXT3, //DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
|
||||||
gli::DXT5, //DXGI_FORMAT_BC3_TYPELESS = 76,
|
|
||||||
gli::DXT5, //DXGI_FORMAT_BC3_UNORM = 77,
|
|
||||||
gli::DXT5, //DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
|
||||||
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_TYPELESS = 79,
|
|
||||||
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_UNORM = 80,
|
|
||||||
gli::ATI1N_SNORM, //DXGI_FORMAT_BC4_SNORM = 81,
|
|
||||||
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_TYPELESS = 82,
|
|
||||||
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_UNORM = 83,
|
|
||||||
gli::ATI2N_SNORM, //DXGI_FORMAT_BC5_SNORM = 84,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_B5G6R5_UNORM = 85,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
|
||||||
gli::FORMAT_NULL, //DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
|
||||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
|
||||||
gli::BP_UF16, //DXGI_FORMAT_BC6H_TYPELESS = 94,
|
|
||||||
gli::BP_UF16, //DXGI_FORMAT_BC6H_UF16 = 95,
|
|
||||||
gli::BP_SF16, //DXGI_FORMAT_BC6H_SF16 = 96,
|
|
||||||
gli::BP, //DXGI_FORMAT_BC7_TYPELESS = 97,
|
|
||||||
gli::BP, //DXGI_FORMAT_BC7_UNORM = 98,
|
|
||||||
gli::BP, //DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
|
||||||
gli::R32U //DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
|
|
||||||
};
|
|
||||||
|
|
||||||
return Cast[Format];
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace detail
|
|
||||||
|
|
||||||
inline texture2D loadDDS10
|
|
||||||
(
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
|
||||||
if(FileIn.fail())
|
|
||||||
return texture2D();
|
|
||||||
|
|
||||||
loader_dds9::detail::ddsHeader HeaderDesc;
|
|
||||||
detail::ddsHeader10 HeaderDesc10;
|
|
||||||
char Magic[4];
|
|
||||||
|
|
||||||
//* Read magic number and check if valid .dds file
|
|
||||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
|
||||||
|
|
||||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
|
||||||
|
|
||||||
// Get the surface descriptor
|
|
||||||
FileIn.read((char*)&HeaderDesc, sizeof(HeaderDesc));
|
|
||||||
if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC && HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
|
|
||||||
FileIn.read((char*)&HeaderDesc10, sizeof(HeaderDesc10));
|
|
||||||
|
|
||||||
loader_dds9::detail::DDLoader Loader;
|
|
||||||
if(HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
|
|
||||||
Loader.Format = detail::format_dds2gli_cast(HeaderDesc10.dxgiFormat);
|
|
||||||
else if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC)
|
|
||||||
Loader.Format = detail::format_fourcc2gli_cast(HeaderDesc.format.fourCC);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch(HeaderDesc.format.bpp)
|
|
||||||
{
|
|
||||||
case 8:
|
|
||||||
Loader.Format = R8U;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
Loader.Format = RG8U;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
Loader.Format = RGB8U;
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
Loader.Format = RGBA8U;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loader.BlockSize = size(image2D(texture2D::dimensions_type(0), Loader.Format), BLOCK_SIZE);
|
|
||||||
Loader.BPP = size(image2D(image2D::dimensions_type(0), Loader.Format), BIT_PER_PIXEL);
|
|
||||||
|
|
||||||
std::size_t Width = HeaderDesc.width;
|
|
||||||
std::size_t Height = HeaderDesc.height;
|
|
||||||
|
|
||||||
gli::format Format = Loader.Format;
|
|
||||||
|
|
||||||
std::streamoff Curr = FileIn.tellg();
|
|
||||||
FileIn.seekg(0, std::ios_base::end);
|
|
||||||
std::streamoff End = FileIn.tellg();
|
|
||||||
FileIn.seekg(Curr, std::ios_base::beg);
|
|
||||||
|
|
||||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
|
||||||
std::size_t Offset = 0;
|
|
||||||
|
|
||||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
|
||||||
|
|
||||||
//texture2D Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
|
||||||
std::size_t MipMapCount = (HeaderDesc.flags & loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT) ? HeaderDesc.mipMapLevels : 1;
|
|
||||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
|
||||||
// MipMapCount -= 2;
|
|
||||||
texture2D Image(MipMapCount);
|
|
||||||
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
|
|
||||||
{
|
|
||||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
|
||||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
|
||||||
|
|
||||||
std::size_t MipmapSize = 0;
|
|
||||||
if((Loader.BlockSize << 3) > Loader.BPP)
|
|
||||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
|
||||||
else
|
|
||||||
MipmapSize = Width * Height * Loader.BlockSize;
|
|
||||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
|
||||||
|
|
||||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
|
||||||
|
|
||||||
image2D::dimensions_type Dimensions(Width, Height);
|
|
||||||
Image[Level] = image2D(Dimensions, Format, MipmapData);
|
|
||||||
|
|
||||||
Offset += MipmapSize;
|
|
||||||
Width >>= 1;
|
|
||||||
Height >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void saveDDS10
|
|
||||||
(
|
|
||||||
gli::texture2D const & Image,
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
|
||||||
if (!FileOut)
|
|
||||||
return;
|
|
||||||
|
|
||||||
char const * Magic = "DDS ";
|
|
||||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
|
||||||
|
|
||||||
glm::uint32 Caps = loader_dds9::detail::GLI_DDSD_CAPS | loader_dds9::detail::GLI_DDSD_HEIGHT | loader_dds9::detail::GLI_DDSD_WIDTH | loader_dds9::detail::GLI_DDSD_PIXELFORMAT;
|
|
||||||
|
|
||||||
loader_dds9::detail::ddsHeader HeaderDesc;
|
|
||||||
HeaderDesc.size = sizeof(loader_dds9::detail::ddsHeader);
|
|
||||||
HeaderDesc.flags = Caps | (loader_dds9::detail::isCompressed(Image) ? loader_dds9::detail::GLI_DDSD_LINEARSIZE : loader_dds9::detail::GLI_DDSD_PITCH) | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
|
||||||
HeaderDesc.width = Image[0].dimensions().x;
|
|
||||||
HeaderDesc.height = Image[0].dimensions().y;
|
|
||||||
HeaderDesc.pitch = loader_dds9::detail::isCompressed(Image) ? size(Image, LINEAR_SIZE) : 32;
|
|
||||||
HeaderDesc.depth = 0;
|
|
||||||
HeaderDesc.mipMapLevels = glm::uint32(Image.levels());
|
|
||||||
HeaderDesc.format.size = sizeof(loader_dds9::detail::ddsPixelFormat);
|
|
||||||
HeaderDesc.format.flags = loader_dds9::detail::GLI_DDPF_FOURCC;
|
|
||||||
HeaderDesc.format.fourCC = loader_dds9::detail::GLI_FOURCC_DX10;
|
|
||||||
HeaderDesc.format.bpp = size(Image, BIT_PER_PIXEL);
|
|
||||||
HeaderDesc.format.redMask = 0;
|
|
||||||
HeaderDesc.format.greenMask = 0;
|
|
||||||
HeaderDesc.format.blueMask = 0;
|
|
||||||
HeaderDesc.format.alphaMask = 0;
|
|
||||||
HeaderDesc.surfaceFlags = loader_dds9::detail::GLI_DDSCAPS_TEXTURE | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSCAPS_MIPMAP : 0);
|
|
||||||
HeaderDesc.cubemapFlags = 0;
|
|
||||||
FileOut.write((char*)&HeaderDesc, sizeof(HeaderDesc));
|
|
||||||
|
|
||||||
detail::ddsHeader10 HeaderDesc10;
|
|
||||||
HeaderDesc10.arraySize = 1;
|
|
||||||
HeaderDesc10.resourceDimension = detail::D3D10_RESOURCE_DIMENSION_TEXTURE2D;
|
|
||||||
HeaderDesc10.miscFlag = 0;//Image.levels() > 0 ? detail::D3D10_RESOURCE_MISC_GENERATE_MIPS : 0;
|
|
||||||
HeaderDesc10.dxgiFormat = detail::format_gli2dds_cast(Image.format());
|
|
||||||
HeaderDesc10.reserved = 0;
|
|
||||||
|
|
||||||
FileOut.write((char*)&HeaderDesc10, sizeof(HeaderDesc10));
|
|
||||||
|
|
||||||
for(gli::texture2D::level_type Level = 0; Level < Image.levels(); ++Level)
|
|
||||||
{
|
|
||||||
gli::texture2D::size_type ImageSize = size(Image[Level], gli::LINEAR_SIZE);
|
|
||||||
FileOut.write((char*)(Image[Level].data()), ImageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(FileOut.fail() || FileOut.bad())
|
|
||||||
return;
|
|
||||||
|
|
||||||
FileOut.close ();
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace loader_dds10
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-08
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader_dds9.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_LOADER_DDS9_INCLUDED
|
|
||||||
#define GLI_GTX_LOADER_DDS9_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader_dds9
|
|
||||||
{
|
|
||||||
texture2D loadDDS9(
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
void saveDDS9(
|
|
||||||
texture2D const & Texture,
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
void saveTextureCubeDDS9(
|
|
||||||
textureCube const & Texture,
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
}//namespace loader_dds9
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::loader_dds9;}
|
|
||||||
|
|
||||||
#include "loader_dds9.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_LOADER_DDS9_INCLUDED
|
|
||||||
@@ -1,790 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-08
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader_dds9.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader_dds9{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
// DDS Documentation
|
|
||||||
/*
|
|
||||||
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
|
|
||||||
http://msdn.microsoft.com/en-us/library/bb943992.aspx
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
|
||||||
(glm::uint32)( \
|
|
||||||
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
|
|
||||||
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
|
|
||||||
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
|
|
||||||
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
|
|
||||||
|
|
||||||
//enum dds_format
|
|
||||||
//{
|
|
||||||
// GLI_D3DFMT_R8G8B8 = 20,
|
|
||||||
// GLI_D3DFMT_A8R8G8B8 = 21,
|
|
||||||
// GLI_D3DFMT_X8R8G8B8 = 22,
|
|
||||||
// GLI_D3DFMT_A8 = 28,
|
|
||||||
// GLI_D3DFMT_A2B10G10R10 = 31,
|
|
||||||
// GLI_D3DFMT_A8B8G8R8 = 32,
|
|
||||||
// GLI_D3DFMT_X8B8G8R8 = 33,
|
|
||||||
// GLI_D3DFMT_G16R16 = 34,
|
|
||||||
// GLI_D3DFMT_A2R10G10B10 = 35,
|
|
||||||
// GLI_D3DFMT_A16B16G16R16 = 36,
|
|
||||||
|
|
||||||
// GLI_D3DFMT_L8 = 50,
|
|
||||||
// GLI_D3DFMT_A8L8 = 51,
|
|
||||||
|
|
||||||
// GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
|
|
||||||
// GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
|
|
||||||
// GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
|
|
||||||
// GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
|
|
||||||
// GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
|
|
||||||
// GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
|
|
||||||
|
|
||||||
// GLI_D3DFMT_D32 = 71,
|
|
||||||
// GLI_D3DFMT_D24S8 = 75,
|
|
||||||
// GLI_D3DFMT_D24X8 = 77,
|
|
||||||
// GLI_D3DFMT_D16 = 80,
|
|
||||||
// GLI_D3DFMT_L16 = 81,
|
|
||||||
// GLI_D3DFMT_D32F_LOCKABLE = 82,
|
|
||||||
// GLI_D3DFMT_D24FS8 = 83,
|
|
||||||
|
|
||||||
// GLI_D3DFMT_R16F = 111,
|
|
||||||
// GLI_D3DFMT_G16R16F = 112,
|
|
||||||
// GLI_D3DFMT_A16B16G16R16F = 113,
|
|
||||||
|
|
||||||
// GLI_D3DFMT_R32F = 114,
|
|
||||||
// GLI_D3DFMT_G32R32F = 115,
|
|
||||||
// GLI_D3DFMT_A32B32G32R32F = 116
|
|
||||||
//};
|
|
||||||
|
|
||||||
enum ddsCubemapflag
|
|
||||||
{
|
|
||||||
GLI_DDSCAPS2_CUBEMAP = 0x00000200,
|
|
||||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400,
|
|
||||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800,
|
|
||||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000,
|
|
||||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000,
|
|
||||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000,
|
|
||||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000,
|
|
||||||
GLI_DDSCAPS2_VOLUME = 0x00200000
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ddsSurfaceflag
|
|
||||||
{
|
|
||||||
GLI_DDSCAPS_COMPLEX = 0x00000008,
|
|
||||||
GLI_DDSCAPS_MIPMAP = 0x00400000,
|
|
||||||
GLI_DDSCAPS_TEXTURE = 0x00001000
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ddsPixelFormat
|
|
||||||
{
|
|
||||||
glm::uint32 size; // 32
|
|
||||||
glm::uint32 flags;
|
|
||||||
glm::uint32 fourCC;
|
|
||||||
glm::uint32 bpp;
|
|
||||||
glm::uint32 redMask;
|
|
||||||
glm::uint32 greenMask;
|
|
||||||
glm::uint32 blueMask;
|
|
||||||
glm::uint32 alphaMask;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ddsHeader
|
|
||||||
{
|
|
||||||
glm::uint32 size;
|
|
||||||
glm::uint32 flags;
|
|
||||||
glm::uint32 height;
|
|
||||||
glm::uint32 width;
|
|
||||||
glm::uint32 pitch;
|
|
||||||
glm::uint32 depth;
|
|
||||||
glm::uint32 mipMapLevels;
|
|
||||||
glm::uint32 reserved1[11];
|
|
||||||
ddsPixelFormat format;
|
|
||||||
glm::uint32 surfaceFlags;
|
|
||||||
glm::uint32 cubemapFlags;
|
|
||||||
glm::uint32 reserved2[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
glm::uint32 const GLI_D3DFMT_R8G8B8 = 20;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A8R8G8B8 = 21;
|
|
||||||
glm::uint32 const GLI_D3DFMT_X8R8G8B8 = 22;
|
|
||||||
glm::uint32 const GLI_D3DFMT_R5G6B5 = 23;
|
|
||||||
glm::uint32 const GLI_D3DFMT_X1R5G5B5 = 24;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A1R5G5B5 = 25;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A4R4G4B4 = 26;
|
|
||||||
glm::uint32 const GLI_D3DFMT_X4R4G4B4 = 30;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A2B10G10R10 = 31;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A8B8G8R8 = 32;
|
|
||||||
glm::uint32 const GLI_D3DFMT_X8B8G8R8 = 33;
|
|
||||||
glm::uint32 const GLI_D3DFMT_G16R16 = 34;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A2R10G10B10 = 35;
|
|
||||||
glm::uint32 const GLI_D3DFMT_A16B16G16R16 = 36;
|
|
||||||
|
|
||||||
|
|
||||||
glm::uint32 const GLI_FOURCC_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1');
|
|
||||||
glm::uint32 const GLI_FOURCC_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2');
|
|
||||||
glm::uint32 const GLI_FOURCC_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3');
|
|
||||||
glm::uint32 const GLI_FOURCC_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4');
|
|
||||||
glm::uint32 const GLI_FOURCC_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5');
|
|
||||||
glm::uint32 const GLI_FOURCC_ATI1 = GLI_MAKEFOURCC('A', 'T', 'I', '1'); // ATI1
|
|
||||||
glm::uint32 const GLI_FOURCC_ATI2 = GLI_MAKEFOURCC('A', 'T', 'I', '2'); // ATI2 (AKA 3Dc)
|
|
||||||
glm::uint32 const GLI_FOURCC_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0');
|
|
||||||
glm::uint32 const GLI_FOURCC_BC4U = GLI_MAKEFOURCC('B', 'C', '4', 'U');
|
|
||||||
glm::uint32 const GLI_FOURCC_BC4S = GLI_MAKEFOURCC('B', 'C', '4', 'S');
|
|
||||||
glm::uint32 const GLI_FOURCC_BC5U = GLI_MAKEFOURCC('B', 'C', '5', 'U');
|
|
||||||
glm::uint32 const GLI_FOURCC_BC5S = GLI_MAKEFOURCC('B', 'C', '5', 'S');
|
|
||||||
glm::uint32 const GLI_FOURCC_BC6H = GLI_MAKEFOURCC('B', 'C', '6', 'H');
|
|
||||||
glm::uint32 const GLI_FOURCC_BC7 = GLI_MAKEFOURCC('B', 'C', '7', 'U');
|
|
||||||
|
|
||||||
glm::uint32 const GLI_FOURCC_R16F = 0x0000006f; // 16-bit float Red
|
|
||||||
glm::uint32 const GLI_FOURCC_G16R16F = 0x00000070; // 16-bit float Red/Green
|
|
||||||
glm::uint32 const GLI_FOURCC_A16B16G16R16F = 0x00000071; // 16-bit float RGBA
|
|
||||||
glm::uint32 const GLI_FOURCC_R32F = 0x00000072; // 32-bit float Red
|
|
||||||
glm::uint32 const GLI_FOURCC_G32R32F = 0x00000073; // 32-bit float Red/Green
|
|
||||||
glm::uint32 const GLI_FOURCC_A32B32G32R32F = 0x00000074; // 32-bit float RGBA
|
|
||||||
|
|
||||||
glm::uint32 const GLI_DDPF_ALPHAPIXELS = 0x00000001; // The surface has alpha channel information in the pixel format.
|
|
||||||
glm::uint32 const GLI_DDPF_ALPHA = 0x00000002; // The pixel format contains alpha only information
|
|
||||||
glm::uint32 const GLI_DDPF_FOURCC = 0x00000004; // The FourCC code is valid.
|
|
||||||
glm::uint32 const GLI_DDPF_RGB = 0x00000040; // The RGB data in the pixel format structure is valid.
|
|
||||||
//glm::uint32 const GLI_DDPF_COMPRESSED = 0x00000080; // The surface will accept pixel data in the format specified and compress it during the write.
|
|
||||||
//glm::uint32 const GLI_DDPF_RGBTOYUV = 0x00000100; // The surface will accept RGB data and translate it during the write to YUV data.
|
|
||||||
glm::uint32 const GLI_DDPF_YUV = 0x00000200; // Pixel format is YUV - YUV data in pixel format struct is valid.
|
|
||||||
//glm::uint32 const GLI_DDPF_ZBUFFER = 0x00000400; // Pixel format is a z buffer only surface
|
|
||||||
//glm::uint32 const GLI_DDPF_ZPIXELS = 0x00002000; // The surface contains Z information in the pixels
|
|
||||||
//glm::uint32 const GLI_DDPF_STENCILBUFFER = 0x00004000; // The surface contains stencil information along with Z
|
|
||||||
//glm::uint32 const GLI_DDPF_ALPHAPREMULT = 0x00008000; // Premultiplied alpha format -- the color components have been premultiplied by the alpha component.
|
|
||||||
glm::uint32 const GLI_DDPF_LUMINANCE = 0x00020000; // Luminance data in the pixel format is valid.
|
|
||||||
//glm::uint32 const GLI_DDPF_BUMPLUMINANCE = 0x00040000; // Use this flag for luminance-only or luminance+alpha surfaces, the bit depth is then ddpf.dwLuminanceBitCount.
|
|
||||||
//glm::uint32 const GLI_DDPF_BUMPDUDV = 0x00080000; // Bump map dUdV data in the pixel format is valid.
|
|
||||||
|
|
||||||
glm::uint32 const GLI_DDSD_CAPS = 0x00000001;
|
|
||||||
glm::uint32 const GLI_DDSD_HEIGHT = 0x00000002;
|
|
||||||
glm::uint32 const GLI_DDSD_WIDTH = 0x00000004;
|
|
||||||
glm::uint32 const GLI_DDSD_PITCH = 0x00000008;
|
|
||||||
glm::uint32 const GLI_DDSD_PIXELFORMAT = 0x00001000;
|
|
||||||
glm::uint32 const GLI_DDSD_MIPMAPCOUNT = 0x00020000;
|
|
||||||
glm::uint32 const GLI_DDSD_LINEARSIZE = 0x00080000;
|
|
||||||
glm::uint32 const GLI_DDSD_DEPTH = 0x00800000;
|
|
||||||
|
|
||||||
struct DDLoader
|
|
||||||
{
|
|
||||||
glm::uint32 BlockSize;
|
|
||||||
glm::uint32 BPP;
|
|
||||||
gli::format Format;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum format_type
|
|
||||||
{
|
|
||||||
FORMAT_TYPE_NULL,
|
|
||||||
FORMAT_RGBA,
|
|
||||||
FORMAT_FOURCC
|
|
||||||
};
|
|
||||||
|
|
||||||
inline glm::uint32 getFormatFourCC(gli::texture2D const & Image)
|
|
||||||
{
|
|
||||||
switch(Image.format())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
case DXT1:
|
|
||||||
return GLI_FOURCC_DXT1;
|
|
||||||
case DXT3:
|
|
||||||
return GLI_FOURCC_DXT3;
|
|
||||||
case DXT5:
|
|
||||||
return GLI_FOURCC_DXT5;
|
|
||||||
case ATI1N_UNORM:
|
|
||||||
case ATI1N_SNORM:
|
|
||||||
case ATI2N_UNORM:
|
|
||||||
case ATI2N_SNORM:
|
|
||||||
case BP_UF16:
|
|
||||||
case BP_SF16:
|
|
||||||
case BP:
|
|
||||||
return GLI_FOURCC_DX10;
|
|
||||||
case R16F:
|
|
||||||
return GLI_FOURCC_R16F;
|
|
||||||
case RG16F:
|
|
||||||
return GLI_FOURCC_G16R16F;
|
|
||||||
case RGBA16F:
|
|
||||||
return GLI_FOURCC_A16B16G16R16F;
|
|
||||||
case R32F:
|
|
||||||
return GLI_FOURCC_R32F;
|
|
||||||
case RG32F:
|
|
||||||
return GLI_FOURCC_G32R32F;
|
|
||||||
case RGBA32F:
|
|
||||||
return GLI_FOURCC_A32B32G32R32F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline glm::uint32 getFormatBlockSize(gli::texture2D const & Image)
|
|
||||||
{
|
|
||||||
switch(Image.format())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
case DXT1:
|
|
||||||
return 8;
|
|
||||||
case DXT3:
|
|
||||||
return 16;
|
|
||||||
case DXT5:
|
|
||||||
return 16;
|
|
||||||
case ATI1N_UNORM:
|
|
||||||
case ATI1N_SNORM:
|
|
||||||
return 16;
|
|
||||||
case ATI2N_UNORM:
|
|
||||||
case ATI2N_SNORM:
|
|
||||||
return 32;
|
|
||||||
case BP_UF16:
|
|
||||||
case BP_SF16:
|
|
||||||
return 32;
|
|
||||||
case BP:
|
|
||||||
return 32;
|
|
||||||
case R16F:
|
|
||||||
return 2;
|
|
||||||
case RG16F:
|
|
||||||
return 4;
|
|
||||||
case RGBA16F:
|
|
||||||
return 8;
|
|
||||||
case R32F:
|
|
||||||
return 4;
|
|
||||||
case RG32F:
|
|
||||||
return 8;
|
|
||||||
case RGBA32F:
|
|
||||||
return 16;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline glm::uint32 getFormatFlags(gli::texture2D const & Image)
|
|
||||||
{
|
|
||||||
glm::uint32 Result = 0;
|
|
||||||
|
|
||||||
switch(Image.format())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case R8U:
|
|
||||||
case RG8U:
|
|
||||||
case RGB8U:
|
|
||||||
case RGBA8U:
|
|
||||||
case R16U:
|
|
||||||
case RG16U:
|
|
||||||
case RGB16U:
|
|
||||||
case RGBA16U:
|
|
||||||
case R32U:
|
|
||||||
case RG32U:
|
|
||||||
case RGB32U:
|
|
||||||
case RGBA32U:
|
|
||||||
case R8I:
|
|
||||||
case RG8I:
|
|
||||||
case RGB8I:
|
|
||||||
case RGBA8I:
|
|
||||||
case R16I:
|
|
||||||
case RG16I:
|
|
||||||
case RGB16I:
|
|
||||||
case RGBA16I:
|
|
||||||
case R32I:
|
|
||||||
case RG32I:
|
|
||||||
case RGB32I:
|
|
||||||
case RGBA32I:
|
|
||||||
Result |= GLI_DDPF_RGB;
|
|
||||||
break;
|
|
||||||
case R16F:
|
|
||||||
case RG16F:
|
|
||||||
case RGB16F:
|
|
||||||
case RGBA16F:
|
|
||||||
case R32F:
|
|
||||||
case RG32F:
|
|
||||||
case RGB32F:
|
|
||||||
case RGBA32F:
|
|
||||||
case RGBE8:
|
|
||||||
case RGB9E5:
|
|
||||||
case RG11B10F:
|
|
||||||
case R5G6B5:
|
|
||||||
case RGBA4:
|
|
||||||
case RGB10A2:
|
|
||||||
case D16:
|
|
||||||
case D24X8:
|
|
||||||
case D24S8:
|
|
||||||
case D32F:
|
|
||||||
case D32FS8X24:
|
|
||||||
case DXT1:
|
|
||||||
case DXT3:
|
|
||||||
case DXT5:
|
|
||||||
case ATI1N_UNORM:
|
|
||||||
case ATI1N_SNORM:
|
|
||||||
case ATI2N_UNORM:
|
|
||||||
case ATI2N_SNORM:
|
|
||||||
case BP_UF16:
|
|
||||||
case BP_SF16:
|
|
||||||
case BP:
|
|
||||||
Result |= GLI_DDPF_FOURCC;
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline glm::uint32 getFormatBPP(gli::texture2D const & Image)
|
|
||||||
{
|
|
||||||
switch(Image.format())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
case R8U:
|
|
||||||
case R8I:
|
|
||||||
return 8;
|
|
||||||
case RG8U:
|
|
||||||
case RG8I:
|
|
||||||
return 16;
|
|
||||||
case RGB8U:
|
|
||||||
case RGB8I:
|
|
||||||
return 24;
|
|
||||||
case RGBA8U:
|
|
||||||
case RGBA8I:
|
|
||||||
return 32;
|
|
||||||
case DXT1:
|
|
||||||
return 4;
|
|
||||||
case DXT3:
|
|
||||||
return 8;
|
|
||||||
case DXT5:
|
|
||||||
return 8;
|
|
||||||
case ATI1N_UNORM:
|
|
||||||
case ATI1N_SNORM:
|
|
||||||
return 4;
|
|
||||||
case ATI2N_UNORM:
|
|
||||||
case ATI2N_SNORM:
|
|
||||||
return 8;
|
|
||||||
case BP_UF16:
|
|
||||||
case BP_SF16:
|
|
||||||
return 8;
|
|
||||||
case BP:
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool isCompressed(gli::texture2D const & Image)
|
|
||||||
{
|
|
||||||
switch(Image.format())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
case DXT1:
|
|
||||||
case DXT3:
|
|
||||||
case DXT5:
|
|
||||||
case ATI1N_UNORM:
|
|
||||||
case ATI1N_SNORM:
|
|
||||||
case ATI2N_UNORM:
|
|
||||||
case ATI2N_SNORM:
|
|
||||||
case BP_UF16:
|
|
||||||
case BP_SF16:
|
|
||||||
case BP:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace detail
|
|
||||||
|
|
||||||
inline texture2D loadDDS9
|
|
||||||
(
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
|
||||||
if(FileIn.fail())
|
|
||||||
return texture2D();
|
|
||||||
|
|
||||||
detail::ddsHeader SurfaceDesc;
|
|
||||||
char Magic[4];
|
|
||||||
|
|
||||||
//* Read magic number and check if valid .dds file
|
|
||||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
|
||||||
|
|
||||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
|
||||||
|
|
||||||
// Get the surface descriptor
|
|
||||||
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
|
||||||
|
|
||||||
std::size_t Width = SurfaceDesc.width;
|
|
||||||
std::size_t Height = SurfaceDesc.height;
|
|
||||||
|
|
||||||
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
|
|
||||||
|
|
||||||
detail::DDLoader Loader;
|
|
||||||
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
|
|
||||||
{
|
|
||||||
switch(SurfaceDesc.format.fourCC)
|
|
||||||
{
|
|
||||||
case detail::GLI_FOURCC_DX10:
|
|
||||||
assert(0);
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_DXT1:
|
|
||||||
Loader.BlockSize = 8;
|
|
||||||
Loader.Format = DXT1;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_DXT3:
|
|
||||||
Loader.BlockSize = 16;
|
|
||||||
Loader.Format = DXT3;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_DXT5:
|
|
||||||
Loader.BlockSize = 16;
|
|
||||||
Loader.Format = DXT5;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_R16F:
|
|
||||||
Loader.BlockSize = 2;
|
|
||||||
Loader.Format = R16F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_G16R16F:
|
|
||||||
Loader.BlockSize = 4;
|
|
||||||
Loader.Format = RG16F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_A16B16G16R16F:
|
|
||||||
Loader.BlockSize = 8;
|
|
||||||
Loader.Format = RGBA16F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_R32F:
|
|
||||||
Loader.BlockSize = 4;
|
|
||||||
Loader.Format = R32F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_G32R32F:
|
|
||||||
Loader.BlockSize = 8;
|
|
||||||
Loader.Format = RG32F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_A32B32G32R32F:
|
|
||||||
Loader.BlockSize = 16;
|
|
||||||
Loader.Format = RGBA32F;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return texture2D();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
|
|
||||||
{
|
|
||||||
switch(SurfaceDesc.format.bpp)
|
|
||||||
{
|
|
||||||
case 8:
|
|
||||||
Loader.BlockSize = 2;
|
|
||||||
Loader.Format = R8U;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
Loader.BlockSize = 2;
|
|
||||||
Loader.Format = RG8U;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
Loader.BlockSize = 3;
|
|
||||||
Loader.Format = RGB8U;
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
Loader.BlockSize = 4;
|
|
||||||
Loader.Format = RGBA8U;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::format Format = Loader.Format;
|
|
||||||
|
|
||||||
std::streamoff Curr = FileIn.tellg();
|
|
||||||
FileIn.seekg(0, std::ios_base::end);
|
|
||||||
std::streamoff End = FileIn.tellg();
|
|
||||||
FileIn.seekg(Curr, std::ios_base::beg);
|
|
||||||
|
|
||||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
|
||||||
std::size_t Offset = 0;
|
|
||||||
|
|
||||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
|
||||||
|
|
||||||
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
|
||||||
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
|
|
||||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
|
||||||
// MipMapCount -= 2;
|
|
||||||
texture2D Image(MipMapCount);
|
|
||||||
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
|
|
||||||
{
|
|
||||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
|
||||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
|
||||||
|
|
||||||
std::size_t MipmapSize = 0;
|
|
||||||
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
|
||||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
|
||||||
else
|
|
||||||
MipmapSize = Width * Height * Loader.BlockSize;
|
|
||||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
|
||||||
|
|
||||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
|
||||||
|
|
||||||
image2D::dimensions_type Dimensions(Width, Height);
|
|
||||||
Image[Level] = image2D(Dimensions, Format, MipmapData);
|
|
||||||
|
|
||||||
Offset += MipmapSize;
|
|
||||||
Width >>= 1;
|
|
||||||
Height >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline textureCube loadTextureCubeDDS9
|
|
||||||
(
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
|
||||||
if(FileIn.fail())
|
|
||||||
return textureCube();
|
|
||||||
|
|
||||||
detail::ddsHeader SurfaceDesc;
|
|
||||||
char Magic[4];
|
|
||||||
|
|
||||||
//* Read magic number and check if valid .dds file
|
|
||||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
|
||||||
|
|
||||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
|
||||||
|
|
||||||
// Get the surface descriptor
|
|
||||||
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
|
||||||
|
|
||||||
std::size_t Width = SurfaceDesc.width;
|
|
||||||
std::size_t Height = SurfaceDesc.height;
|
|
||||||
|
|
||||||
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
|
|
||||||
|
|
||||||
detail::DDLoader Loader;
|
|
||||||
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
|
|
||||||
{
|
|
||||||
switch(SurfaceDesc.format.fourCC)
|
|
||||||
{
|
|
||||||
case detail::GLI_FOURCC_DX10:
|
|
||||||
assert(0);
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_DXT1:
|
|
||||||
Loader.BlockSize = 8;
|
|
||||||
Loader.Format = DXT1;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_DXT3:
|
|
||||||
Loader.BlockSize = 16;
|
|
||||||
Loader.Format = DXT3;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_DXT5:
|
|
||||||
Loader.BlockSize = 16;
|
|
||||||
Loader.Format = DXT5;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_R16F:
|
|
||||||
Loader.BlockSize = 2;
|
|
||||||
Loader.Format = R16F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_G16R16F:
|
|
||||||
Loader.BlockSize = 4;
|
|
||||||
Loader.Format = RG16F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_A16B16G16R16F:
|
|
||||||
Loader.BlockSize = 8;
|
|
||||||
Loader.Format = RGBA16F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_R32F:
|
|
||||||
Loader.BlockSize = 4;
|
|
||||||
Loader.Format = R32F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_G32R32F:
|
|
||||||
Loader.BlockSize = 8;
|
|
||||||
Loader.Format = RG32F;
|
|
||||||
break;
|
|
||||||
case detail::GLI_FOURCC_A32B32G32R32F:
|
|
||||||
Loader.BlockSize = 16;
|
|
||||||
Loader.Format = RGBA32F;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return textureCube();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
|
|
||||||
{
|
|
||||||
switch(SurfaceDesc.format.bpp)
|
|
||||||
{
|
|
||||||
case 8:
|
|
||||||
Loader.BlockSize = 2;
|
|
||||||
Loader.Format = R8U;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
Loader.BlockSize = 2;
|
|
||||||
Loader.Format = RG8U;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
Loader.BlockSize = 3;
|
|
||||||
Loader.Format = RGB8U;
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
Loader.BlockSize = 4;
|
|
||||||
Loader.Format = RGBA8U;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::format Format = Loader.Format;
|
|
||||||
|
|
||||||
std::streamoff Curr = FileIn.tellg();
|
|
||||||
FileIn.seekg(0, std::ios_base::end);
|
|
||||||
std::streamoff End = FileIn.tellg();
|
|
||||||
FileIn.seekg(Curr, std::ios_base::beg);
|
|
||||||
|
|
||||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
|
||||||
std::size_t Offset = 0;
|
|
||||||
|
|
||||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
|
||||||
|
|
||||||
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
|
||||||
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
|
|
||||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
|
||||||
// MipMapCount -= 2;
|
|
||||||
textureCube Texture(MipMapCount);
|
|
||||||
|
|
||||||
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
|
|
||||||
{
|
|
||||||
Width = SurfaceDesc.width;
|
|
||||||
Height = SurfaceDesc.height;
|
|
||||||
|
|
||||||
for(textureCube::size_type Level = 0; Level < Texture.levels() && (Width || Height); ++Level)
|
|
||||||
{
|
|
||||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
|
||||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
|
||||||
|
|
||||||
std::size_t MipmapSize = 0;
|
|
||||||
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
|
||||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
|
||||||
else
|
|
||||||
MipmapSize = Width * Height * Loader.BlockSize;
|
|
||||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
|
||||||
|
|
||||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
|
||||||
|
|
||||||
textureCube::dimensions_type Dimensions(Width, Height);
|
|
||||||
Texture[textureCube::face_type(Face)][Level] = image2D(Dimensions, Format, MipmapData);
|
|
||||||
|
|
||||||
Offset += MipmapSize;
|
|
||||||
Width >>= 1;
|
|
||||||
Height >>= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void saveDDS9
|
|
||||||
(
|
|
||||||
texture2D const & Texture,
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
|
||||||
if (!FileOut)
|
|
||||||
return;
|
|
||||||
|
|
||||||
char const * Magic = "DDS ";
|
|
||||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
|
||||||
|
|
||||||
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT;
|
|
||||||
|
|
||||||
detail::ddsHeader SurfaceDesc;
|
|
||||||
SurfaceDesc.size = sizeof(detail::ddsHeader);
|
|
||||||
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
|
||||||
SurfaceDesc.width = Texture[0].dimensions().x;
|
|
||||||
SurfaceDesc.height = Texture[0].dimensions().y;
|
|
||||||
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture) ? size(Texture, LINEAR_SIZE) : 32;
|
|
||||||
SurfaceDesc.depth = 0;
|
|
||||||
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
|
|
||||||
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
|
|
||||||
SurfaceDesc.format.flags = detail::getFormatFlags(Texture);
|
|
||||||
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture);
|
|
||||||
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture);
|
|
||||||
SurfaceDesc.format.redMask = 0;
|
|
||||||
SurfaceDesc.format.greenMask = 0;
|
|
||||||
SurfaceDesc.format.blueMask = 0;
|
|
||||||
SurfaceDesc.format.alphaMask = 0;
|
|
||||||
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
|
|
||||||
SurfaceDesc.cubemapFlags = 0;
|
|
||||||
|
|
||||||
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
|
||||||
|
|
||||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
|
||||||
{
|
|
||||||
texture2D::size_type ImageSize = size(Texture[Level], gli::LINEAR_SIZE);
|
|
||||||
FileOut.write((char*)(Texture[Level].data()), ImageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(FileOut.fail() || FileOut.bad())
|
|
||||||
return;
|
|
||||||
|
|
||||||
FileOut.close ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void saveTextureCubeDDS9
|
|
||||||
(
|
|
||||||
textureCube const & Texture,
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
|
||||||
if (!FileOut || Texture.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
char const * Magic = "DDS ";
|
|
||||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
|
||||||
|
|
||||||
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT | detail::GLI_DDSCAPS_COMPLEX;
|
|
||||||
|
|
||||||
detail::ddsHeader SurfaceDesc;
|
|
||||||
SurfaceDesc.size = sizeof(detail::ddsHeader);
|
|
||||||
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture[POSITIVE_X]) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
|
||||||
SurfaceDesc.width = Texture[POSITIVE_X][0].dimensions().x;
|
|
||||||
SurfaceDesc.height = Texture[POSITIVE_X][0].dimensions().y;
|
|
||||||
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture[POSITIVE_X]) ? size(Texture[POSITIVE_X], LINEAR_SIZE) : 32;
|
|
||||||
SurfaceDesc.depth = 0;
|
|
||||||
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
|
|
||||||
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
|
|
||||||
SurfaceDesc.format.flags = detail::getFormatFlags(Texture[POSITIVE_X]);
|
|
||||||
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture[POSITIVE_X]);
|
|
||||||
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture[POSITIVE_X]);
|
|
||||||
SurfaceDesc.format.redMask = 0;
|
|
||||||
SurfaceDesc.format.greenMask = 0;
|
|
||||||
SurfaceDesc.format.blueMask = 0;
|
|
||||||
SurfaceDesc.format.alphaMask = 0;
|
|
||||||
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
|
|
||||||
SurfaceDesc.cubemapFlags =
|
|
||||||
detail::GLI_DDSCAPS2_CUBEMAP | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEX | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEX | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEY | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEY | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEZ | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ;
|
|
||||||
|
|
||||||
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
|
||||||
|
|
||||||
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
|
|
||||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
|
||||||
{
|
|
||||||
texture2D::size_type ImageSize = size(Texture[textureCube::face_type(Face)][Level], gli::LINEAR_SIZE);
|
|
||||||
FileOut.write((char*)(Texture[textureCube::face_type(Face)][Level].data()), ImageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(FileOut.fail() || FileOut.bad())
|
|
||||||
return;
|
|
||||||
|
|
||||||
FileOut.close ();
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace loader_dds9
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-08
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader_tga.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_LOADER_TGA_INCLUDED
|
|
||||||
#define GLI_GTX_LOADER_TGA_INCLUDED
|
|
||||||
|
|
||||||
#include "../gli.hpp"
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader_tga
|
|
||||||
{
|
|
||||||
texture2D loadTGA(
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
void saveTGA(
|
|
||||||
texture2D const & Image,
|
|
||||||
std::string const & Filename);
|
|
||||||
|
|
||||||
}//namespace loader_tga
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::loader_tga;}
|
|
||||||
|
|
||||||
#include "loader_tga.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_LOADER_TGA_INCLUDED
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-08
|
|
||||||
// Updated : 2010-09-27
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/loader_tga.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace loader_tga
|
|
||||||
{
|
|
||||||
inline texture2D loadTGA
|
|
||||||
(
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
|
||||||
if(!FileIn)
|
|
||||||
return texture2D();
|
|
||||||
|
|
||||||
unsigned char IdentificationFieldSize;
|
|
||||||
unsigned char ColorMapType;
|
|
||||||
unsigned char ImageType;
|
|
||||||
unsigned short ColorMapOrigin;
|
|
||||||
unsigned short ColorMapLength;
|
|
||||||
unsigned char ColorMapEntrySize;
|
|
||||||
unsigned short OriginX;
|
|
||||||
unsigned short OriginY;
|
|
||||||
unsigned short Width;
|
|
||||||
unsigned short Height;
|
|
||||||
unsigned char TexelSize;
|
|
||||||
unsigned char Descriptor;
|
|
||||||
|
|
||||||
FileIn.read((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
|
|
||||||
FileIn.read((char*)&ColorMapType, sizeof(ColorMapType));
|
|
||||||
FileIn.read((char*)&ImageType, sizeof(ImageType));
|
|
||||||
FileIn.read((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
|
|
||||||
FileIn.read((char*)&ColorMapLength, sizeof(ColorMapLength));
|
|
||||||
FileIn.read((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
|
|
||||||
FileIn.read((char*)&OriginX, sizeof(OriginX));
|
|
||||||
FileIn.read((char*)&OriginY, sizeof(OriginY));
|
|
||||||
FileIn.read((char*)&Width, sizeof(Width));
|
|
||||||
FileIn.read((char*)&Height, sizeof(Height));
|
|
||||||
FileIn.read((char*)&TexelSize, sizeof(TexelSize));
|
|
||||||
FileIn.read((char*)&Descriptor, sizeof(Descriptor));
|
|
||||||
|
|
||||||
gli::format Format = gli::FORMAT_NULL;
|
|
||||||
if(TexelSize == 24)
|
|
||||||
Format = gli::RGB8U;
|
|
||||||
else if(TexelSize == 32)
|
|
||||||
Format = gli::RGBA8U;
|
|
||||||
else
|
|
||||||
assert(0);
|
|
||||||
|
|
||||||
image2D Mipmap(texture2D::dimensions_type(Width, Height), Format);
|
|
||||||
|
|
||||||
if (FileIn.fail() || FileIn.bad())
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return texture2D();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(ImageType)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return texture2D();
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
FileIn.seekg(18 + ColorMapLength, std::ios::beg);
|
|
||||||
|
|
||||||
char* IdentificationField = new char[IdentificationFieldSize + 1];
|
|
||||||
FileIn.read(IdentificationField, IdentificationFieldSize);
|
|
||||||
IdentificationField[IdentificationFieldSize] = '\0';
|
|
||||||
delete[] IdentificationField;
|
|
||||||
|
|
||||||
std::size_t DataSize = Width * Height * (TexelSize >> 3);
|
|
||||||
FileIn.read((char*)Mipmap.data(), std::streamsize(DataSize));
|
|
||||||
|
|
||||||
if(FileIn.fail() || FileIn.bad())
|
|
||||||
return texture2D();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileIn.close();
|
|
||||||
|
|
||||||
texture2D Image(1);
|
|
||||||
Image[0] = Mipmap;
|
|
||||||
|
|
||||||
// TGA images are saved in BGR or BGRA format.
|
|
||||||
if(TexelSize == 24)
|
|
||||||
Image.swizzle<glm::u8vec3>(gli::B, gli::G, gli::R, gli::A);
|
|
||||||
if(TexelSize == 32)
|
|
||||||
Image.swizzle<glm::u8vec4>(gli::B, gli::G, gli::R, gli::A);
|
|
||||||
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void saveTGA
|
|
||||||
(
|
|
||||||
gli::texture2D const & ImageIn,
|
|
||||||
std::string const & Filename
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
|
||||||
if (!FileOut)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gli::texture2D Image = duplicate(ImageIn);
|
|
||||||
|
|
||||||
unsigned char IdentificationFieldSize = 1;
|
|
||||||
unsigned char ColorMapType = 0;
|
|
||||||
unsigned char ImageType = 2;
|
|
||||||
unsigned short ColorMapOrigin = 0;
|
|
||||||
unsigned short ColorMapLength = 0;
|
|
||||||
unsigned char ColorMapEntrySize = 0;
|
|
||||||
unsigned short OriginX = 0;
|
|
||||||
unsigned short OriginY = 0;
|
|
||||||
unsigned short Width = Image[0].dimensions().x;
|
|
||||||
unsigned short Height = Image[0].dimensions().y;
|
|
||||||
unsigned char TexelSize = (unsigned char)(Image[0].value_size());
|
|
||||||
unsigned char Descriptor = 0;
|
|
||||||
|
|
||||||
if(TexelSize == 24)
|
|
||||||
Image.swizzle<glm::u8vec3>(gli::B, gli::G, gli::R, gli::A);
|
|
||||||
if(TexelSize == 32)
|
|
||||||
Image.swizzle<glm::u8vec4>(gli::B, gli::G, gli::R, gli::A);
|
|
||||||
|
|
||||||
FileOut.write((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
|
|
||||||
FileOut.write((char*)&ColorMapType, sizeof(ColorMapType));
|
|
||||||
FileOut.write((char*)&ImageType, sizeof(ImageType));
|
|
||||||
FileOut.write((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
|
|
||||||
FileOut.write((char*)&ColorMapLength, sizeof(ColorMapLength));
|
|
||||||
FileOut.write((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
|
|
||||||
FileOut.write((char*)&OriginX, sizeof(OriginX));
|
|
||||||
FileOut.write((char*)&OriginY, sizeof(OriginY));
|
|
||||||
FileOut.write((char*)&Width, sizeof(Width));
|
|
||||||
FileOut.write((char*)&Height, sizeof(Height));
|
|
||||||
FileOut.write((char*)&TexelSize, sizeof(TexelSize));
|
|
||||||
FileOut.write((char*)&Descriptor, sizeof(Descriptor));
|
|
||||||
|
|
||||||
if (FileOut.fail () || FileOut.bad ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
FileOut.seekp(18 + ColorMapLength, std::ios::beg);
|
|
||||||
char* IdentificationField = new char[IdentificationFieldSize + 1];
|
|
||||||
FileOut.write(IdentificationField, std::streamsize(IdentificationFieldSize));
|
|
||||||
delete[] IdentificationField;
|
|
||||||
FileOut.write((char*)Image[0].data(), std::streamsize(Image[0].capacity()));
|
|
||||||
if(FileOut.fail() || FileOut.bad())
|
|
||||||
return;
|
|
||||||
|
|
||||||
FileOut.close ();
|
|
||||||
}
|
|
||||||
}//namespace loader_tga
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-01-09
|
|
||||||
// Updated : 2010-01-09
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/wavelet.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLI_GTX_WAVELET_INCLUDED
|
|
||||||
#define GLI_GTX_WAVELET_INCLUDED
|
|
||||||
|
|
||||||
namespace gli{
|
|
||||||
namespace gtx{
|
|
||||||
namespace wavelet
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}//namespace wavelet
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace gli
|
|
||||||
|
|
||||||
namespace gli{using namespace gtx::wavelet;}
|
|
||||||
|
|
||||||
#include "wavelet.inl"
|
|
||||||
|
|
||||||
#endif//GLI_GTX_WAVELET_INCLUDED
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-01-09
|
|
||||||
// Updated : 2010-01-09
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : gli/gtx/wavelet.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="1">
|
|
||||||
<includedir>
|
|
||||||
<dir name="../glm"/>
|
|
||||||
</includedir>
|
|
||||||
</project>
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
glmCreateTestGTC(gtc_constants)
|
|
||||||
glmCreateTestGTC(gtc_epsilon)
|
|
||||||
glmCreateTestGTC(gtc_matrix_access)
|
|
||||||
glmCreateTestGTC(gtc_matrix_integer)
|
|
||||||
glmCreateTestGTC(gtc_matrix_inverse)
|
|
||||||
glmCreateTestGTC(gtc_matrix_transform)
|
|
||||||
glmCreateTestGTC(gtc_noise)
|
|
||||||
glmCreateTestGTC(gtc_packing)
|
|
||||||
glmCreateTestGTC(gtc_quaternion)
|
|
||||||
glmCreateTestGTC(gtc_random)
|
|
||||||
glmCreateTestGTC(gtc_reciprocal)
|
|
||||||
glmCreateTestGTC(gtc_type_precision)
|
|
||||||
glmCreateTestGTC(gtc_type_ptr)
|
|
||||||
glmCreateTestGTC(gtc_ulp)
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2012-09-19
|
|
||||||
// Updated : 2012-12-13
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/constants.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
|
|
||||||
int test_epsilon()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
float Test = glm::epsilon<float>();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
double Test = glm::epsilon<double>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
//float MinHalf = 0.0f;
|
|
||||||
//while (glm::half(MinHalf) == glm::half(0.0f))
|
|
||||||
// MinHalf += std::numeric_limits<float>::epsilon();
|
|
||||||
Error += test_epsilon();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2012-09-19
|
|
||||||
// Updated : 2012-09-19
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/epsilon.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
|
|
||||||
int test_defined()
|
|
||||||
{
|
|
||||||
glm::epsilonEqual(glm::vec2(), glm::vec2(), glm::vec2());
|
|
||||||
glm::epsilonEqual(glm::vec3(), glm::vec3(), glm::vec3());
|
|
||||||
glm::epsilonEqual(glm::vec4(), glm::vec4(), glm::vec4());
|
|
||||||
|
|
||||||
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), glm::vec2());
|
|
||||||
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), glm::vec3());
|
|
||||||
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), glm::vec4());
|
|
||||||
|
|
||||||
glm::epsilonEqual(glm::vec2(), glm::vec2(), 0.0f);
|
|
||||||
glm::epsilonEqual(glm::vec3(), glm::vec3(), 0.0f);
|
|
||||||
glm::epsilonEqual(glm::vec4(), glm::vec4(), 0.0f);
|
|
||||||
glm::epsilonEqual(glm::quat(), glm::quat(), 0.0f);
|
|
||||||
|
|
||||||
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), 0.0f);
|
|
||||||
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), 0.0f);
|
|
||||||
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), 0.0f);
|
|
||||||
glm::epsilonNotEqual(glm::quat(), glm::quat(), 0.0f);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
int test_equal()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
T A = glm::epsilon<T>();
|
|
||||||
T B = glm::epsilon<T>();
|
|
||||||
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
T A(0);
|
|
||||||
T B = static_cast<T>(0) + glm::epsilon<T>();
|
|
||||||
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
T A(0);
|
|
||||||
T B = static_cast<T>(0) - glm::epsilon<T>();
|
|
||||||
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
T A = static_cast<T>(0) + glm::epsilon<T>();
|
|
||||||
T B = static_cast<T>(0);
|
|
||||||
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
T A = static_cast<T>(0) - glm::epsilon<T>();
|
|
||||||
T B = static_cast<T>(0);
|
|
||||||
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += test_defined();
|
|
||||||
Error += test_equal<float>();
|
|
||||||
Error += test_equal<double>();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,391 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2013-05-10
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/matrix_access.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/matrix_access.hpp>
|
|
||||||
#include <glm/mat2x2.hpp>
|
|
||||||
#include <glm/mat2x3.hpp>
|
|
||||||
#include <glm/mat2x4.hpp>
|
|
||||||
#include <glm/mat3x2.hpp>
|
|
||||||
#include <glm/mat3x3.hpp>
|
|
||||||
#include <glm/mat3x4.hpp>
|
|
||||||
#include <glm/mat4x2.hpp>
|
|
||||||
#include <glm/mat4x3.hpp>
|
|
||||||
#include <glm/mat4x4.hpp>
|
|
||||||
|
|
||||||
int test_mat2x2_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat2x2 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec2( 0, 1));
|
|
||||||
m = glm::row(m, 1, glm::vec2( 4, 5));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat2x2_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat2x2 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec2( 0, 1));
|
|
||||||
m = glm::column(m, 1, glm::vec2( 4, 5));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat2x3_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat2x3 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec2( 0, 1));
|
|
||||||
m = glm::row(m, 1, glm::vec2( 4, 5));
|
|
||||||
m = glm::row(m, 2, glm::vec2( 8, 9));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat2x3_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat2x3 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
|
|
||||||
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat2x4_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat2x4 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec2( 0, 1));
|
|
||||||
m = glm::row(m, 1, glm::vec2( 4, 5));
|
|
||||||
m = glm::row(m, 2, glm::vec2( 8, 9));
|
|
||||||
m = glm::row(m, 3, glm::vec2(12, 13));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 3) == glm::vec2(12, 13) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat2x4_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat2x4 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
|
|
||||||
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x2_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat3x2 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
|
|
||||||
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x2_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat3x2 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec2( 0, 1));
|
|
||||||
m = glm::column(m, 1, glm::vec2( 4, 5));
|
|
||||||
m = glm::column(m, 2, glm::vec2( 8, 9));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x3_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat3x3 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
|
|
||||||
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
|
|
||||||
m = glm::row(m, 2, glm::vec3( 8, 9, 10));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x3_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat3x3 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
|
|
||||||
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
|
|
||||||
m = glm::column(m, 2, glm::vec3( 8, 9, 10));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x4_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat3x4 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
|
|
||||||
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
|
|
||||||
m = glm::row(m, 2, glm::vec3( 8, 9, 10));
|
|
||||||
m = glm::row(m, 3, glm::vec3(12, 13, 14));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat3x4_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat3x4 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
|
|
||||||
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
|
|
||||||
m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x2_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4x2 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
|
|
||||||
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x2_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4x2 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec2( 0, 1));
|
|
||||||
m = glm::column(m, 1, glm::vec2( 4, 5));
|
|
||||||
m = glm::column(m, 2, glm::vec2( 8, 9));
|
|
||||||
m = glm::column(m, 3, glm::vec2(12, 13));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 3) == glm::vec2(12, 13) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x3_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4x3 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
|
|
||||||
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
|
|
||||||
m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x3_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4x3 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
|
|
||||||
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
|
|
||||||
m = glm::column(m, 2, glm::vec3( 8, 9, 10));
|
|
||||||
m = glm::column(m, 3, glm::vec3(12, 13, 14));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x4_row_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4 m(1);
|
|
||||||
|
|
||||||
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
|
|
||||||
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
|
|
||||||
m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11));
|
|
||||||
m = glm::row(m, 3, glm::vec4(12, 13, 14, 15));
|
|
||||||
|
|
||||||
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
|
|
||||||
Error += glm::row(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x4_col_set()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4 m(1);
|
|
||||||
|
|
||||||
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
|
|
||||||
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
|
|
||||||
m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11));
|
|
||||||
m = glm::column(m, 3, glm::vec4(12, 13, 14, 15));
|
|
||||||
|
|
||||||
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
|
|
||||||
Error += glm::column(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x4_row_get()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4 m(1);
|
|
||||||
|
|
||||||
glm::vec4 A = glm::row(m, 0);
|
|
||||||
Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1;
|
|
||||||
glm::vec4 B = glm::row(m, 1);
|
|
||||||
Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1;
|
|
||||||
glm::vec4 C = glm::row(m, 2);
|
|
||||||
Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1;
|
|
||||||
glm::vec4 D = glm::row(m, 3);
|
|
||||||
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_mat4x4_col_get()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4 m(1);
|
|
||||||
|
|
||||||
glm::vec4 A = glm::column(m, 0);
|
|
||||||
Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1;
|
|
||||||
glm::vec4 B = glm::column(m, 1);
|
|
||||||
Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1;
|
|
||||||
glm::vec4 C = glm::column(m, 2);
|
|
||||||
Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1;
|
|
||||||
glm::vec4 D = glm::column(m, 3);
|
|
||||||
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_mat2x2_row_set();
|
|
||||||
Error += test_mat2x2_col_set();
|
|
||||||
Error += test_mat2x3_row_set();
|
|
||||||
Error += test_mat2x3_col_set();
|
|
||||||
Error += test_mat2x4_row_set();
|
|
||||||
Error += test_mat2x4_col_set();
|
|
||||||
Error += test_mat3x2_row_set();
|
|
||||||
Error += test_mat3x2_col_set();
|
|
||||||
Error += test_mat3x3_row_set();
|
|
||||||
Error += test_mat3x3_col_set();
|
|
||||||
Error += test_mat3x4_row_set();
|
|
||||||
Error += test_mat3x4_col_set();
|
|
||||||
Error += test_mat4x2_row_set();
|
|
||||||
Error += test_mat4x2_col_set();
|
|
||||||
Error += test_mat4x3_row_set();
|
|
||||||
Error += test_mat4x3_col_set();
|
|
||||||
Error += test_mat4x4_row_set();
|
|
||||||
Error += test_mat4x4_col_set();
|
|
||||||
|
|
||||||
Error += test_mat4x4_row_get();
|
|
||||||
Error += test_mat4x4_col_get();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2010-09-16
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/matrix_integer.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/matrix_integer.hpp>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2010-09-16
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/matrix_inverse.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/matrix_inverse.hpp>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2010-09-16
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/matrix_transform.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
|
||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
|
|
||||||
glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240));
|
|
||||||
|
|
||||||
glm::lowp_vec3 v(1.0);
|
|
||||||
glm::lowp_mat4 m(0);
|
|
||||||
glm::lowp_mat4 t = glm::translate(m, v);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,199 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-04-21
|
|
||||||
// Updated : 2011-04-26
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/noise.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/noise.hpp>
|
|
||||||
#include <gli/gli.hpp>
|
|
||||||
#include <gli/gtx/loader.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int test_simplex()
|
|
||||||
{
|
|
||||||
std::size_t const Size = 256;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_simplex2d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_simplex3d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_simplex4d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_perlin()
|
|
||||||
{
|
|
||||||
std::size_t const Size = 256;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_perlin2d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_perlin3d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_perlin4d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_perlin_pedioric()
|
|
||||||
{
|
|
||||||
std::size_t const Size = 256;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f), glm::vec2(2.0f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_perlin_pedioric_2d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f), glm::vec3(2.0f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_perlin_pedioric_3d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<glm::byte> ImageData(Size * Size * 3);
|
|
||||||
|
|
||||||
for(std::size_t y = 0; y < Size; ++y)
|
|
||||||
for(std::size_t x = 0; x < Size; ++x)
|
|
||||||
{
|
|
||||||
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f), glm::vec4(2.0f)) * 128.f + 127.f);
|
|
||||||
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
gli::texture2D Texture(1);
|
|
||||||
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
|
|
||||||
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
|
|
||||||
gli::saveDDS9(Texture, "texture_perlin_pedioric_4d_256.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_simplex();
|
|
||||||
Error += test_perlin();
|
|
||||||
Error += test_perlin_pedioric();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,267 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// OpenGL Mathematics (glm.g-truc.net)
|
|
||||||
///
|
|
||||||
/// Copyright (c) 2005 - 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 test
|
|
||||||
/// @file test/gtc/packing.cpp
|
|
||||||
/// @date 2013-08-09 / 2013-08-09
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/packing.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void print_bits(float const & s)
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
float f;
|
|
||||||
unsigned int i;
|
|
||||||
} uif;
|
|
||||||
|
|
||||||
uif.f = s;
|
|
||||||
|
|
||||||
printf("f32: ");
|
|
||||||
for(std::size_t j = sizeof(s) * 8; j > 0; --j)
|
|
||||||
{
|
|
||||||
if(j == 23 || j == 31)
|
|
||||||
printf(" ");
|
|
||||||
printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_10bits(glm::uint const & s)
|
|
||||||
{
|
|
||||||
printf("10b: ");
|
|
||||||
for(std::size_t j = 10; j > 0; --j)
|
|
||||||
{
|
|
||||||
if(j == 5)
|
|
||||||
printf(" ");
|
|
||||||
printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_11bits(glm::uint const & s)
|
|
||||||
{
|
|
||||||
printf("11b: ");
|
|
||||||
for(std::size_t j = 11; j > 0; --j)
|
|
||||||
{
|
|
||||||
if(j == 6)
|
|
||||||
printf(" ");
|
|
||||||
printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_value(float const & s)
|
|
||||||
{
|
|
||||||
printf("%2.5f, ", s);
|
|
||||||
print_bits(s);
|
|
||||||
printf(", ");
|
|
||||||
// print_11bits(detail::floatTo11bit(s));
|
|
||||||
// printf(", ");
|
|
||||||
// print_10bits(detail::floatTo10bit(s));
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_Half1x16()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<float> Tests;
|
|
||||||
Tests.push_back(0.0f);
|
|
||||||
Tests.push_back(1.0f);
|
|
||||||
Tests.push_back(-1.0f);
|
|
||||||
Tests.push_back(2.0f);
|
|
||||||
Tests.push_back(-2.0f);
|
|
||||||
Tests.push_back(1.9f);
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
|
|
||||||
float v0 = glm::unpackHalf1x16(p0);
|
|
||||||
glm::uint32 p1 = glm::packHalf1x16(v0);
|
|
||||||
float v1 = glm::unpackHalf1x16(p0);
|
|
||||||
Error += (v0 == v1) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_Half4x16()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec4> Tests;
|
|
||||||
Tests.push_back(glm::vec4(1.0f));
|
|
||||||
Tests.push_back(glm::vec4(0.0f));
|
|
||||||
Tests.push_back(glm::vec4(2.0f));
|
|
||||||
Tests.push_back(glm::vec4(0.1f));
|
|
||||||
Tests.push_back(glm::vec4(0.5f));
|
|
||||||
Tests.push_back(glm::vec4(-0.9f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
|
|
||||||
glm::vec4 v0 = glm::unpackHalf4x16(p0);
|
|
||||||
glm::uint64 p1 = glm::packHalf4x16(v0);
|
|
||||||
glm::vec4 v1 = glm::unpackHalf4x16(p0);
|
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_I3x10_1x2()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::ivec4> Tests;
|
|
||||||
Tests.push_back(glm::ivec4(0));
|
|
||||||
Tests.push_back(glm::ivec4(1));
|
|
||||||
Tests.push_back(glm::ivec4(-1));
|
|
||||||
Tests.push_back(glm::ivec4(2));
|
|
||||||
Tests.push_back(glm::ivec4(-2));
|
|
||||||
Tests.push_back(glm::ivec4(3));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
|
|
||||||
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
|
|
||||||
glm::uint32 p1 = glm::packI3x10_1x2(v0);
|
|
||||||
glm::ivec4 v1 = glm::unpackI3x10_1x2(p0);
|
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_U3x10_1x2()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::uvec4> Tests;
|
|
||||||
Tests.push_back(glm::uvec4(0));
|
|
||||||
Tests.push_back(glm::uvec4(1));
|
|
||||||
Tests.push_back(glm::uvec4(2));
|
|
||||||
Tests.push_back(glm::uvec4(3));
|
|
||||||
Tests.push_back(glm::uvec4(4));
|
|
||||||
Tests.push_back(glm::uvec4(5));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
|
|
||||||
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
|
|
||||||
glm::uint32 p1 = glm::packU3x10_1x2(v0);
|
|
||||||
glm::uvec4 v1 = glm::unpackU3x10_1x2(p0);
|
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_Snorm3x10_1x2()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec4> Tests;
|
|
||||||
Tests.push_back(glm::vec4(1.0f));
|
|
||||||
Tests.push_back(glm::vec4(0.0f));
|
|
||||||
Tests.push_back(glm::vec4(2.0f));
|
|
||||||
Tests.push_back(glm::vec4(0.1f));
|
|
||||||
Tests.push_back(glm::vec4(0.5f));
|
|
||||||
Tests.push_back(glm::vec4(0.9f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
|
|
||||||
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
|
|
||||||
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
|
|
||||||
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0);
|
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_Unorm3x10_1x2()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec4> Tests;
|
|
||||||
Tests.push_back(glm::vec4(1.0f));
|
|
||||||
Tests.push_back(glm::vec4(0.0f));
|
|
||||||
Tests.push_back(glm::vec4(2.0f));
|
|
||||||
Tests.push_back(glm::vec4(0.1f));
|
|
||||||
Tests.push_back(glm::vec4(0.5f));
|
|
||||||
Tests.push_back(glm::vec4(0.9f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
|
|
||||||
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
|
|
||||||
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
|
|
||||||
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0);
|
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_F2x11_1x10()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
std::vector<glm::vec3> Tests;
|
|
||||||
Tests.push_back(glm::vec3(1.0f));
|
|
||||||
Tests.push_back(glm::vec3(0.0f));
|
|
||||||
Tests.push_back(glm::vec3(2.0f));
|
|
||||||
Tests.push_back(glm::vec3(0.1f));
|
|
||||||
Tests.push_back(glm::vec3(0.5f));
|
|
||||||
Tests.push_back(glm::vec3(0.9f));
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
|
||||||
{
|
|
||||||
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
|
|
||||||
glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
|
|
||||||
glm::uint32 p1 = glm::packF2x11_1x10(v0);
|
|
||||||
glm::vec3 v1 = glm::unpackF2x11_1x10(p0);
|
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += test_F2x11_1x10();
|
|
||||||
Error += test_Snorm3x10_1x2();
|
|
||||||
Error += test_Unorm3x10_1x2();
|
|
||||||
Error += test_I3x10_1x2();
|
|
||||||
Error += test_U3x10_1x2();
|
|
||||||
Error += test_Half1x16();
|
|
||||||
Error += test_U3x10_1x2();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2011-05-25
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/quaternion.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/vector_relational.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int test_quat_angle()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
|
||||||
glm::quat N = glm::normalize(Q);
|
|
||||||
float L = glm::length(N);
|
|
||||||
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
|
|
||||||
float A = glm::angle(N);
|
|
||||||
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(0, 1, 1)));
|
|
||||||
glm::quat N = glm::normalize(Q);
|
|
||||||
float L = glm::length(N);
|
|
||||||
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
|
|
||||||
float A = glm::angle(N);
|
|
||||||
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(1, 2, 3)));
|
|
||||||
glm::quat N = glm::normalize(Q);
|
|
||||||
float L = glm::length(N);
|
|
||||||
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
|
|
||||||
float A = glm::angle(N);
|
|
||||||
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_angleAxis()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
|
|
||||||
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
|
|
||||||
glm::quat C = glm::mix(A, B, 0.5f);
|
|
||||||
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_mix()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
|
|
||||||
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
|
|
||||||
glm::quat C = glm::mix(A, B, 0.5f);
|
|
||||||
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_precision()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_quat) <= sizeof(glm::mediump_quat) ? 0 : 1;
|
|
||||||
Error += sizeof(glm::mediump_quat) <= sizeof(glm::highp_quat) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_normalize()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
|
||||||
glm::quat N = glm::normalize(Q);
|
|
||||||
float L = glm::length(N);
|
|
||||||
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 2));
|
|
||||||
glm::quat N = glm::normalize(Q);
|
|
||||||
float L = glm::length(N);
|
|
||||||
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(1, 2, 3));
|
|
||||||
glm::quat N = glm::normalize(Q);
|
|
||||||
float L = glm::length(N);
|
|
||||||
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_euler()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
float Roll = glm::roll(q);
|
|
||||||
float Pitch = glm::pitch(q);
|
|
||||||
float Yaw = glm::yaw(q);
|
|
||||||
glm::vec3 Angles = glm::eulerAngles(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dquat q(1.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
double Roll = glm::roll(q);
|
|
||||||
double Pitch = glm::pitch(q);
|
|
||||||
double Yaw = glm::yaw(q);
|
|
||||||
glm::dvec3 Angles = glm::eulerAngles(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_slerp()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
float const Epsilon = 0.0001f;//glm::epsilon<float>();
|
|
||||||
|
|
||||||
float sqrt2 = sqrt(2.0f)/2.0f;
|
|
||||||
glm::quat id;
|
|
||||||
glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f);
|
|
||||||
glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f);
|
|
||||||
|
|
||||||
// Testing a == 0
|
|
||||||
// Must be id
|
|
||||||
glm::quat id2 = glm::slerp(id, Y90rot, 0.0f);
|
|
||||||
Error += glm::all(glm::epsilonEqual(id, id2, Epsilon)) ? 0 : 1;
|
|
||||||
|
|
||||||
// Testing a == 1
|
|
||||||
// Must be 90° rotation on Y : 0 0.7 0 0.7
|
|
||||||
glm::quat Y90rot2 = glm::slerp(id, Y90rot, 1.0f);
|
|
||||||
Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot2, Epsilon)) ? 0 : 1;
|
|
||||||
|
|
||||||
// Testing standard, easy case
|
|
||||||
// Must be 45° rotation on Y : 0 0.38 0 0.92
|
|
||||||
glm::quat Y45rot1 = glm::slerp(id, Y90rot, 0.5f);
|
|
||||||
|
|
||||||
// Testing reverse case
|
|
||||||
// Must be 45° rotation on Y : 0 0.38 0 0.92
|
|
||||||
glm::quat Ym45rot2 = glm::slerp(Y90rot, id, 0.5f);
|
|
||||||
|
|
||||||
// Testing against full circle around the sphere instead of shortest path
|
|
||||||
// Must be 45° rotation on Y
|
|
||||||
// certainly not a 135° rotation
|
|
||||||
glm::quat Y45rot3 = glm::slerp(id , -Y90rot, 0.5f);
|
|
||||||
float Y45angle3 = glm::angle(Y45rot3);
|
|
||||||
Error += glm::epsilonEqual(Y45angle3, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::epsilonEqual(Ym45rot2, Y45rot3, Epsilon)) ? 0 : 1;
|
|
||||||
|
|
||||||
// Same, but inverted
|
|
||||||
// Must also be 45° rotation on Y : 0 0.38 0 0.92
|
|
||||||
// -0 -0.38 -0 -0.92 is ok too
|
|
||||||
glm::quat Y45rot4 = glm::slerp(-Y90rot, id, 0.5f);
|
|
||||||
Error += glm::all(glm::epsilonEqual(Ym45rot2, -Y45rot4, Epsilon)) ? 0 : 1;
|
|
||||||
|
|
||||||
// Testing q1 = q2
|
|
||||||
// Must be 90° rotation on Y : 0 0.7 0 0.7
|
|
||||||
glm::quat Y90rot3 = glm::slerp(Y90rot, Y90rot, 0.5f);
|
|
||||||
Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot3, Epsilon)) ? 0 : 1;
|
|
||||||
|
|
||||||
// Testing 180° rotation
|
|
||||||
// Must be 90° rotation on almost any axis that is on the XZ plane
|
|
||||||
glm::quat XZ90rot = glm::slerp(id, -Y90rot, 0.5f);
|
|
||||||
float XZ90angle = glm::angle(XZ90rot); // Must be PI/4 = 0.78;
|
|
||||||
Error += glm::epsilonEqual(XZ90angle, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
|
|
||||||
|
|
||||||
// Testing almost equal quaternions (this test should pass through the linear interpolation)
|
|
||||||
// Must be 0 0.00X 0 0.99999
|
|
||||||
glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_mul()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::quat temp1 = glm::normalize(glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0)));
|
|
||||||
glm::quat temp2 = glm::normalize(glm::quat(0.5f, glm::vec3(1.0, 0.0, 0.0)));
|
|
||||||
|
|
||||||
glm::vec3 transformed0 = (temp1 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp1));
|
|
||||||
glm::vec3 temp4 = temp2 * transformed0 * glm::inverse(temp2);
|
|
||||||
|
|
||||||
glm::quat temp5 = glm::normalize(temp1 * temp2);
|
|
||||||
glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::quat temp7;
|
|
||||||
|
|
||||||
temp7 *= temp5;
|
|
||||||
temp7 *= glm::inverse(temp5);
|
|
||||||
|
|
||||||
Error += temp7 != glm::quat();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_two_axis_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
glm::quat q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
|
||||||
glm::vec3 v1 = q1 * glm::vec3(1, 0, 0);
|
|
||||||
Error += glm::all(glm::epsilonEqual(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::quat q2 = q1 * q1;
|
|
||||||
glm::vec3 v2 = q2 * glm::vec3(1, 0, 0);
|
|
||||||
Error += glm::all(glm::epsilonEqual(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_type()
|
|
||||||
{
|
|
||||||
glm::quat A;
|
|
||||||
glm::dquat B;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_quat_ctr()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
# if(GLM_HAS_INITIALIZER_LISTS)
|
|
||||||
{
|
|
||||||
glm::quat A{0, 1, 2, 3};
|
|
||||||
|
|
||||||
std::vector<glm::quat> B{
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{0, 1, 2, 3}};
|
|
||||||
}
|
|
||||||
# endif//GLM_HAS_INITIALIZER_LISTS
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += test_quat_ctr();
|
|
||||||
Error += test_quat_two_axis_ctr();
|
|
||||||
Error += test_quat_mul();
|
|
||||||
Error += test_quat_precision();
|
|
||||||
Error += test_quat_type();
|
|
||||||
Error += test_quat_angle();
|
|
||||||
Error += test_quat_angleAxis();
|
|
||||||
Error += test_quat_mix();
|
|
||||||
Error += test_quat_normalize();
|
|
||||||
Error += test_quat_euler();
|
|
||||||
Error += test_quat_slerp();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-09-19
|
|
||||||
// Updated : 2011-09-19
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/random.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/random.hpp>
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
|
|
||||||
# include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int test_linearRand()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float ResultFloat = 0.0f;
|
|
||||||
double ResultDouble = 0.0f;
|
|
||||||
for(std::size_t i = 0; i < 100000; ++i)
|
|
||||||
{
|
|
||||||
ResultFloat += glm::linearRand(-1.0f, 1.0f);
|
|
||||||
ResultDouble += glm::linearRand(-1.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(ResultFloat, 0.0f, 0.0001f);
|
|
||||||
Error += glm::epsilonEqual(ResultDouble, 0.0, 0.0001);
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_circularRand()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::size_t Max = 100000;
|
|
||||||
float ResultFloat = 0.0f;
|
|
||||||
double ResultDouble = 0.0f;
|
|
||||||
double Radius = 2.0f;
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Max; ++i)
|
|
||||||
{
|
|
||||||
ResultFloat += glm::length(glm::circularRand(1.0f));
|
|
||||||
ResultDouble += glm::length(glm::circularRand(Radius));
|
|
||||||
}
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(ResultFloat, float(Max), 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_sphericalRand()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::size_t Max = 100000;
|
|
||||||
float ResultFloatA = 0.0f;
|
|
||||||
float ResultFloatB = 0.0f;
|
|
||||||
float ResultFloatC = 0.0f;
|
|
||||||
double ResultDoubleA = 0.0f;
|
|
||||||
double ResultDoubleB = 0.0f;
|
|
||||||
double ResultDoubleC = 0.0f;
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Max; ++i)
|
|
||||||
{
|
|
||||||
ResultFloatA += glm::length(glm::sphericalRand(1.0f));
|
|
||||||
ResultDoubleA += glm::length(glm::sphericalRand(1.0));
|
|
||||||
ResultFloatB += glm::length(glm::sphericalRand(2.0f));
|
|
||||||
ResultDoubleB += glm::length(glm::sphericalRand(2.0));
|
|
||||||
ResultFloatC += glm::length(glm::sphericalRand(3.0f));
|
|
||||||
ResultDoubleC += glm::length(glm::sphericalRand(3.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_diskRand()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float ResultFloat = 0.0f;
|
|
||||||
double ResultDouble = 0.0f;
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < 100000; ++i)
|
|
||||||
{
|
|
||||||
ResultFloat += glm::length(glm::diskRand(2.0f));
|
|
||||||
ResultDouble += glm::length(glm::diskRand(2.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
Error += ResultFloat < 200000.f ? 0 : 1;
|
|
||||||
Error += ResultDouble < 200000.0 ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ballRand()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
float ResultFloat = 0.0f;
|
|
||||||
double ResultDouble = 0.0f;
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < 100000; ++i)
|
|
||||||
{
|
|
||||||
ResultFloat += glm::length(glm::ballRand(2.0f));
|
|
||||||
ResultDouble += glm::length(glm::ballRand(2.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
Error += ResultFloat < 200000.f ? 0 : 1;
|
|
||||||
Error += ResultDouble < 200000.0 ? 0 : 1;
|
|
||||||
assert(!Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
|
|
||||||
int test_grid()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
typedef std::array<int, 8> colors;
|
|
||||||
typedef std::array<int, 8 * 8> grid;
|
|
||||||
|
|
||||||
grid Grid;
|
|
||||||
colors Colors;
|
|
||||||
|
|
||||||
grid GridBest;
|
|
||||||
colors ColorsBest;
|
|
||||||
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
for(std::size_t i = 0; i < Grid.size(); ++i)
|
|
||||||
Grid[i] = int(glm::linearRand(0.0, 8.0 * 8.0 * 8.0 - 1.0) / 64.0);
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i < Grid.size(); ++i)
|
|
||||||
++Colors[Grid[i]];
|
|
||||||
|
|
||||||
bool Exit = true;
|
|
||||||
for(std::size_t i = 0; i < Colors.size(); ++i)
|
|
||||||
{
|
|
||||||
if(Colors[i] == 8)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Exit = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Exit == true)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_linearRand();
|
|
||||||
Error += test_circularRand();
|
|
||||||
Error += test_sphericalRand();
|
|
||||||
Error += test_diskRand();
|
|
||||||
Error += test_ballRand();
|
|
||||||
/*
|
|
||||||
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
|
|
||||||
Error += test_grid();
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2012-09-19
|
|
||||||
// Updated : 2012-09-19
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/reciprocal.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/reciprocal.hpp>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,900 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2013-04-16
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/type_precision.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/type_precision.hpp>
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#if GLM_HAS_OPENMP
|
|
||||||
# include <omp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int test_scalar_size()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += sizeof(glm::int8) != 1;
|
|
||||||
Error += sizeof(glm::int16) != 2;
|
|
||||||
Error += sizeof(glm::int32) != 4;
|
|
||||||
Error += sizeof(glm::int64) != 8;
|
|
||||||
Error += sizeof(glm::uint8) != 1;
|
|
||||||
Error += sizeof(glm::uint16) != 2;
|
|
||||||
Error += sizeof(glm::uint32) != 4;
|
|
||||||
Error += sizeof(glm::uint64) != 8;
|
|
||||||
Error += sizeof(glm::float32) != 4;
|
|
||||||
Error += sizeof(glm::float64) != 8;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_int8) != 1;
|
|
||||||
Error += sizeof(glm::lowp_int16) != 2;
|
|
||||||
Error += sizeof(glm::lowp_int32) != 4;
|
|
||||||
Error += sizeof(glm::lowp_int64) != 8;
|
|
||||||
Error += sizeof(glm::lowp_uint8) != 1;
|
|
||||||
Error += sizeof(glm::lowp_uint16) != 2;
|
|
||||||
Error += sizeof(glm::lowp_uint32) != 4;
|
|
||||||
Error += sizeof(glm::lowp_uint64) != 8;
|
|
||||||
Error += sizeof(glm::lowp_float32) != 4;
|
|
||||||
Error += sizeof(glm::lowp_float64) != 8;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_int8) != 1;
|
|
||||||
Error += sizeof(glm::mediump_int16) != 2;
|
|
||||||
Error += sizeof(glm::mediump_int32) != 4;
|
|
||||||
Error += sizeof(glm::mediump_int64) != 8;
|
|
||||||
Error += sizeof(glm::mediump_uint8) != 1;
|
|
||||||
Error += sizeof(glm::mediump_uint16) != 2;
|
|
||||||
Error += sizeof(glm::mediump_uint32) != 4;
|
|
||||||
Error += sizeof(glm::mediump_uint64) != 8;
|
|
||||||
Error += sizeof(glm::mediump_float32) != 4;
|
|
||||||
Error += sizeof(glm::mediump_float64) != 8;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_int8) != 1;
|
|
||||||
Error += sizeof(glm::highp_int16) != 2;
|
|
||||||
Error += sizeof(glm::highp_int32) != 4;
|
|
||||||
Error += sizeof(glm::highp_int64) != 8;
|
|
||||||
Error += sizeof(glm::highp_uint8) != 1;
|
|
||||||
Error += sizeof(glm::highp_uint16) != 2;
|
|
||||||
Error += sizeof(glm::highp_uint32) != 4;
|
|
||||||
Error += sizeof(glm::highp_uint64) != 8;
|
|
||||||
Error += sizeof(glm::highp_float32) != 4;
|
|
||||||
Error += sizeof(glm::highp_float64) != 8;
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_fvec_size()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += sizeof(glm::f32vec2) != 8;
|
|
||||||
Error += sizeof(glm::f32vec3) != 12;
|
|
||||||
Error += sizeof(glm::f32vec4) != 16;
|
|
||||||
Error += sizeof(glm::f64vec2) != 16;
|
|
||||||
Error += sizeof(glm::f64vec3) != 24;
|
|
||||||
Error += sizeof(glm::f64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_f32vec2) != 8;
|
|
||||||
Error += sizeof(glm::lowp_f32vec3) != 12;
|
|
||||||
Error += sizeof(glm::lowp_f32vec4) != 16;
|
|
||||||
Error += sizeof(glm::lowp_f64vec2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_f64vec3) != 24;
|
|
||||||
Error += sizeof(glm::lowp_f64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_f32vec2) != 8;
|
|
||||||
Error += sizeof(glm::mediump_f32vec3) != 12;
|
|
||||||
Error += sizeof(glm::mediump_f32vec4) != 16;
|
|
||||||
Error += sizeof(glm::mediump_f64vec2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_f64vec3) != 24;
|
|
||||||
Error += sizeof(glm::mediump_f64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_f32vec2) != 8;
|
|
||||||
Error += sizeof(glm::highp_f32vec3) != 12;
|
|
||||||
Error += sizeof(glm::highp_f32vec4) != 16;
|
|
||||||
Error += sizeof(glm::highp_f64vec2) != 16;
|
|
||||||
Error += sizeof(glm::highp_f64vec3) != 24;
|
|
||||||
Error += sizeof(glm::highp_f64vec4) != 32;
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_fvec_precision()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
glm::f32vec2 v1;
|
|
||||||
glm::lowp_f32vec2 v2((glm::f32vec2(v1)));
|
|
||||||
glm::mediump_f32vec2 v3((glm::f32vec2(v1)));
|
|
||||||
glm::highp_f32vec2 v4((glm::f32vec2(v1)));
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, v4)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
glm::f32vec2 v1;
|
|
||||||
glm::lowp_f32vec2 v2(v1);
|
|
||||||
glm::mediump_f32vec2 v3(v1);
|
|
||||||
glm::highp_f32vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::f32vec3 v1;
|
|
||||||
glm::lowp_f32vec3 v2(v1);
|
|
||||||
glm::mediump_f32vec3 v3(v1);
|
|
||||||
glm::highp_f32vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::f32vec4 v1;
|
|
||||||
glm::lowp_f32vec4 v2(v1);
|
|
||||||
glm::mediump_f32vec4 v3(v1);
|
|
||||||
glm::highp_f32vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f32vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_dvec_precision()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::f64vec2 v1;
|
|
||||||
glm::lowp_f64vec2 v2(v1);
|
|
||||||
glm::mediump_f64vec2 v3(v1);
|
|
||||||
glm::highp_f64vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::f64vec3 v1;
|
|
||||||
glm::lowp_f64vec3 v2(v1);
|
|
||||||
glm::mediump_f64vec3 v3(v1);
|
|
||||||
glm::highp_f64vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::f64vec4 v1;
|
|
||||||
glm::lowp_f64vec4 v2(v1);
|
|
||||||
glm::mediump_f64vec4 v3(v1);
|
|
||||||
glm::highp_f64vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::f64vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_ivec_size()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += sizeof(glm::i8vec2) != 2;
|
|
||||||
Error += sizeof(glm::i8vec3) != 3;
|
|
||||||
Error += sizeof(glm::i8vec4) != 4;
|
|
||||||
Error += sizeof(glm::i16vec2) != 4;
|
|
||||||
Error += sizeof(glm::i16vec3) != 6;
|
|
||||||
Error += sizeof(glm::i16vec4) != 8;
|
|
||||||
Error += sizeof(glm::i32vec2) != 8;
|
|
||||||
Error += sizeof(glm::i32vec3) != 12;
|
|
||||||
Error += sizeof(glm::i32vec4) != 16;
|
|
||||||
Error += sizeof(glm::i64vec2) != 16;
|
|
||||||
Error += sizeof(glm::i64vec3) != 24;
|
|
||||||
Error += sizeof(glm::i64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_i8vec2) != 2;
|
|
||||||
Error += sizeof(glm::lowp_i8vec3) != 3;
|
|
||||||
Error += sizeof(glm::lowp_i8vec4) != 4;
|
|
||||||
Error += sizeof(glm::lowp_i16vec2) != 4;
|
|
||||||
Error += sizeof(glm::lowp_i16vec3) != 6;
|
|
||||||
Error += sizeof(glm::lowp_i16vec4) != 8;
|
|
||||||
Error += sizeof(glm::lowp_i32vec2) != 8;
|
|
||||||
Error += sizeof(glm::lowp_i32vec3) != 12;
|
|
||||||
Error += sizeof(glm::lowp_i32vec4) != 16;
|
|
||||||
Error += sizeof(glm::lowp_i64vec2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_i64vec3) != 24;
|
|
||||||
Error += sizeof(glm::lowp_i64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_i8vec2) != 2;
|
|
||||||
Error += sizeof(glm::mediump_i8vec3) != 3;
|
|
||||||
Error += sizeof(glm::mediump_i8vec4) != 4;
|
|
||||||
Error += sizeof(glm::mediump_i16vec2) != 4;
|
|
||||||
Error += sizeof(glm::mediump_i16vec3) != 6;
|
|
||||||
Error += sizeof(glm::mediump_i16vec4) != 8;
|
|
||||||
Error += sizeof(glm::mediump_i32vec2) != 8;
|
|
||||||
Error += sizeof(glm::mediump_i32vec3) != 12;
|
|
||||||
Error += sizeof(glm::mediump_i32vec4) != 16;
|
|
||||||
Error += sizeof(glm::mediump_i64vec2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_i64vec3) != 24;
|
|
||||||
Error += sizeof(glm::mediump_i64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_i8vec2) != 2;
|
|
||||||
Error += sizeof(glm::highp_i8vec3) != 3;
|
|
||||||
Error += sizeof(glm::highp_i8vec4) != 4;
|
|
||||||
Error += sizeof(glm::highp_i16vec2) != 4;
|
|
||||||
Error += sizeof(glm::highp_i16vec3) != 6;
|
|
||||||
Error += sizeof(glm::highp_i16vec4) != 8;
|
|
||||||
Error += sizeof(glm::highp_i32vec2) != 8;
|
|
||||||
Error += sizeof(glm::highp_i32vec3) != 12;
|
|
||||||
Error += sizeof(glm::highp_i32vec4) != 16;
|
|
||||||
Error += sizeof(glm::highp_i64vec2) != 16;
|
|
||||||
Error += sizeof(glm::highp_i64vec3) != 24;
|
|
||||||
Error += sizeof(glm::highp_i64vec4) != 32;
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_ivec_precision()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i8vec2 v1;
|
|
||||||
glm::lowp_i8vec2 v2(v1);
|
|
||||||
glm::mediump_i8vec2 v3(v1);
|
|
||||||
glm::highp_i8vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i8vec3 v1;
|
|
||||||
glm::lowp_i8vec3 v2(v1);
|
|
||||||
glm::mediump_i8vec3 v3(v1);
|
|
||||||
glm::highp_i8vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i8vec4 v1;
|
|
||||||
glm::lowp_i8vec4 v2(v1);
|
|
||||||
glm::mediump_i8vec4 v3(v1);
|
|
||||||
glm::highp_i8vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i8vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i16vec2 v1;
|
|
||||||
glm::lowp_i16vec2 v2(v1);
|
|
||||||
glm::mediump_i16vec2 v3(v1);
|
|
||||||
glm::highp_i16vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i16vec3 v1;
|
|
||||||
glm::lowp_i16vec3 v2(v1);
|
|
||||||
glm::mediump_i16vec3 v3(v1);
|
|
||||||
glm::highp_i16vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i16vec4 v1;
|
|
||||||
glm::lowp_i16vec4 v2(v1);
|
|
||||||
glm::mediump_i16vec4 v3(v1);
|
|
||||||
glm::highp_i16vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i16vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i32vec2 v1;
|
|
||||||
glm::lowp_i32vec2 v2(v1);
|
|
||||||
glm::mediump_i32vec2 v3(v1);
|
|
||||||
glm::highp_i32vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i32vec3 v1;
|
|
||||||
glm::lowp_i32vec3 v2(v1);
|
|
||||||
glm::mediump_i32vec3 v3(v1);
|
|
||||||
glm::highp_i32vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i32vec4 v1;
|
|
||||||
glm::lowp_i32vec4 v2(v1);
|
|
||||||
glm::mediump_i32vec4 v3(v1);
|
|
||||||
glm::highp_i32vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i32vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i64vec2 v1;
|
|
||||||
glm::lowp_i64vec2 v2(v1);
|
|
||||||
glm::mediump_i64vec2 v3(v1);
|
|
||||||
glm::highp_i64vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i64vec3 v1;
|
|
||||||
glm::lowp_i64vec3 v2(v1);
|
|
||||||
glm::mediump_i64vec3 v3(v1);
|
|
||||||
glm::highp_i64vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::i64vec4 v1;
|
|
||||||
glm::lowp_i64vec4 v2(v1);
|
|
||||||
glm::mediump_i64vec4 v3(v1);
|
|
||||||
glm::highp_i64vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::i64vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_uvec_size()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += sizeof(glm::u8vec2) != 2;
|
|
||||||
Error += sizeof(glm::u8vec3) != 3;
|
|
||||||
Error += sizeof(glm::u8vec4) != 4;
|
|
||||||
Error += sizeof(glm::u16vec2) != 4;
|
|
||||||
Error += sizeof(glm::u16vec3) != 6;
|
|
||||||
Error += sizeof(glm::u16vec4) != 8;
|
|
||||||
Error += sizeof(glm::u32vec2) != 8;
|
|
||||||
Error += sizeof(glm::u32vec3) != 12;
|
|
||||||
Error += sizeof(glm::u32vec4) != 16;
|
|
||||||
Error += sizeof(glm::u64vec2) != 16;
|
|
||||||
Error += sizeof(glm::u64vec3) != 24;
|
|
||||||
Error += sizeof(glm::u64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_u8vec2) != 2;
|
|
||||||
Error += sizeof(glm::lowp_u8vec3) != 3;
|
|
||||||
Error += sizeof(glm::lowp_u8vec4) != 4;
|
|
||||||
Error += sizeof(glm::lowp_u16vec2) != 4;
|
|
||||||
Error += sizeof(glm::lowp_u16vec3) != 6;
|
|
||||||
Error += sizeof(glm::lowp_u16vec4) != 8;
|
|
||||||
Error += sizeof(glm::lowp_u32vec2) != 8;
|
|
||||||
Error += sizeof(glm::lowp_u32vec3) != 12;
|
|
||||||
Error += sizeof(glm::lowp_u32vec4) != 16;
|
|
||||||
Error += sizeof(glm::lowp_u64vec2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_u64vec3) != 24;
|
|
||||||
Error += sizeof(glm::lowp_u64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_u8vec2) != 2;
|
|
||||||
Error += sizeof(glm::mediump_u8vec3) != 3;
|
|
||||||
Error += sizeof(glm::mediump_u8vec4) != 4;
|
|
||||||
Error += sizeof(glm::mediump_u16vec2) != 4;
|
|
||||||
Error += sizeof(glm::mediump_u16vec3) != 6;
|
|
||||||
Error += sizeof(glm::mediump_u16vec4) != 8;
|
|
||||||
Error += sizeof(glm::mediump_u32vec2) != 8;
|
|
||||||
Error += sizeof(glm::mediump_u32vec3) != 12;
|
|
||||||
Error += sizeof(glm::mediump_u32vec4) != 16;
|
|
||||||
Error += sizeof(glm::mediump_u64vec2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_u64vec3) != 24;
|
|
||||||
Error += sizeof(glm::mediump_u64vec4) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_u8vec2) != 2;
|
|
||||||
Error += sizeof(glm::highp_u8vec3) != 3;
|
|
||||||
Error += sizeof(glm::highp_u8vec4) != 4;
|
|
||||||
Error += sizeof(glm::highp_u16vec2) != 4;
|
|
||||||
Error += sizeof(glm::highp_u16vec3) != 6;
|
|
||||||
Error += sizeof(glm::highp_u16vec4) != 8;
|
|
||||||
Error += sizeof(glm::highp_u32vec2) != 8;
|
|
||||||
Error += sizeof(glm::highp_u32vec3) != 12;
|
|
||||||
Error += sizeof(glm::highp_u32vec4) != 16;
|
|
||||||
Error += sizeof(glm::highp_u64vec2) != 16;
|
|
||||||
Error += sizeof(glm::highp_u64vec3) != 24;
|
|
||||||
Error += sizeof(glm::highp_u64vec4) != 32;
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_uvec_precision()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u8vec2 v1;
|
|
||||||
glm::lowp_u8vec2 v2(v1);
|
|
||||||
glm::mediump_u8vec2 v3(v1);
|
|
||||||
glm::highp_u8vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u8vec3 v1;
|
|
||||||
glm::lowp_u8vec3 v2(v1);
|
|
||||||
glm::mediump_u8vec3 v3(v1);
|
|
||||||
glm::highp_u8vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u8vec4 v1;
|
|
||||||
glm::lowp_u8vec4 v2(v1);
|
|
||||||
glm::mediump_u8vec4 v3(v1);
|
|
||||||
glm::highp_u8vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u8vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u16vec2 v1;
|
|
||||||
glm::lowp_u16vec2 v2(v1);
|
|
||||||
glm::mediump_u16vec2 v3(v1);
|
|
||||||
glm::highp_u16vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u16vec3 v1;
|
|
||||||
glm::lowp_u16vec3 v2(v1);
|
|
||||||
glm::mediump_u16vec3 v3(v1);
|
|
||||||
glm::highp_u16vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u16vec4 v1;
|
|
||||||
glm::lowp_u16vec4 v2(v1);
|
|
||||||
glm::mediump_u16vec4 v3(v1);
|
|
||||||
glm::highp_u16vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u16vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u32vec2 v1;
|
|
||||||
glm::lowp_u32vec2 v2(v1);
|
|
||||||
glm::mediump_u32vec2 v3(v1);
|
|
||||||
glm::highp_u32vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u32vec3 v1;
|
|
||||||
glm::lowp_u32vec3 v2(v1);
|
|
||||||
glm::mediump_u32vec3 v3(v1);
|
|
||||||
glm::highp_u32vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u32vec4 v1;
|
|
||||||
glm::lowp_u32vec4 v2(v1);
|
|
||||||
glm::mediump_u32vec4 v3(v1);
|
|
||||||
glm::highp_u32vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u32vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u64vec2 v1;
|
|
||||||
glm::lowp_u64vec2 v2(v1);
|
|
||||||
glm::mediump_u64vec2 v3(v1);
|
|
||||||
glm::highp_u64vec2 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec2(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec2(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec2(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u64vec3 v1;
|
|
||||||
glm::lowp_u64vec3 v2(v1);
|
|
||||||
glm::mediump_u64vec3 v3(v1);
|
|
||||||
glm::highp_u64vec3 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec3(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec3(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec3(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::u64vec4 v1;
|
|
||||||
glm::lowp_u64vec4 v2(v1);
|
|
||||||
glm::mediump_u64vec4 v3(v1);
|
|
||||||
glm::highp_u64vec4 v4(v1);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec4(v2))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec4(v3))) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(v1, glm::u64vec4(v4))) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_fmat_size()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += sizeof(glm::mat2) != 16;
|
|
||||||
Error += sizeof(glm::mat3) != 36;
|
|
||||||
Error += sizeof(glm::mat4) != 64;
|
|
||||||
Error += sizeof(glm::mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::mat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::fmat2) != 16;
|
|
||||||
Error += sizeof(glm::fmat3) != 36;
|
|
||||||
Error += sizeof(glm::fmat4) != 64;
|
|
||||||
Error += sizeof(glm::fmat2x2) != 16;
|
|
||||||
Error += sizeof(glm::fmat2x3) != 24;
|
|
||||||
Error += sizeof(glm::fmat2x4) != 32;
|
|
||||||
Error += sizeof(glm::fmat3x2) != 24;
|
|
||||||
Error += sizeof(glm::fmat3x3) != 36;
|
|
||||||
Error += sizeof(glm::fmat3x4) != 48;
|
|
||||||
Error += sizeof(glm::fmat4x2) != 32;
|
|
||||||
Error += sizeof(glm::fmat4x3) != 48;
|
|
||||||
Error += sizeof(glm::fmat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::f32mat2) != 16;
|
|
||||||
Error += sizeof(glm::f32mat3) != 36;
|
|
||||||
Error += sizeof(glm::f32mat4) != 64;
|
|
||||||
Error += sizeof(glm::f32mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::f32mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::f32mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::f32mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::f32mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::f32mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::f32mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::f32mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::f32mat4x4) != 64;
|
|
||||||
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_mat2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_mat3) != 36;
|
|
||||||
Error += sizeof(glm::lowp_mat4) != 64;
|
|
||||||
Error += sizeof(glm::lowp_mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::lowp_mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::lowp_mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::lowp_mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::lowp_mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::lowp_mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::lowp_mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::lowp_mat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_fmat2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_fmat3) != 36;
|
|
||||||
Error += sizeof(glm::lowp_fmat4) != 64;
|
|
||||||
Error += sizeof(glm::lowp_fmat2x2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_fmat2x3) != 24;
|
|
||||||
Error += sizeof(glm::lowp_fmat2x4) != 32;
|
|
||||||
Error += sizeof(glm::lowp_fmat3x2) != 24;
|
|
||||||
Error += sizeof(glm::lowp_fmat3x3) != 36;
|
|
||||||
Error += sizeof(glm::lowp_fmat3x4) != 48;
|
|
||||||
Error += sizeof(glm::lowp_fmat4x2) != 32;
|
|
||||||
Error += sizeof(glm::lowp_fmat4x3) != 48;
|
|
||||||
Error += sizeof(glm::lowp_fmat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_f32mat2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_f32mat3) != 36;
|
|
||||||
Error += sizeof(glm::lowp_f32mat4) != 64;
|
|
||||||
Error += sizeof(glm::lowp_f32mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::lowp_f32mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::lowp_f32mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::lowp_f32mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::lowp_f32mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::lowp_f32mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::lowp_f32mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::lowp_f32mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::lowp_f32mat4x4) != 64;
|
|
||||||
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_mat2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_mat3) != 36;
|
|
||||||
Error += sizeof(glm::mediump_mat4) != 64;
|
|
||||||
Error += sizeof(glm::mediump_mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::mediump_mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::mediump_mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::mediump_mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::mediump_mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::mediump_mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::mediump_mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::mediump_mat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_fmat2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_fmat3) != 36;
|
|
||||||
Error += sizeof(glm::mediump_fmat4) != 64;
|
|
||||||
Error += sizeof(glm::mediump_fmat2x2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_fmat2x3) != 24;
|
|
||||||
Error += sizeof(glm::mediump_fmat2x4) != 32;
|
|
||||||
Error += sizeof(glm::mediump_fmat3x2) != 24;
|
|
||||||
Error += sizeof(glm::mediump_fmat3x3) != 36;
|
|
||||||
Error += sizeof(glm::mediump_fmat3x4) != 48;
|
|
||||||
Error += sizeof(glm::mediump_fmat4x2) != 32;
|
|
||||||
Error += sizeof(glm::mediump_fmat4x3) != 48;
|
|
||||||
Error += sizeof(glm::mediump_fmat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_f32mat2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_f32mat3) != 36;
|
|
||||||
Error += sizeof(glm::mediump_f32mat4) != 64;
|
|
||||||
Error += sizeof(glm::mediump_f32mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::mediump_f32mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::mediump_f32mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::mediump_f32mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::mediump_f32mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::mediump_f32mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::mediump_f32mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::mediump_f32mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::mediump_f32mat4x4) != 64;
|
|
||||||
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_mat2) != 16;
|
|
||||||
Error += sizeof(glm::highp_mat3) != 36;
|
|
||||||
Error += sizeof(glm::highp_mat4) != 64;
|
|
||||||
Error += sizeof(glm::highp_mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::highp_mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::highp_mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::highp_mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::highp_mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::highp_mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::highp_mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::highp_mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::highp_mat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_fmat2) != 16;
|
|
||||||
Error += sizeof(glm::highp_fmat3) != 36;
|
|
||||||
Error += sizeof(glm::highp_fmat4) != 64;
|
|
||||||
Error += sizeof(glm::highp_fmat2x2) != 16;
|
|
||||||
Error += sizeof(glm::highp_fmat2x3) != 24;
|
|
||||||
Error += sizeof(glm::highp_fmat2x4) != 32;
|
|
||||||
Error += sizeof(glm::highp_fmat3x2) != 24;
|
|
||||||
Error += sizeof(glm::highp_fmat3x3) != 36;
|
|
||||||
Error += sizeof(glm::highp_fmat3x4) != 48;
|
|
||||||
Error += sizeof(glm::highp_fmat4x2) != 32;
|
|
||||||
Error += sizeof(glm::highp_fmat4x3) != 48;
|
|
||||||
Error += sizeof(glm::highp_fmat4x4) != 64;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_f32mat2) != 16;
|
|
||||||
Error += sizeof(glm::highp_f32mat3) != 36;
|
|
||||||
Error += sizeof(glm::highp_f32mat4) != 64;
|
|
||||||
Error += sizeof(glm::highp_f32mat2x2) != 16;
|
|
||||||
Error += sizeof(glm::highp_f32mat2x3) != 24;
|
|
||||||
Error += sizeof(glm::highp_f32mat2x4) != 32;
|
|
||||||
Error += sizeof(glm::highp_f32mat3x2) != 24;
|
|
||||||
Error += sizeof(glm::highp_f32mat3x3) != 36;
|
|
||||||
Error += sizeof(glm::highp_f32mat3x4) != 48;
|
|
||||||
Error += sizeof(glm::highp_f32mat4x2) != 32;
|
|
||||||
Error += sizeof(glm::highp_f32mat4x3) != 48;
|
|
||||||
Error += sizeof(glm::highp_f32mat4x4) != 64;
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_dmat_size()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += sizeof(glm::f64mat2) != 32;
|
|
||||||
Error += sizeof(glm::f64mat3) != 72;
|
|
||||||
Error += sizeof(glm::f64mat4) != 128;
|
|
||||||
Error += sizeof(glm::f64mat2x2) != 32;
|
|
||||||
Error += sizeof(glm::f64mat2x3) != 48;
|
|
||||||
Error += sizeof(glm::f64mat2x4) != 64;
|
|
||||||
Error += sizeof(glm::f64mat3x2) != 48;
|
|
||||||
Error += sizeof(glm::f64mat3x3) != 72;
|
|
||||||
Error += sizeof(glm::f64mat3x4) != 96;
|
|
||||||
Error += sizeof(glm::f64mat4x2) != 64;
|
|
||||||
Error += sizeof(glm::f64mat4x3) != 96;
|
|
||||||
Error += sizeof(glm::f64mat4x4) != 128;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_f64mat2) != 32;
|
|
||||||
Error += sizeof(glm::lowp_f64mat3) != 72;
|
|
||||||
Error += sizeof(glm::lowp_f64mat4) != 128;
|
|
||||||
Error += sizeof(glm::lowp_f64mat2x2) != 32;
|
|
||||||
Error += sizeof(glm::lowp_f64mat2x3) != 48;
|
|
||||||
Error += sizeof(glm::lowp_f64mat2x4) != 64;
|
|
||||||
Error += sizeof(glm::lowp_f64mat3x2) != 48;
|
|
||||||
Error += sizeof(glm::lowp_f64mat3x3) != 72;
|
|
||||||
Error += sizeof(glm::lowp_f64mat3x4) != 96;
|
|
||||||
Error += sizeof(glm::lowp_f64mat4x2) != 64;
|
|
||||||
Error += sizeof(glm::lowp_f64mat4x3) != 96;
|
|
||||||
Error += sizeof(glm::lowp_f64mat4x4) != 128;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_f64mat2) != 32;
|
|
||||||
Error += sizeof(glm::mediump_f64mat3) != 72;
|
|
||||||
Error += sizeof(glm::mediump_f64mat4) != 128;
|
|
||||||
Error += sizeof(glm::mediump_f64mat2x2) != 32;
|
|
||||||
Error += sizeof(glm::mediump_f64mat2x3) != 48;
|
|
||||||
Error += sizeof(glm::mediump_f64mat2x4) != 64;
|
|
||||||
Error += sizeof(glm::mediump_f64mat3x2) != 48;
|
|
||||||
Error += sizeof(glm::mediump_f64mat3x3) != 72;
|
|
||||||
Error += sizeof(glm::mediump_f64mat3x4) != 96;
|
|
||||||
Error += sizeof(glm::mediump_f64mat4x2) != 64;
|
|
||||||
Error += sizeof(glm::mediump_f64mat4x3) != 96;
|
|
||||||
Error += sizeof(glm::mediump_f64mat4x4) != 128;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_f64mat2) != 32;
|
|
||||||
Error += sizeof(glm::highp_f64mat3) != 72;
|
|
||||||
Error += sizeof(glm::highp_f64mat4) != 128;
|
|
||||||
Error += sizeof(glm::highp_f64mat2x2) != 32;
|
|
||||||
Error += sizeof(glm::highp_f64mat2x3) != 48;
|
|
||||||
Error += sizeof(glm::highp_f64mat2x4) != 64;
|
|
||||||
Error += sizeof(glm::highp_f64mat3x2) != 48;
|
|
||||||
Error += sizeof(glm::highp_f64mat3x3) != 72;
|
|
||||||
Error += sizeof(glm::highp_f64mat3x4) != 96;
|
|
||||||
Error += sizeof(glm::highp_f64mat4x2) != 64;
|
|
||||||
Error += sizeof(glm::highp_f64mat4x3) != 96;
|
|
||||||
Error += sizeof(glm::highp_f64mat4x4) != 128;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_quat_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
Error += sizeof(glm::f32quat) != 16;
|
|
||||||
Error += sizeof(glm::f64quat) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::lowp_f32quat) != 16;
|
|
||||||
Error += sizeof(glm::lowp_f64quat) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::mediump_f32quat) != 16;
|
|
||||||
Error += sizeof(glm::mediump_f64quat) != 32;
|
|
||||||
|
|
||||||
Error += sizeof(glm::highp_f32quat) != 16;
|
|
||||||
Error += sizeof(glm::highp_f64quat) != 32;
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_quat_precision()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::f32quat q1;
|
|
||||||
glm::lowp_f32quat qA(q1);
|
|
||||||
glm::mediump_f32quat qB(q1);
|
|
||||||
glm::highp_f32quat qC(q1);
|
|
||||||
glm::f32quat q2(qA);
|
|
||||||
glm::f32quat q3(qB);
|
|
||||||
glm::f32quat q4(qC);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(q1, q2)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(q1, q3)) ? 0 : 1;
|
|
||||||
Error += glm::all(glm::equal(q1, q4)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_fvec_conversion()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::highp_vec4 a = glm::vec4(1, 2, 3, 4);
|
|
||||||
glm::mediump_vec4 b = glm::vec4(1, 2, 3, 4);
|
|
||||||
glm::lowp_vec4 c = b;
|
|
||||||
glm::mediump_vec4 d = c;
|
|
||||||
glm::lowp_ivec4 e = glm::ivec4(d);
|
|
||||||
glm::lowp_ivec3 f = glm::ivec3(e);
|
|
||||||
|
|
||||||
Error += glm::all(glm::equal(b, d)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_openmp()
|
|
||||||
{
|
|
||||||
std::vector<glm::u8vec3> VectorA(1000);
|
|
||||||
std::vector<glm::u8vec3> VectorB(1000);
|
|
||||||
std::vector<glm::u8vec3> VectorC(1000);
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < VectorA.size(); ++i)
|
|
||||||
{
|
|
||||||
VectorA[i] = glm::u8vec3(1, 1, 1);
|
|
||||||
VectorB[i] = glm::u8vec3(1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma omp parallel for default(none) shared(VectorA, VectorB, VectorC)
|
|
||||||
for (int i = 0; i < VectorC.size(); ++i)
|
|
||||||
{
|
|
||||||
VectorC[i] = VectorA[i] + VectorB[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
Error += test_openmp();
|
|
||||||
Error += test_scalar_size();
|
|
||||||
Error += test_fvec_size();
|
|
||||||
Error += test_fvec_precision();
|
|
||||||
Error += test_fvec_conversion();
|
|
||||||
Error += test_dvec_precision();
|
|
||||||
Error += test_ivec_size();
|
|
||||||
Error += test_ivec_precision();
|
|
||||||
Error += test_uvec_size();
|
|
||||||
Error += test_uvec_precision();
|
|
||||||
Error += test_fmat_size();
|
|
||||||
Error += test_dmat_size();
|
|
||||||
Error += test_quat_size();
|
|
||||||
Error += test_quat_precision();
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,262 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2010-09-16
|
|
||||||
// Updated : 2011-05-27
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/type_ptr.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
|
|
||||||
int test_value_ptr_vec()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 v(1.0);
|
|
||||||
float * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec3 v(1.0);
|
|
||||||
float * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 v(1.0);
|
|
||||||
float * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec2 v(1.0);
|
|
||||||
double * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::dvec3 v(1.0);
|
|
||||||
double * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::dvec4 v(1.0);
|
|
||||||
double * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_value_ptr_vec_const()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec2 const v(1.0);
|
|
||||||
float const * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec3 const v(1.0);
|
|
||||||
float const * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::vec4 const v(1.0);
|
|
||||||
float const * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::dvec2 const v(1.0);
|
|
||||||
double const * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::dvec3 const v(1.0);
|
|
||||||
double const * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::dvec4 const v(1.0);
|
|
||||||
double const * p = glm::value_ptr(v);
|
|
||||||
Error += p == &v[0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_value_ptr_mat()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat2x2 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat2x3 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat2x4 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat3x2 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat3x3 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat3x4 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat4x2 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat4x3 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat4x4 m(1.0);
|
|
||||||
float * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_value_ptr_mat_const()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::mat2x2 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat2x3 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat2x4 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat3x2 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat3x3 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat3x4 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat4x2 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat4x3 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
glm::mat4x4 const m(1.0);
|
|
||||||
float const * p = glm::value_ptr(m);
|
|
||||||
Error += p == &m[0][0] ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_make_pointer_mat()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
||||||
double ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
||||||
|
|
||||||
glm::mat2x2 Mat2x2A = glm::make_mat2x2(ArrayA);
|
|
||||||
glm::mat2x3 Mat2x3A = glm::make_mat2x3(ArrayA);
|
|
||||||
glm::mat2x4 Mat2x4A = glm::make_mat2x4(ArrayA);
|
|
||||||
glm::mat3x2 Mat3x2A = glm::make_mat3x2(ArrayA);
|
|
||||||
glm::mat3x3 Mat3x3A = glm::make_mat3x3(ArrayA);
|
|
||||||
glm::mat3x4 Mat3x4A = glm::make_mat3x4(ArrayA);
|
|
||||||
glm::mat4x2 Mat4x2A = glm::make_mat4x2(ArrayA);
|
|
||||||
glm::mat4x3 Mat4x3A = glm::make_mat4x3(ArrayA);
|
|
||||||
glm::mat4x4 Mat4x4A = glm::make_mat4x4(ArrayA);
|
|
||||||
|
|
||||||
glm::dmat2x2 Mat2x2B = glm::make_mat2x2(ArrayB);
|
|
||||||
glm::dmat2x3 Mat2x3B = glm::make_mat2x3(ArrayB);
|
|
||||||
glm::dmat2x4 Mat2x4B = glm::make_mat2x4(ArrayB);
|
|
||||||
glm::dmat3x2 Mat3x2B = glm::make_mat3x2(ArrayB);
|
|
||||||
glm::dmat3x3 Mat3x3B = glm::make_mat3x3(ArrayB);
|
|
||||||
glm::dmat3x4 Mat3x4B = glm::make_mat3x4(ArrayB);
|
|
||||||
glm::dmat4x2 Mat4x2B = glm::make_mat4x2(ArrayB);
|
|
||||||
glm::dmat4x3 Mat4x3B = glm::make_mat4x3(ArrayB);
|
|
||||||
glm::dmat4x4 Mat4x4B = glm::make_mat4x4(ArrayB);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_make_pointer_vec()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
||||||
int ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
||||||
bool ArrayC[] = {true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false};
|
|
||||||
|
|
||||||
glm::vec2 Vec2A = glm::make_vec2(ArrayA);
|
|
||||||
glm::vec3 Vec3A = glm::make_vec3(ArrayA);
|
|
||||||
glm::vec4 Vec4A = glm::make_vec4(ArrayA);
|
|
||||||
|
|
||||||
glm::ivec2 Vec2B = glm::make_vec2(ArrayB);
|
|
||||||
glm::ivec3 Vec3B = glm::make_vec3(ArrayB);
|
|
||||||
glm::ivec4 Vec4B = glm::make_vec4(ArrayB);
|
|
||||||
|
|
||||||
glm::bvec2 Vec2C = glm::make_vec2(ArrayC);
|
|
||||||
glm::bvec3 Vec3C = glm::make_vec3(ArrayC);
|
|
||||||
glm::bvec4 Vec4C = glm::make_vec4(ArrayC);
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_make_pointer_vec();
|
|
||||||
Error += test_make_pointer_mat();
|
|
||||||
Error += test_value_ptr_vec();
|
|
||||||
Error += test_value_ptr_vec_const();
|
|
||||||
Error += test_value_ptr_mat();
|
|
||||||
Error += test_value_ptr_mat_const();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2011-04-26
|
|
||||||
// Updated : 2011-04-26
|
|
||||||
// Licence : This source is under MIT licence
|
|
||||||
// File : test/gtc/ulp.cpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
|
||||||
#include <glm/gtc/ulp.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
int test_ulp_float_dist()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
float A = 1.0f;
|
|
||||||
|
|
||||||
float B = glm::next_float(A);
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
float C = glm::prev_float(B);
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
int D = glm::float_distance(A, B);
|
|
||||||
Error += D == 1 ? 0 : 1;
|
|
||||||
int E = glm::float_distance(A, C);
|
|
||||||
Error += E == 0 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ulp_float_step()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
float A = 1.0f;
|
|
||||||
|
|
||||||
for(int i = 10; i < 1000; i *= 10)
|
|
||||||
{
|
|
||||||
float B = glm::next_float(A, i);
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
float C = glm::prev_float(B, i);
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
int D = glm::float_distance(A, B);
|
|
||||||
Error += D == i ? 0 : 1;
|
|
||||||
int E = glm::float_distance(A, C);
|
|
||||||
Error += E == 0 ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ulp_double_dist()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
double A = 1.0;
|
|
||||||
|
|
||||||
double B = glm::next_float(A);
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
double C = glm::prev_float(B);
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
int D = glm::float_distance(A, B);
|
|
||||||
Error += D == 1 ? 0 : 1;
|
|
||||||
int E = glm::float_distance(A, C);
|
|
||||||
Error += E == 0 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_ulp_double_step()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
double A = 1.0;
|
|
||||||
|
|
||||||
for(int i = 10; i < 1000; i *= 10)
|
|
||||||
{
|
|
||||||
double B = glm::next_float(A, i);
|
|
||||||
Error += A != B ? 0 : 1;
|
|
||||||
double C = glm::prev_float(B, i);
|
|
||||||
Error += A == C ? 0 : 1;
|
|
||||||
|
|
||||||
int D = glm::float_distance(A, B);
|
|
||||||
Error += D == i ? 0 : 1;
|
|
||||||
int E = glm::float_distance(A, C);
|
|
||||||
Error += E == 0 ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
Error += test_ulp_float_dist();
|
|
||||||
Error += test_ulp_float_step();
|
|
||||||
Error += test_ulp_double_dist();
|
|
||||||
Error += test_ulp_double_step();
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
glmCreateTestGTC(gtx_associated_min_max)
|
|
||||||
glmCreateTestGTC(gtx_bit)
|
|
||||||
glmCreateTestGTC(gtx_closest_point)
|
|
||||||
glmCreateTestGTC(gtx_color_space_YCoCg)
|
|
||||||
glmCreateTestGTC(gtx_color_space)
|
|
||||||
glmCreateTestGTC(gtx_compatibility)
|
|
||||||
glmCreateTestGTC(gtx_component_wise)
|
|
||||||
glmCreateTestGTC(gtx_euler_angle)
|
|
||||||
glmCreateTestGTC(gtx_extend)
|
|
||||||
glmCreateTestGTC(gtx_extented_min_max)
|
|
||||||
glmCreateTestGTC(gtx_fast_exponential)
|
|
||||||
glmCreateTestGTC(gtx_fast_square_root)
|
|
||||||
glmCreateTestGTC(gtx_fast_trigonometry)
|
|
||||||
glmCreateTestGTC(gtx_gradient_paint)
|
|
||||||
glmCreateTestGTC(gtx_handed_coordinate_space)
|
|
||||||
glmCreateTestGTC(gtx_inertia)
|
|
||||||
glmCreateTestGTC(gtx_integer)
|
|
||||||
glmCreateTestGTC(gtx_intersect)
|
|
||||||
glmCreateTestGTC(gtx_io)
|
|
||||||
glmCreateTestGTC(gtx_log_base)
|
|
||||||
glmCreateTestGTC(gtx_matrix_cross_product)
|
|
||||||
glmCreateTestGTC(gtx_matrix_interpolation)
|
|
||||||
glmCreateTestGTC(gtx_matrix_major_storage)
|
|
||||||
glmCreateTestGTC(gtx_matrix_operation)
|
|
||||||
glmCreateTestGTC(gtx_matrix_query)
|
|
||||||
glmCreateTestGTC(gtx_multiple)
|
|
||||||
glmCreateTestGTC(gtx_norm)
|
|
||||||
glmCreateTestGTC(gtx_normal)
|
|
||||||
glmCreateTestGTC(gtx_normalize_dot)
|
|
||||||
glmCreateTestGTC(gtx_number_precision)
|
|
||||||
glmCreateTestGTC(gtx_orthonormalize)
|
|
||||||
glmCreateTestGTC(gtx_optimum_pow)
|
|
||||||
glmCreateTestGTC(gtx_perpendicular)
|
|
||||||
glmCreateTestGTC(gtx_polar_coordinates)
|
|
||||||
glmCreateTestGTC(gtx_projection)
|
|
||||||
glmCreateTestGTC(gtx_quaternion)
|
|
||||||
glmCreateTestGTC(gtx_dual_quaternion)
|
|
||||||
glmCreateTestGTC(gtx_rotate_normalized_axis)
|
|
||||||
glmCreateTestGTC(gtx_rotate_vector)
|
|
||||||
glmCreateTestGTC(gtx_scalar_relational)
|
|
||||||
glmCreateTestGTC(gtx_simd_vec4)
|
|
||||||
glmCreateTestGTC(gtx_simd_mat4)
|
|
||||||
glmCreateTestGTC(gtx_spline)
|
|
||||||
glmCreateTestGTC(gtx_string_cast)
|
|
||||||
glmCreateTestGTC(gtx_vector_angle)
|
|
||||||
glmCreateTestGTC(gtx_vector_query)
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user