diff --git a/camera/Camera.h b/camera/Camera.h index 85d24a7..62927a9 100644 --- a/camera/Camera.h +++ b/camera/Camera.h @@ -33,6 +33,9 @@ struct Camera { float sensitivity; float zoom; + uint16 viewport_width; + uint16 viewport_height; + float fov; float znear; float zfar; @@ -202,29 +205,30 @@ void camera_movement(Camera* camera, CameraMovement* movement, float dt, bool re } } -// @question should we remove the fov for this or not, fov shouldn't matter for UI!? inline void camera_orth_matrix_lh(const Camera* __restrict camera, float* __restrict orth) { mat4_identity_sparse(orth); - - float ymax, xmax; - ymax = camera->znear * tanf(camera->fov * 0.5f); - xmax = ymax * camera->aspect; - - mat4_ortho_sparse_lh(orth, -xmax, xmax, -ymax, ymax, camera->znear, camera->zfar); + mat4_ortho_sparse_lh( + orth, + 0, camera->viewport_width, + 0, camera->viewport_height, + camera->znear, + camera->zfar + ); } inline void camera_orth_matrix_rh(const Camera* __restrict camera, float* __restrict orth) { mat4_identity_sparse(orth); - - float ymax, xmax; - ymax = camera->znear * tanf(camera->fov * 0.5f); - xmax = ymax * camera->aspect; - - mat4_ortho_sparse_rh(orth, -xmax, xmax, -ymax, ymax, camera->znear, camera->zfar); + mat4_ortho_sparse_rh( + orth, + 0, camera->viewport_width, + 0, camera->viewport_height, + camera->znear, + camera->zfar + ); } inline diff --git a/log/Debug.cpp b/log/Debug.cpp index 1eae4ec..dd935d5 100644 --- a/log/Debug.cpp +++ b/log/Debug.cpp @@ -151,20 +151,6 @@ void debug_memory_reset() } } -#if DEBUG - #define DEBUG_MEMORY_INIT(start, size) debug_memory_init((start), (size)) - #define DEBUG_MEMORY_READ(start, size) debug_memory_read((start), (size)) - #define DEBUG_MEMORY_WRITE(start, size) debug_memory_write((start), (size)) - #define DEBUG_MEMORY_DELETE(start, size) debug_memory_delete((start), (size)) - #define DEBUG_MEMORY_RESET() debug_memory_reset() -#else - #define DEBUG_MEMORY_INIT(start, size) ((void) 0) - #define DEBUG_MEMORY_READ(start, size) ((void) 0) - #define DEBUG_MEMORY_WRITE(start, size) ((void) 0) - #define DEBUG_MEMORY_DELETE(start, size) ((void) 0) - #define DEBUG_MEMORY_RESET() ((void) 0) -#endif - byte* log_get_memory(uint64 size, byte aligned = 1, bool zeroed = false) { ASSERT_SIMPLE(size <= debug_container->log_memory.size); diff --git a/log/DebugMemory.h b/log/DebugMemory.h index 34fdfc1..8424183 100644 --- a/log/DebugMemory.h +++ b/log/DebugMemory.h @@ -46,4 +46,18 @@ struct DebugMemoryContainer { DebugMemory* memory_stats; }; +#if DEBUG + #define DEBUG_MEMORY_INIT(start, size) debug_memory_init((start), (size)) + #define DEBUG_MEMORY_READ(start, size) debug_memory_read((start), (size)) + #define DEBUG_MEMORY_WRITE(start, size) debug_memory_write((start), (size)) + #define DEBUG_MEMORY_DELETE(start, size) debug_memory_delete((start), (size)) + #define DEBUG_MEMORY_RESET() debug_memory_reset() +#else + #define DEBUG_MEMORY_INIT(start, size) ((void) 0) + #define DEBUG_MEMORY_READ(start, size) ((void) 0) + #define DEBUG_MEMORY_WRITE(start, size) ((void) 0) + #define DEBUG_MEMORY_DELETE(start, size) ((void) 0) + #define DEBUG_MEMORY_RESET() ((void) 0) +#endif + #endif \ No newline at end of file diff --git a/math/matrix/MatrixFloat32.h b/math/matrix/MatrixFloat32.h index e0bd2f0..a51f5b4 100644 --- a/math/matrix/MatrixFloat32.h +++ b/math/matrix/MatrixFloat32.h @@ -778,36 +778,6 @@ void mat4_ortho_sparse_lh( float tb_delta = top - bottom; float fn_delta = zfar - znear; - matrix[0] = 2.0f / rl_delta; - //matrix[1] = 0.0f; - //matrix[2] = 0.0f; - //matrix[3] = 0.0f; - - //matrix[4] = 0.0f; - matrix[5] = 2.0f / tb_delta; - //matrix[6] = 0.0f; - //matrix[7] = 0.0f; - - //matrix[8] = 0.0f; - //matrix[9] = 0.0f; - matrix[10] = -2.0f / fn_delta; - //matrix[11] = 0.0f; - - matrix[12] = -(right + left) / rl_delta; - matrix[13] = -(top + bottom) / tb_delta; - matrix[14] = -(zfar + znear) / fn_delta; - matrix[15] = 1.0f; -} - -void mat4_ortho_sparse_rh( - float *matrix, - float left, float right, float bottom, float top, - float znear, float zfar -) { - float rl_delta = right - left; - float tb_delta = top - bottom; - float fn_delta = zfar - znear; - matrix[0] = 2.0f / rl_delta; //matrix[1] = 0.0f; //matrix[2] = 0.0f; @@ -829,6 +799,36 @@ void mat4_ortho_sparse_rh( matrix[15] = 1.0f; } +void mat4_ortho_sparse_rh( + float *matrix, + float left, float right, float bottom, float top, + float znear, float zfar +) { + float rl_delta = right - left; + float tb_delta = top - bottom; + float fn_delta = zfar - znear; + + matrix[0] = 2.0f / rl_delta; + //matrix[1] = 0.0f; + //matrix[2] = 0.0f; + //matrix[3] = 0.0f; + + //matrix[4] = 0.0f; + matrix[5] = 2.0f / tb_delta; + //matrix[6] = 0.0f; + //matrix[7] = 0.0f; + + //matrix[8] = 0.0f; + //matrix[9] = 0.0f; + matrix[10] = -2.0f / fn_delta; + //matrix[11] = 0.0f; + + matrix[12] = -(right + left) / rl_delta; + matrix[13] = -(top + bottom) / tb_delta; + matrix[14] = -(zfar + znear) / fn_delta; + matrix[15] = 1.0f; +} + void mat4_translate(float* matrix, float dx, float dy, float dz) { float temp[16]; diff --git a/models/settings/Settings.h b/models/settings/Settings.h index 7a2d1a5..d274a42 100644 --- a/models/settings/Settings.h +++ b/models/settings/Settings.h @@ -184,8 +184,8 @@ struct CSettings { byte audio_volume_music = 128; byte audio_volume_speech = 128; - uint32 game_window1_dim[2] = {1024, 768}; - uint32 game_window1_pos[2]; + uint16 game_window1_dim[2] = {1024, 768}; + uint16 game_window1_pos[2]; byte game_window1_mode = SETTING_TYPE_WINDOW_MODE_FULLSCREEN; byte game_zoom; diff --git a/platform/win32/UtilsWindows.h b/platform/win32/UtilsWindows.h index db9c920..887e93b 100644 --- a/platform/win32/UtilsWindows.h +++ b/platform/win32/UtilsWindows.h @@ -39,8 +39,8 @@ void monitor_resolution(const Window* __restrict w, v2_int32* __restrict resolut inline void monitor_resolution(Window* __restrict w) { - w->width = GetDeviceCaps(w->hdc, HORZRES); - w->height = GetDeviceCaps(w->hdc, VERTRES); + w->width = (uint16) GetDeviceCaps(w->hdc, HORZRES); + w->height = (uint16) GetDeviceCaps(w->hdc, VERTRES); } inline @@ -114,8 +114,8 @@ void window_create(Window* __restrict window, void* proc) } if (window->is_fullscreen) { - window->width = GetSystemMetrics(SM_CXSCREEN); - window->height = GetSystemMetrics(SM_CYSCREEN); + window->width = (uint16) GetSystemMetrics(SM_CXSCREEN); + window->height = (uint16) GetSystemMetrics(SM_CYSCREEN); DEVMODE screen_settings; diff --git a/platform/win32/Window.h b/platform/win32/Window.h index e8cca22..932a39f 100644 --- a/platform/win32/Window.h +++ b/platform/win32/Window.h @@ -13,22 +13,22 @@ #include "../../stdlib/Types.h" struct WindowState { - uint64 style; - int32 width; - int32 height; + uint16 width; + uint16 height; int32 x; int32 y; + uint64 style; }; struct Window { - bool is_fullscreen; - int32 width; - int32 height; + uint16 width; + uint16 height; int32 x; int32 y; + bool is_fullscreen; bool mouse_captured; HWND hwnd;