Cleaning up dependencies in platform layer

master
Allen Webster 2019-10-01 16:50:56 -07:00
parent 19034b7887
commit e32231c0a0
7 changed files with 38 additions and 79 deletions

View File

@ -168,7 +168,7 @@ gl__make_program(char *header, char *vertex, char *fragment){
#define GLOffset(S,m) ((void*)(OffsetOfMember(S,m))) #define GLOffset(S,m) ((void*)(OffsetOfMember(S,m)))
internal void internal void
gl_render(Render_Target *t, Arena *scratch){ gl_render(Render_Target *t){
Font_Set *font_set = (Font_Set*)t->font_set; Font_Set *font_set = (Font_Set*)t->font_set;
local_persist b32 first_opengl_call = true; local_persist b32 first_opengl_call = true;

View File

@ -97,7 +97,17 @@ read_command_line(Thread_Context *tctx, i32 argc, char **argv){
char **files = 0; char **files = 0;
i32 *file_count = 0; i32 *file_count = 0;
void *result = app.read_command_line(tctx, &sysfunc, curdir, &plat_settings, &files, &file_count, argc, argv); void *result = app.read_command_line(tctx, &sysfunc, curdir, &plat_settings, &files, &file_count, argc, argv);
sysshared_filter_real_files(scratch, files, file_count); {
i32 end = *file_count;
i32 i = 0, j = 0;
for (; i < end; ++i){
if (system_file_can_be_made(scratch, (u8*)files[i])){
files[j] = files[i];
++j;
}
}
*file_count = j;
}
return(result); return(result);
} }

View File

@ -12,32 +12,11 @@
#if !defined(FCODER_SYSTEM_SHARED_CPP) #if !defined(FCODER_SYSTEM_SHARED_CPP)
#define FCODER_SYSTEM_SHARED_CPP #define FCODER_SYSTEM_SHARED_CPP
//
// Standard implementation of file system stuff based on the file track layer.
//
internal void
init_shared_vars(){
shared_vars.font_scratch = make_arena_system(&sysfunc);
shared_vars.pixel_scratch = make_arena_system(&sysfunc);
}
// //
// General shared pieces // General shared pieces
// //
internal void #error Remove this file
sysshared_filter_real_files(Arena *scratch, char **files, i32 *file_count){
i32 end = *file_count;
i32 i = 0, j = 0;
for (; i < end; ++i){
if (system_file_can_be_made(scratch, (u8*)files[i])){
files[j] = files[i];
++j;
}
}
*file_count = j;
}
#endif #endif

View File

@ -17,21 +17,7 @@
#if !defined(FRED_SYSTEM_SHARED_H) #if !defined(FRED_SYSTEM_SHARED_H)
#define FRED_SYSTEM_SHARED_H #define FRED_SYSTEM_SHARED_H
struct File_Data{ #error Remove this file
char *data;
u32 size;
b32 got_file;
};
global File_Data null_file_data = {};
#define Sys_File_Can_Be_Made_Sig(name) b32 name(Arena *scratch, u8 *filename)
internal Sys_File_Can_Be_Made_Sig(system_file_can_be_made);
struct Shared_Vars{
Arena font_scratch;
Arena pixel_scratch;
};
global Shared_Vars shared_vars;
#endif #endif

View File

@ -48,6 +48,7 @@
#include <Windows.h> #include <Windows.h>
#define function static #define function static
#include "win32_utf8.h"
#include "win32_gl.h" #include "win32_gl.h"
////////////////////////////// //////////////////////////////
@ -62,10 +63,6 @@ win32_output_error_string(Arena *scratch, i32 error_string_type);
////////////////////////////// //////////////////////////////
#include "win32_utf8.h"
#include "4ed_system_shared.h"
#define WM_4coder_ANIMATE (WM_USER + 0) #define WM_4coder_ANIMATE (WM_USER + 0)
struct Control_Keys{ struct Control_Keys{
@ -324,8 +321,6 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){
return(result); return(result);
} }
#include "4ed_system_shared.cpp"
// //
// Clipboard // Clipboard
// //
@ -1529,13 +1524,18 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
InitializeCriticalSection(&win32vars.thread_launch_mutex); InitializeCriticalSection(&win32vars.thread_launch_mutex);
InitializeConditionVariable(&win32vars.thread_launch_cv); InitializeConditionVariable(&win32vars.thread_launch_cv);
// SetProcessDPIAware();
// HACK(allen):
// Previously zipped stuff is here, it should be zipped in the new pattern now.
//
init_shared_vars(); {
HDC dc = GetDC(0);
i32 x_dpi = GetDeviceCaps(dc, LOGPIXELSX);
i32 y_dpi = GetDeviceCaps(dc, LOGPIXELSY);
i32 max_dpi = max(x_dpi, y_dpi);
win32vars.screen_scale_factor = ((f32)max_dpi)/96.f;
ReleaseDC(0, dc);
}
// TODO(allen):
load_app_code(win32vars.tctx); load_app_code(win32vars.tctx);
win32vars.log_string = app.get_logger(&sysfunc); win32vars.log_string = app.get_logger(&sysfunc);
void *base_ptr = read_command_line(win32vars.tctx, argc, argv); void *base_ptr = read_command_line(win32vars.tctx, argc, argv);
@ -1550,18 +1550,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
custom_api.get_bindings = get_bindings; custom_api.get_bindings = get_bindings;
#endif #endif
SetProcessDPIAware();
{
HDC dc = GetDC(0);
i32 x_dpi = GetDeviceCaps(dc, LOGPIXELSX);
i32 y_dpi = GetDeviceCaps(dc, LOGPIXELSY);
i32 max_dpi = max(x_dpi, y_dpi);
win32vars.screen_scale_factor = ((f32)max_dpi)/96.f;
ReleaseDC(0, dc);
}
// //
// Window and GL Initialization // Window and GL Initialization
// //
@ -1903,7 +1891,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
// NOTE(allen): render // NOTE(allen): render
HDC hdc = GetDC(win32vars.window_handle); HDC hdc = GetDC(win32vars.window_handle);
gl_render(&target, &shared_vars.pixel_scratch); gl_render(&target);
SwapBuffers(hdc); SwapBuffers(hdc);
ReleaseDC(win32vars.window_handle, hdc); ReleaseDC(win32vars.window_handle, hdc);

View File

@ -9,12 +9,8 @@
// TOP // TOP
// internal b32
// Shared system functions (system_shared.h) system_file_can_be_made(Arena *scratch, u8 *filename){
//
internal
Sys_File_Can_Be_Made_Sig(system_file_can_be_made){
HANDLE file = CreateFile_utf8(scratch, filename, FILE_APPEND_DATA, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); HANDLE file = CreateFile_utf8(scratch, filename, FILE_APPEND_DATA, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
b32 result = false; b32 result = false;
if (file != INVALID_HANDLE_VALUE){ if (file != INVALID_HANDLE_VALUE){

View File

@ -12,34 +12,34 @@
#if !defined(FRED_WIN32_UTF8_H) #if !defined(FRED_WIN32_UTF8_H)
#define FRED_WIN32_UTF8_H #define FRED_WIN32_UTF8_H
internal HANDLE function HANDLE
CreateFile_utf8(Arena *scratch, u8 *name, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES security, DWORD creation, DWORD flags, HANDLE template_file); CreateFile_utf8(Arena *scratch, u8 *name, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES security, DWORD creation, DWORD flags, HANDLE template_file);
internal DWORD function DWORD
GetFinalPathNameByHandle_utf8(Arena *scratch, HANDLE file, u8 *file_path_out, DWORD path_max, DWORD flags); GetFinalPathNameByHandle_utf8(Arena *scratch, HANDLE file, u8 *file_path_out, DWORD path_max, DWORD flags);
internal HANDLE function HANDLE
FindFirstFile_utf8(Arena *scratch, u8 *name, LPWIN32_FIND_DATA find_data); FindFirstFile_utf8(Arena *scratch, u8 *name, LPWIN32_FIND_DATA find_data);
internal DWORD function DWORD
GetFileAttributes_utf8(Arena *scratch, u8 *name); GetFileAttributes_utf8(Arena *scratch, u8 *name);
internal DWORD function DWORD
GetModuleFileName_utf8(Arena *scratch, HMODULE module, u8 *file_out, DWORD max); GetModuleFileName_utf8(Arena *scratch, HMODULE module, u8 *file_out, DWORD max);
internal BOOL function BOOL
CreateProcess_utf8(Arena *scratch, u8 *app_name, u8 *command, LPSECURITY_ATTRIBUTES security, LPSECURITY_ATTRIBUTES thread, BOOL inherit_handles, DWORD creation, LPVOID environment, u8 *curdir, LPSTARTUPINFO startup, LPPROCESS_INFORMATION process); CreateProcess_utf8(Arena *scratch, u8 *app_name, u8 *command, LPSECURITY_ATTRIBUTES security, LPSECURITY_ATTRIBUTES thread, BOOL inherit_handles, DWORD creation, LPVOID environment, u8 *curdir, LPSTARTUPINFO startup, LPPROCESS_INFORMATION process);
internal DWORD function DWORD
GetCurrentDirectory_utf8(Arena *scratch, DWORD max, u8 *buffer); GetCurrentDirectory_utf8(Arena *scratch, DWORD max, u8 *buffer);
internal int function int
MessageBox_utf8(Arena *scratch, HWND owner, u8 *text, u8 *caption, UINT type); MessageBox_utf8(Arena *scratch, HWND owner, u8 *text, u8 *caption, UINT type);
internal BOOL function BOOL
SetWindowText_utf8(Arena *scratch, HWND window, u8 *string); SetWindowText_utf8(Arena *scratch, HWND window, u8 *string);
internal BOOL function BOOL
GetFileAttributesEx_utf8String(Arena *scratch, String_Const_u8 file_name, GET_FILEEX_INFO_LEVELS info_level_id, LPVOID file_info); GetFileAttributesEx_utf8String(Arena *scratch, String_Const_u8 file_name, GET_FILEEX_INFO_LEVELS info_level_id, LPVOID file_info);
#endif #endif