feature/imgui-sdl
Last change
on this file since 6d698e5 was db2d995, checked in by Dmitry Portnoy <dportnoy@…>, 3 years ago |
Make the printVec and printMat functions a bit easier to use and add a printVec for vec2
|
-
Property mode
set to
100644
|
File size:
979 bytes
|
Line | |
---|
1 | #ifndef __UTILS_H__
|
---|
2 | #define __UTILS_H__
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 |
|
---|
6 | #include <glm/mat4x4.hpp>
|
---|
7 | #include <glm/gtc/type_ptr.hpp>
|
---|
8 |
|
---|
9 | using namespace std;
|
---|
10 | using namespace glm;
|
---|
11 |
|
---|
12 | void seedRandomNums();
|
---|
13 | float getRandomNum(float low, float high);
|
---|
14 |
|
---|
15 | void printVec(string label, const vec2& v);
|
---|
16 | void printVec(string label, const vec3& v);
|
---|
17 | void printVec(string label, const vec4& v);
|
---|
18 | void printMat(string label, const mat4& m);
|
---|
19 |
|
---|
20 | // Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
|
---|
21 |
|
---|
22 | template <typename T1, typename T2>
|
---|
23 | struct offset_of_impl {
|
---|
24 | static T2 object;
|
---|
25 | static constexpr size_t offset(T1 T2::*member) {
|
---|
26 | return size_t(&(offset_of_impl<T1, T2>::object.*member)) -
|
---|
27 | size_t(&offset_of_impl<T1, T2>::object);
|
---|
28 | }
|
---|
29 | };
|
---|
30 | template <typename T1, typename T2>
|
---|
31 | T2 offset_of_impl<T1, T2>::object;
|
---|
32 |
|
---|
33 | template <typename T1, typename T2>
|
---|
34 | inline constexpr size_t offset_of(T1 T2::*member) {
|
---|
35 | return offset_of_impl<T1, T2>::offset(member);
|
---|
36 | }
|
---|
37 |
|
---|
38 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.