diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index 0582f1007..f45698979 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -448,7 +448,7 @@ int screen_height; GLuint fogTextureId; #ifdef TEST_AUTOMATION -void dump_screenshot(u8 *buffer, u32 width, u32 height) +static void dump_screenshot(u8 *buffer, u32 width, u32 height) { FILE *fp = fopen("screenshot.png", "wb"); if (fp == NULL) @@ -487,6 +487,36 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height) free(rows); } + +static void do_swap_automation() +{ + static FILE* video_file = fopen(cfgLoadStr("record", "rawvid","").c_str(), "wb"); + extern bool do_screenshot; + + if (video_file) + { + int bytesz = screen_width * screen_height * 3; + u8* img = new u8[bytesz]; + + glReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, img); + fwrite(img, 1, bytesz, video_file); + fflush(video_file); + } + + if (do_screenshot) + { + extern void dc_exit(); + int bytesz = screen_width * screen_height * 3; + u8* img = new u8[bytesz]; + + glReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, img); + dump_screenshot(img, screen_width, screen_height); + delete[] img; + dc_exit(); + exit(0); + } +} + #endif #ifdef USE_EGL @@ -657,6 +687,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height) //swap buffers void gl_swap() { + do_swap_automation(); #ifdef TARGET_PANDORA0 if (fbdev >= 0) { @@ -830,6 +861,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height) #include void gl_swap() { + do_swap_automation(); wglSwapLayerBuffers(ourWindowHandleToDeviceContext,WGL_SWAP_MAIN_PLANE); //SwapBuffers(ourWindowHandleToDeviceContext); } @@ -862,33 +894,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height) void gl_swap() { -#ifdef TEST_AUTOMATION - static FILE* video_file = fopen(cfgLoadStr("record", "rawvid","").c_str(), "wb"); - extern bool do_screenshot; - - if (video_file) - { - int bytesz = screen_width * screen_height * 3; - u8* img = new u8[bytesz]; - - glReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, img); - fwrite(img, 1, bytesz, video_file); - fflush(video_file); - } - - if (do_screenshot) - { - extern void dc_exit(); - int bytesz = screen_width * screen_height * 3; - u8* img = new u8[bytesz]; - - glReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, img); - dump_screenshot(img, screen_width, screen_height); - delete[] img; - dc_exit(); - exit(0); - } -#endif + do_swap_automation(); glXSwapBuffers((Display*)libPvr_GetRenderSurface(), (GLXDrawable)libPvr_GetRenderTarget()); Window win; @@ -923,6 +929,14 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height) #else extern void gl_term(); +#if HOST_OS == OS_DARWIN +void gl_swap() +{ +#ifdef TEST_AUTOMATION + do_swap_automation(); +#endif +} +#endif #endif static void gl_delete_shaders() diff --git a/shell/apple/emulator-osx/emulator-osx/osx-main.mm b/shell/apple/emulator-osx/emulator-osx/osx-main.mm index 432dd40d3..89ad58412 100644 --- a/shell/apple/emulator-osx/emulator-osx/osx-main.mm +++ b/shell/apple/emulator-osx/emulator-osx/osx-main.mm @@ -83,10 +83,6 @@ void gl_term() { } -void gl_swap() { - -} - void common_linux_setup(); int reicast_init(int argc, char* argv[]); void dc_exit(); @@ -160,7 +156,19 @@ extern "C" int emu_reicast_init() { LogManager::Init(); common_linux_setup(); - return reicast_init(0, NULL); + NSArray *arguments = [[NSProcessInfo processInfo] arguments]; + unsigned long argc = [arguments count]; + char **argv = (char **)malloc(argc * sizeof(char*)); + for (unsigned long i = 0; i < argc; i++) + argv[i] = strdup([[arguments objectAtIndex:i] UTF8String]); + + int rc = reicast_init((int)argc, argv); + + for (unsigned long i = 0; i < argc; i++) + free(argv[i]); + free(argv); + + return rc; } extern "C" void emu_key_input(UInt16 keyCode, bool pressed, UInt modifierFlags) { diff --git a/shell/apple/emulator-osx/reicast-osx.xcodeproj/xcshareddata/xcschemes/reicast-osx.xcscheme b/shell/apple/emulator-osx/reicast-osx.xcodeproj/xcshareddata/xcschemes/reicast-osx.xcscheme index 6afe3077d..4afd62a18 100644 --- a/shell/apple/emulator-osx/reicast-osx.xcodeproj/xcshareddata/xcschemes/reicast-osx.xcscheme +++ b/shell/apple/emulator-osx/reicast-osx.xcodeproj/xcshareddata/xcschemes/reicast-osx.xcscheme @@ -74,7 +74,7 @@ launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" - debugDocumentVersioning = "YES" + debugDocumentVersioning = "NO" debugServiceExtension = "internal" allowLocationSimulation = "YES">