source: opengl-game/utils.hpp@ 7f60b28

feature/imgui-sdl
Last change on this file since 7f60b28 was 0807aeb, checked in by Dmitry Portnoy <dmp1488@…>, 5 years ago

Spawn asteroids at a regular interval and make them move in the player's direction, change the movement of all game objects to depend on elapsed time and be framerate-independent, and switch from SDL2 timers to the C++ chrono library

  • Property mode set to 100644
File size: 938 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
[0807aeb]12void seedRandomNums();
[a23fc08]13float getRandomNum(float low, float high);
14
15void printVec3(string label, const vec3& v);
16void printVec4(string label, const vec4& v);
17void printMat4(string label, const mat4& m);
18
[caa2359]19// Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
[7e10667]20
21template <typename T1, typename T2>
22struct offset_of_impl {
23 static T2 object;
24 static constexpr size_t offset(T1 T2::*member) {
25 return size_t(&(offset_of_impl<T1, T2>::object.*member)) -
26 size_t(&offset_of_impl<T1, T2>::object);
27 }
28};
29template <typename T1, typename T2>
30T2 offset_of_impl<T1, T2>::object;
31
32template <typename T1, typename T2>
33inline constexpr size_t offset_of(T1 T2::*member) {
34 return offset_of_impl<T1, T2>::offset(member);
[a23fc08]35}
36
[4762301]37#endif
Note: See TracBrowser for help on using the repository browser.