Add cogl_sdl_onscreen_get_window()

This adds a function to get a pointer to the SDL_Window associated
with a CoglOnscreen when using the SDL2 winsys.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 071f4b80daa8a2f967746a30b3acf014d74f781a)
This commit is contained in:
Neil Roberts 2012-11-26 13:07:36 +00:00 committed by Robert Bragg
parent ff11a2b207
commit eec0f1cd65
3 changed files with 34 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#define __COGL_SDL_H__ #define __COGL_SDL_H__
#include <cogl/cogl-context.h> #include <cogl/cogl-context.h>
#include <cogl/cogl-onscreen.h>
#include <SDL.h> #include <SDL.h>
#ifdef _MSC_VER #ifdef _MSC_VER
@ -202,6 +203,22 @@ cogl_sdl_handle_event (CoglContext *context, SDL_Event *event);
void void
cogl_sdl_idle (CoglContext *context); cogl_sdl_idle (CoglContext *context);
#if SDL_MAJOR_VERSION >= 2
/**
* cogl_sdl_onscreen_get_window:
* @onscreen: A #CoglOnscreen
*
* Returns the underlying SDL_Window associated with an onscreen framebuffer.
*
* Since: 2.0
* Stability: unstable
*/
SDL_Window *
cogl_sdl_onscreen_get_window (CoglOnscreen *onscreen);
#endif /* SDL_MAJOR_VERSION */
G_END_DECLS G_END_DECLS
#endif /* __COGL_SDL_H__ */ #endif /* __COGL_SDL_H__ */

View File

@ -38,6 +38,7 @@
#include "cogl-onscreen-private.h" #include "cogl-onscreen-private.h"
#include "cogl-winsys-sdl-private.h" #include "cogl-winsys-sdl-private.h"
#include "cogl-error-private.h" #include "cogl-error-private.h"
#include "cogl-sdl.h"
typedef struct _CoglContextSdl2 typedef struct _CoglContextSdl2
{ {
@ -510,6 +511,21 @@ _cogl_winsys_poll_dispatch (CoglContext *context,
} }
} }
SDL_Window *
cogl_sdl_onscreen_get_window (CoglOnscreen *onscreen)
{
CoglOnscreenSdl2 *sdl_onscreen;
_COGL_RETURN_VAL_IF_FAIL (cogl_is_onscreen (onscreen), NULL);
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), NULL))
return NULL;
sdl_onscreen = onscreen->winsys;
return sdl_onscreen->window;
}
const CoglWinsysVtable * const CoglWinsysVtable *
_cogl_winsys_sdl_get_vtable (void) _cogl_winsys_sdl_get_vtable (void)
{ {

View File

@ -822,4 +822,5 @@ cogl_sdl_renderer_set_event_type
cogl_sdl_renderer_get_event_type cogl_sdl_renderer_get_event_type
cogl_sdl_handle_event cogl_sdl_handle_event
cogl_sdl_idle cogl_sdl_idle
cogl_sdl_onscreen_get_window
</SECTION> </SECTION>