feature/imgui-sdl
Last change
on this file since e1f88a9 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
|
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 |
|
---|
9 | using namespace std;
|
---|
10 | using namespace glm;
|
---|
11 |
|
---|
12 | void seedRandomNums();
|
---|
13 | float getRandomNum(float low, float high);
|
---|
14 |
|
---|
15 | void printVec3(string label, const vec3& v);
|
---|
16 | void printVec4(string label, const vec4& v);
|
---|
17 | void printMat4(string label, const mat4& m);
|
---|
18 |
|
---|
19 | // Code for offset_of function from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
|
---|
20 |
|
---|
21 | template <typename T1, typename T2>
|
---|
22 | struct 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 | };
|
---|
29 | template <typename T1, typename T2>
|
---|
30 | T2 offset_of_impl<T1, T2>::object;
|
---|
31 |
|
---|
32 | template <typename T1, typename T2>
|
---|
33 | inline constexpr size_t offset_of(T1 T2::*member) {
|
---|
34 | return offset_of_impl<T1, T2>::offset(member);
|
---|
35 | }
|
---|
36 |
|
---|
37 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.