mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-11 11:18:40 +00:00
Fixed bug in orth matrix, UI is now nice
This commit is contained in:
parent
0b945e07e9
commit
fd39f1042d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user