feature/imgui-sdl
Last change
on this file since 6d698e5 was db2d995, checked in by Dmitry Portnoy <dportnoy@…>, 3 years ago |
Make the printVec and printMat functions a bit easier to use and add a printVec for vec2
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | #include "utils.hpp"
|
---|
2 |
|
---|
3 | #include <ctime>
|
---|
4 | #include <iostream>
|
---|
5 |
|
---|
6 | #include "compiler.hpp"
|
---|
7 |
|
---|
8 | #ifdef WINDOWS
|
---|
9 | #include <process.h>
|
---|
10 | #else
|
---|
11 | #include <unistd.h>
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | // TODO: Use a more modern method of generating random numbers
|
---|
15 |
|
---|
16 | void seedRandomNums() {
|
---|
17 | #ifdef WINDOWS
|
---|
18 | srand(_getpid() ^ time(nullptr));
|
---|
19 | #else
|
---|
20 | srand(getpid() ^ time(nullptr));
|
---|
21 | #endif
|
---|
22 | }
|
---|
23 |
|
---|
24 | float getRandomNum(float low, float high) {
|
---|
25 | return low + ((float)rand() / RAND_MAX) * (high - low);
|
---|
26 | }
|
---|
27 |
|
---|
28 | void printVec(string label, const vec2& v) {
|
---|
29 | cout << label << " -> (" << v.x << "," << v.y << ")" << endl;
|
---|
30 | }
|
---|
31 |
|
---|
32 | void printVec(string label, const vec3& v) {
|
---|
33 | cout << label << " -> (" << v.x << "," << v.y << "," << v.z << ")" << endl;
|
---|
34 | }
|
---|
35 |
|
---|
36 | void printVec(string label, const vec4& v) {
|
---|
37 | cout << label << " -> (" << v.x << "," << v.y << "," << v.z << "," << v.w << ")" << endl;
|
---|
38 | }
|
---|
39 |
|
---|
40 | void printMat(string label, const mat4& m) {
|
---|
41 | cout << label << ": " << endl;
|
---|
42 | cout << "[ " << m[0][0] << " " << m[1][0] << " " << m[2][0] << " " << m[3][0] << " ]" << endl;
|
---|
43 | cout << "[ " << m[0][1] << " " << m[1][1] << " " << m[2][1] << " " << m[3][1] << " ]" << endl;
|
---|
44 | cout << "[ " << m[0][2] << " " << m[1][2] << " " << m[2][2] << " " << m[3][2] << " ]" << endl;
|
---|
45 | cout << "[ " << m[0][3] << " " << m[1][3] << " " << m[2][3] << " " << m[3][3] << " ]" << endl;
|
---|
46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.