X11/OpenGLES fixes

Hi,

please consider applying the following 3 patches for the X11/OpenGLES video driver.

Regards,
Andre


src/video/x11/SDL_x11video.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index ee54a2a…1cba0b5 100755
— a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -148,6 +148,8 @@ X11_CreateDevice(int devindex)
device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
if (!device->gles_data) {
SDL_OutOfMemory();

  •    SDL_free(device->driverdata);
    
  •    SDL_free(device);
       return NULL;
    
    }
    #endif
    @@ -175,6 +177,10 @@ X11_CreateDevice(int devindex)
    }
    #endif
    if (data->display == NULL) {
    +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
  •    SDL_free(device->gles_data);
    

+#endif

  •    SDL_free(device->driverdata);
       SDL_free(device);
       SDL_SetError("Couldn't open X11 display");
       return NULL;
    


1.7.10.4

We cannot use SDL_VIDEO_GL_DRIVER for both, EGL and GLES1/2, so rename
the envvar for EGL to SDL_VIDEO_EGL_DRIVER and keep SDL_VIDEO_GL_DRIVER
for GLES1/2.—
src/video/x11/SDL_x11opengles.c | 2 ±
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c
index 6b5a8be…3fe2d1c 100755
— a/src/video/x11/SDL_x11opengles.c
+++ b/src/video/x11/SDL_x11opengles.c
@@ -115,7 +115,7 @@ X11_GLES_LoadLibrary(_THIS, const char *path)
if ((dlsym(handle, “eglChooseConfig”) == NULL) && (path == NULL)) {

     dlclose(handle);
  •    path = getenv("SDL_VIDEO_GL_DRIVER");
    
  •    path = getenv("SDL_VIDEO_EGL_DRIVER");
       if (path == NULL) {
           path = DEFAULT_EGL;
       }
    


1.7.10.4

Both options default to “yes” via configure, and having libs/headers
for both installed is not unusual.

We default to OpenGL on this compile time combination, but can enforce
OpenGLES via setting the envvar SDL_VIDEO_X11_GLES.—
src/video/x11/SDL_x11video.c | 65 +++++++++++++++++++++++++±--------------
src/video/x11/SDL_x11video.h | 4 +±
src/video/x11/SDL_x11window.c | 23 +++++±--------
3 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 1cba0b5…dec4173 100755
— a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -144,13 +144,26 @@ X11_CreateDevice(int devindex)
}
device->driverdata = data;

  • /* In case GL and GLES/GLES2 is compiled in, we default to GL, but use
  • * GLES if SDL_VIDEO_X11_GLES is set.
    
  • */
    

#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2

  • device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
  • if (!device->gles_data) {
  •    SDL_OutOfMemory();
    
  •    SDL_free(device->driverdata);
    
  •    SDL_free(device);
    
  •    return NULL;
    

+#if SDL_VIDEO_OPENGL_GLX

  • data->gles = SDL_getenv(“SDL_VIDEO_X11_GLES”) != NULL;
    +#else
  • data->gles = SDL_TRUE;
    +#endif
    +#endif

+#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2

  • if (data->gles) {
  •    device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
    
  •    if (!device->gles_data) {
    
  •        SDL_OutOfMemory();
    
  •        SDL_free(device->driverdata);
    
  •        SDL_free(device);
    
  •        return NULL;
    
  •    }
    
    }
    #endif

@@ -224,26 +237,30 @@ X11_CreateDevice(int devindex)
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;

#if SDL_VIDEO_OPENGL_GLX

  • device->GL_LoadLibrary = X11_GL_LoadLibrary;
  • device->GL_GetProcAddress = X11_GL_GetProcAddress;
  • device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
  • device->GL_CreateContext = X11_GL_CreateContext;
  • device->GL_MakeCurrent = X11_GL_MakeCurrent;
  • device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
  • device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
  • device->GL_SwapWindow = X11_GL_SwapWindow;
  • device->GL_DeleteContext = X11_GL_DeleteContext;
  • if (!data->gles) {
  •    device->GL_LoadLibrary = X11_GL_LoadLibrary;
    
  •    device->GL_GetProcAddress = X11_GL_GetProcAddress;
    
  •    device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
    
  •    device->GL_CreateContext = X11_GL_CreateContext;
    
  •    device->GL_MakeCurrent = X11_GL_MakeCurrent;
    
  •    device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
    
  •    device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
    
  •    device->GL_SwapWindow = X11_GL_SwapWindow;
    
  •    device->GL_DeleteContext = X11_GL_DeleteContext;
    
  • }
    #endif
    #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
  • device->GL_LoadLibrary = X11_GLES_LoadLibrary;
  • device->GL_GetProcAddress = X11_GLES_GetProcAddress;
  • device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
  • device->GL_CreateContext = X11_GLES_CreateContext;
  • device->GL_MakeCurrent = X11_GLES_MakeCurrent;
  • device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
  • device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
  • device->GL_SwapWindow = X11_GLES_SwapWindow;
  • device->GL_DeleteContext = X11_GLES_DeleteContext;
  • if (data->gles) {

  •    device->GL_LoadLibrary = X11_GLES_LoadLibrary;
    
  •    device->GL_GetProcAddress = X11_GLES_GetProcAddress;
    
  •    device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
    
  •    device->GL_CreateContext = X11_GLES_CreateContext;
    
  •    device->GL_MakeCurrent = X11_GLES_MakeCurrent;
    
  •    device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
    
  •    device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
    
  •    device->GL_SwapWindow = X11_GLES_SwapWindow;
    
  •    device->GL_DeleteContext = X11_GLES_DeleteContext;
    
  • }
    #endif

    device->SetClipboardText = X11_SetClipboardText;
    diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h
    index 5923429…c3935cd 100755
    — a/src/video/x11/SDL_x11video.h
    +++ b/src/video/x11/SDL_x11video.h
    @@ -92,7 +92,9 @@ typedef struct SDL_VideoData
    Atom UTF8_STRING;

    SDL_Scancode key_layout[256];

  • SDL_bool selection_waiting;
  • SDL_bool selection_waiting;
  • SDL_bool gles;
    } SDL_VideoData;

extern SDL_bool X11_UseDirectColorVisuals(void);
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 887d4c3…90557d1 100755
— a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -269,24 +269,19 @@ X11_CreateWindow(_THIS, SDL_Window * window)
Atom wmstate_atoms[3];
Uint32 fevent = 0;

-#if SDL_VIDEO_OPENGL_GLX
+#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
if (window->flags & SDL_WINDOW_OPENGL) {
XVisualInfo *vinfo;

  •    vinfo = X11_GL_GetVisual(_this, display, screen);
    
  •    if (!vinfo) {
    
  •        return -1;
    
  •    }
    
  •    visual = vinfo->visual;
    
  •    depth = vinfo->depth;
    
  •    XFree(vinfo);
    
  • } else
    -#endif
    #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
  • if (window->flags & SDL_WINDOW_OPENGL) {
  •    XVisualInfo *vinfo;
    
  •    if (data->gles) {
    
  •        vinfo = X11_GLES_GetVisual(_this, display, screen);
    
  •    } else
    

+#endif

  •    {
    
  •        vinfo = X11_GL_GetVisual(_this, display, screen);
    
  •    }
    
  •    vinfo = X11_GLES_GetVisual(_this, display, screen);
       if (!vinfo) {
           return -1;
       }
    

@@ -395,7 +390,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
return -1;
}
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2

  • if (window->flags & SDL_WINDOW_OPENGL) {
  • if (data->gles && window->flags & SDL_WINDOW_OPENGL) {
    /* Create the GLES window surface */
    _this->gles_data->egl_surface =
    _this->gles_data->eglCreateWindowSurface(_this->gles_data->

    1.7.10.4

These three look correct and good to me.

PatrickOn Tue, Jul 17, 2012 at 3:16 PM, Andre Heider <a.heider at gmail.com> wrote:

Hi,

please consider applying the following 3 patches for the X11/OpenGLES
video driver.

Regards,
Andre


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Both options default to “yes” via configure, and having libs/headers
for both installed is not unusual.

We default to OpenGL on this compile time combination, but can enforce
OpenGLES via setting the envvar SDL_VIDEO_X11_GLES.—
src/video/x11/SDL_x11video.c | 65 +++++++++++++++++++++++++±--------------
src/video/x11/SDL_x11video.h | 4 +±
src/video/x11/SDL_x11window.c | 27 +++++++±--------
3 files changed, 56 insertions(+), 40 deletions(-)

v2: protect X11_GL_GetVisual() with SDL_VIDEO_OPENGL_GLX for the combination
–disable-video-opengl --enable-video-opengles

diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 1cba0b5…dec4173 100755
— a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -144,13 +144,26 @@ X11_CreateDevice(int devindex)
}
device->driverdata = data;

  • /* In case GL and GLES/GLES2 is compiled in, we default to GL, but use
  • * GLES if SDL_VIDEO_X11_GLES is set.
    
  • */
    

#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2

  • device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
  • if (!device->gles_data) {
  •    SDL_OutOfMemory();
    
  •    SDL_free(device->driverdata);
    
  •    SDL_free(device);
    
  •    return NULL;
    

+#if SDL_VIDEO_OPENGL_GLX

  • data->gles = SDL_getenv(“SDL_VIDEO_X11_GLES”) != NULL;
    +#else
  • data->gles = SDL_TRUE;
    +#endif
    +#endif

+#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2

  • if (data->gles) {
  •    device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
    
  •    if (!device->gles_data) {
    
  •        SDL_OutOfMemory();
    
  •        SDL_free(device->driverdata);
    
  •        SDL_free(device);
    
  •        return NULL;
    
  •    }
    
    }
    #endif

@@ -224,26 +237,30 @@ X11_CreateDevice(int devindex)
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;

#if SDL_VIDEO_OPENGL_GLX

  • device->GL_LoadLibrary = X11_GL_LoadLibrary;
  • device->GL_GetProcAddress = X11_GL_GetProcAddress;
  • device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
  • device->GL_CreateContext = X11_GL_CreateContext;
  • device->GL_MakeCurrent = X11_GL_MakeCurrent;
  • device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
  • device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
  • device->GL_SwapWindow = X11_GL_SwapWindow;
  • device->GL_DeleteContext = X11_GL_DeleteContext;
  • if (!data->gles) {
  •    device->GL_LoadLibrary = X11_GL_LoadLibrary;
    
  •    device->GL_GetProcAddress = X11_GL_GetProcAddress;
    
  •    device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
    
  •    device->GL_CreateContext = X11_GL_CreateContext;
    
  •    device->GL_MakeCurrent = X11_GL_MakeCurrent;
    
  •    device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
    
  •    device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
    
  •    device->GL_SwapWindow = X11_GL_SwapWindow;
    
  •    device->GL_DeleteContext = X11_GL_DeleteContext;
    
  • }
    #endif
    #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
  • device->GL_LoadLibrary = X11_GLES_LoadLibrary;
  • device->GL_GetProcAddress = X11_GLES_GetProcAddress;
  • device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
  • device->GL_CreateContext = X11_GLES_CreateContext;
  • device->GL_MakeCurrent = X11_GLES_MakeCurrent;
  • device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
  • device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
  • device->GL_SwapWindow = X11_GLES_SwapWindow;
  • device->GL_DeleteContext = X11_GLES_DeleteContext;
  • if (data->gles) {

  •    device->GL_LoadLibrary = X11_GLES_LoadLibrary;
    
  •    device->GL_GetProcAddress = X11_GLES_GetProcAddress;
    
  •    device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
    
  •    device->GL_CreateContext = X11_GLES_CreateContext;
    
  •    device->GL_MakeCurrent = X11_GLES_MakeCurrent;
    
  •    device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
    
  •    device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
    
  •    device->GL_SwapWindow = X11_GLES_SwapWindow;
    
  •    device->GL_DeleteContext = X11_GLES_DeleteContext;
    
  • }
    #endif

    device->SetClipboardText = X11_SetClipboardText;
    diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h
    index 5923429…c3935cd 100755
    — a/src/video/x11/SDL_x11video.h
    +++ b/src/video/x11/SDL_x11video.h
    @@ -92,7 +92,9 @@ typedef struct SDL_VideoData
    Atom UTF8_STRING;

    SDL_Scancode key_layout[256];

  • SDL_bool selection_waiting;
  • SDL_bool selection_waiting;
  • SDL_bool gles;
    } SDL_VideoData;

extern SDL_bool X11_UseDirectColorVisuals(void);
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 887d4c3…cc1d658 100755
— a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -269,24 +269,21 @@ X11_CreateWindow(_THIS, SDL_Window * window)
Atom wmstate_atoms[3];
Uint32 fevent = 0;

-#if SDL_VIDEO_OPENGL_GLX
+#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
if (window->flags & SDL_WINDOW_OPENGL) {

  •    XVisualInfo *vinfo;
    
  •    XVisualInfo *vinfo = NULL;
    
  •    vinfo = X11_GL_GetVisual(_this, display, screen);
    
  •    if (!vinfo) {
    
  •        return -1;
    
  •    }
    
  •    visual = vinfo->visual;
    
  •    depth = vinfo->depth;
    
  •    XFree(vinfo);
    
  • } else
    -#endif
    #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
  • if (window->flags & SDL_WINDOW_OPENGL) {
  •    XVisualInfo *vinfo;
    
  •    if (data->gles) {
    
  •        vinfo = X11_GLES_GetVisual(_this, display, screen);
    
  •    } else
    

+#endif

  •    {
    

+#if SDL_VIDEO_OPENGL_GLX

  •        vinfo = X11_GL_GetVisual(_this, display, screen);
    

+#endif

  •    }
    
  •    vinfo = X11_GLES_GetVisual(_this, display, screen);
       if (!vinfo) {
           return -1;
       }
    

@@ -395,7 +392,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
return -1;
}
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2

  • if (window->flags & SDL_WINDOW_OPENGL) {
  • if (data->gles && window->flags & SDL_WINDOW_OPENGL) {
    /* Create the GLES window surface */
    _this->gles_data->egl_surface =
    _this->gles_data->eglCreateWindowSurface(_this->gles_data->

    1.7.10.4

Andre, can you create a bug in bugzilla and attach the patches there?
http://bugzilla.libsdl.org

Thanks!On Tue, Jul 17, 2012 at 4:16 PM, Andre Heider <a.heider at gmail.com> wrote:

Hi,

please consider applying the following 3 patches for the X11/OpenGLES
video driver.

Regards,
Andre


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Done, attached them to the existing item
http://bugzilla.libsdl.org/show_bug.cgi?id=1428

Are patches via mailing list generally not accepted?

Thanks,
AndreOn Wed, Jul 18, 2012 at 10:22 PM, Sam Lantinga wrote:

Andre, can you create a bug in bugzilla and attach the patches there?
http://bugzilla.libsdl.org

They can get lost or need further discussion. Plus, if they’re inline in
the body of an e-mail, I can’t apply them directly.

Thanks!On Wed, Jul 18, 2012 at 5:10 PM, Andre Heider <a.heider at gmail.com> wrote:

On Wed, Jul 18, 2012 at 10:22 PM, Sam Lantinga <@slouken> wrote:

Andre, can you create a bug in bugzilla and attach the patches there?
http://bugzilla.libsdl.org

Done, attached them to the existing item
http://bugzilla.libsdl.org/show_bug.cgi?id=1428

Are patches via mailing list generally not accepted?

Thanks,
Andre


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org