diff --git a/src/main.c b/src/main.c index ab1c904..9e62150 100644 --- a/src/main.c +++ b/src/main.c @@ -170,11 +170,6 @@ void orca_log(log_level level, msg); } -mg_surface orca_surface_canvas(void) -{ - return(__orcaApp.surface); -} - typedef struct orca_surface_create_data { mp_window window; @@ -183,13 +178,25 @@ typedef struct orca_surface_create_data } orca_surface_create_data; -i32 orca_surface_gles_callback(void* user) +i32 orca_surface_callback(void* user) { orca_surface_create_data* data = (orca_surface_create_data*)user; data->surface = mg_surface_create_for_window(data->window, data->api); return(0); } +mg_surface orca_surface_canvas(void) +{ + orca_surface_create_data data = { + .surface = mg_surface_nil(), + .window = __orcaApp.window, + .api = MG_CANVAS + }; + + mp_dispatch_on_main_thread_sync(orca_surface_callback, (void*)&data); + return(data.surface); +} + mg_surface orca_surface_gles(void) { orca_surface_create_data data = { @@ -198,7 +205,7 @@ mg_surface orca_surface_gles(void) .api = MG_GLES }; - mp_dispatch_on_main_thread_sync(orca_surface_gles_callback, (void*)&data); + mp_dispatch_on_main_thread_sync(orca_surface_callback, (void*)&data); return(data.surface); } @@ -478,9 +485,6 @@ i32 orca_runloop(void* user) app->rootDir = cmp.handle; } - //NOTE: prepare GL surface - mg_surface_prepare(app->surface); - IM3Function* exports = app->runtime.exports; //NOTE: call init handler @@ -759,7 +763,6 @@ i32 orca_runloop(void* user) if(exports[G_EXPORT_FRAME_REFRESH]) { - mg_surface_prepare(app->surface); m3_Call(exports[G_EXPORT_FRAME_REFRESH], 0, 0); } @@ -788,11 +791,6 @@ int main(int argc, char** argv) mp_rect windowRect = {.x = 100, .y = 100, .w = 810, .h = 610}; app->window = mp_window_create(windowRect, "orca", 0); - app->surface = mg_surface_create_for_window(app->window, MG_CANVAS); - app->canvas = mg_canvas_create(); - mg_surface_swap_interval(app->surface, 1); - - app->debugOverlay.show = false; app->debugOverlay.surface = mg_surface_create_for_window(app->window, MG_CANVAS); app->debugOverlay.canvas = mg_canvas_create(); @@ -812,11 +810,6 @@ int main(int argc, char** argv) for(int i=0; i<3; i++) { - mg_surface_prepare(app->surface); - mg_canvas_set_current(app->canvas); - mg_render(app->surface, app->canvas); - mg_surface_present(app->surface); - mg_surface_prepare(app->debugOverlay.surface); mg_canvas_set_current(app->debugOverlay.canvas); mg_render(app->debugOverlay.surface, app->debugOverlay.canvas); @@ -840,9 +833,6 @@ int main(int argc, char** argv) mp_thread_join(runloopThread, NULL); - mg_canvas_destroy(app->canvas); - mg_surface_destroy(app->surface); - mg_canvas_destroy(app->debugOverlay.canvas); mg_surface_destroy(app->debugOverlay.surface); diff --git a/src/orca_app.h b/src/orca_app.h index f6d74b6..edd545a 100644 --- a/src/orca_app.h +++ b/src/orca_app.h @@ -112,8 +112,6 @@ typedef struct orca_debug_overlay typedef struct orca_app { mp_window window; - mg_surface surface; - mg_canvas canvas; file_table fileTable; file_handle rootDir;