Small fix for OpenGL support on X11 when only GLES2 is available (not GLES1)

Hello,

I have attached a patch so that SDL2 builds correctly with OpenGL
support on X11 in case that GLES2 is available but not GLES1.

Regards,
Eleni

-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl_gles2.patch
Type: text/x-patch
Size: 1335 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130328/d2e521ee/attachment.bin

Can you describe more about this fix? Does it work without the initial
#undef? I don’t want to break GLES support…On Thu, Mar 28, 2013 at 1:08 PM, Eleni Maria S. <elene.mst at gmail.com> wrote:

Hello,

I have attached a patch so that SDL2 builds correctly with OpenGL support
on X11 in case that GLES2 is available but not GLES1.

Regards,
Eleni


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

Sam,

I think the current X11 opengles backend makes some assumptions that may not be
correct.

Typically from my experience opengl venders support 1.X ES separate from 2.0 ES.
There are separate headers and libraries. Desktop drivers support both through
the same header and library.

The way SDL_opengles.h is written it is using the 1.X ES header, so this patch
appears to allow a new define to point to 2.0 ES headers.
I would actually change it to this since EGL is commonly in the folder EGL:+
+#if SDL_VIDEO_OPENGL_ES
#include <GLES/gl.h>
+#else
+#include <GLES2/gl2.h>
+#endif
+#include <EGL/egl.h>
+

This change below doesnt make much sense in my opinion, if you dont have GL1
then why enable this code?

-#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_DRIVER_X11 && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2)

Was it ever intended to attempt to support both SDL_VIDEO_OPENGL_ES and
SDL_VIDEO_OPENGL_ES2 simultaneously?

Scott


From: slouken@libsdl.org (slouken)
To: SDL Development List
Sent: Tue, April 2, 2013 2:42:34 AM
Subject: Re: [SDL] small fix for OpenGL support on X11 when only GLES2 is
available (not GLES1)

Can you describe more about this fix? Does it work without the initial #undef?
I don’t want to break GLES support…

On Thu, Mar 28, 2013 at 1:08 PM, Eleni Maria S. <elene.mst at gmail.com> wrote:

Hello,

I have attached a patch so that SDL2 builds correctly with OpenGL support on X11
in case that GLES2 is available but not GLES1.

Regards,
Eleni


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

Hello,

Can you describe more about this fix? Does it work without the initial
#undef? I don’t want to break GLES support…

The problem was that the previous code worked only in systems where both OpenGLES1 and OpenGLES2 were available. I tried to use SDL2 on a system were only OpenGLES2 was installed and I was getting errors that were gone after this change.

There are 3 parts to this diff.

  1. In configure.in there was a check for the OpenGLES2 which was setting the following:
    AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
    but the corresponding undef was missing from the SDL_config.h.in file which led autoconf to ignore that statement so, I added it.

  2. In SDL_x11opengles.c there was a check for OpenGLES1 but not for OpenGLES2:
    #if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES
    so I changed this to: #if SDL_VIDEO_DRIVER_X11 && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2) to have support for both.

  3. In SDL_x11opengles.h the files: <GLES/gl.h> and <GLES/egl.h> where always included but if there’s no OpenGLES1 available on the system these files are missing. I changed it to:
    #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
    #if SDL_VIDEO_OPENGL_ES
    #include <GLES/gl.h>
    #include <GLES/egl.h>
    #else
    #include <GLES2/gl2.h>
    #include <EGL/egl.h>
    #endif
    so that when we use OpenGLES we include the OpenGLES headers when we have OpenGLES2 we include the OpenGLES2 headers.

These 3 small changes seemed to fix the errors in my system!

Regards,
Eleni