• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// @ref core
2 /// @file glm/core/dummy.cpp
3 ///
4 /// GLM is a header only library. There is nothing to compile.
5 /// dummy.cpp exist only a wordaround for CMake file.
6 
7 /*
8 #define GLM_MESSAGES
9 #include <glm/glm.hpp>
10 #include <glm/ext.hpp>
11 #include <limits>
12 
13 struct material
14 {
15 	glm::vec4 emission; // Ecm
16 	glm::vec4 ambient; // Acm
17 	glm::vec4 diffuse; // Dcm
18 	glm::vec4 specular; // Scm
19 	float shininess; // Srm
20 };
21 
22 struct light
23 {
24 	glm::vec4 ambient; // Acli
25 	glm::vec4 diffuse; // Dcli
26 	glm::vec4 specular; // Scli
27 	glm::vec4 position; // Ppli
28 	glm::vec4 halfVector; // Derived: Hi
29 	glm::vec3 spotDirection; // Sdli
30 	float spotExponent; // Srli
31 	float spotCutoff; // Crli
32 	// (range: [0.0,90.0], 180.0)
33 	float spotCosCutoff; // Derived: cos(Crli)
34 	// (range: [1.0,0.0],-1.0)
35 	float constantAttenuation; // K0
36 	float linearAttenuation; // K1
37 	float quadraticAttenuation;// K2
38 };
39 
40 
41 // Sample 1
42 #include <glm/vec3.hpp>// glm::vec3
43 #include <glm/geometric.hpp>// glm::cross, glm::normalize
44 
45 glm::vec3 computeNormal
46 (
47 	glm::vec3 const & a,
48 	glm::vec3 const & b,
49 	glm::vec3 const & c
50 )
51 {
52 	return glm::normalize(glm::cross(c - a, b - a));
53 }
54 
55 typedef unsigned int GLuint;
56 #define GL_FALSE 0
57 void glUniformMatrix4fv(GLuint, int, int, float*){}
58 
59 // Sample 2
60 #include <glm/vec3.hpp> // glm::vec3
61 #include <glm/vec4.hpp> // glm::vec4, glm::ivec4
62 #include <glm/mat4x4.hpp> // glm::mat4
63 #include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
64 #include <glm/gtc/type_ptr.hpp> // glm::value_ptr
65 void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate)
66 {
67 	glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
68 	glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
69 	glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
70 	glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
71 	glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
72 	glm::mat4 MVP = Projection * View * Model;
73 	glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP));
74 }
75 
76 // Sample 3
77 #include <glm/vec2.hpp>// glm::vec2
78 #include <glm/packing.hpp>// glm::packUnorm2x16
79 #include <glm/integer.hpp>// glm::uint
80 #include <glm/gtc/type_precision.hpp>// glm::i8vec2, glm::i32vec2
81 std::size_t const VertexCount = 4;
82 // Float quad geometry
83 std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2);
84 glm::vec2 const PositionDataF32[VertexCount] =
85 {
86 	glm::vec2(-1.0f,-1.0f),
87 	glm::vec2( 1.0f,-1.0f),
88 	glm::vec2( 1.0f, 1.0f),
89 	glm::vec2(-1.0f, 1.0f)
90 	};
91 // Half-float quad geometry
92 std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint);
93 glm::uint const PositionDataF16[VertexCount] =
94 {
95 	glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))),
96 	glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))),
97 	glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))),
98 	glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f)))
99 };
100 // 8 bits signed integer quad geometry
101 std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2);
102 glm::i8vec2 const PositionDataI8[VertexCount] =
103 {
104 	glm::i8vec2(-1,-1),
105 	glm::i8vec2( 1,-1),
106 	glm::i8vec2( 1, 1),
107 	glm::i8vec2(-1, 1)
108 };
109 // 32 bits signed integer quad geometry
110 std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2);
111 glm::i32vec2 const PositionDataI32[VertexCount] =
112 {
113 	glm::i32vec2 (-1,-1),
114 	glm::i32vec2 ( 1,-1),
115 	glm::i32vec2 ( 1, 1),
116 	glm::i32vec2 (-1, 1)
117 };
118 
119 struct intersection
120 {
121 	glm::vec4 position;
122 	glm::vec3 normal;
123 };
124 */
125 
126 
127 /*
128 // Sample 4
129 #include <glm/vec3.hpp>// glm::vec3
130 #include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
131 #include <glm/exponential.hpp>// glm::pow
132 #include <glm/gtc/random.hpp>// glm::vecRand3
133 glm::vec3 lighting
134 (
135 	intersection const & Intersection,
136 	material const & Material,
137 	light const & Light,
138 	glm::vec3 const & View
139 )
140 {
141 	glm::vec3 Color(0.0f);
142 	glm::vec3 LightVertor(glm::normalize(
143 		Light.position - Intersection.position +
144 		glm::vecRand3(0.0f, Light.inaccuracy));
145 
146 	if(!shadow(Intersection.position, Light.position, LightVertor))
147 	{
148 		float Diffuse = glm::dot(Intersection.normal, LightVector);
149 		if(Diffuse <= 0.0f)
150 			return Color;
151 		if(Material.isDiffuse())
152 			Color += Light.color() * Material.diffuse * Diffuse;
153 		if(Material.isSpecular())
154 		{
155 			glm::vec3 Reflect(glm::reflect(
156 				glm::normalize(-LightVector),
157 				glm::normalize(Intersection.normal)));
158 			float Dot = glm::dot(Reflect, View);
159 			float Base = Dot > 0.0f ? Dot : 0.0f;
160 			float Specular = glm::pow(Base, Material.exponent);
161 			Color += Material.specular * Specular;
162 		}
163 	}
164 	return Color;
165 }
166 */
167 
168 /*
169 template <typename T, glm::precision P, template<typename, glm::precision> class vecType>
170 T normalizeDotA(vecType<T, P> const & x, vecType<T, P> const & y)
171 {
172 	return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y));
173 }
174 
175 #define GLM_TEMPLATE_GENTYPE typename T, glm::precision P, template<typename, glm::precision> class
176 
177 template <GLM_TEMPLATE_GENTYPE vecType>
178 T normalizeDotB(vecType<T, P> const & x, vecType<T, P> const & y)
179 {
180 	return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y));
181 }
182 
183 template <typename vecType>
184 typename vecType::value_type normalizeDotC(vecType const & a, vecType const & b)
185 {
186 	return glm::dot(a, b) * glm::inversesqrt(glm::dot(a, a) * glm::dot(b, b));
187 }
188 */
main()189 int main()
190 {
191 /*
192 	glm::vec1 o(1);
193 	glm::vec2 a(1);
194 	glm::vec3 b(1);
195 	glm::vec4 c(1);
196 
197 	glm::quat q;
198 	glm::dualquat p;
199 
200 	glm::mat4 m(1);
201 
202 	float a0 = normalizeDotA(a, a);
203 	float b0 = normalizeDotB(b, b);
204 	float c0 = normalizeDotC(c, c);
205 */
206 	return 0;
207 }
208