source: opengl-game/utils.h@ bfd620e

feature/imgui-sdl points-test
Last change on this file since bfd620e was 4762301, checked in by Dmitry Portnoy <dmp1488@…>, 5 years ago

Make CrashLogger work for Debian-based systems

  • Property mode set to 100644
File size: 915 bytes
RevLine 
[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
9using namespace std;
10using namespace glm;
11
12float getRandomNum(float low, float high);
13
14void printVec3(string label, const vec3& v);
15void printVec4(string label, const vec4& v);
16void printMat4(string label, const mat4& m);
17
[caa2359]18// Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
[7e10667]19
20template <typename T1, typename T2>
21struct 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};
28template <typename T1, typename T2>
29T2 offset_of_impl<T1, T2>::object;
30
31template <typename T1, typename T2>
32inline 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.