source: opengl-game/utils.hpp@ a0c5f28

feature/imgui-sdl points-test
Last change on this file since a0c5f28 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
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
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
18// Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
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);
34}
35
36#endif
Note: See TracBrowser for help on using the repository browser.