added dpi aware back in

master
Allen Webster 2016-06-01 12:03:45 -04:00
parent 2f572ee72b
commit f1996a6f1f
2 changed files with 34 additions and 6 deletions

View File

@ -57,12 +57,13 @@ table_at_capacity(Table *table){
internal b32
table_add(Table *table, void *item, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){
u32 hash, *inspect;
i32 i;
i32 i, start;
Assert(table->count * 8 < table->max * 7);
hash = (hash_func(item, arg) | TableHashMin);
i = hash % table->max;
start = i;
inspect = table->hash_array + i;
while (*inspect >= TableHashMin){
@ -77,6 +78,7 @@ table_add(Table *table, void *item, void *arg, Hash_Function *hash_func, Compare
i = 0;
inspect = table->hash_array;
}
Assert(i != start);
}
*inspect = hash;
memcpy(table->data_array + i*table->item_size, item, table->item_size);
@ -111,6 +113,7 @@ table_find_pos(Table *table, void *search_key, void *arg, i32 *pos, i32 *index,
i = 0;
inspect = table->hash_array;
}
if (i == start) break;
}
return(0);

View File

@ -28,6 +28,8 @@
#include "system_shared.h"
#define SUPPORT_DPI 1
#define FPS 60
#define frame_useconds (1000000 / FPS)
@ -168,7 +170,9 @@ struct Win32_Vars{
HWND window_handle;
Render_Target target;
Partition font_part;
#if SUPPORT_DPI
i32 dpi_x, dpi_y;
#endif
u64 count_per_usecond;
b32 first;
@ -1137,6 +1141,15 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
#include "system_shared.cpp"
#include "4ed_rendering.cpp"
internal f32
size_change(i32 dpi_x, i32 dpi_y){
// TODO(allen): We're just hoping dpi_x == dpi_y for now I guess.
f32 size_x = win32vars.dpi_x / 96.f;
f32 size_y = win32vars.dpi_y / 96.f;
f32 size_max = Max(size_x, size_y);
return(size_max);
}
internal
Font_Load_Sig(system_draw_font_load){
if (win32vars.font_part.base == 0){
@ -1145,6 +1158,10 @@ Font_Load_Sig(system_draw_font_load){
i32 oversample = 2;
#if SUPPORT_DPI
pt_size = ROUND32(pt_size * size_change(win32vars.dpi_x, win32vars.dpi_y));
#endif
for (b32 success = 0; success == 0;){
success = draw_font_load(&win32vars.font_part,
font_out,
@ -1947,9 +1964,18 @@ WinMain(HINSTANCE hInstance,
exit(1);
}
HDC hdc = GetDC(win32vars.window_handle);
// TODO(allen): not Windows XP compatible, do we care?
// SetProcessDPIAware();
#if SUPPORT_DPI
// TODO(allen): not Windows XP compatible, how do I handle that?
SetProcessDPIAware();
win32vars.dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
win32vars.dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
#else
win32vars.dpi_x = 1;
win32vars.dpi_y = 1;
#endif
GetClientRect(win32vars.window_handle, &window_rect);
@ -1971,7 +1997,6 @@ WinMain(HINSTANCE hInstance,
0,
0, 0, 0 };
HDC hdc = GetDC(win32vars.window_handle);
{
i32 pixel_format;
pixel_format = ChoosePixelFormat(hdc, &pfd);