Minor tweak for OpenGLES 2.0 support on X11

Hi,

the attached patch (against SDL2 hg) adds some minor autoconf / preprocessor
tweaks for OpenGL ES 2.0 on x11.

GLES2.0 support is a really useful feature to have when targeting
mobile devices, because testing/debugging on e.g. linux is often less
of a hassle then on the actual device.

thanks,

Manuel

-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL-GLES2.patch
Type: text/x-patch
Size: 1807 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120324/60f7f8c7/attachment.bin

Ho,

the attached patch (against SDL2 hg) adds some minor autoconf /
preprocessor tweaks for OpenGL ES 2.0 on x11.

I’ve attached another patch, which fixes GLES / GLES2 initialization on
64bit xlib; without the patch, EGL based initialization fails on 64bit xorg.

During SDL window init, eglGetConfigAttrib is used to query the native
visual id. which expects pointer to an EGLint for stroring the query result,
but SDL passes a pointer to a VisualID variable (an xlib defined type).

This only works as long as EGLint and VisualID have the same underlying data
type; it fails on 64bit xlib, where VisualID is 64bit wide, but EGLint is only
32bit wide (EGLint is implementation defined, but mesa defines it as 32bit
type even for 64bit builds - I suppose VisualID handles are still 32bit
internally).

Could someone on the list review / apply these patches, or should I submit
them elsewhere?

bye,

Manuel

-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_GLES_xlib64.patch
Type: text/x-patch
Size: 405 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120326/c7612192/attachment.bin

It can take a while for the devs to see and review the patch; normally
they’re good at catching ones posted to this list, but it can’t hurt
to make a ticket on http://bugzilla.libsdl.org .

Out of interest, can I ask about how you set up EGL under x86-64? I
was the guy who submitted the glue to make x11opengles
autoconf-friendly; all testing for that was done under just two ARM
systems, so I’m on the lookout for more ways to roadtest GLES.

Cheers,
ScottOn Tue, Mar 27, 2012 at 5:29 AM, Manuel Massing <m.massing at warped-space.de> wrote:

Ho,

the attached patch (against SDL2 hg) adds some minor autoconf /

preprocessor tweaks for OpenGL ES 2.0 on x11.

I’ve attached another patch, which fixes GLES / GLES2 initialization on

64bit xlib; without the patch, EGL based initialization fails on 64bit xorg.

During SDL window init, eglGetConfigAttrib is used to query the native

visual id. which expects pointer to an EGLint for stroring the query result,

but SDL passes a pointer to a VisualID variable (an xlib defined type).

This only works as long as EGLint and VisualID have the same underlying data
type; it fails on 64bit xlib, where VisualID is 64bit wide, but EGLint is
only 32bit wide (EGLint is implementation defined, but mesa defines it as
32bit type even for 64bit builds - I suppose VisualID handles are still
32bit

internally).

Could someone on the list review / apply these patches, or should I submit

them elsewhere?

bye,

Manuel


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

Hi Scott,

Out of interest, can I ask about how you set up EGL under x86-64? I
was the guy who submitted the glue to make x11opengles
autoconf-friendly; all testing for that was done under just two ARM
systems, so I’m on the lookout for more ways to roadtest GLES.

ah, then thank you for the autoconf stuff - GLES detection worked nicely.

I use the llvmpipe mesa software rasterizer for OpenGL ES / ES2 support
on linux. Alternatively, there are emulation libraries on top of OpenGL, e.g.

http://www.malideveloper.com/developer-resources/tools/opengl-es-20-
emulator.php

If you want to use Mesa:

  1. Download recent mesa release or clone the git repo

  2. Build mesa/gallium with opengles support, e.g.:

    ./autogen.sh --disable-dri --with-gallium-drivers=swrast --enable-
    gallium-llvm --enable-gallium-egl --disable-opengl --enable-gles1 --enable-
    gles2

  3. Build SDL with GLES support (disable OpenGL, otherwise it will take
    precedence when requesting a GL context)

    ./configure --disable-video-opengl

  4. The usual SDL video init / window creation. Make sure to set the
    SDL_WINDOW_OPENGL flag when creating the window. Specify context
    version to choose between GLES 1 / GLES 2 before creating a context:

    // Request OpenGL ES 2.0 context
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

    // Set up OpenGL double buffering
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    // Set some very conservative bitdepth requirements…
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 2);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 3);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 2);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 2);

    ctx = SDL_GL_CreateContext(win);

good luck,

Manuel