Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
4.8KB

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