Skip to content

Commit

Permalink
Clean up the EGL related video backends (X11, Android, RPi)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabomdq committed Nov 14, 2013
1 parent a4a7c78 commit 35915d4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
7 changes: 1 addition & 6 deletions src/video/SDL_egl.c
Expand Up @@ -209,9 +209,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}

/* We need to select a config here to satisfy some video backends such as X11 */
SDL_EGL_ChooseConfig(_this);

return 0;
return SDL_EGL_ChooseConfig(_this);
}

int
Expand Down Expand Up @@ -399,9 +397,6 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
_this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context);
}

/* FIXME: This "crappy fix" comes from the X11 code,
* it's required so you can create a GLX context, destroy it and create a EGL one */
SDL_EGL_UnloadLibrary(_this);
}

EGLSurface *
Expand Down
4 changes: 4 additions & 0 deletions src/video/android/SDL_androidwindow.c
Expand Up @@ -72,6 +72,7 @@ Android_CreateWindow(_THIS, SDL_Window * window)
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);

if (data->egl_surface == EGL_NO_SURFACE) {
ANativeWindow_release(data->native_window);
SDL_free(data);
return SDL_SetError("Could not create GLES window surface");
}
Expand Down Expand Up @@ -102,6 +103,9 @@ Android_DestroyWindow(_THIS, SDL_Window * window)

if(window->driverdata) {
data = (SDL_WindowData *) window->driverdata;
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}
if(data->native_window) {
ANativeWindow_release(data->native_window);
}
Expand Down
20 changes: 16 additions & 4 deletions src/video/raspberry/SDL_rpivideo.c
Expand Up @@ -281,6 +281,22 @@ RPI_CreateWindow(_THIS, SDL_Window * window)
return 0;
}

void
RPI_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data;

if(window->driverdata) {
data = (SDL_WindowData *) window->driverdata;
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
data->egl_surface = EGL_NO_SURFACE;
}
SDL_free(window->driverdata);
window->driverdata = NULL;
}
}

int
RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
Expand Down Expand Up @@ -331,10 +347,6 @@ void
RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{

}
void
RPI_DestroyWindow(_THIS, SDL_Window * window)
{
}

/*****************************************************************************/
Expand Down
13 changes: 13 additions & 0 deletions src/video/x11/SDL_x11opengles.c
Expand Up @@ -100,6 +100,19 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window)
return context;
}

void
X11_GLES_DeleteContext(_THIS, SDL_GLContext context)
{
/* FIXME: This "crappy fix" comes from the previous GLES X11 code,
* it's required so you can create a GLX context, destroy it and create a EGL one
* To be able to fix this, we need to add a function SDL_GL_ResetContext and
* disallow SDL_GL_MakeCurrent from taking a NULL pointer, thus ensuring we can
* determine if it is a GLX or EGL context
*/
SDL_EGL_DeleteContext(_this, context);
X11_GLES_UnloadLibrary(_this);
}

SDL_EGL_SwapWindow_impl(X11)
SDL_EGL_MakeCurrent_impl(X11)

Expand Down
2 changes: 1 addition & 1 deletion src/video/x11/SDL_x11opengles.h
Expand Up @@ -38,13 +38,13 @@ typedef struct SDL_PrivateGLESData
#define X11_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
#define X11_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define X11_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define X11_GLES_DeleteContext SDL_EGL_DeleteContext

extern int X11_GLES_LoadLibrary(_THIS, const char *path);
extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen);
extern SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window);
extern void X11_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
extern void X11_GLES_DeleteContext(_THIS, SDL_GLContext context);

#endif /* SDL_VIDEO_OPENGL_EGL */

Expand Down

0 comments on commit 35915d4

Please sign in to comment.