summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2014-02-13 12:23:53 +0000
committerRobert Bragg <robert@linux.intel.com>2014-02-20 01:16:01 +0000
commit9381db740c8ac62894cf359c9c1ca78eecf68e90 (patch)
treec4402ae0464d0c603d7f0eeba1b32142767dea90
parent87571e97f88079be3681cda4f103c1cbc608d7e4 (diff)
downloadcogl-9381db740c8ac62894cf359c9c1ca78eecf68e90.tar.gz
sdl2: Add android support
This adds Android support to the SDL2 winsys. Unlike some other window systems, Android's SDL2 backend only allows you to create one window. Since the Cogl SDL2 winsys creates a "dummy" window when setting up the display (so we have something to bind a GL context to) it wasn't then possible to create a CoglOnscreen framebuffer for rendering. This updates the winsys so that the first CoglOnscreen framebuffer created will actually refer to the dummy window we created earlier. Note: it doesn't matter that we request the dummy window to have a 1x1 size, and request for it to be hidden because these are overridden by SDL's Android backend.
-rw-r--r--cogl/winsys/cogl-winsys-sdl2.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/cogl/winsys/cogl-winsys-sdl2.c b/cogl/winsys/cogl-winsys-sdl2.c
index c54e73bf..01880a8b 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -61,6 +61,7 @@ typedef struct _CoglDisplaySdl2
{
SDL_Window *dummy_window;
SDL_GLContext *context;
+ CoglBool have_onscreen;
} CoglDisplaySdl2;
typedef struct _CoglOnscreenSdl2
@@ -499,6 +500,32 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
int width, height;
SDL_WindowFlags flags;
+#ifdef __ANDROID__
+ {
+ CoglDisplay *display = framebuffer->context->display;
+ CoglDisplaySdl2 *sdl_display = display->winsys;
+ int win_width, win_height;
+
+ if (sdl_display->have_onscreen)
+ {
+ _cogl_set_error (error, COGL_WINSYS_ERROR,
+ COGL_WINSYS_ERROR_CREATE_ONSCREEN,
+ "Android platform only supports a single "
+ "onscreen window");
+ return FALSE;
+ }
+
+ window = sdl_display->dummy_window;
+
+ SDL_GetWindowSize (window, &win_width, &win_height);
+
+ _cogl_framebuffer_winsys_update_size (framebuffer, win_width, win_height);
+
+ sdl_display->have_onscreen = TRUE;
+ }
+
+#else /* __ANDROID__ */
+
width = cogl_framebuffer_get_width (framebuffer);
height = cogl_framebuffer_get_height (framebuffer);
@@ -513,7 +540,6 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
0, 0, /* x/y */
width, height,
flags);
-
if (window == NULL)
{
_cogl_set_error (error, COGL_WINSYS_ERROR,
@@ -523,6 +549,8 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
return FALSE;
}
+#endif /* __ANDROID__ */
+
SDL_SetWindowData (window, COGL_SDL_WINDOW_DATA_KEY, onscreen);
onscreen->winsys = g_slice_new (CoglOnscreenSdl2);