Patch from David Carre:
authorSam Lantinga <slouken@libsdl.org>
Thu, 30 Jul 2009 14:53:57 +0000
changeset 321881773a1eac83
parent 3217 26ce0b98f2fb
child 3219 b91354fa65a2
Patch from David Carre:

I fixed a bug in the "SDL_DestroyRenderer()" function in the pandora x11 renderer (in fact the bug was in the "X11_GLES_MakeCurrent()" function) that was causing a crash when exiting SDL.

There was a problem while terminating the x11 egl window, that was preventing to quit/close SDL/SDL-window then reload SDL/SDL-window inside the same application.
Makefile.pandora
src/haptic/linux/SDL_syshaptic.c
src/video/x11/SDL_x11opengles.c
src/video/x11/SDL_x11video.c
     1.1 --- a/Makefile.pandora	Sun Jul 19 08:04:59 2009 +0000
     1.2 +++ b/Makefile.pandora	Thu Jul 30 14:53:57 2009 +0000
     1.3 @@ -8,7 +8,7 @@
     1.4  
     1.5  CFLAGS  = -O3 -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp \
     1.6  	-mfpu=neon -ftree-vectorize -ffast-math -fomit-frame-pointer -fno-strict-aliasing -fsingle-precision-constant \
     1.7 -	-I./include -I$(PNDSDK)/usr/include
     1.8 +	-I./include -I$(PNDSDK)/usr/include -DSDL_REVISION=0
     1.9  
    1.10  TARGET  = libSDL.a
    1.11  
    1.12 @@ -24,14 +24,13 @@
    1.13  
    1.14  OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
    1.15  
    1.16 +CONFIG_H = $(shell cp include/SDL_config_pandora.h include/SDL_config.h && touch include/SDL_revision.h)
    1.17 +
    1.18  all: $(TARGET)
    1.19  
    1.20  $(TARGET): $(CONFIG_H) $(OBJECTS)
    1.21  	$(AR) crv $@ $^
    1.22  	$(RANLIB) $@
    1.23  
    1.24 -$(CONFIG_H):
    1.25 -	cp include/SDL_config_pandora.h include/SDL_config.h
    1.26 -
    1.27  clean:
    1.28  	rm -f $(TARGET) $(OBJECTS)
     2.1 --- a/src/haptic/linux/SDL_syshaptic.c	Sun Jul 19 08:04:59 2009 +0000
     2.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Thu Jul 30 14:53:57 2009 +0000
     2.3 @@ -35,6 +35,7 @@
     2.4  #include <limits.h>             /* INT_MAX */
     2.5  #include <errno.h>              /* errno, strerror */
     2.6  #include <math.h>               /* atan2 */
     2.7 +#include <sys/stat.h>           /* stat */
     2.8  
     2.9  /* Just in case. */
    2.10  #ifndef M_PI
     3.1 --- a/src/video/x11/SDL_x11opengles.c	Sun Jul 19 08:04:59 2009 +0000
     3.2 +++ b/src/video/x11/SDL_x11opengles.c	Thu Jul 30 14:53:57 2009 +0000
     3.3 @@ -298,8 +298,8 @@
     3.4  {
     3.5      int retval;
     3.6  
     3.7 -    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     3.8 -    Display *display = data->videodata->display;
     3.9 +//    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    3.10 +//    Display *display = data->videodata->display;
    3.11  
    3.12      retval = 1;
    3.13      if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display,
    3.14 @@ -309,7 +309,7 @@
    3.15          SDL_SetError("Unable to make EGL context current");
    3.16          retval = -1;
    3.17      }
    3.18 -    XSync(display, False);
    3.19 +//    XSync(display, False);
    3.20  
    3.21      return (retval);
    3.22  }
    3.23 @@ -359,6 +359,10 @@
    3.24          }
    3.25      }
    3.26      _this->gles_data->egl_active = 0;
    3.27 +
    3.28 +/* crappy fix */
    3.29 +    X11_GLES_UnloadLibrary(_this);
    3.30 +
    3.31  }
    3.32  
    3.33  #endif /* SDL_VIDEO_OPENGL_ES */
     4.1 --- a/src/video/x11/SDL_x11video.c	Sun Jul 19 08:04:59 2009 +0000
     4.2 +++ b/src/video/x11/SDL_x11video.c	Thu Jul 30 14:53:57 2009 +0000
     4.3 @@ -28,6 +28,9 @@
     4.4  
     4.5  #include "SDL_x11video.h"
     4.6  
     4.7 +#if SDL_VIDEO_DRIVER_PANDORA
     4.8 +#include "SDL_x11opengles.h"
     4.9 +#endif
    4.10  
    4.11  /* Initialization/Query functions */
    4.12  static int X11_VideoInit(_THIS);
    4.13 @@ -101,6 +104,9 @@
    4.14      }
    4.15      SDL_free(data->windowlist);
    4.16      SDL_free(device->driverdata);
    4.17 +#if SDL_VIDEO_DRIVER_PANDORA
    4.18 +    SDL_free(device->gles_data);
    4.19 +#endif
    4.20      SDL_free(device);
    4.21  
    4.22      SDL_X11_UnloadSymbols();
    4.23 @@ -131,6 +137,14 @@
    4.24      }
    4.25      device->driverdata = data;
    4.26  
    4.27 +#if SDL_VIDEO_DRIVER_PANDORA
    4.28 +    device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
    4.29 +    if (!device->gles_data) {
    4.30 +        SDL_OutOfMemory();
    4.31 +        return NULL;
    4.32 +    }
    4.33 +#endif
    4.34 +
    4.35      /* FIXME: Do we need this?
    4.36         if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) ||
    4.37         (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
    4.38 @@ -198,6 +212,17 @@
    4.39      device->GL_SwapWindow = X11_GL_SwapWindow;
    4.40      device->GL_DeleteContext = X11_GL_DeleteContext;
    4.41  #endif
    4.42 +#if SDL_VIDEO_DRIVER_PANDORA
    4.43 +    device->GL_LoadLibrary = X11_GLES_LoadLibrary;
    4.44 +    device->GL_GetProcAddress = X11_GLES_GetProcAddress;
    4.45 +    device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
    4.46 +    device->GL_CreateContext = X11_GLES_CreateContext;
    4.47 +    device->GL_MakeCurrent = X11_GLES_MakeCurrent;
    4.48 +    device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
    4.49 +    device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
    4.50 +    device->GL_SwapWindow = X11_GLES_SwapWindow;
    4.51 +    device->GL_DeleteContext = X11_GLES_DeleteContext;
    4.52 +#endif
    4.53  
    4.54      device->free = X11_DeleteDevice;
    4.55