parent
9b01c2d57c
commit
d7f768718c
31 changed files with 769 additions and 241 deletions
@ -1,59 +0,0 @@ |
||||
|
||||
__author__="eloraiby" |
||||
__date__ ="$5-Sep-2010 9:35:29 PM$" |
||||
|
||||
atomic_types = ["unsigned char", "unsigned short", "unsigned int", |
||||
"signed char", "signed short", "signed int", |
||||
"float", "double"] |
||||
|
||||
|
||||
glsl_vector_types = ["tvec2", "tvec3", "tvec4"] |
||||
glsl_matrix_types = ["tmat2x2", "tmat2x3", "tmat2x4", |
||||
"tmat3x2", "tmat3x3", "tmat3x4", |
||||
"tmat4x2", "tmat4x3", "tmat4x4"] |
||||
|
||||
glsl_operators = [] |
||||
|
||||
def gen_vectors(): |
||||
for v in glsl_vector_types: |
||||
print |
||||
print "//" |
||||
print "// " + v + " type explicit instantiation" |
||||
print "//" |
||||
for a in atomic_types: |
||||
print "template struct " + v + "<" + a + ">;" |
||||
print |
||||
|
||||
def gen_matrices(): |
||||
for m in glsl_matrix_types: |
||||
print |
||||
print "//" |
||||
print "// " + m + " type explicit instantiation" |
||||
print "//" |
||||
for a in atomic_types: |
||||
print "template struct " + m + "<" + a + ">;" |
||||
print |
||||
|
||||
if __name__ == "__main__": |
||||
print "//" |
||||
print "// GLM External templates generator script version 0.1 for GLM core" |
||||
print "//" |
||||
print "// atomic types:", atomic_types |
||||
print "// GLSL vector types:", glsl_vector_types; |
||||
print "// GLSL matrix types:", glsl_matrix_types; |
||||
print "//" |
||||
print |
||||
print "#include \"glm.hpp\"" |
||||
print |
||||
print "namespace glm {" |
||||
print "namespace detail {" |
||||
|
||||
|
||||
gen_vectors() |
||||
gen_matrices() |
||||
|
||||
print "} // namespace detail" |
||||
print "} // namespace glm" |
||||
|
||||
|
||||
|
@ -1,170 +0,0 @@ |
||||
//
|
||||
// GLM External templates generator script version 0.1 for GLM core
|
||||
//
|
||||
// atomic types: ['unsigned char', 'unsigned short', 'unsigned int', 'signed char', 'signed short', 'signed int', 'float', 'double']
|
||||
// GLSL vector types: ['tvec2', 'tvec3', 'tvec4']
|
||||
// GLSL matrix types: ['tmat2x2', 'tmat2x3', 'tmat2x4', 'tmat3x2', 'tmat3x3', 'tmat3x4', 'tmat4x2', 'tmat4x3', 'tmat4x4']
|
||||
//
|
||||
|
||||
#include "glm.hpp" |
||||
|
||||
namespace glm { |
||||
namespace detail { |
||||
|
||||
//
|
||||
// tvec2 type explicit instantiation
|
||||
//
|
||||
template struct tvec2<unsigned char>; |
||||
template struct tvec2<unsigned short>; |
||||
template struct tvec2<unsigned int>; |
||||
template struct tvec2<signed char>; |
||||
template struct tvec2<signed short>; |
||||
template struct tvec2<signed int>; |
||||
template struct tvec2<float>; |
||||
template struct tvec2<double>; |
||||
|
||||
|
||||
//
|
||||
// tvec3 type explicit instantiation
|
||||
//
|
||||
template struct tvec3<unsigned char>; |
||||
template struct tvec3<unsigned short>; |
||||
template struct tvec3<unsigned int>; |
||||
template struct tvec3<signed char>; |
||||
template struct tvec3<signed short>; |
||||
template struct tvec3<signed int>; |
||||
template struct tvec3<float>; |
||||
template struct tvec3<double>; |
||||
|
||||
|
||||
//
|
||||
// tvec4 type explicit instantiation
|
||||
//
|
||||
template struct tvec4<unsigned char>; |
||||
template struct tvec4<unsigned short>; |
||||
template struct tvec4<unsigned int>; |
||||
template struct tvec4<signed char>; |
||||
template struct tvec4<signed short>; |
||||
template struct tvec4<signed int>; |
||||
template struct tvec4<float>; |
||||
template struct tvec4<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat2x2 type explicit instantiation
|
||||
//
|
||||
template struct tmat2x2<unsigned char>; |
||||
template struct tmat2x2<unsigned short>; |
||||
template struct tmat2x2<unsigned int>; |
||||
template struct tmat2x2<signed char>; |
||||
template struct tmat2x2<signed short>; |
||||
template struct tmat2x2<signed int>; |
||||
template struct tmat2x2<float>; |
||||
template struct tmat2x2<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat2x3 type explicit instantiation
|
||||
//
|
||||
template struct tmat2x3<unsigned char>; |
||||
template struct tmat2x3<unsigned short>; |
||||
template struct tmat2x3<unsigned int>; |
||||
template struct tmat2x3<signed char>; |
||||
template struct tmat2x3<signed short>; |
||||
template struct tmat2x3<signed int>; |
||||
template struct tmat2x3<float>; |
||||
template struct tmat2x3<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat2x4 type explicit instantiation
|
||||
//
|
||||
template struct tmat2x4<unsigned char>; |
||||
template struct tmat2x4<unsigned short>; |
||||
template struct tmat2x4<unsigned int>; |
||||
template struct tmat2x4<signed char>; |
||||
template struct tmat2x4<signed short>; |
||||
template struct tmat2x4<signed int>; |
||||
template struct tmat2x4<float>; |
||||
template struct tmat2x4<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat3x2 type explicit instantiation
|
||||
//
|
||||
template struct tmat3x2<unsigned char>; |
||||
template struct tmat3x2<unsigned short>; |
||||
template struct tmat3x2<unsigned int>; |
||||
template struct tmat3x2<signed char>; |
||||
template struct tmat3x2<signed short>; |
||||
template struct tmat3x2<signed int>; |
||||
template struct tmat3x2<float>; |
||||
template struct tmat3x2<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat3x3 type explicit instantiation
|
||||
//
|
||||
template struct tmat3x3<unsigned char>; |
||||
template struct tmat3x3<unsigned short>; |
||||
template struct tmat3x3<unsigned int>; |
||||
template struct tmat3x3<signed char>; |
||||
template struct tmat3x3<signed short>; |
||||
template struct tmat3x3<signed int>; |
||||
template struct tmat3x3<float>; |
||||
template struct tmat3x3<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat3x4 type explicit instantiation
|
||||
//
|
||||
template struct tmat3x4<unsigned char>; |
||||
template struct tmat3x4<unsigned short>; |
||||
template struct tmat3x4<unsigned int>; |
||||
template struct tmat3x4<signed char>; |
||||
template struct tmat3x4<signed short>; |
||||
template struct tmat3x4<signed int>; |
||||
template struct tmat3x4<float>; |
||||
template struct tmat3x4<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat4x2 type explicit instantiation
|
||||
//
|
||||
template struct tmat4x2<unsigned char>; |
||||
template struct tmat4x2<unsigned short>; |
||||
template struct tmat4x2<unsigned int>; |
||||
template struct tmat4x2<signed char>; |
||||
template struct tmat4x2<signed short>; |
||||
template struct tmat4x2<signed int>; |
||||
template struct tmat4x2<float>; |
||||
template struct tmat4x2<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat4x3 type explicit instantiation
|
||||
//
|
||||
template struct tmat4x3<unsigned char>; |
||||
template struct tmat4x3<unsigned short>; |
||||
template struct tmat4x3<unsigned int>; |
||||
template struct tmat4x3<signed char>; |
||||
template struct tmat4x3<signed short>; |
||||
template struct tmat4x3<signed int>; |
||||
template struct tmat4x3<float>; |
||||
template struct tmat4x3<double>; |
||||
|
||||
|
||||
//
|
||||
// tmat4x4 type explicit instantiation
|
||||
//
|
||||
template struct tmat4x4<unsigned char>; |
||||
template struct tmat4x4<unsigned short>; |
||||
template struct tmat4x4<unsigned int>; |
||||
template struct tmat4x4<signed char>; |
||||
template struct tmat4x4<signed short>; |
||||
template struct tmat4x4<signed int>; |
||||
template struct tmat4x4<float>; |
||||
template struct tmat4x4<double>; |
||||
|
||||
} // namespace detail
|
||||
} // namespace glm
|
@ -0,0 +1,12 @@ |
||||
function(glmCreateTestGTC NAME) |
||||
set(SAMPLE_NAME test-${NAME}) |
||||
|
||||
add_executable(${SAMPLE_NAME} ${NAME}.cpp) |
||||
endfunction(glmCreateTestGTC) |
||||
|
||||
add_subdirectory(bug) |
||||
add_subdirectory(core) |
||||
add_subdirectory(gtc) |
||||
add_subdirectory(gtx) |
||||
add_subdirectory(img) |
||||
|
@ -0,0 +1,18 @@ |
||||
glmCreateTestGTC(core_type_float) |
||||
glmCreateTestGTC(core_type_half) |
||||
glmCreateTestGTC(core_type_int) |
||||
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) |
||||
|
||||
|
@ -0,0 +1,18 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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_float.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
return -1; |
||||
} |
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-08-31
|
||||
// Updated : 2010-08-25
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/core/type_half.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <glm/gtc/half_float.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
int Result = 0; |
||||
|
||||
glm::half A(1.0f); |
||||
glm::half B(2.0f); |
||||
glm::half C = A + B; |
||||
glm::half D(C); |
||||
float E = D; |
||||
int F = C; |
||||
glm::half G = B * C; |
||||
glm::half H = G / C; |
||||
H += glm::half(1.0f); |
||||
double J = H; |
||||
int I = H; |
||||
|
||||
Result = Result && J == 3.0; |
||||
|
||||
return Result != 0; |
||||
} |
@ -0,0 +1,15 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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_int.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
return -1; |
||||
} |
@ -0,0 +1,36 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
@ -0,0 +1,36 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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_mat2x3.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
@ -0,0 +1,38 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
||||
|
||||
|
@ -0,0 +1,37 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
||||
|
@ -0,0 +1,63 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <cstdio> |
||||
|
||||
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]); |
||||
} |
||||
|
||||
bool 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 true; |
||||
} |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_mat3x3(); |
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
||||
|
@ -0,0 +1,37 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
||||
|
@ -0,0 +1,37 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
||||
|
@ -0,0 +1,38 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
||||
|
||||
|
@ -0,0 +1,64 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <cstdio> |
||||
|
||||
void print(glm::dmat4 const & Mat0) |
||||
{ |
||||
printf("mat4(\n"); |
||||
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]); |
||||
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]); |
||||
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]); |
||||
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]); |
||||
} |
||||
|
||||
bool test_mat4x4() |
||||
{ |
||||
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 true; |
||||
} |
||||
|
||||
static bool test_operators() |
||||
{ |
||||
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; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
bool Result = true; |
||||
|
||||
Result = Result && test_mat4x4(); |
||||
Result = Result && test_operators(); |
||||
|
||||
assert(Result); |
||||
return Result; |
||||
} |
@ -0,0 +1,15 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
return -1; |
||||
} |
@ -0,0 +1,15 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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_vec2.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
return -1; |
||||
} |
@ -0,0 +1,15 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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_vec3.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
return -1; |
||||
} |
@ -0,0 +1,42 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 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_vec4.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <xmmintrin.h> |
||||
#include <emmintrin.h> |
||||
|
||||
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 main() |
||||
{ |
||||
__m128 DataA = swizzle<X, Y, Z, W>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); |
||||
__m128 DataB = swizzle<W, Z, Y, X>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); |
||||
|
||||
return 0; |
||||
} |
||||
|
@ -0,0 +1,3 @@ |
||||
glmCreateTestGTC(gtx-bit) |
||||
glmCreateTestGTC(gtx-simd-vec4) |
||||
glmCreateTestGTC(gtx-simd-mat4) |
@ -0,0 +1,134 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-16
|
||||
// Updated : 2010-09-16
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/gtx/bit.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <glm/gtx/number_precision.hpp> |
||||
#include <glm/gtx/bit.hpp> |
||||
#include <iostream> |
||||
|
||||
enum result |
||||
{ |
||||
SUCCESS, |
||||
FAIL, |
||||
ASSERT, |
||||
STATIC_ASSERT |
||||
}; |
||||
|
||||
namespace extractField |
||||
{ |
||||
template <typename genType, typename sizeType> |
||||
struct type |
||||
{ |
||||
genType Value; |
||||
sizeType BitFirst; |
||||
sizeType BitCount; |
||||
genType Return; |
||||
result Result; |
||||
}; |
||||
|
||||
typedef type<glm::uint64, glm::uint> typeU64; |
||||
|
||||
typeU64 const Data64[] = |
||||
{ |
||||
{0xffffffffffffffff, 8, 0, 0x0000000000000000, SUCCESS}, |
||||
{0x0000000000000000, 0,64, 0x0000000000000000, SUCCESS}, |
||||
{0xffffffffffffffff, 0,64, 0xffffffffffffffff, SUCCESS}, |
||||
{0x0f0f0f0f0f0f0f0f, 0,64, 0x0f0f0f0f0f0f0f0f, SUCCESS}, |
||||
{0x0000000000000000, 8, 0, 0x0000000000000000, SUCCESS}, |
||||
{0x8000000000000000,63, 1, 0x0000000000000001, SUCCESS}, |
||||
{0x7fffffffffffffff,63, 1, 0x0000000000000000, SUCCESS}, |
||||
{0x0000000000000300, 8, 8, 0x0000000000000003, SUCCESS}, |
||||
{0x000000000000ff00, 8, 8, 0x00000000000000ff, SUCCESS}, |
||||
{0xfffffffffffffff0, 0, 5, 0x0000000000000010, SUCCESS}, |
||||
{0x00000000000000ff, 1, 3, 0x0000000000000007, SUCCESS}, |
||||
{0x00000000000000ff, 0, 3, 0x0000000000000007, SUCCESS}, |
||||
{0x0000000000000000, 0, 2, 0x0000000000000000, SUCCESS}, |
||||
{0xffffffffffffffff, 0, 8, 0x00000000000000ff, SUCCESS}, |
||||
{0xffffffff00000000,32,32, 0x00000000ffffffff, SUCCESS}, |
||||
{0xfffffffffffffff0, 0, 8, 0x0000000000000000, FAIL}, |
||||
{0xffffffffffffffff,32,32, 0x0000000000000000, FAIL}, |
||||
//{0xffffffffffffffff,64, 1, 0x0000000000000000, ASSERT}, /* Throw an assert */
|
||||
//{0xffffffffffffffff, 0,65, 0x0000000000000000, ASSERT}, /* Throw an assert */
|
||||
//{0xffffffffffffffff,33,32, 0x0000000000000000, ASSERT}, /* Throw an assert */
|
||||
}; |
||||
|
||||
int test() |
||||
{ |
||||
glm::uint32 count = sizeof(Data64) / sizeof(typeU64); |
||||
|
||||
for(glm::uint32 i = 0; i < count; ++i) |
||||
{ |
||||
glm::uint64 Return = glm::extractField( |
||||
Data64[i].Value,
|
||||
Data64[i].BitFirst,
|
||||
Data64[i].BitCount); |
||||
|
||||
bool Compare = Data64[i].Return == Return; |
||||
|
||||
if(Data64[i].Result == SUCCESS && Compare) |
||||
continue; |
||||
else if(Data64[i].Result == FAIL && !Compare) |
||||
continue; |
||||
|
||||
std::cout << "glm::extractfield test fail on test " << i << std::endl; |
||||
return 1; |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
}//extractField
|
||||
|
||||
namespace bitRevert |
||||
{ |
||||
template <typename genType> |
||||
struct type |
||||
{ |
||||
genType Value; |
||||
genType Return; |
||||
result Result; |
||||
}; |
||||
|
||||
typedef type<glm::uint64> typeU64; |
||||
|
||||
typeU64 const Data64[] = |
||||
{ |
||||
{0xffffffffffffffff, 0xffffffffffffffff, SUCCESS}, |
||||
{0x0000000000000000, 0x0000000000000000, SUCCESS}, |
||||
{0xf000000000000000, 0x000000000000000f, SUCCESS}, |
||||
}; |
||||
|
||||
int test() |
||||
{ |
||||
glm::uint32 count = sizeof(Data64) / sizeof(typeU64); |
||||
|
||||
for(glm::uint32 i = 0; i < count; ++i) |
||||
{ |
||||
glm::uint64 Return = glm::bitRevert( |
||||
Data64[i].Value); |
||||
|
||||
bool Compare = Data64[i].Return == Return; |
||||
|
||||
if(Data64[i].Result == SUCCESS && Compare) |
||||
continue; |
||||
else if(Data64[i].Result == FAIL && !Compare) |
||||
continue; |
||||
|
||||
std::cout << "glm::extractfield test fail on test " << i << std::endl; |
||||
return 1; |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
}//bitRevert
|
||||
|
||||
int main(int argc, void* argv[]) |
||||
{ |
||||
::extractField::test(); |
||||
::bitRevert::test(); |
||||
} |
@ -0,0 +1,17 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-16
|
||||
// Updated : 2010-09-16
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/gtx/simd-mat4.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <glm/gtx/simd_mat4.hpp> |
||||
#include <iostream> |
||||
|
||||
int main(int argc, void* argv[]) |
||||
{ |
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-16
|
||||
// Updated : 2010-09-16
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/gtx/simd-vec4.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <glm/gtx/simd_vec4.hpp> |
||||
#include <cstdio> |
||||
|
||||
int main(int argc, char* argv[]) |
||||
{ |
||||
glm::simd_vec4 A1(0.0f, 0.1f, 0.2f, 0.3f); |
||||
glm::simd_vec4 B1(0.4f, 0.5f, 0.6f, 0.7f); |
||||
glm::simd_vec4 C1 = A1 + B1; |
||||
glm::simd_vec4 D1 = A1.swizzle<glm::X, glm::Z, glm::Y, glm::W>(); |
||||
|
||||
printf("A1(%2.3f, %2.3f, %2.3f, %2.3f)\n", A1.x, A1.y, A1.z, A1.w); |
||||
printf("B1(%2.3f, %2.3f, %2.3f, %2.3f)\n", B1.x, B1.y, B1.z, B1.w); |
||||
printf("C1(%2.3f, %2.3f, %2.3f, %2.3f)\n", C1.x, C1.y, C1.z, C1.w); |
||||
printf("D1(%2.3f, %2.3f, %2.3f, %2.3f)\n", D1.x, D1.y, D1.z, D1.w); |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in New Issue