source: opengl-game/utils.cpp

feature/imgui-sdl
Last change on this file was db2d995, checked in by Dmitry Portnoy <dportnoy@…>, 4 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
RevLine 
[203ab1b]1#include "utils.hpp"
[a23fc08]2
[0807aeb]3#include <ctime>
[a23fc08]4#include <iostream>
5
[0807aeb]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
16void seedRandomNums() {
17#ifdef WINDOWS
18 srand(_getpid() ^ time(nullptr));
19#else
20 srand(getpid() ^ time(nullptr));
21#endif
22}
23
[a23fc08]24float getRandomNum(float low, float high) {
[0807aeb]25 return low + ((float)rand() / RAND_MAX) * (high - low);
[a23fc08]26}
27
[db2d995]28void printVec(string label, const vec2& v) {
29 cout << label << " -> (" << v.x << "," << v.y << ")" << endl;
30}
31
32void printVec(string label, const vec3& v) {
[a23fc08]33 cout << label << " -> (" << v.x << "," << v.y << "," << v.z << ")" << endl;
34}
35
[db2d995]36void printVec(string label, const vec4& v) {
[a23fc08]37 cout << label << " -> (" << v.x << "," << v.y << "," << v.z << "," << v.w << ")" << endl;
38}
39
[db2d995]40void printMat(string label, const mat4& m) {
[a23fc08]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;
[203ab1b]46}
Note: See TracBrowser for help on using the repository browser.