Fixed windows startup crash; new themes system

This commit is contained in:
Allen Webster 2017-06-16 16:57:02 -04:00
parent e65be95289
commit 067ffdef58
10 changed files with 228 additions and 324 deletions

View File

@ -1,6 +1,6 @@
#define MAJOR 4 #define MAJOR 4
#define MINOR 0 #define MINOR 0
#define PATCH 20 #define PATCH 21
// string // string
#define VN__(a,b,c) #a"."#b"."#c #define VN__(a,b,c) #a"."#b"."#c

295
4ed.cpp
View File

@ -629,301 +629,6 @@ app_hardcode_styles(Models *models){
style->main.file_info_style = file_info_style; style->main.file_info_style = file_info_style;
++style; ++style;
/////////////////
style_set_name(style, make_lit_string("Handmade Hero"));
style->main.back_color = 0xFF161616;
style->main.margin_color = 0xFF262626;
style->main.margin_hover_color = 0xFF333333;
style->main.margin_active_color = 0xFF404040;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFF40FF40;
style->main.at_cursor_color = style->main.back_color;
style->main.mark_color = 0xFF808080;
style->main.highlight_color = 0xFF703419;
style->main.at_highlight_color = 0xFFCDAA7D;
style->main.default_color = 0xFFA08563;
style->main.comment_color = 0xFF7D7D7D;
style->main.keyword_color = 0xFFCD950C;
style->main.str_constant_color = 0xFF6B8E23;
style->main.char_constant_color = style->main.str_constant_color;
style->main.int_constant_color = style->main.str_constant_color;
style->main.float_constant_color = style->main.str_constant_color;
style->main.bool_constant_color = style->main.str_constant_color;
style->main.include_color = 0xFF6B8E23;
style->main.preproc_color = 0xFFDAB98F;
style->main.special_character_color = 0xFFFF0000;
style->main.ghost_character_color = color_blend(style->main.default_color, 0.5f, style->main.back_color);
style->main.paste_color = 0xFFFFBB00;
style->main.undo_color = 0xFF80005D;
style->main.highlight_junk_color = 0xFF3A0000;
style->main.highlight_white_color = 0xFF003A3A;
file_info_style.bar_color = 0xFFCACACA;
file_info_style.bar_active_color = 0xFFA8A8A8;
file_info_style.base_color = 0xFF000000;
file_info_style.pop1_color = 0xFF03CF0C;
file_info_style.pop2_color = 0xFFFF0000;
style->main.file_info_style = file_info_style;
++style;
/////////////////
style_set_name(style, make_lit_string("Twilight"));
style->main.back_color = 0xFF090D12;
style->main.margin_color = 0xFF1A2634;
style->main.margin_hover_color = 0xFF2D415B;
style->main.margin_active_color = 0xFF405D82;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFFEEE800;
style->main.at_cursor_color = style->main.back_color;
style->main.mark_color = 0xFF8BA8CC;
style->main.highlight_color = 0xFF037A7B;
style->main.at_highlight_color = 0xFFFEB56C;
style->main.default_color = 0xFFB7C19E;
style->main.comment_color = 0xFF20ECF0;
style->main.keyword_color = 0xFFD86909;
style->main.str_constant_color = 0xFFC4EA5D;
style->main.char_constant_color = style->main.str_constant_color;
style->main.int_constant_color = style->main.str_constant_color;
style->main.float_constant_color = style->main.str_constant_color;
style->main.bool_constant_color = style->main.str_constant_color;
style->main.include_color = style->main.str_constant_color;
style->main.preproc_color = style->main.default_color;
style->main.special_character_color = 0xFFFF0000;
style->main.ghost_character_color = color_blend(0xFFFFFFFF, 0.75f, style->main.back_color);
style->main.paste_color = 0xFFDDEE00;
style->main.undo_color = 0xFF00DDEE;
style->main.highlight_junk_color = 0xff3a0000;
style->main.highlight_white_color = 0xFF151F2A;
file_info_style.bar_color = 0xFF315E68;
file_info_style.bar_active_color = 0xFF0F3C46;
file_info_style.base_color = 0xFF000000;
file_info_style.pop1_color = 0xFF1BFF0C;
file_info_style.pop2_color = 0xFFFF200D;
style->main.file_info_style = file_info_style;
++style;
/////////////////
style_set_name(style, make_lit_string("Wolverine"));
style->main.back_color = 0xFF070711;
style->main.margin_color = 0xFF111168;
style->main.margin_hover_color = 0xFF191996;
style->main.margin_active_color = 0xFF2121C3;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFF7082F9;
style->main.at_cursor_color = 0xFF000014;
style->main.mark_color = 0xFF4b5028;
style->main.highlight_color = 0xFFDDEE00;
style->main.at_highlight_color = 0xFF000019;
style->main.default_color = 0xFF8C9740;
style->main.comment_color = 0xFF3A8B29;
style->main.keyword_color = 0xFFD6B109;
style->main.str_constant_color = 0xFFAF5FA7;
style->main.char_constant_color = style->main.str_constant_color;
style->main.int_constant_color = style->main.str_constant_color;
style->main.float_constant_color = style->main.str_constant_color;
style->main.bool_constant_color = style->main.str_constant_color;
style->main.include_color = style->main.str_constant_color;
style->main.preproc_color = style->main.default_color;
style->main.special_character_color = 0xFFFF0000;
style->main.ghost_character_color = color_blend(style->main.default_color, 0.5f, style->main.back_color);
style->main.paste_color = 0xFF900090;
style->main.undo_color = 0xFF606090;
style->main.highlight_junk_color = 0xff3a0000;
style->main.highlight_white_color = 0xff003a3a;
file_info_style.bar_color = 0xFF7082F9;
file_info_style.bar_active_color = 0xFF4E60D7;
file_info_style.base_color = 0xFF000000;
file_info_style.pop1_color = 0xFFFAFA15;
file_info_style.pop2_color = 0xFFD20000;
style->main.file_info_style = file_info_style;
++style;
/////////////////
style_set_name(style, make_lit_string("stb"));
style->main.back_color = 0xFFD6D6D6;
style->main.margin_color = 0xFF9E9E9E;
style->main.margin_hover_color = 0xFF7E7E7E;
style->main.margin_active_color = 0xFF5C5C5C;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFF000000;
style->main.at_cursor_color = 0xFFD6D6D6;
style->main.mark_color = 0xFF525252;
style->main.highlight_color = 0xFF0044FF;
style->main.at_highlight_color = 0xFFD6D6D6;
style->main.default_color = 0xFF000000;
style->main.comment_color = 0xFF005800;
style->main.keyword_color = 0xFF000000;
style->main.str_constant_color = 0xFF000000;
style->main.char_constant_color = style->main.str_constant_color;
style->main.int_constant_color = style->main.str_constant_color;
style->main.float_constant_color = style->main.str_constant_color;
style->main.bool_constant_color = style->main.str_constant_color;
style->main.include_color = style->main.str_constant_color;
style->main.preproc_color = style->main.default_color;
style->main.special_character_color = 0xFF9A0000;
style->main.ghost_character_color = color_blend(style->main.default_color, 0.5f, style->main.back_color);
style->main.paste_color = 0xFF00B8B8;
style->main.undo_color = 0xFFB800B8;
style->main.highlight_junk_color = 0xFFFF7878;
style->main.highlight_white_color = 0xFFBCBCBC;
file_info_style.bar_color = 0xFF606060;
file_info_style.bar_active_color = 0xFF3E3E3E;
file_info_style.base_color = 0xFF000000;
file_info_style.pop1_color = 0xFF1111DC;
file_info_style.pop2_color = 0xFFE80505;
style->main.file_info_style = file_info_style;
++style;
/////////////////
style_set_name(style, make_lit_string("stb dark"));
style->main.back_color = 0xFF303030;
style->main.margin_color = 0xFF383838;
style->main.margin_hover_color = 0xFF404040;
style->main.margin_active_color = 0xFF484848;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFFDDDDDD;
style->main.at_cursor_color = 0xFF303030;
style->main.mark_color = 0xFF808080;
style->main.highlight_color = 0xFF006080;
style->main.at_highlight_color = 0xFF303030;
style->main.default_color = 0xFFAAAAAA;
style->main.comment_color = 0xFF6AC000;
style->main.keyword_color = 0xFFAAAAAA;
style->main.str_constant_color = 0xFFAAAAAA;
style->main.char_constant_color = style->main.str_constant_color;
style->main.int_constant_color = style->main.str_constant_color;
style->main.float_constant_color = style->main.str_constant_color;
style->main.bool_constant_color = style->main.str_constant_color;
style->main.include_color = style->main.str_constant_color;
style->main.preproc_color = style->main.default_color;
style->main.special_character_color = 0xFFFF0000;
style->main.ghost_character_color = color_blend(style->main.default_color, 0.5f, style->main.back_color);
style->main.paste_color = 0xFF00FFFF;
style->main.undo_color = 0xFFFF00FF;
style->main.highlight_junk_color = 0xFF482020;
style->main.highlight_white_color = 0xFF383838;
file_info_style.bar_color = 0xFF606060;
file_info_style.bar_active_color = 0xFF3E3E3E;
file_info_style.base_color = 0xFF000000;
file_info_style.pop1_color = 0xFF00B0D0;
file_info_style.pop2_color = 0xFFFF3A00;
style->main.file_info_style = file_info_style;
++style;
/////////////////
style_set_name(style, make_lit_string("Hjortshoej"));
style->main.back_color = 0xFFF0F0F0;
style->main.margin_color = 0xFF9E9E9E;
style->main.margin_hover_color = 0xFF7E7E7E;
style->main.margin_active_color = 0xFF5C5C5C;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFF000000;
style->main.at_cursor_color = 0xFFD6D6D6;
style->main.mark_color = 0xFF525252;
style->main.highlight_color = 0xFFB87600;
style->main.at_highlight_color = 0xFF000000;
style->main.default_color = 0xFF000000;
style->main.comment_color = 0xFF007E00;
style->main.keyword_color = 0xFF8B4303;
style->main.str_constant_color = 0xFF7C0000;
style->main.char_constant_color = 0xFF7C0000;
style->main.include_color = 0xFF7C0000;
style->main.int_constant_color = 0xFF007C00;
style->main.float_constant_color = 0xFF007C00;
style->main.bool_constant_color = 0xFF007C00;
style->main.preproc_color = 0xFF0000FF;
style->main.special_character_color = 0xFF9A0000;
style->main.ghost_character_color = color_blend(style->main.default_color, 0.5f, style->main.back_color);
style->main.paste_color = 0xFFB87600;
style->main.undo_color = 0xFFB87600;
style->main.highlight_junk_color = 0xFFFF7878;
style->main.highlight_white_color = 0xFFB87600;
file_info_style.bar_color = 0xFF606060;
file_info_style.bar_active_color = 0xFF3E3E3E;
file_info_style.base_color = 0xFFFFFFFF;
file_info_style.pop1_color = 0xFF007E00;
file_info_style.pop2_color = 0xFFE80505;
style->main.file_info_style = file_info_style;
++style;
/////////////////
style_set_name(style, make_lit_string("Strange"));
style->main.back_color = 0xFF161616;
style->main.margin_color = 0xFF606590;
style->main.margin_hover_color = 0xFF606590;
style->main.margin_active_color = 0xFF9a99e7;
style->main.list_item_color = style->main.margin_color;
style->main.list_item_hover_color = style->main.margin_hover_color;
style->main.list_item_active_color = style->main.margin_active_color;
style->main.cursor_color = 0xFFd96e26;
style->main.at_cursor_color = style->main.back_color;
style->main.mark_color = 0xFF808080;
style->main.highlight_color = 0xFF703419;
style->main.at_highlight_color = 0xFFCDAA7D;
style->main.default_color = 0xFFFFFFFF;
style->main.comment_color = 0xFF505f89;
style->main.keyword_color = 0xFFaa8da7;
style->main.str_constant_color = 0xFF9a99e7;
style->main.char_constant_color = style->main.str_constant_color;
style->main.int_constant_color = style->main.str_constant_color;
style->main.float_constant_color = style->main.str_constant_color;
style->main.bool_constant_color = style->main.str_constant_color;
style->main.include_color = 0xFF9a99e7;
style->main.preproc_color = 0xFF606590;
style->main.special_character_color = 0xFFFF0000;
style->main.ghost_character_color = color_blend(style->main.default_color, 0.5f, style->main.back_color);
style->main.paste_color = 0xFFFFBB00;
style->main.undo_color = 0xFF80005D;
style->main.highlight_junk_color = 0xFF3A0000;
style->main.highlight_white_color = 0xFF003A3A;
file_info_style.bar_color = 0xFF9a99e7;
file_info_style.bar_active_color = 0xFF9a99e7;
file_info_style.base_color = 0xFF000000;
file_info_style.pop1_color = 0xFF03CF0C;
file_info_style.pop2_color = 0xFFFF0000;
style->main.file_info_style = file_info_style;
++style;
///////////////// /////////////////
models->styles.count = (i32)(style - styles); models->styles.count = (i32)(style - styles);
models->styles.max = ArrayCount(models->styles.styles); models->styles.max = ArrayCount(models->styles.styles);

View File

@ -36,4 +36,4 @@ Bar = 0xFF888888;
Bar_Active = 0xFF666666; Bar_Active = 0xFF666666;
Base = 0xFF000000; Base = 0xFF000000;
Pop1 = 0xFF3C57DC; Pop1 = 0xFF3C57DC;
Pop2 = 0xFFFF0000; Pop2 = 0xFFFF0000;

View File

@ -36,4 +36,4 @@ Bar = 0xFFCACACA;
Bar_Active = FFA8A8A8; Bar_Active = FFA8A8A8;
Base = 0xFF000000; Base = 0xFF000000;
Pop1 = 0xFF03CF0C; Pop1 = 0xFF03CF0C;
Pop2 = 0xFFFF0000; Pop2 = 0xFFFF0000;

View File

@ -0,0 +1,39 @@
name = "Hjortshoej";
Back = 0xFFF0F0F0;
Margin = 0xFF9E9E9E;
Margin_Hover = 0xFF7E7E7E;
Margin_Active = 0xFF5C5C5C;
List_Item = Margin;
List_Item_Hover = Margin_Hover;
List_Item_Active = Margin_Active;
Cursor = 0xFF000000;
At_Cursor = 0xFFD6D6D6;
Mark = 0xFF525252;
Highlight = 0xFFB87600;
At_Highlight = 0xFF000000;
Default = 0xFF000000;
Comment = 0xFF007E00;
Keyword = 0xFF8B4303;
Str_Constant = 0xFF7C0000;
Char_Constant = Str_Constant;
Include = Str_Constant;
Int_Constant = 0xFF007C00;
Float_Constant = Int_Constant;
Bool_Constant = Int_Constant;
Preproc = 0xFF0000FF;
Special_Character = 0xFF9A0000;
Ghost_Character = 0xFF181818;
Paste = 0xFF00FFFF;
Undo = 0xFFFF00FF;
Highlight_Junk = 0xFF482020;
Highlight_White = 0xFF383838;
Bar = 0xFF606060;
Bar_Active = 0xFF3E3E3E;
Base = 0xFFFFFFFF;
Pop1 = 0xFF007E00;
Pop2 = 0xFFE80505;

View File

@ -0,0 +1,38 @@
name = "stb-dark";
Back = 0xFF303030;
Margin = 0xFF383838;
Margin_Hover = 0xFF404040;
Margin_Active = 0xFF484848;
List_Item = Margin;
List_Item_Hover = Margin_Hover;
List_Item_Active = Margin_Active;
Cursor = 0xFFDDDDDD;
At_Cursor = Back;
Mark = 0xFF808080;
Highlight = 0xFF006080;
At_Highlight = Back;
Default = 0xFFAAAAAA;
Comment = 0xFF6AC000;
Keyword = Default;
Str_Constant = Default;
Char_Constant = Str_Constant;
Int_Constant = Str_Constant;
Float_Constant = Str_Constant;
Bool_Constant = Str_Constant;
Include = Str_Constant;
Preproc = Default;
Special_Character = 0xFFFF0000;
Ghost_Character = 0xFF181818;
Paste = 0xFF00FFFF;
Undo = 0xFFFF00FF;
Highlight_Junk = 0xFF482020;
Highlight_White = 0xFF383838;
Bar = 0xFF606060;
Bar_Active = 0xFF3E3E3E;
Base = 0xFF000000;
Pop1 = 0xFF00B0D0;
Pop2 = 0xFFFF3A00;

38
themes/theme-stb.4coder Normal file
View File

@ -0,0 +1,38 @@
name = "stb";
Back = 0xFFD6D6D6;
Margin = 0xFF9E9E9E;
Margin_Hover = 0xFF7E7E7E;
Margin_Active = 0xFF5C5C5C;
List_Item = Margin;
List_Item_Hover = Margin_Hover;
List_Item_Active = Margin_Active;
Cursor = 0xFF000000;
At_Cursor = Back;
Mark = 0xFF525252;
Highlight = 0xFF0044FF;
At_Highlight = Back;
Default = 0xFF000000;
Comment = 0xFF005800;
Keyword = Default;
Str_Constant = Default;
Char_Constant = Str_Constant;
Int_Constant = Str_Constant;
Float_Constant = Str_Constant;
Bool_Constant = Str_Constant;
Include = Str_Constant;
Preproc = Default;
Special_Character = 0xFF9A0000;
Ghost_Character = 0xFF6B6B6B;
Paste = 0xFF00B8B8;
Undo = 0xFFB800B8;
Highlight_Junk = 0xFFFF7878;
Highlight_White = 0xFFBCBCBC;
Bar = 0xFF606060;
Bar_Active = 0xFF3E3E3E;
Base = 0xFF000000;
Pop1 = 0xFF1111DC;
Pop2 = 0xFFE80505;

View File

@ -0,0 +1,39 @@
name = "Strange";
Back = 0xFF161616;
Margin = 0xFF606590;
Margin_Hover = 0xFF606590;
Margin_Active = 0xFF9A99E7;
List_Item = Margin;
List_Item_Hover = Margin_Hover;
List_Item_Active = Margin_Active;
Cursor = 0xFFd96e26;
At_Cursor = Back;
Mark = 0xFF808080;
Highlight = 0xFF703419;
At_Highlight = 0xFFCDAA7D;
Default = 0xFFFFFFFF;
Comment = 0xFF505F89;
Keyword = 0xFFAA8DA7;
Str_Constant = 0xFF9A99E7;
Char_Constant = Str_Constant;
Include = Str_Constant;
Int_Constant = 0xFF007C00;
Float_Constant = Int_Constant;
Bool_Constant = Int_Constant;
Preproc = 0xFF606590;
Special_Character = 0xFFFF0000;
Ghost_Character = 0xFF8A8A8A;
Paste = 0xFFFFBB00;
Undo = 0xFF80005D;
Highlight_Junk = 0xFF3A0000;
Highlight_White = 0xFF003A3A;
Bar = 0xFF9A99E7;
Bar_Active = 0xFF9A99E7;
Base = 0xFF000000;
Pop1 = 0xFF03CF0C;
Pop2 = 0xFFFF0000;

View File

@ -0,0 +1,38 @@
name = "Twilight";
Back = 0xFF090D12;
Margin = 0xFF1A2634;
Margin_Hover = 0xFF2D415B;
Margin_Active = 0xFF405D82;
List_Item = Margin;
List_Item_Hover = Margin_Hover;
List_Item_Active = Margin_Active;
Cursor = 0xFFEEE800;
At_Cursor = Back;
Mark = 0xFF8BA8CC;
Highlight = 0xFF037A7B;
At_Highlight = Back;
Default = 0xFFB7C19E;
Comment = 0xFF20ECF0;
Keyword = 0xFFD86909;
Str_Constant = 0xFFC4EA5D;
Char_Constant = Str_Constant;
Int_Constant = Str_Constant;
Float_Constant = Str_Constant;
Bool_Constant = Str_Constant;
Include = Str_Constant;
Preproc = Default;
Special_Character = 0xFFFF0000;
Ghost_Character = 0xFF46494D;
Paste = 0xFFDDEE00;
Undo = 0xFF00DDEE;
Highlight_Junk = 0xFF3A0000;
Highlight_White = 0xFF151F2A;
Bar = 0xFF315E68;
Bar_Active = 0xFF0F3C46;
Base = 0xFF000000;
Pop1 = 0xFF1BFF0C;
Pop2 = 0xFFFF200D;

View File

@ -28,7 +28,6 @@
// Program setup // Program setup
// //
#define SUPPORT_DPI 1
#define UNICODE #define UNICODE
#define FPS 60 #define FPS 60
@ -195,11 +194,9 @@ struct Win32_Vars{
HWND window_handle; HWND window_handle;
Render_Target target; Render_Target target;
#if SUPPORT_DPI
i32 dpi_x, dpi_y; i32 dpi_x, dpi_y;
#endif
u64 count_per_usecond; f64 count_per_usecond;
b32 first; b32 first;
i32 running_cli; i32 running_cli;
@ -1712,7 +1709,7 @@ Win32HighResolutionTime(){
u64 result = 0; u64 result = 0;
LARGE_INTEGER t; LARGE_INTEGER t;
if (QueryPerformanceCounter(&t)){ if (QueryPerformanceCounter(&t)){
result = (u64)t.QuadPart / win32vars.count_per_usecond; result = (u64) (t.QuadPart / win32vars.count_per_usecond);
} }
return(result); return(result);
} }
@ -2123,25 +2120,30 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
#if defined(FRED_SUPER) #if defined(FRED_SUPER)
char *custom_file_default = "custom_4coder.dll"; char *custom_file_default = "custom_4coder.dll";
char *custom_file = 0; char *custom_file = 0;
if (win32vars.settings.custom_dll) custom_file = win32vars.settings.custom_dll; if (win32vars.settings.custom_dll){
else custom_file = custom_file_default; custom_file = win32vars.settings.custom_dll;
}
else{
custom_file = custom_file_default;
}
LOGF(system, "Trying to load custom DLL: %s\n", custom_file);
win32vars.custom = LoadLibraryA(custom_file); win32vars.custom = LoadLibraryA(custom_file);
if (!win32vars.custom && custom_file != custom_file_default){ if (!win32vars.custom && custom_file != custom_file_default){
if (!win32vars.settings.custom_dll_is_strict){ if (!win32vars.settings.custom_dll_is_strict){
LOGF(system, "Trying to load custom DLL: %s\n", custom_file_default);
win32vars.custom = LoadLibraryA(custom_file_default); win32vars.custom = LoadLibraryA(custom_file_default);
} }
} }
if (win32vars.custom){ if (win32vars.custom){
win32vars.custom_api.get_alpha_4coder_version = (_Get_Version_Function*) win32vars.custom_api.get_alpha_4coder_version = (_Get_Version_Function*)GetProcAddress(win32vars.custom, "get_alpha_4coder_version");
GetProcAddress(win32vars.custom, "get_alpha_4coder_version");
if (win32vars.custom_api.get_alpha_4coder_version == 0 || if (win32vars.custom_api.get_alpha_4coder_version == 0 || win32vars.custom_api.get_alpha_4coder_version(MAJOR, MINOR, PATCH) == 0){
win32vars.custom_api.get_alpha_4coder_version(MAJOR, MINOR, PATCH) == 0){
MessageBox_utf8(0, (u8*)"Error: The application and custom version numbers don't match.\n", (u8*)"Error",0); MessageBox_utf8(0, (u8*)"Error: The application and custom version numbers don't match.\n", (u8*)"Error",0);
exit(1); exit(1);
} }
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)GetProcAddress(win32vars.custom, "get_bindings"); win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)GetProcAddress(win32vars.custom, "get_bindings");
} }
@ -2158,7 +2160,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
// Window and GL Initialization // Window and GL Initialization
// //
WNDCLASS window_class = {}; WNDCLASS window_class = {0};
window_class.style = CS_HREDRAW|CS_VREDRAW; window_class.style = CS_HREDRAW|CS_VREDRAW;
window_class.lpfnWndProc = (WNDPROC)(Win32Callback); window_class.lpfnWndProc = (WNDPROC)(Win32Callback);
window_class.hInstance = hInstance; window_class.hInstance = hInstance;
@ -2169,8 +2171,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
exit(1); exit(1);
} }
RECT window_rect = {}; RECT window_rect = {0};
if (win32vars.settings.set_window_size){ if (win32vars.settings.set_window_size){
window_rect.right = win32vars.settings.window_w; window_rect.right = win32vars.settings.window_w;
window_rect.bottom = win32vars.settings.window_h; window_rect.bottom = win32vars.settings.window_h;
@ -2181,7 +2182,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
} }
if (!AdjustWindowRect(&window_rect, WS_OVERLAPPEDWINDOW, false)){ if (!AdjustWindowRect(&window_rect, WS_OVERLAPPEDWINDOW, false)){
// TODO(allen): non-fatal diagnostics LOG(system, "Could not get adjusted window.\n");
} }
i32 window_x = CW_USEDEFAULT; i32 window_x = CW_USEDEFAULT;
@ -2190,6 +2191,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
if (win32vars.settings.set_window_pos){ if (win32vars.settings.set_window_pos){
window_x = win32vars.settings.window_x; window_x = win32vars.settings.window_x;
window_y = win32vars.settings.window_y; window_y = win32vars.settings.window_y;
LOGF(system, "Setting window position (%d, %d)\n", window_x, window_y);
} }
i32 window_style = WS_OVERLAPPEDWINDOW; i32 window_style = WS_OVERLAPPEDWINDOW;
@ -2199,25 +2201,24 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
#define WINDOW_NAME L"4coder-window: " L_VERSION #define WINDOW_NAME L"4coder-window: " L_VERSION
LOG(system, "Creating window... ");
win32vars.window_handle = CreateWindow(window_class.lpszClassName, WINDOW_NAME, window_style, window_x, window_y, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, 0, 0, hInstance, 0); win32vars.window_handle = CreateWindow(window_class.lpszClassName, WINDOW_NAME, window_style, window_x, window_y, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, 0, 0, hInstance, 0);
if (win32vars.window_handle == 0){ if (win32vars.window_handle == 0){
LOG(system, "Failed\n");
exit(1); exit(1);
} }
else{
LOG(system, "Success\n");
}
{ {
HDC hdc = GetDC(win32vars.window_handle); HDC hdc = GetDC(win32vars.window_handle);
#if SUPPORT_DPI
// TODO(allen): not Windows XP compatible, how do I handle that? // TODO(allen): not Windows XP compatible, how do I handle that?
SetProcessDPIAware(); SetProcessDPIAware();
win32vars.dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); win32vars.dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
win32vars.dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); win32vars.dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
#else
win32vars.dpi_x = 1;
win32vars.dpi_y = 1;
#endif
GetClientRect(win32vars.window_handle, &window_rect); GetClientRect(win32vars.window_handle, &window_rect);
ReleaseDC(win32vars.window_handle, hdc); ReleaseDC(win32vars.window_handle, hdc);
@ -2230,12 +2231,14 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
// Font System Init // Font System Init
// //
LOG(system, "Initializing fonts\n");
system_font_init(&system->font, 0, 0, win32vars.settings.font_size, win32vars.settings.use_hinting); system_font_init(&system->font, 0, 0, win32vars.settings.font_size, win32vars.settings.use_hinting);
// //
// Misc System Initializations // Misc System Initializations
// //
LOG(system, "Initializing clipboard\n");
win32vars.clip_max = KB(16); win32vars.clip_max = KB(16);
win32vars.clip_buffer = (u8*)system_memory_allocate(win32vars.clip_max); win32vars.clip_buffer = (u8*)system_memory_allocate(win32vars.clip_max);
@ -2263,24 +2266,27 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
LARGE_INTEGER f; LARGE_INTEGER f;
if (QueryPerformanceFrequency(&f)){ if (QueryPerformanceFrequency(&f)){
win32vars.count_per_usecond = (u64)f.QuadPart / 1000000; win32vars.count_per_usecond = (f32)f.QuadPart / 1000000.f;
LOGF(system, "Got performance frequency %f\n", win32vars.count_per_usecond);
} }
else{ else{
// NOTE(allen): Just guess. // NOTE(allen): Just guess.
win32vars.count_per_usecond = 1; win32vars.count_per_usecond = 1.f;
LOG(system, "Did not get performance frequency, just guessing with 1.\n");
} }
Assert(win32vars.count_per_usecond != 0); Assert(win32vars.count_per_usecond > 0.f);
// //
// Main Loop // Main Loop
// //
LOG(system, "Initializing application variables\n");
win32vars.app.init(system, &win32vars.target, &memory_vars, win32vars.clipboard_contents, current_directory, win32vars.custom_api); win32vars.app.init(system, &win32vars.target, &memory_vars, win32vars.clipboard_contents, current_directory, win32vars.custom_api);
system_memory_free(current_directory.str, 0); system_memory_free(current_directory.str, 0);
b32 keep_playing = 1; b32 keep_playing = true;
win32vars.first = 1; win32vars.first = true;
timeBeginPeriod(1); timeBeginPeriod(1);
if (win32vars.settings.fullscreen_window){ if (win32vars.settings.fullscreen_window){
@ -2291,6 +2297,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
SetActiveWindow(win32vars.window_handle); SetActiveWindow(win32vars.window_handle);
ShowWindow(win32vars.window_handle, SW_SHOW); ShowWindow(win32vars.window_handle, SW_SHOW);
LOG(system, "Beginning main loop\n");
u64 timer_start = Win32HighResolutionTime(); u64 timer_start = Win32HighResolutionTime();
system_acquire_lock(FRAME_LOCK); system_acquire_lock(FRAME_LOCK);
MSG msg; MSG msg;