Added a c++ platform layer file.
This commit is contained in:
parent
18dd91197f
commit
54f5e72aa5
|
@ -0,0 +1 @@
|
||||||
|
/* Mac C++ layer for 4coder */
|
|
@ -1,5 +1,36 @@
|
||||||
|
/* Mac Objective C layer for 4coder */
|
||||||
|
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#define FPS 60
|
||||||
|
#define frame_useconds (1000000 / FPS)
|
||||||
|
|
||||||
|
#include "4coder_base_types.h"
|
||||||
|
#include "4coder_version.h"
|
||||||
|
#include "4coder_events.h"
|
||||||
|
|
||||||
|
#include "4coder_system_types.h"
|
||||||
|
#define STATIC_LINK_API
|
||||||
|
#include "generated/system_api.h"
|
||||||
|
|
||||||
|
#include "generated/system_api.cpp"
|
||||||
|
|
||||||
|
#include "4coder_base_types.cpp"
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
#define SLASH '\\'
|
||||||
|
#define DLL "dll"
|
||||||
|
|
||||||
|
#include "4coder_hash_functions.cpp"
|
||||||
|
#include "4coder_system_allocator.cpp"
|
||||||
|
#include "4coder_codepoint_map.cpp"
|
||||||
|
|
||||||
|
#include "4ed_mem.cpp"
|
||||||
|
#include "4ed_font_set.cpp"
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
@interface App_Delegate : NSObject<NSApplicationDelegate, NSWindowDelegate>
|
@interface App_Delegate : NSObject<NSApplicationDelegate, NSWindowDelegate>
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -19,7 +50,7 @@
|
||||||
return frame_size;
|
return frame_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowWillClose:(id)sender {
|
- (void)windowWillClose:(id)sender{
|
||||||
// global_running = false;
|
// global_running = false;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -27,7 +58,7 @@
|
||||||
int
|
int
|
||||||
main(int arg_count, char **args){
|
main(int arg_count, char **args){
|
||||||
@autoreleasepool{
|
@autoreleasepool{
|
||||||
// NOTE(yuval): NSApplication & Delegate Creation
|
// NOTE(yuval): Create NSApplication & Delegate
|
||||||
NSApplication* app = [NSApplication sharedApplication];
|
NSApplication* app = [NSApplication sharedApplication];
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
|
||||||
|
@ -36,7 +67,7 @@ main(int arg_count, char **args){
|
||||||
|
|
||||||
[NSApp finishLaunching];
|
[NSApp finishLaunching];
|
||||||
|
|
||||||
#if 0
|
// NOTE(yuval): Context Setup
|
||||||
Thread_Context _tctx = {};
|
Thread_Context _tctx = {};
|
||||||
thread_ctx_init(&_tctx, ThreadKind_Main,
|
thread_ctx_init(&_tctx, ThreadKind_Main,
|
||||||
get_base_allocator_system(),
|
get_base_allocator_system(),
|
||||||
|
@ -45,11 +76,23 @@ main(int arg_count, char **args){
|
||||||
block_zero_struct(&global_mac_vars);
|
block_zero_struct(&global_mac_vars);
|
||||||
global_mac_vars.tctx = &_tctx;
|
global_mac_vars.tctx = &_tctx;
|
||||||
|
|
||||||
|
API_VTable_system system_vtable = {};
|
||||||
|
system_api_fill_vtable(&system_vtable);
|
||||||
|
|
||||||
|
API_VTable_graphics graphics_vtable = {};
|
||||||
|
graphics_api_fill_vtable(&graphics_vtable);
|
||||||
|
|
||||||
|
API_VTable_font font_vtable = {};
|
||||||
|
font_api_fill_vtable(&font_vtable);
|
||||||
|
|
||||||
|
// NOTE(yuval): Memory
|
||||||
|
global_mac_vars.frame_arena = reserve_arena(global_mac_vars.tctx);
|
||||||
|
global_target.arean = make_arena_system(KB(256));
|
||||||
|
|
||||||
// NOTE(yuval): Application Core Update
|
// NOTE(yuval): Application Core Update
|
||||||
Application_Step_Result result = {};
|
Application_Step_Result result = {};
|
||||||
if (app.step != 0){
|
if (app.step != 0){
|
||||||
result = app.step(mac_vars.tctx, &target, base_ptr, &input);
|
result = app.step(mac_vars.tctx, &target, base_ptr, &input);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue