win32 layer organization
This commit is contained in:
parent
7b4f422744
commit
3ad0772662
|
@ -141,22 +141,24 @@ CUSTOM_COMMAND_SIG(open_my_files){
|
||||||
// any circumstance.
|
// any circumstance.
|
||||||
push_parameter(app, par_name, literal("w:/4ed/data/test/basic.cpp"));
|
push_parameter(app, par_name, literal("w:/4ed/data/test/basic.cpp"));
|
||||||
exec_command(app, cmdid_interactive_open);
|
exec_command(app, cmdid_interactive_open);
|
||||||
|
|
||||||
|
#if 0
|
||||||
exec_command(app, cmdid_change_active_panel);
|
exec_command(app, cmdid_change_active_panel);
|
||||||
|
|
||||||
char my_file[256];
|
char my_file[256];
|
||||||
int my_file_len;
|
int my_file_len;
|
||||||
|
|
||||||
my_file_len = sizeof("w:/4ed/data/test/basic.txt") - 1;
|
my_file_len = sizeof("w:/4ed/data/test/basic.txt") - 1;
|
||||||
for (int i = 0; i < my_file_len; ++i){
|
for (int i = 0; i < my_file_len; ++i){
|
||||||
my_file[i] = ("w:/4ed/data/test/basic.txt")[i];
|
my_file[i] = ("w:/4ed/data/test/basic.txt")[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen|a3.1): null terminators are not needed for strings.
|
// NOTE(allen|a3.1): null terminators are not needed for strings.
|
||||||
push_parameter(app, par_name, my_file, my_file_len);
|
push_parameter(app, par_name, my_file, my_file_len);
|
||||||
exec_command(app, cmdid_interactive_open);
|
exec_command(app, cmdid_interactive_open);
|
||||||
|
|
||||||
exec_command(app, cmdid_change_active_panel);
|
exec_command(app, cmdid_change_active_panel);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(build_at_launch_location){
|
CUSTOM_COMMAND_SIG(build_at_launch_location){
|
||||||
|
@ -434,93 +436,7 @@ get_bindings(void *data, int size){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Custom_Vars{
|
#include "4coder_default_view.cpp"
|
||||||
int initialized;
|
|
||||||
Partition part;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum View_Mode{
|
|
||||||
ViewMode_File,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct View_Vars{
|
|
||||||
int id;
|
|
||||||
View_Mode mode;
|
|
||||||
|
|
||||||
GUI_Scroll_Vars scroll;
|
|
||||||
i32_Rect scroll_region;
|
|
||||||
|
|
||||||
int buffer_id;
|
|
||||||
};
|
|
||||||
inline View_Vars
|
|
||||||
view_vars_zero(){
|
|
||||||
View_Vars vars = {0};
|
|
||||||
return(vars);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void
|
|
||||||
view_routine(Application_Links *app, int view_id){
|
|
||||||
Custom_Vars *vars = (Custom_Vars*)app->memory;
|
|
||||||
View_Vars view = {0};
|
|
||||||
view.id = view_id;
|
|
||||||
|
|
||||||
int show_scrollbar = 1;
|
|
||||||
|
|
||||||
if (!vars->initialized){
|
|
||||||
vars->initialized = 1;
|
|
||||||
vars->part = make_part(app->memory, app->memory_size);
|
|
||||||
push_struct(&vars->part, Custom_Vars);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(;;){
|
|
||||||
Event_Message message = {0};
|
|
||||||
message = app->get_event_message(app);
|
|
||||||
|
|
||||||
switch (message.type){
|
|
||||||
case EM_Open_View:
|
|
||||||
{
|
|
||||||
view = view_vars_zero();
|
|
||||||
view.id = view_id;
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case EM_Frame:
|
|
||||||
{
|
|
||||||
GUI_Functions *guifn = app->get_gui_functions(app);
|
|
||||||
GUI *gui = app->get_gui(app, view_id);
|
|
||||||
|
|
||||||
guifn->begin(gui);
|
|
||||||
guifn->top_bar(gui);
|
|
||||||
|
|
||||||
switch (view.mode){
|
|
||||||
case ViewMode_File:
|
|
||||||
// TODO(allen): Overlapped widget
|
|
||||||
GUI_id scroll_id;
|
|
||||||
scroll_id.id[1] = view.mode;
|
|
||||||
scroll_id.id[0] = view.buffer_id;
|
|
||||||
|
|
||||||
guifn->get_scroll_vars(gui, scroll_id, &view.scroll,
|
|
||||||
&view.scroll_region);
|
|
||||||
guifn->begin_scrollable(gui, scroll_id, view.scroll,
|
|
||||||
144.f, show_scrollbar);
|
|
||||||
guifn->file(gui, view.buffer_id);
|
|
||||||
guifn->end_scrollable(gui);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
guifn->end(gui);
|
|
||||||
|
|
||||||
// TODO(allen): Put this code in charge of dispatching
|
|
||||||
// to the command or command coroutine or whatever.
|
|
||||||
|
|
||||||
// TODO(allen): Put this code in charge of when to process
|
|
||||||
// the GUI with input and retrieve new layout data.
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case EM_Close_View:
|
|
||||||
{}break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
|
||||||
|
struct Custom_Vars{
|
||||||
|
int initialized;
|
||||||
|
Partition part;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum View_Mode{
|
||||||
|
ViewMode_File,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct View_Vars{
|
||||||
|
int id;
|
||||||
|
View_Mode mode;
|
||||||
|
|
||||||
|
GUI_Scroll_Vars scroll;
|
||||||
|
i32_Rect scroll_region;
|
||||||
|
|
||||||
|
int buffer_id;
|
||||||
|
};
|
||||||
|
inline View_Vars
|
||||||
|
view_vars_zero(){
|
||||||
|
View_Vars vars = {0};
|
||||||
|
return(vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void
|
||||||
|
view_routine(Application_Links *app, int view_id){
|
||||||
|
Custom_Vars *vars = (Custom_Vars*)app->memory;
|
||||||
|
View_Vars view = {0};
|
||||||
|
view.id = view_id;
|
||||||
|
|
||||||
|
int show_scrollbar = 1;
|
||||||
|
|
||||||
|
if (!vars->initialized){
|
||||||
|
vars->initialized = 1;
|
||||||
|
vars->part = make_part(app->memory, app->memory_size);
|
||||||
|
push_struct(&vars->part, Custom_Vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(;;){
|
||||||
|
Event_Message message = {0};
|
||||||
|
message = app->get_event_message(app);
|
||||||
|
|
||||||
|
switch (message.type){
|
||||||
|
case EM_Open_View:
|
||||||
|
{
|
||||||
|
view = view_vars_zero();
|
||||||
|
view.id = view_id;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case EM_Frame:
|
||||||
|
{
|
||||||
|
GUI_Functions *guifn = app->get_gui_functions(app);
|
||||||
|
GUI *gui = app->get_gui(app, view_id);
|
||||||
|
|
||||||
|
guifn->begin(gui);
|
||||||
|
guifn->top_bar(gui);
|
||||||
|
|
||||||
|
switch (view.mode){
|
||||||
|
case ViewMode_File:
|
||||||
|
// TODO(allen): Overlapped widget
|
||||||
|
GUI_id scroll_id;
|
||||||
|
scroll_id.id[1] = view.mode;
|
||||||
|
scroll_id.id[0] = view.buffer_id;
|
||||||
|
|
||||||
|
guifn->get_scroll_vars(gui, scroll_id, &view.scroll,
|
||||||
|
&view.scroll_region);
|
||||||
|
guifn->begin_scrollable(gui, scroll_id, view.scroll,
|
||||||
|
144.f, show_scrollbar);
|
||||||
|
guifn->file(gui, view.buffer_id);
|
||||||
|
guifn->end_scrollable(gui);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
guifn->end(gui);
|
||||||
|
|
||||||
|
// TODO(allen): Put this code in charge of dispatching
|
||||||
|
// to the command or command coroutine or whatever.
|
||||||
|
|
||||||
|
// TODO(allen): Put this code in charge of when to process
|
||||||
|
// the GUI with input and retrieve new layout data.
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case EM_Close_View:
|
||||||
|
{}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -143,7 +143,9 @@ general_memory_attempt_merge(Bubble *left, Bubble *right){
|
||||||
internal void
|
internal void
|
||||||
general_memory_free(General_Memory *general, void *memory){
|
general_memory_free(General_Memory *general, void *memory){
|
||||||
Bubble *bubble = ((Bubble*)memory) - 1;
|
Bubble *bubble = ((Bubble*)memory) - 1;
|
||||||
Assert((!FRED_INTERNAL) || (bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_DEBUG);
|
#if FRED_INTERNAL
|
||||||
|
Assert((bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_DEBUG);
|
||||||
|
#endif
|
||||||
bubble->flags &= ~MEM_BUBBLE_USED;
|
bubble->flags &= ~MEM_BUBBLE_USED;
|
||||||
bubble->type = 0;
|
bubble->type = 0;
|
||||||
Bubble *prev, *next;
|
Bubble *prev, *next;
|
||||||
|
@ -158,7 +160,9 @@ general_memory_reallocate(General_Memory *general, void *old, i32 old_size, i32
|
||||||
void *result = old;
|
void *result = old;
|
||||||
Bubble *bubble = ((Bubble*)old) - 1;
|
Bubble *bubble = ((Bubble*)old) - 1;
|
||||||
bubble->type = type;
|
bubble->type = type;
|
||||||
Assert((!FRED_INTERNAL) || (bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_DEBUG);
|
#if FRED_INTERNAL
|
||||||
|
Assert((bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_DEBUG);
|
||||||
|
#endif
|
||||||
i32 additional_space = size - bubble->size;
|
i32 additional_space = size - bubble->size;
|
||||||
if (additional_space > 0){
|
if (additional_space > 0){
|
||||||
Bubble *next = bubble->next;
|
Bubble *next = bubble->next;
|
||||||
|
|
10
4ed_system.h
10
4ed_system.h
|
@ -226,15 +226,15 @@ struct System_Functions{
|
||||||
System_File_Load_Begin *file_load_begin;
|
System_File_Load_Begin *file_load_begin;
|
||||||
System_File_Load_End *file_load_end;
|
System_File_Load_End *file_load_end;
|
||||||
System_File_Save *file_save;
|
System_File_Save *file_save;
|
||||||
|
|
||||||
// file system navigation (4coder_custom.h): 3
|
// file system navigation (4coder_custom.h): 3
|
||||||
File_Exists_Function *file_exists;
|
File_Exists_Function *file_exists;
|
||||||
Directory_CD_Function *directory_cd;
|
Directory_CD_Function *directory_cd;
|
||||||
Get_4ed_Path_Function *get_4ed_path;
|
Get_4ed_Path_Function *get_4ed_path;
|
||||||
|
|
||||||
// clipboard: 1
|
// clipboard: 1
|
||||||
System_Post_Clipboard *post_clipboard;
|
System_Post_Clipboard *post_clipboard;
|
||||||
|
|
||||||
// time: 1
|
// time: 1
|
||||||
System_Time *time;
|
System_Time *time;
|
||||||
|
|
||||||
|
@ -249,14 +249,14 @@ struct System_Functions{
|
||||||
System_CLI_Begin_Update *cli_begin_update;
|
System_CLI_Begin_Update *cli_begin_update;
|
||||||
System_CLI_Update_Step *cli_update_step;
|
System_CLI_Update_Step *cli_update_step;
|
||||||
System_CLI_End_Update *cli_end_update;
|
System_CLI_End_Update *cli_end_update;
|
||||||
|
|
||||||
// threads: 5
|
// threads: 5
|
||||||
System_Post_Job *post_job;
|
System_Post_Job *post_job;
|
||||||
System_Cancel_Job *cancel_job;
|
System_Cancel_Job *cancel_job;
|
||||||
System_Grow_Thread_Memory *grow_thread_memory;
|
System_Grow_Thread_Memory *grow_thread_memory;
|
||||||
System_Acquire_Lock *acquire_lock;
|
System_Acquire_Lock *acquire_lock;
|
||||||
System_Release_Lock *release_lock;
|
System_Release_Lock *release_lock;
|
||||||
|
|
||||||
// debug: 3
|
// debug: 3
|
||||||
INTERNAL_System_Sentinel *internal_sentinel;
|
INTERNAL_System_Sentinel *internal_sentinel;
|
||||||
INTERNAL_System_Get_Thread_States *internal_get_thread_states;
|
INTERNAL_System_Get_Thread_States *internal_get_thread_states;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Distribution Date: 24.5.2016 (dd.mm.yyyy)
|
Distribution Date: 28.5.2016 (dd.mm.yyyy)
|
||||||
|
|
||||||
Thank you for contributing to the 4coder project!
|
Thank you for contributing to the 4coder project!
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Distribution Date: 24.5.2016 (dd.mm.yyyy)
|
Distribution Date: 28.5.2016 (dd.mm.yyyy)
|
||||||
|
|
||||||
Thank you for contributing to the 4coder project!
|
Thank you for contributing to the 4coder project!
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ if %ERRORLEVEL% neq 0 (set FirstError=1)
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd ..\build
|
pushd ..\build
|
||||||
call "..\code\buildsuper.bat" ..\code\4coder_default_bindings.cpp
|
REM call "..\code\buildsuper.bat" ..\code\4coder_default_bindings.cpp
|
||||||
REM call "..\code\buildsuper.bat" ..\code\power\4coder_experiments.cpp
|
call "..\code\buildsuper.bat" ..\code\power\4coder_experiments.cpp
|
||||||
REM call "..\code\buildsuper.bat" ..\code\power\4coder_casey.cpp
|
REM call "..\code\buildsuper.bat" ..\code\power\4coder_casey.cpp
|
||||||
if %ERRORLEVEL% neq 0 (set FirstError=1)
|
if %ERRORLEVEL% neq 0 (set FirstError=1)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#define NO_BINDING
|
#define NO_BINDING
|
||||||
#include "../4coder_default_bindings.cpp"
|
#include "../4coder_default_bindings.cpp"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(kill_rect){
|
CUSTOM_COMMAND_SIG(kill_rect){
|
||||||
View_Summary view = app->get_active_view(app);
|
View_Summary view = app->get_active_view(app);
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id);
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id);
|
||||||
|
@ -377,10 +379,7 @@ get_bindings(void *data, int size){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
#include "..\4coder_default_view.cpp"
|
||||||
view_routine(Application_Links *app, int view_id){
|
|
||||||
app->get_user_input(app, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
225
win32_4ed.cpp
225
win32_4ed.cpp
|
@ -200,7 +200,7 @@ Win32Ptr(void *h){
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// System Layer Memory
|
// Memory (not exposed to application, but needed in system_shared.cpp)
|
||||||
//
|
//
|
||||||
|
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
|
@ -273,7 +273,7 @@ INTERNAL_system_debug_message(char *message){
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Platform Layer File Services
|
// File
|
||||||
//
|
//
|
||||||
|
|
||||||
internal
|
internal
|
||||||
|
@ -388,8 +388,7 @@ Sys_File_Save_Sig(system_file_save){
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_File_Time_Stamp_Sig(system_file_time_stamp){
|
Sys_File_Time_Stamp_Sig(system_file_time_stamp){
|
||||||
u64 result;
|
u64 result = 0;
|
||||||
result = 0;
|
|
||||||
|
|
||||||
FILETIME last_write;
|
FILETIME last_write;
|
||||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||||
|
@ -539,6 +538,7 @@ Sys_File_Unique_Hash_Sig(system_file_unique_hash){
|
||||||
return(hash);
|
return(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): Exposed to the custom layer.
|
||||||
internal
|
internal
|
||||||
FILE_EXISTS_SIG(system_file_exists){
|
FILE_EXISTS_SIG(system_file_exists){
|
||||||
char full_filename_space[1024];
|
char full_filename_space[1024];
|
||||||
|
@ -571,6 +571,7 @@ b32 Win32DirectoryExists(char *path){
|
||||||
(attrib & FILE_ATTRIBUTE_DIRECTORY));
|
(attrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): Exposed to the custom layer.
|
||||||
internal
|
internal
|
||||||
DIRECTORY_CD_SIG(system_directory_cd){
|
DIRECTORY_CD_SIG(system_directory_cd){
|
||||||
String directory = make_string(dir, *len, capacity);
|
String directory = make_string(dir, *len, capacity);
|
||||||
|
@ -618,11 +619,16 @@ Sys_Get_Binary_Path_Sig(system_get_binary_path){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): Exposed to the custom layer.
|
||||||
GET_4ED_PATH_SIG(system_get_4ed_path){
|
GET_4ED_PATH_SIG(system_get_4ed_path){
|
||||||
String str = make_string(out, 0, capacity);
|
String str = make_string(out, 0, capacity);
|
||||||
return(system_get_binary_path(&str));
|
return(system_get_binary_path(&str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clipboard
|
||||||
|
//
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
if (OpenClipboard(win32vars.window_handle)){
|
if (OpenClipboard(win32vars.window_handle)){
|
||||||
|
@ -640,6 +646,10 @@ Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Multithreading
|
||||||
|
//
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_Acquire_Lock_Sig(system_acquire_lock){
|
Sys_Acquire_Lock_Sig(system_acquire_lock){
|
||||||
WaitForSingleObject(win32vars.locks[id], INFINITE);
|
WaitForSingleObject(win32vars.locks[id], INFINITE);
|
||||||
|
@ -650,38 +660,7 @@ Sys_Release_Lock_Sig(system_release_lock){
|
||||||
ReleaseSemaphore(win32vars.locks[id], 1, 0);
|
ReleaseSemaphore(win32vars.locks[id], 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal DWORD
|
||||||
Win32SetCursorFromUpdate(Application_Mouse_Cursor cursor){
|
|
||||||
switch (cursor){
|
|
||||||
case APP_MOUSE_CURSOR_ARROW:
|
|
||||||
SetCursor(win32vars.cursor_arrow); break;
|
|
||||||
|
|
||||||
case APP_MOUSE_CURSOR_IBEAM:
|
|
||||||
SetCursor(win32vars.cursor_ibeam); break;
|
|
||||||
|
|
||||||
case APP_MOUSE_CURSOR_LEFTRIGHT:
|
|
||||||
SetCursor(win32vars.cursor_leftright); break;
|
|
||||||
|
|
||||||
case APP_MOUSE_CURSOR_UPDOWN:
|
|
||||||
SetCursor(win32vars.cursor_updown); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
Win32Resize(i32 width, i32 height){
|
|
||||||
if (width > 0 && height > 0){
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
glOrtho(0, width, height, 0, -1, 1);
|
|
||||||
glScissor(0, 0, width, height);
|
|
||||||
|
|
||||||
win32vars.target.width = width;
|
|
||||||
win32vars.target.height = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal DWORD WINAPI
|
|
||||||
JobThreadProc(LPVOID lpParameter){
|
JobThreadProc(LPVOID lpParameter){
|
||||||
Thread_Context *thread = (Thread_Context*)lpParameter;
|
Thread_Context *thread = (Thread_Context*)lpParameter;
|
||||||
Work_Queue *queue = thread->queue;
|
Work_Queue *queue = thread->queue;
|
||||||
|
@ -766,6 +745,8 @@ Sys_Post_Job_Sig(system_post_job){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(allen): I would like to get rid of job canceling
|
||||||
|
// but I still don't know what exactly I would do without it.
|
||||||
internal
|
internal
|
||||||
Sys_Cancel_Job_Sig(system_cancel_job){
|
Sys_Cancel_Job_Sig(system_cancel_job){
|
||||||
Work_Queue *queue = exchange_vars.thread.queues + group_id;
|
Work_Queue *queue = exchange_vars.thread.queues + group_id;
|
||||||
|
@ -829,6 +810,10 @@ INTERNAL_get_thread_states(Thread_Group_ID id, bool8 *running, i32 *pending){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Coroutine
|
||||||
|
//
|
||||||
|
|
||||||
internal Win32_Coroutine*
|
internal Win32_Coroutine*
|
||||||
Win32AllocCoroutine(){
|
Win32AllocCoroutine(){
|
||||||
Win32_Coroutine *result = win32vars.coroutine_free;
|
Win32_Coroutine *result = win32vars.coroutine_free;
|
||||||
|
@ -919,6 +904,10 @@ Sys_Yield_Coroutine_Sig(system_yield_coroutine){
|
||||||
SwitchToFiber(coroutine->yield_handle);
|
SwitchToFiber(coroutine->yield_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Command Line Exectuion
|
||||||
|
//
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_CLI_Call_Sig(system_cli_call){
|
Sys_CLI_Call_Sig(system_cli_call){
|
||||||
char cmd[] = "c:\\windows\\system32\\cmd.exe";
|
char cmd[] = "c:\\windows\\system32\\cmd.exe";
|
||||||
|
@ -1060,6 +1049,40 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
|
||||||
return close_me;
|
return close_me;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "system_shared.cpp"
|
||||||
|
#include "4ed_rendering.cpp"
|
||||||
|
|
||||||
|
internal
|
||||||
|
Font_Load_Sig(system_draw_font_load){
|
||||||
|
if (win32vars.font_part.base == 0){
|
||||||
|
win32vars.font_part = Win32ScratchPartition(Mbytes(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
i32 oversample = 2;
|
||||||
|
|
||||||
|
for (b32 success = 0; success == 0;){
|
||||||
|
success = draw_font_load(&win32vars.font_part,
|
||||||
|
font_out,
|
||||||
|
filename,
|
||||||
|
pt_size,
|
||||||
|
tab_width,
|
||||||
|
oversample);
|
||||||
|
|
||||||
|
// TODO(allen): Make the growable partition something that can
|
||||||
|
// just be passed directly to font load and let it be grown there.
|
||||||
|
if (!success){
|
||||||
|
Win32ScratchPartitionDouble(&win32vars.font_part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Linkage to Custom and Application
|
||||||
|
//
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
Win32LoadAppCode(){
|
Win32LoadAppCode(){
|
||||||
b32 result = 0;
|
b32 result = 0;
|
||||||
|
@ -1151,7 +1174,7 @@ Win32LoadSystemCode(){
|
||||||
win32vars.system->acquire_lock = system_acquire_lock;
|
win32vars.system->acquire_lock = system_acquire_lock;
|
||||||
win32vars.system->release_lock = system_release_lock;
|
win32vars.system->release_lock = system_release_lock;
|
||||||
|
|
||||||
#ifdef FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
win32vars.system->internal_sentinel = INTERNAL_system_sentinel;
|
win32vars.system->internal_sentinel = INTERNAL_system_sentinel;
|
||||||
win32vars.system->internal_get_thread_states = INTERNAL_get_thread_states;
|
win32vars.system->internal_get_thread_states = INTERNAL_get_thread_states;
|
||||||
win32vars.system->internal_debug_message = INTERNAL_system_debug_message;
|
win32vars.system->internal_debug_message = INTERNAL_system_debug_message;
|
||||||
|
@ -1160,35 +1183,6 @@ Win32LoadSystemCode(){
|
||||||
win32vars.system->slash = '/';
|
win32vars.system->slash = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "system_shared.cpp"
|
|
||||||
#include "4ed_rendering.cpp"
|
|
||||||
|
|
||||||
internal
|
|
||||||
Font_Load_Sig(system_draw_font_load){
|
|
||||||
if (win32vars.font_part.base == 0){
|
|
||||||
win32vars.font_part = Win32ScratchPartition(Mbytes(8));
|
|
||||||
}
|
|
||||||
|
|
||||||
i32 oversample = 2;
|
|
||||||
|
|
||||||
for (b32 success = 0; success == 0;){
|
|
||||||
success = draw_font_load(&win32vars.font_part,
|
|
||||||
font_out,
|
|
||||||
filename,
|
|
||||||
pt_size,
|
|
||||||
tab_width,
|
|
||||||
oversample);
|
|
||||||
|
|
||||||
// TODO(allen): Make the growable partition something that can
|
|
||||||
// just be passed directly to font load and let it be grown there.
|
|
||||||
if (!success){
|
|
||||||
Win32ScratchPartitionDouble(&win32vars.font_part);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
Win32LoadRenderCode(){
|
Win32LoadRenderCode(){
|
||||||
win32vars.target.push_clip = draw_push_clip;
|
win32vars.target.push_clip = draw_push_clip;
|
||||||
|
@ -1200,26 +1194,14 @@ Win32LoadRenderCode(){
|
||||||
win32vars.target.font_set.release_font = draw_release_font;
|
win32vars.target.font_set.release_font = draw_release_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
//
|
||||||
Win32RedrawScreen(HDC hdc){
|
// Helpers
|
||||||
launch_rendering(&win32vars.target);
|
//
|
||||||
glFlush();
|
|
||||||
SwapBuffers(hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
Win32RedrawFromUpdate(){
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HWND hwnd = win32vars.window_handle;
|
|
||||||
HDC hdc = BeginPaint(hwnd, &ps);
|
|
||||||
Win32RedrawScreen(hdc);
|
|
||||||
EndPaint(hwnd, &ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
globalvar u8 keycode_lookup_table[255];
|
globalvar u8 keycode_lookup_table[255];
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
keycode_init(){
|
Win32KeycodeInit(){
|
||||||
keycode_lookup_table[VK_BACK] = key_back;
|
keycode_lookup_table[VK_BACK] = key_back;
|
||||||
keycode_lookup_table[VK_DELETE] = key_del;
|
keycode_lookup_table[VK_DELETE] = key_del;
|
||||||
keycode_lookup_table[VK_UP] = key_up;
|
keycode_lookup_table[VK_UP] = key_up;
|
||||||
|
@ -1252,9 +1234,55 @@ keycode_init(){
|
||||||
keycode_lookup_table[VK_F16] = key_f16;
|
keycode_lookup_table[VK_F16] = key_f16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Win32RedrawScreen(HDC hdc){
|
||||||
|
launch_rendering(&win32vars.target);
|
||||||
|
glFlush();
|
||||||
|
SwapBuffers(hdc);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Win32RedrawFromUpdate(){
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HWND hwnd = win32vars.window_handle;
|
||||||
|
HDC hdc = BeginPaint(hwnd, &ps);
|
||||||
|
Win32RedrawScreen(hdc);
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Win32Resize(i32 width, i32 height){
|
||||||
|
if (width > 0 && height > 0){
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, width, height, 0, -1, 1);
|
||||||
|
glScissor(0, 0, width, height);
|
||||||
|
|
||||||
|
win32vars.target.width = width;
|
||||||
|
win32vars.target.height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Win32SetCursorFromUpdate(Application_Mouse_Cursor cursor){
|
||||||
|
switch (cursor){
|
||||||
|
case APP_MOUSE_CURSOR_ARROW:
|
||||||
|
SetCursor(win32vars.cursor_arrow); break;
|
||||||
|
|
||||||
|
case APP_MOUSE_CURSOR_IBEAM:
|
||||||
|
SetCursor(win32vars.cursor_ibeam); break;
|
||||||
|
|
||||||
|
case APP_MOUSE_CURSOR_LEFTRIGHT:
|
||||||
|
SetCursor(win32vars.cursor_leftright); break;
|
||||||
|
|
||||||
|
case APP_MOUSE_CURSOR_UPDOWN:
|
||||||
|
SetCursor(win32vars.cursor_updown); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal LRESULT
|
internal LRESULT
|
||||||
Win32Callback(HWND hwnd, UINT uMsg,
|
Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
||||||
WPARAM wParam, LPARAM lParam){
|
|
||||||
LRESULT result = {};
|
LRESULT result = {};
|
||||||
switch (uMsg){
|
switch (uMsg){
|
||||||
case WM_MENUCHAR:
|
case WM_MENUCHAR:
|
||||||
|
@ -1562,7 +1590,6 @@ OpenGLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsi
|
||||||
OutputDebugStringA("\n");
|
OutputDebugStringA("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
int
|
int
|
||||||
WinMain(HINSTANCE hInstance,
|
WinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
|
@ -1572,12 +1599,6 @@ WinMain(HINSTANCE hInstance,
|
||||||
int argc = __argc;
|
int argc = __argc;
|
||||||
char **argv = __argv;
|
char **argv = __argv;
|
||||||
|
|
||||||
#else
|
|
||||||
int main(int argc, char **argv){
|
|
||||||
|
|
||||||
HINSTANCE hInstance = GetModuleHandle(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HANDLE original_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE original_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
memset(&win32vars, 0, sizeof(win32vars));
|
memset(&win32vars, 0, sizeof(win32vars));
|
||||||
|
@ -1701,6 +1722,14 @@ int main(int argc, char **argv){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (win32vars.custom_api.get_bindings == 0){
|
||||||
|
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)get_bindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (win32vars.custom_api.view_routine == 0){
|
||||||
|
win32vars.custom_api.view_routine = (View_Routine_Function*)view_routine;
|
||||||
|
}
|
||||||
|
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
|
||||||
sysshared_filter_real_files(files, file_count);
|
sysshared_filter_real_files(files, file_count);
|
||||||
|
@ -1716,11 +1745,7 @@ int main(int argc, char **argv){
|
||||||
win32vars.start_time = ((u64)filetime.dwHighDateTime << 32) | (filetime.dwLowDateTime);
|
win32vars.start_time = ((u64)filetime.dwHighDateTime << 32) | (filetime.dwLowDateTime);
|
||||||
win32vars.start_time /= 10;
|
win32vars.start_time /= 10;
|
||||||
|
|
||||||
keycode_init();
|
Win32KeycodeInit();
|
||||||
|
|
||||||
if (win32vars.custom_api.get_bindings == 0){
|
|
||||||
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)get_bindings;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread_Context background[4];
|
Thread_Context background[4];
|
||||||
memset(background, 0, sizeof(background));
|
memset(background, 0, sizeof(background));
|
||||||
|
@ -2074,6 +2099,14 @@ int main(int argc, char **argv){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// NOTE(allen): In case I want to switch back to a console
|
||||||
|
// application at some point.
|
||||||
|
int main(int argc, char **argv){
|
||||||
|
HINSTANCE hInstance = GetModuleHandle(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue