feature/imgui-sdl
points-test
Last change
on this file since 5a23277 was 203ab1b, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago |
Rename utils.h to utils.hpp
|
-
Property mode
set to
100644
|
File size:
915 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 |
|
---|
| 12 | float getRandomNum(float low, float high);
|
---|
| 13 |
|
---|
| 14 | void printVec3(string label, const vec3& v);
|
---|
| 15 | void printVec4(string label, const vec4& v);
|
---|
| 16 | void printMat4(string label, const mat4& m);
|
---|
| 17 |
|
---|
[caa2359] | 18 | // Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
|
---|
[7e10667] | 19 |
|
---|
| 20 | template <typename T1, typename T2>
|
---|
| 21 | struct offset_of_impl {
|
---|
| 22 | static T2 object;
|
---|
| 23 | static constexpr size_t offset(T1 T2::*member) {
|
---|
| 24 | return size_t(&(offset_of_impl<T1, T2>::object.*member)) -
|
---|
| 25 | size_t(&offset_of_impl<T1, T2>::object);
|
---|
| 26 | }
|
---|
| 27 | };
|
---|
| 28 | template <typename T1, typename T2>
|
---|
| 29 | T2 offset_of_impl<T1, T2>::object;
|
---|
| 30 |
|
---|
| 31 | template <typename T1, typename T2>
|
---|
| 32 | inline constexpr size_t offset_of(T1 T2::*member) {
|
---|
| 33 | return offset_of_impl<T1, T2>::offset(member);
|
---|
[a23fc08] | 34 | }
|
---|
| 35 |
|
---|
[4762301] | 36 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.