#include "utils.hpp"

#include <ctime>
#include <iostream>

#include "compiler.hpp"

#ifdef WINDOWS
   #include <process.h>
#else
   #include <unistd.h>
#endif

// TODO: Use a more modern method of generating random numbers

void seedRandomNums() {
#ifdef WINDOWS
   srand(_getpid() ^ time(nullptr));
#else
   srand(getpid() ^ time(nullptr));
#endif
}

float getRandomNum(float low, float high) {
   return low + ((float)rand() / RAND_MAX) * (high - low);
}

void printVec(string label, const vec2& v) {
   cout << label << " -> (" << v.x << "," << v.y << ")" << endl;
}

void printVec(string label, const vec3& v) {
   cout << label << " -> (" << v.x << "," << v.y << "," << v.z << ")" << endl;
}

void printVec(string label, const vec4& v) {
   cout << label << " -> (" << v.x << "," << v.y << "," << v.z << "," << v.w << ")" << endl;
}

void printMat(string label, const mat4& m) {
   cout << label << ": " << endl;
   cout << "[ " << m[0][0] << " " << m[1][0] << " " << m[2][0] << " " << m[3][0] <<  " ]" << endl;
   cout << "[ " << m[0][1] << " " << m[1][1] << " " << m[2][1] << " " << m[3][1] <<  " ]" << endl;
   cout << "[ " << m[0][2] << " " << m[1][2] << " " << m[2][2] << " " << m[3][2] <<  " ]" << endl;
   cout << "[ " << m[0][3] << " " << m[1][3] << " " << m[2][3] << " " << m[3][3] <<  " ]" << endl;
}
