(iOS) Skeleton camera driver
This commit is contained in:
parent
7cd8f6c188
commit
cc7cda7252
|
@ -339,6 +339,7 @@
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
OTHER_CFLAGS = (
|
OTHER_CFLAGS = (
|
||||||
|
"-DHAVE_CAMERA",
|
||||||
"-DHAVE_GRIFFIN",
|
"-DHAVE_GRIFFIN",
|
||||||
"-DHAVE_RGUI",
|
"-DHAVE_RGUI",
|
||||||
"-DHAVE_MENU",
|
"-DHAVE_MENU",
|
||||||
|
@ -389,6 +390,7 @@
|
||||||
OTHER_CFLAGS = (
|
OTHER_CFLAGS = (
|
||||||
"-DNS_BLOCK_ASSERTIONS=1",
|
"-DNS_BLOCK_ASSERTIONS=1",
|
||||||
"-DNDEBUG",
|
"-DNDEBUG",
|
||||||
|
"-DHAVE_CAMERA",
|
||||||
"-DHAVE_GRIFFIN",
|
"-DHAVE_GRIFFIN",
|
||||||
"-DHAVE_RGUI",
|
"-DHAVE_RGUI",
|
||||||
"-DHAVE_MENU",
|
"-DHAVE_MENU",
|
||||||
|
@ -433,6 +435,7 @@
|
||||||
LIBRARY_SEARCH_PATHS = "";
|
LIBRARY_SEARCH_PATHS = "";
|
||||||
OTHER_CFLAGS = (
|
OTHER_CFLAGS = (
|
||||||
"-DHAVE_RARCH_MAIN_WRAP",
|
"-DHAVE_RARCH_MAIN_WRAP",
|
||||||
|
"-DHAVE_CAMERA",
|
||||||
"-DHAVE_GRIFFIN",
|
"-DHAVE_GRIFFIN",
|
||||||
"-DHAVE_RGUI",
|
"-DHAVE_RGUI",
|
||||||
"-DHAVE_MENU",
|
"-DHAVE_MENU",
|
||||||
|
@ -476,6 +479,7 @@
|
||||||
"-DNS_BLOCK_ASSERTIONS=1",
|
"-DNS_BLOCK_ASSERTIONS=1",
|
||||||
"-DNDEBUG",
|
"-DNDEBUG",
|
||||||
"-DHAVE_RARCH_MAIN_WRAP",
|
"-DHAVE_RARCH_MAIN_WRAP",
|
||||||
|
"-DHAVE_CAMERA",
|
||||||
"-DHAVE_GRIFFIN",
|
"-DHAVE_GRIFFIN",
|
||||||
"-DHAVE_RGUI",
|
"-DHAVE_RGUI",
|
||||||
"-DHAVE_MENU",
|
"-DHAVE_MENU",
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <OpenGLES/ES2/gl.h>
|
||||||
|
#include <OpenGLES/ES2/glext.h>
|
||||||
|
#include "../driver.h"
|
||||||
|
|
||||||
|
typedef struct ios_camera
|
||||||
|
{
|
||||||
|
GLuint tex;
|
||||||
|
} ioscamera_t;
|
||||||
|
|
||||||
|
static void *ios_camera_init(const char *device, uint64_t caps, unsigned width, unsigned height)
|
||||||
|
{
|
||||||
|
if ((caps & (1ULL << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE)) == 0)
|
||||||
|
{
|
||||||
|
RARCH_ERR("ioscamera returns OpenGL texture.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioscamera_t *ioscamera = (ioscamera_t*)calloc(1, sizeof(ioscamera_t));
|
||||||
|
if (!ioscamera)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return ioscamera;
|
||||||
|
dealloc:
|
||||||
|
free(ioscamera);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ios_camera_free(void *data)
|
||||||
|
{
|
||||||
|
ioscamera_t *ioscamera = (ioscamera_t*)data;
|
||||||
|
|
||||||
|
if (ioscamera)
|
||||||
|
free(ioscamera);
|
||||||
|
ioscamera = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ios_camera_start(void *data)
|
||||||
|
{
|
||||||
|
ioscamera_t *ioscamera = (ioscamera_t*)data;
|
||||||
|
|
||||||
|
glGenTextures(1, &ioscamera->tex);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, ioscamera->tex);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ios_camera_stop(void *data)
|
||||||
|
{
|
||||||
|
ioscamera_t *ioscamera = (ioscamera_t*)data;
|
||||||
|
|
||||||
|
if (ioscamera->tex)
|
||||||
|
glDeleteTextures(1, &ioscamera->tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ios_camera_poll(void *data, retro_camera_frame_raw_framebuffer_t frame_raw_cb,
|
||||||
|
retro_camera_frame_opengl_texture_t frame_gl_cb)
|
||||||
|
{
|
||||||
|
ioscamera_t *ioscamera = (ioscamera_t*)data;
|
||||||
|
|
||||||
|
bool newFrame = false;
|
||||||
|
(void)frame_raw_cb;
|
||||||
|
(void)newFrame;
|
||||||
|
|
||||||
|
if (newFrame)
|
||||||
|
{
|
||||||
|
// FIXME: Identity for now. Use proper texture matrix as returned by iOS Camera (if at all?).
|
||||||
|
static const float affine[] = {
|
||||||
|
1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
if (frame_gl_cb)
|
||||||
|
frame_gl_cb(ioscamera->tex,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
|
affine);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const camera_driver_t camera_ios = {
|
||||||
|
ios_camera_init,
|
||||||
|
ios_camera_free,
|
||||||
|
ios_camera_start,
|
||||||
|
ios_camera_stop,
|
||||||
|
ios_camera_poll,
|
||||||
|
"ios",
|
||||||
|
};
|
|
@ -84,6 +84,7 @@ enum
|
||||||
CAMERA_V4L2,
|
CAMERA_V4L2,
|
||||||
CAMERA_RWEBCAM,
|
CAMERA_RWEBCAM,
|
||||||
CAMERA_ANDROID,
|
CAMERA_ANDROID,
|
||||||
|
CAMERA_IOS,
|
||||||
CAMERA_NULL,
|
CAMERA_NULL,
|
||||||
|
|
||||||
OSK_PS3,
|
OSK_PS3,
|
||||||
|
@ -192,6 +193,8 @@ enum
|
||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_RWEBCAM
|
#define CAMERA_DEFAULT_DRIVER CAMERA_RWEBCAM
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_ANDROID
|
#define CAMERA_DEFAULT_DRIVER CAMERA_ANDROID
|
||||||
|
#elif defined(IOS)
|
||||||
|
#define CAMERA_DEFAULT_DRIVER CAMERA_IOS
|
||||||
#else
|
#else
|
||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_NULL
|
#define CAMERA_DEFAULT_DRIVER CAMERA_NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
3
driver.c
3
driver.c
|
@ -242,6 +242,9 @@ static const camera_driver_t *camera_drivers[] = {
|
||||||
#endif
|
#endif
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
&camera_android,
|
&camera_android,
|
||||||
|
#endif
|
||||||
|
#ifdef IOS
|
||||||
|
&camera_ios,
|
||||||
#endif
|
#endif
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
1
driver.h
1
driver.h
|
@ -620,6 +620,7 @@ extern const input_driver_t input_null;
|
||||||
extern const camera_driver_t camera_v4l2;
|
extern const camera_driver_t camera_v4l2;
|
||||||
extern const camera_driver_t camera_android;
|
extern const camera_driver_t camera_android;
|
||||||
extern const camera_driver_t camera_rwebcam;
|
extern const camera_driver_t camera_rwebcam;
|
||||||
|
extern const camera_driver_t camera_ios;
|
||||||
extern const input_osk_driver_t input_ps3_osk;
|
extern const input_osk_driver_t input_ps3_osk;
|
||||||
|
|
||||||
#include "driver_funcs.h"
|
#include "driver_funcs.h"
|
||||||
|
|
|
@ -358,6 +358,8 @@ CAMERA
|
||||||
#ifdef HAVE_CAMERA
|
#ifdef HAVE_CAMERA
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
#include "../camera/android.c"
|
#include "../camera/android.c"
|
||||||
|
#elif defined(IOS)
|
||||||
|
#include "../camera/ios.c"
|
||||||
#elif defined(EMSCRIPTEN)
|
#elif defined(EMSCRIPTEN)
|
||||||
#include "../camera/rwebcam.c"
|
#include "../camera/rwebcam.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -176,6 +176,8 @@ const char *config_get_default_camera(void)
|
||||||
return "null";
|
return "null";
|
||||||
case CAMERA_ANDROID:
|
case CAMERA_ANDROID:
|
||||||
return "android";
|
return "android";
|
||||||
|
case CAMERA_IOS:
|
||||||
|
return "ios";
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue