The projects compiles.

master
Yuval Dolev 2019-12-30 02:33:30 +02:00
parent dc213307a9
commit 50b8a64614
2 changed files with 46 additions and 8 deletions

View File

@ -52,6 +52,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <libproc.h> // NOTE(yuval): Used for proc_pidpath #include <libproc.h> // NOTE(yuval): Used for proc_pidpath
#include <mach/mach_time.h> // NOTE(yuval): Used for mach_absolute_time, mach_timebase_info, mach_timebase_info_data_t
#include <dirent.h> // NOTE(yuval): Used for opendir, readdir #include <dirent.h> // NOTE(yuval): Used for opendir, readdir
#include <dlfcn.h> // NOTE(yuval): Used for dlopen, dlclose, dlsym #include <dlfcn.h> // NOTE(yuval): Used for dlopen, dlclose, dlsym
@ -83,6 +84,16 @@
//////////////////////////////// ////////////////////////////////
@interface App_Delegate : NSObject<NSApplicationDelegate, NSWindowDelegate>
@end
@interface Opengl_View : NSOpenGLView
@end
////////////////////////////////
////////////////////////////////
typedef i32 Mac_Object_Kind; typedef i32 Mac_Object_Kind;
enum{ enum{
MacObjectKind_ERROR = 0, MacObjectKind_ERROR = 0,
@ -110,6 +121,11 @@ struct Mac_Vars {
String_Const_u8 binary_path; String_Const_u8 binary_path;
NSWindow* window;
Opengl_View* view;
mach_timebase_info_data_t timebase_info;
Node free_mac_objects; Node free_mac_objects;
Node timer_objects; Node timer_objects;
}; };
@ -133,7 +149,7 @@ mac_to_object(Plat_Handle handle){
return(result); return(result);
} }
function function Mac_Object*
mac_alloc_object(Mac_Object_Kind kind){ mac_alloc_object(Mac_Object_Kind kind){
Mac_Object *result = 0; Mac_Object *result = 0;
@ -170,7 +186,7 @@ mac_alloc_object(Mac_Object_Kind kind){
return(result); return(result);
} }
function function void
mac_free_object(Mac_Object *object){ mac_free_object(Mac_Object *object){
if (object->node.next != 0){ if (object->node.next != 0){
dll_remove(&object->node); dll_remove(&object->node);
@ -185,9 +201,6 @@ mac_free_object(Mac_Object *object){
//////////////////////////////// ////////////////////////////////
@interface App_Delegate : NSObject<NSApplicationDelegate, NSWindowDelegate>
@end
@implementation App_Delegate @implementation App_Delegate
- (void)applicationDidFinishLaunching:(id)sender{ - (void)applicationDidFinishLaunching:(id)sender{
} }
@ -209,6 +222,28 @@ mac_free_object(Mac_Object *object){
} }
@end @end
@implementation Opengl_View
- (id)init {
self = [super init];
return self;
}
- (void)prepareOpenGL {
[super prepareOpenGL];
[[self openGLContext] makeCurrentContext];
}
- (void)reshape {
[super reshape];
NSRect bounds = [self bounds];
// [global_opengl_context makeCurrentContext];
// [global_opengl_context update];
// glViewport(0, 0, (GLsizei)bounds.size.width,
// (GLsizei)bounds.size.height);
}
@end
//////////////////////////////// ////////////////////////////////
int int
@ -265,6 +300,9 @@ main(int arg_count, char **args){
dll_init_sentinel(&mac_vars.free_mac_objects); dll_init_sentinel(&mac_vars.free_mac_objects);
dll_init_sentinel(&mac_vars.timer_objects); dll_init_sentinel(&mac_vars.timer_objects);
// NOTE(yuval): Get the timebase info
mach_timebase_info(&mac_vars.timebase_info);
#endif #endif
#if 0 #if 0

View File

@ -385,8 +385,8 @@ function
system_wake_up_timer_release_sig(){ system_wake_up_timer_release_sig(){
Mac_Object *object = (Mac_Object*)mac_to_object(handle); Mac_Object *object = (Mac_Object*)mac_to_object(handle);
if (object->kind == MacObjectKind_Timer){ if (object->kind == MacObjectKind_Timer){
if ((object->timer != nil) && [object->timer isValid]) { if ((object->timer.timer != nil) && [object->timer.timer isValid]) {
[object->timer invalidate]; [object->timer.timer invalidate];
mac_free_object(object); mac_free_object(object);
} }
} }
@ -397,7 +397,7 @@ system_wake_up_timer_set_sig(){
Mac_Object *object = (Mac_Object*)mac_to_object(handle); Mac_Object *object = (Mac_Object*)mac_to_object(handle);
if (object->kind == MacObjectKind_Timer){ if (object->kind == MacObjectKind_Timer){
f64 time_seconds = ((f64)time_milliseconds / 1000.0); f64 time_seconds = ((f64)time_milliseconds / 1000.0);
object->timer = [NSTimer scheduledTimerWithTimeInterval: time_seconds object->timer.timer = [NSTimer scheduledTimerWithTimeInterval: time_seconds
target: mac_vars.view target: mac_vars.view
selector: @selector(requestDisplay) selector: @selector(requestDisplay)
userInfo: nil repeats:NO]; userInfo: nil repeats:NO];