mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +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
|
// Define compatibility symbols and categories
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
|
#include <COreVideo/CVOpenGLESTextureCache.h>
|
||||||
#define APP_HAS_FOCUS ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
#define APP_HAS_FOCUS ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||||
|
|
||||||
#define GLContextClass EAGLContext
|
#define GLContextClass EAGLContext
|
||||||
@ -57,7 +58,6 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
|
|
||||||
#include <GLKit/GLKit.h>
|
#include <GLKit/GLKit.h>
|
||||||
@ -76,7 +76,6 @@ static NSOpenGLPixelFormat* g_format;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static bool g_initialized;
|
static bool g_initialized;
|
||||||
static RAGameView* g_instance;
|
static RAGameView* g_instance;
|
||||||
static GLContextClass* g_context;
|
static GLContextClass* g_context;
|
||||||
@ -149,7 +148,8 @@ static bool g_is_syncing = true;
|
|||||||
g_current_input_data.touches[0].screen_y = pos.y;
|
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
|
- (id)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
@ -444,4 +444,13 @@ void apple_bind_game_view_fbo(void)
|
|||||||
[g_view bindDrawable];
|
[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
|
#endif
|
||||||
|
21
camera/ios.c
21
camera/ios.c
@ -25,6 +25,8 @@
|
|||||||
#include <CoreVideo/CVOpenGLESTextureCache.h>
|
#include <CoreVideo/CVOpenGLESTextureCache.h>
|
||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
|
|
||||||
|
extern CVReturn texture_cache_create(CVOpenGLESTextureCacheRef *ref);
|
||||||
|
|
||||||
typedef struct ios_camera
|
typedef struct ios_camera
|
||||||
{
|
{
|
||||||
CFDictionaryRef empty;
|
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)
|
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)
|
if ((caps & (1ULL << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE)) == 0)
|
||||||
{
|
{
|
||||||
RARCH_ERR("ioscamera returns OpenGL texture.\n");
|
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,
|
ret = CVPixelBufferCreate(kCFAllocatorDefault, width, height,
|
||||||
kCVPixelFormatType_32BGRA, ioscamera->attrs, &ioscamera->renderTarget);
|
kCVPixelFormatType_32BGRA, ioscamera->attrs, &ioscamera->renderTarget);
|
||||||
if (ret != 0)
|
if (ret)
|
||||||
|
{
|
||||||
|
RARCH_ERR("ioscamera: CVPixelBufferCreate failed.\n");
|
||||||
goto dealloc;
|
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.
|
// create a texture from our render target.
|
||||||
// textureCache will be what you previously made with CVOpenGLESTextureCacheCreate
|
// textureCache will be what you previously made with CVOpenGLESTextureCacheCreate
|
||||||
ret = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
|
ret = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
|
||||||
ioscamera->textureCache, ioscamera->renderTarget, NULL, GL_TEXTURE_2D,
|
ioscamera->textureCache, ioscamera->renderTarget, NULL, GL_TEXTURE_2D,
|
||||||
GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0, &ioscamera->renderTexture);
|
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;
|
goto dealloc;
|
||||||
|
}
|
||||||
|
|
||||||
return ioscamera;
|
return ioscamera;
|
||||||
dealloc:
|
dealloc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user