Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a3e53c

Browse files
committed
Fix missing GLM_ENABLE_EXPERIMENTAL
1 parent 0f2a76c commit 5a3e53c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

08_Loading_models.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ namespace std {
303303
template<> struct hash<Vertex> {
304304
size_t operator()(Vertex const& vertex) const {
305305
return ((hash<glm::vec3>()(vertex.pos) ^
306-
(hash<glm::vec3>()(vertex.color) << 1)) >> 1) ^
306+
(hash<glm::vec3>()(vertex.color) << 1)) >> 1) ^
307307
(hash<glm::vec2>()(vertex.texCoord) << 1);
308308
}
309309
};
@@ -314,9 +314,15 @@ This code should be placed outside the `Vertex` struct. The hash functions for
314314
the GLM types need to be included using the following header:
315315
316316
```c++
317+
#define GLM_ENABLE_EXPERIMENTAL
317318
#include <glm/gtx/hash.hpp>
318319
```
319320

321+
The hash functions are defined in the `gtx` folder, which means that it is
322+
technically still an experimental extension to GLM. Therefore you need to define
323+
`GLM_ENABLE_EXPERIMENTAL` to use it. It means that the API could change with a
324+
new version of GLM in the future, but in practice the API is very stable.
325+
320326
You should now be able to successfully compile and run your program. If you
321327
check the size of `vertices`, then you'll see that it has shrunk down from
322328
1,500,000 to 265,645! That means that each vertex is reused in an average number
@@ -345,4 +351,4 @@ Vulkan's explicitness, many concepts still work the same.
345351

346352
[C++ code](/code/model_loading.cpp) /
347353
[Vertex shader](/code/shader_depth.vert) /
348-
[Fragment shader](/code/shader_depth.frag)
354+
[Fragment shader](/code/shader_depth.frag)

code/model_loading.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#define GLM_FORCE_RADIANS
55
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
6+
#define GLM_ENABLE_EXPERIMENTAL
67
#include <glm/glm.hpp>
78
#include <glm/gtc/matrix_transform.hpp>
89
#include <glm/gtx/hash.hpp>

0 commit comments

Comments
 (0)