Refactor windows and web compiling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
struct Vec2 {
|
||||
float x;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#if OS_POSIX
|
||||
#include "filesystem.h"
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -862,7 +861,6 @@ API String PollStdout(Allocator allocator, Process *process, bool force_read) {
|
||||
}
|
||||
|
||||
#elif OS_WASM
|
||||
#include "filesystem.h"
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
Hash table implementation:
|
||||
Pointers to values
|
||||
@@ -11,7 +10,7 @@
|
||||
Hash 0 is reserved for empty hash table entry
|
||||
*/
|
||||
template <class Value>
|
||||
struct Table {
|
||||
struct HashTable {
|
||||
struct Entry {
|
||||
uint64_t hash;
|
||||
uint64_t key;
|
||||
|
||||
@@ -23,11 +23,19 @@ Rect2 operator-(Rect2 r, Vec2 value) { return { {r.min.x - value.x, r.min.y - va
|
||||
Rect2 operator+(Rect2 r, Vec2 value) { return { {r.min.x + value.x, r.min.y + value.y}, {r.max.x + value.x, r.max.y + value.y} }; }
|
||||
Rect2 operator*(Rect2 r, Vec2 value) { return { {r.min.x * value.x, r.min.y * value.y}, {r.max.x * value.x, r.max.y * value.y} }; }
|
||||
Rect2 operator/(Rect2 r, Vec2 value) { return { {r.min.x / value.x, r.min.y / value.y}, {r.max.x / value.x, r.max.y / value.y} }; }
|
||||
Rect2 operator-(Vec2 value, Rect2 r) { return { {r.min.x - value.x, r.min.y - value.y}, {r.max.x - value.x, r.max.y - value.y} }; }
|
||||
Rect2 operator+(Vec2 value, Rect2 r) { return { {r.min.x + value.x, r.min.y + value.y}, {r.max.x + value.x, r.max.y + value.y} }; }
|
||||
Rect2 operator*(Vec2 value, Rect2 r) { return { {r.min.x * value.x, r.min.y * value.y}, {r.max.x * value.x, r.max.y * value.y} }; }
|
||||
Rect2 operator/(Vec2 value, Rect2 r) { return { {r.min.x / value.x, r.min.y / value.y}, {r.max.x / value.x, r.max.y / value.y} }; }
|
||||
|
||||
Rect2 operator-(Rect2 r, float value) { return { {r.min.x - value, r.min.y - value}, {r.max.x - value, r.max.y - value} }; }
|
||||
Rect2 operator+(Rect2 r, float value) { return { {r.min.x + value, r.min.y + value}, {r.max.x + value, r.max.y + value} }; }
|
||||
Rect2 operator*(Rect2 r, float value) { return { {r.min.x * value, r.min.y * value}, {r.max.x * value, r.max.y * value} }; }
|
||||
Rect2 operator/(Rect2 r, float value) { return { {r.min.x / value, r.min.y / value}, {r.max.x / value, r.max.y / value} }; }
|
||||
Rect2 operator-(float value, Rect2 r) { return { {r.min.x - value, r.min.y - value}, {r.max.x - value, r.max.y - value} }; }
|
||||
Rect2 operator+(float value, Rect2 r) { return { {r.min.x + value, r.min.y + value}, {r.max.x + value, r.max.y + value} }; }
|
||||
Rect2 operator*(float value, Rect2 r) { return { {r.min.x * value, r.min.y * value}, {r.max.x * value, r.max.y * value} }; }
|
||||
Rect2 operator/(float value, Rect2 r) { return { {r.min.x / value, r.min.y / value}, {r.max.x / value, r.max.y / value} }; }
|
||||
|
||||
Rect2 operator-=(Rect2 &r, Rect2 value) { r = r - value; return r; }
|
||||
Rect2 operator+=(Rect2 &r, Rect2 value) { r = r + value; return r; }
|
||||
@@ -60,6 +68,10 @@ Vec2 operator-(Vec2 a, float b) { return {a.x - b, a.y - b}; }
|
||||
Vec2 operator+(Vec2 a, float b) { return {a.x + b, a.y + b}; }
|
||||
Vec2 operator*(Vec2 a, float b) { return {a.x * b, a.y * b}; }
|
||||
Vec2 operator/(Vec2 a, float b) { return {a.x / b, a.y / b}; }
|
||||
Vec2 operator-(float b, Vec2 a) { return {a.x - b, a.y - b}; }
|
||||
Vec2 operator+(float b, Vec2 a) { return {a.x + b, a.y + b}; }
|
||||
Vec2 operator*(float b, Vec2 a) { return {a.x * b, a.y * b}; }
|
||||
Vec2 operator/(float b, Vec2 a) { return {a.x / b, a.y / b}; }
|
||||
|
||||
Vec2 operator-=(Vec2 &a, Vec2 b) { a = a - b; return a; }
|
||||
Vec2 operator+=(Vec2 &a, Vec2 b) { a = a + b; return a; }
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
Vec2I GetSize(Rect2I r) {
|
||||
Vec2I result = {r.max.x - r.min.x, r.max.y - r.min.y};
|
||||
return result;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
Rect2I operator-(Rect2I r, Rect2I value) { return { {r.min.x - value.min.x, r.min.y - value.min.y}, {r.max.x - value.max.x, r.max.y - value.max.y} }; }
|
||||
Rect2I operator+(Rect2I r, Rect2I value) { return { {r.min.x + value.min.x, r.min.y + value.min.y}, {r.max.x + value.max.x, r.max.y + value.max.y} }; }
|
||||
Rect2I operator*(Rect2I r, Rect2I value) { return { {r.min.x * value.min.x, r.min.y * value.min.y}, {r.max.x * value.max.x, r.max.y * value.max.y} }; }
|
||||
@@ -13,7 +7,15 @@ Rect2I operator-(Rect2I r, Vec2I value) { return { {r.min.x - value.x, r.min.y -
|
||||
Rect2I operator+(Rect2I r, Vec2I value) { return { {r.min.x + value.x, r.min.y + value.y}, {r.max.x + value.x, r.max.y + value.y} }; }
|
||||
Rect2I operator*(Rect2I r, Vec2I value) { return { {r.min.x * value.x, r.min.y * value.y}, {r.max.x * value.x, r.max.y * value.y} }; }
|
||||
Rect2I operator/(Rect2I r, Vec2I value) { return { {r.min.x / value.x, r.min.y / value.y}, {r.max.x / value.x, r.max.y / value.y} }; }
|
||||
Rect2I operator-(Vec2I value, Rect2I r) { return { {r.min.x - value.x, r.min.y - value.y}, {r.max.x - value.x, r.max.y - value.y} }; }
|
||||
Rect2I operator+(Vec2I value, Rect2I r) { return { {r.min.x + value.x, r.min.y + value.y}, {r.max.x + value.x, r.max.y + value.y} }; }
|
||||
Rect2I operator*(Vec2I value, Rect2I r) { return { {r.min.x * value.x, r.min.y * value.y}, {r.max.x * value.x, r.max.y * value.y} }; }
|
||||
Rect2I operator/(Vec2I value, Rect2I r) { return { {r.min.x / value.x, r.min.y / value.y}, {r.max.x / value.x, r.max.y / value.y} }; }
|
||||
|
||||
Rect2I operator-(Int value, Rect2I r) { return { {r.min.x - value, r.min.y - value}, {r.max.x - value, r.max.y - value} }; }
|
||||
Rect2I operator+(Int value, Rect2I r) { return { {r.min.x + value, r.min.y + value}, {r.max.x + value, r.max.y + value} }; }
|
||||
Rect2I operator*(Int value, Rect2I r) { return { {r.min.x * value, r.min.y * value}, {r.max.x * value, r.max.y * value} }; }
|
||||
Rect2I operator/(Int value, Rect2I r) { return { {r.min.x / value, r.min.y / value}, {r.max.x / value, r.max.y / value} }; }
|
||||
Rect2I operator-(Rect2I r, Int value) { return { {r.min.x - value, r.min.y - value}, {r.max.x - value, r.max.y - value} }; }
|
||||
Rect2I operator+(Rect2I r, Int value) { return { {r.min.x + value, r.min.y + value}, {r.max.x + value, r.max.y + value} }; }
|
||||
Rect2I operator*(Rect2I r, Int value) { return { {r.min.x * value, r.min.y * value}, {r.max.x * value, r.max.y * value} }; }
|
||||
@@ -41,6 +43,10 @@ Vec2I operator-(Vec2I a, Int b) { return {a.x - b, a.y - b}; }
|
||||
Vec2I operator+(Vec2I a, Int b) { return {a.x + b, a.y + b}; }
|
||||
Vec2I operator*(Vec2I a, Int b) { return {a.x * b, a.y * b}; }
|
||||
Vec2I operator/(Vec2I a, Int b) { return {a.x / b, a.y / b}; }
|
||||
Vec2I operator-(Int b, Vec2I a) { return {a.x - b, a.y - b}; }
|
||||
Vec2I operator+(Int b, Vec2I a) { return {a.x + b, a.y + b}; }
|
||||
Vec2I operator*(Int b, Vec2I a) { return {a.x * b, a.y * b}; }
|
||||
Vec2I operator/(Int b, Vec2I a) { return {a.x / b, a.y / b}; }
|
||||
|
||||
Vec2I operator-=(Vec2I &a, Vec2I b) { a = a - b; return a; }
|
||||
Vec2I operator+=(Vec2I &a, Vec2I b) { a = a + b; return a; }
|
||||
@@ -51,7 +57,10 @@ Vec2I operator+=(Vec2I &a, Int b) { a = a + b; return a; }
|
||||
Vec2I operator*=(Vec2I &a, Int b) { a = a * b; return a; }
|
||||
Vec2I operator/=(Vec2I &a, Int b) { a = a / b; return a; }
|
||||
|
||||
// clang-format on
|
||||
Vec2I GetSize(Rect2I r) {
|
||||
Vec2I result = {r.max.x - r.min.x, r.max.y - r.min.y};
|
||||
return result;
|
||||
}
|
||||
|
||||
Rect2I RectI0Size(Int x, Int y) {
|
||||
Rect2I rect = {0, 0, x, y};
|
||||
|
||||
Reference in New Issue
Block a user