dummy.cpp
Go to the documentation of this file.
1 
32 #define GLM_MESSAGES
33 #include "../glm.hpp"
34 #include <limits>
35 
36 struct material
37 {
42  float shininess; // Srm
43 };
44 
45 struct light
46 {
47  glm::vec4 ambient; // Acli
48  glm::vec4 diffuse; // Dcli
51  glm::vec4 halfVector; // Derived: Hi
53  float spotExponent; // Srli
54  float spotCutoff; // Crli
55  // (range: [0.0,90.0], 180.0)
56  float spotCosCutoff; // Derived: cos(Crli)
57  // (range: [1.0,0.0],-1.0)
58  float constantAttenuation; // K0
59  float linearAttenuation; // K1
61 };
62 
63 
64 // Sample 1
65 #include <glm/vec3.hpp>// glm::vec3
66 #include <glm/geometric.hpp>// glm::cross, glm::normalize
67 
69 (
70  glm::vec3 const & a,
71  glm::vec3 const & b,
72  glm::vec3 const & c
73 )
74 {
75  return glm::normalize(glm::cross(c - a, b - a));
76 }
77 
78 typedef unsigned int GLuint;
79 #define GL_FALSE 0
80 void glUniformMatrix4fv(GLuint, int, int, float*){}
81 
82 // Sample 2
83 #include <glm/vec3.hpp> // glm::vec3
84 #include <glm/vec4.hpp> // glm::vec4, glm::ivec4
85 #include <glm/mat4x4.hpp> // glm::mat4
86 #include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
87 #include <glm/gtc/type_ptr.hpp> // glm::value_ptr
88 void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate)
89 {
90  glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
91  glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
92  glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
93  glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
95  glm::mat4 MVP = Projection * View * Model;
96  glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP));
97 }
98 
99 // Sample 3
100 #include <glm/vec2.hpp>// glm::vec2
101 #include <glm/packing.hpp>// glm::packUnorm2x16
102 #include <glm/integer.hpp>// glm::uint
103 #include <glm/gtc/type_precision.hpp>// glm::i8vec2, glm::i32vec2
104 std::size_t const VertexCount = 4;
105 // Float quad geometry
106 std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2);
108 {
109  glm::vec2(-1.0f,-1.0f),
110  glm::vec2( 1.0f,-1.0f),
111  glm::vec2( 1.0f, 1.0f),
112  glm::vec2(-1.0f, 1.0f)
113  };
114 // Half-float quad geometry
115 std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint);
117 {
122 };
123 // 8 bits signed integer quad geometry
124 std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2);
126 {
127  glm::i8vec2(-1,-1),
128  glm::i8vec2( 1,-1),
129  glm::i8vec2( 1, 1),
130  glm::i8vec2(-1, 1)
131 };
132 // 32 bits signed integer quad geometry
133 std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2);
135 {
136  glm::i32vec2 (-1,-1),
137  glm::i32vec2 ( 1,-1),
138  glm::i32vec2 ( 1, 1),
139  glm::i32vec2 (-1, 1)
140 };
141 
143 {
146 };
147 
148 /*
149 // Sample 4
150 #include <glm/vec3.hpp>// glm::vec3
151 #include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
152 #include <glm/exponential.hpp>// glm::pow
153 #include <glm/gtc/random.hpp>// glm::vecRand3
154 glm::vec3 lighting
155 (
156  intersection const & Intersection,
157  material const & Material,
158  light const & Light,
159  glm::vec3 const & View
160 )
161 {
162  glm::vec3 Color(0.0f);
163  glm::vec3 LightVertor(glm::normalize(
164  Light.position - Intersection.position +
165  glm::vecRand3(0.0f, Light.inaccuracy));
166 
167  if(!shadow(Intersection.position, Light.position, LightVertor))
168  {
169  float Diffuse = glm::dot(Intersection.normal, LightVector);
170  if(Diffuse <= 0.0f)
171  return Color;
172  if(Material.isDiffuse())
173  Color += Light.color() * Material.diffuse * Diffuse;
174  if(Material.isSpecular())
175  {
176  glm::vec3 Reflect(glm::reflect(
177  glm::normalize(-LightVector),
178  glm::normalize(Intersection.normal)));
179  float Dot = glm::dot(Reflect, View);
180  float Base = Dot > 0.0f ? Dot : 0.0f;
181  float Specular = glm::pow(Base, Material.exponent);
182  Color += Material.specular * Specular;
183  }
184  }
185  return Color;
186 }
187 */
188 int main()
189 {
190  return 0;
191 }
glm::vec2
highp_vec2 vec2
Definition: type_vec.hpp:387
PositionDataF16
const glm::uint PositionDataF16[VertexCount]
Definition: dummy.cpp:116
glm::detail::tvec2::x
T x
Definition: type_vec2.hpp:84
material::shininess
float shininess
Definition: dummy.cpp:42
PositionSizeI8
const std::size_t PositionSizeI8
Definition: dummy.cpp:124
PositionSizeI32
const std::size_t PositionSizeI32
Definition: dummy.cpp:133
light::diffuse
glm::vec4 diffuse
Definition: dummy.cpp:48
b
Array< int, 3, 1 > b
Model
noiseModel::Isotropic::shared_ptr Model
light::quadraticAttenuation
float quadraticAttenuation
Definition: dummy.cpp:60
vec3.hpp
intersection::normal
glm::vec3 normal
Definition: dummy.cpp:145
glm::detail::tvec2::y
T y
Definition: type_vec2.hpp:85
c
Scalar Scalar * c
Projection
GeneralSFMFactor< GeneralCamera, Point3 > Projection
packing.hpp
glm::rotate
GLM_FUNC_DECL detail::tmat4x4< T, P > rotate(detail::tmat4x4< T, P > const &m, T const &angle, detail::tvec3< T, P > const &axis)
geometric.hpp
matrix_transform.hpp
material::diffuse
glm::vec4 diffuse
Definition: dummy.cpp:40
glm::value_ptr
GLM_FUNC_DECL const genType::value_type * value_ptr(genType const &vec)
PositionDataI8
const glm::i8vec2 PositionDataI8[VertexCount]
Definition: dummy.cpp:125
light::spotDirection
glm::vec3 spotDirection
Definition: dummy.cpp:52
glm::normalize
GLM_FUNC_DECL genType normalize(genType const &x)
main
int main()
Definition: dummy.cpp:188
light::spotCutoff
float spotCutoff
Definition: dummy.cpp:54
glm::detail::tvec3
Definition: type_mat.hpp:37
glm::detail::tmat4x4
Definition: type_mat.hpp:47
computeNormal
glm::vec3 computeNormal(glm::vec3 const &a, glm::vec3 const &b, glm::vec3 const &c)
Definition: dummy.cpp:69
func
void func(GLuint LocationMVP, float Translate, glm::vec2 const &Rotate)
Definition: dummy.cpp:88
glm::perspective
GLM_FUNC_DECL detail::tmat4x4< T, defaultp > perspective(T const &fovy, T const &aspect, T const &near, T const &far)
GL_FALSE
#define GL_FALSE
Definition: dummy.cpp:79
glm::scale
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
GLuint
unsigned int GLuint
Definition: dummy.cpp:78
PositionDataF32
const glm::vec2 PositionDataF32[VertexCount]
Definition: dummy.cpp:107
light
Definition: dummy.cpp:45
PositionDataI32
const glm::i32vec2 PositionDataI32[VertexCount]
Definition: dummy.cpp:134
glm::detail::tvec4
Definition: type_mat.hpp:38
light::position
glm::vec4 position
Definition: dummy.cpp:50
material
Definition: dummy.cpp:36
material::specular
glm::vec4 specular
Definition: dummy.cpp:41
mat4x4.hpp
VertexCount
const std::size_t VertexCount
Definition: dummy.cpp:104
PositionSizeF16
const std::size_t PositionSizeF16
Definition: dummy.cpp:115
glm::cross
GLM_FUNC_DECL detail::tvec3< T, P > cross(detail::tvec3< T, P > const &x, detail::tvec3< T, P > const &y)
light::ambient
glm::vec4 ambient
Definition: dummy.cpp:47
intersection
Definition: dummy.cpp:142
light::halfVector
glm::vec4 halfVector
Definition: dummy.cpp:51
f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
glm::i8vec2
highp_i8vec2 i8vec2
Definition: fwd.hpp:399
PositionSizeF32
const std::size_t PositionSizeF32
Definition: dummy.cpp:106
a
ArrayXXi a
vec2.hpp
intersection::position
glm::vec4 position
Definition: dummy.cpp:144
light::specular
glm::vec4 specular
Definition: dummy.cpp:49
material::emission
glm::vec4 emission
Definition: dummy.cpp:38
glm::packUnorm2x16
GLM_FUNC_DECL uint packUnorm2x16(vec2 const &v)
glm::uint
unsigned int uint
Definition: type_int.hpp:170
vec4.hpp
light::spotExponent
float spotExponent
Definition: dummy.cpp:53
glm::i32vec2
highp_i32vec2 i32vec2
Definition: fwd.hpp:558
light::constantAttenuation
float constantAttenuation
Definition: dummy.cpp:58
glUniformMatrix4fv
void glUniformMatrix4fv(GLuint, int, int, float *)
Definition: dummy.cpp:80
type_ptr.hpp
light::linearAttenuation
float linearAttenuation
Definition: dummy.cpp:59
glm::translate
GLM_FUNC_DECL detail::tmat4x4< T, P > translate(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
material::ambient
glm::vec4 ambient
Definition: dummy.cpp:39
glm::detail::tvec2
Definition: type_mat.hpp:36
type_precision.hpp
integer.hpp
light::spotCosCutoff
float spotCosCutoff
Definition: dummy.cpp:56


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:09