mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
(iOS) Flesh out camera driver some more - still no image - have to
generate texture cache in RAGameView.m
This commit is contained in:
parent
624250cc7f
commit
224c0b4652
@ -22,6 +22,7 @@
|
||||
|
||||
// Define compatibility symbols and categories
|
||||
#ifdef IOS
|
||||
#include <COreVideo/CVOpenGLESTextureCache.h>
|
||||
#define APP_HAS_FOCUS ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||
|
||||
#define GLContextClass EAGLContext
|
||||
@ -57,7 +58,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef IOS
|
||||
|
||||
#include <GLKit/GLKit.h>
|
||||
@ -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
|
||||
|
21
camera/ios.c
21
camera/ios.c
@ -25,6 +25,8 @@
|
||||
#include <CoreVideo/CVOpenGLESTextureCache.h>
|
||||
#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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user