feature/imgui-sdl
Last change
on this file 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
|
Rev | Line | |
---|
[a23fc08] | 1 | #ifndef __UTILS_H__
|
---|
| 2 | #define __UTILS_H__
|
---|
| 3 |
|
---|
| 4 | #include <string>
|
---|
| 5 |
|
---|
| 6 | #include <glm/mat4x4.hpp>
|
---|
[4762301] | 7 | #include <glm/gtc/type_ptr.hpp>
|
---|
[a23fc08] | 8 |
|
---|
| 9 | using namespace std;
|
---|
| 10 | using namespace glm;
|
---|
| 11 |
|
---|
[0807aeb] | 12 | void seedRandomNums();
|
---|
[a23fc08] | 13 | float getRandomNum(float low, float high);
|
---|
| 14 |
|
---|
[db2d995] | 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);
|
---|
[a23fc08] | 19 |
|
---|
[caa2359] | 20 | // Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
|
---|
[7e10667] | 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);
|
---|
[a23fc08] | 36 | }
|
---|
| 37 |
|
---|
[4762301] | 38 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.