diff --git a/apple/common/RAGameView.m b/apple/common/RAGameView.m index 21273660f6..6395de48f5 100644 --- a/apple/common/RAGameView.m +++ b/apple/common/RAGameView.m @@ -22,6 +22,7 @@ // Define compatibility symbols and categories #ifdef IOS +#include #define APP_HAS_FOCUS ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) #define GLContextClass EAGLContext @@ -57,7 +58,6 @@ #endif - #ifdef IOS #include @@ -76,7 +76,6 @@ static NSOpenGLPixelFormat* g_format; #endif - static bool g_initialized; static RAGameView* g_instance; static GLContextClass* g_context; @@ -149,7 +148,8 @@ static bool g_is_syncing = true; g_current_input_data.touches[0].screen_y = pos.y; } -#elif defined(IOS) // < iOS Pause menu and lifecycle +#elif defined(IOS) +// < iOS Pause menu and lifecycle - (id)init { self = [super init]; @@ -444,4 +444,13 @@ void apple_bind_game_view_fbo(void) [g_view bindDrawable]; }); } + +CVReturn texture_cache_create(CVOpenGLESTextureCacheRef *ref) +{ +#if COREVIDEO_USE_EAGLCONTEXT_CLASS_IN_API + return CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL, g_context, NULL, ref); +#else + return CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL, (__bridge void *)g_context, NULL, ref); +#endif +} #endif diff --git a/camera/ios.c b/camera/ios.c index 346386f2b1..c9079d9862 100644 --- a/camera/ios.c +++ b/camera/ios.c @@ -25,6 +25,8 @@ #include #include "../driver.h" +extern CVReturn texture_cache_create(CVOpenGLESTextureCacheRef *ref); + typedef struct ios_camera { CFDictionaryRef empty; @@ -37,7 +39,7 @@ typedef struct ios_camera static void *ios_camera_init(const char *device, uint64_t caps, unsigned width, unsigned height) { - int ret = 0; + CVReturn ret; if ((caps & (1ULL << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE)) == 0) { RARCH_ERR("ioscamera returns OpenGL texture.\n"); @@ -64,16 +66,29 @@ static void *ios_camera_init(const char *device, uint64_t caps, unsigned width, ret = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, ioscamera->attrs, &ioscamera->renderTarget); - if (ret != 0) + if (ret) + { + RARCH_ERR("ioscamera: CVPixelBufferCreate failed.\n"); goto dealloc; + } + + ret = texture_cache_create(&ioscamera->textureCache); + if (ret) + { + RARCH_ERR("ioscamera: texture_cache_create failed.\n"); + goto dealloc; + } // create a texture from our render target. // textureCache will be what you previously made with CVOpenGLESTextureCacheCreate ret = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, ioscamera->textureCache, ioscamera->renderTarget, NULL, GL_TEXTURE_2D, GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0, &ioscamera->renderTexture); - if (ret != 0) + if (ret) + { + RARCH_ERR("ioscamera: CVOpenGLESTextureCacheCreateTextureFromImage failed.\n"); goto dealloc; + } return ioscamera; dealloc: