Index: quakedef.h
===================================================================
--- quakedef.h	(révision 11832)
+++ quakedef.h	(copie de travail)
@@ -417,7 +417,12 @@
     DP_OS_STR	- "identifier" of the OS, more suited for code to use
     DP_ARCH_STR	- "identifier" of the processor architecture
  */
-#if defined(__linux__)
+#if defined(PANDORA)
+# define DP_OS_NAME           "Pandora"
+# define DP_OS_STR            "pandora"
+# define USE_GLES2            1
+# define USE_EGLPORT          1
+#elif defined(__linux__)
 # define DP_OS_NAME		"Linux"
 # define DP_OS_STR		"linux"
 #elif defined(_WIN64)
Index: makefile.inc
===================================================================
--- makefile.inc	(révision 11832)
+++ makefile.inc	(copie de travail)
@@ -313,7 +313,14 @@
 EXE_WINSVNEXUIZ=nexuiz-dedicated.exe
 EXE_WINSDLNEXUIZ=nexuiz-sdl.exe
 
+ifneq "$(findstring DPANDORA,$(CFLAGS))" ""
+OBJ_COMMON+=eglport.o
+LDFLAGS_RELEASE+=-lEGL -lX11 -lGLESv2
+CFLAGS_SSE=
+CFLAGS_SSE2=
+endif
 
+
 ##### Commands #####
 
 .PHONY : clean clean-profile help \
@@ -453,7 +460,7 @@
 	@echo "========== $(EXE) (debug) =========="
 	$(MAKE) $(EXE) \
 		DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-		CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
+		CFLAGS+="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
 		LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)" LEVEL=2
 
 bin-profile :
@@ -462,7 +469,7 @@
 	@echo "========== $(EXE) (profile) =========="
 	$(MAKE) $(EXE) \
 		DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-		CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
+		CFLAGS+="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
 		LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)" LEVEL=2
 
 bin-release :
@@ -471,9 +478,9 @@
 	@echo "========== $(EXE) (release) =========="
 	$(MAKE) $(EXE) \
 		DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-		CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
+		CFLAGS+="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
 		LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
-	$(STRIP) $(EXE)
+#	$(STRIP) $(EXE)
 
 bin-release-profile :
 	$(CHECKLEVEL1)
@@ -481,9 +488,9 @@
 	@echo "========== $(EXE) (release) =========="
 	$(MAKE) $(EXE) \
 		DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
-		CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)"\
+		CFLAGS+="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)"\
 		LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2
-	$(STRIP) $(EXE)
+#	$(STRIP) $(EXE)
 
 
 snd_modplug.o: snd_modplug.c
Index: cvar.c
===================================================================
--- cvar.c	(révision 11832)
+++ cvar.c	(copie de travail)
@@ -327,7 +327,10 @@
 	size_t valuelen;
 	char vabuf[1024];
 
-	changed = strcmp(var->string, value) != 0;
+	if (value==NULL) {
+		changed = false;
+	}else
+		changed = strcmp(var->string, value) != 0;
 	// LordHavoc: don't reallocate when there is no change
 	if (!changed)
 		return;
Index: glquake.h
===================================================================
--- glquake.h	(révision 11832)
+++ glquake.h	(copie de travail)
@@ -25,8 +25,14 @@
 #ifdef __IPHONEOS__
 #include <OpenGLES/ES2/gl.h>
 #else
+#ifndef USE_EGLPORT
 #include <SDL_opengles2.h>
+#else
+#include "eglport.h"
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
 #endif
+#endif
 // used in R_SetupShader_Generic calls, not actually passed to GL
 #ifndef GL_MODULATE
 #define GL_MODULATE				0x2100
@@ -1056,7 +1062,7 @@
 #define DEBUGGL
 
 #ifdef DEBUGGL
-#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);errornumber = qglGetError ? qglGetError() : 0;if (errornumber) GL_PrintError(errornumber, __FILE__, __LINE__);}}
+#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) {Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);}errornumber = qglGetError ? qglGetError() : 0;if (errornumber) GL_PrintError(errornumber, __FILE__, __LINE__);}}
 extern int errornumber;
 void GL_PrintError(int errornumber, const char *filename, int linenumber);
 #else
Index: eglport.c
===================================================================
--- eglport.c	(révision 0)
+++ eglport.c	(copie de travail)
@@ -0,0 +1,512 @@
+/**
+ *
+ *  EGLPORT.C
+ *  Copyright (C) 2011-2012 Scott R. Smith
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
+ *  of this software and associated documentation files (the "Software"), to deal
+ *  in the Software without restriction, including without limitation the rights
+ *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ *  copies of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ *  THE SOFTWARE.
+ *
+ */
+#define USE_GLES2 1
+
+#include "eglport.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined(USE_EGL_SDL)
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "SDL_syswm.h"
+#include "SDL.h"
+#endif /* USE_EGL_SDL */
+
+#if defined(PANDORA) /* Pandora VSync Support */
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/fb.h>
+
+#ifndef FBIO_WAITFORVSYNC
+#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
+#endif
+int fbdev = -1;
+
+#elif defined(RPI)
+#include "bcm_host.h"
+#endif /* PANDORA */
+
+EGLint useVsync    = 0;	/** Controls on the system vsync if available. */
+EGLint useFSAA     = 0; /** Number of samples for full screen AA. 0 is off, 2/4 samples */
+
+NativeDisplayType   g_nativeDisplay = 0; /** Reference to the systems native display */
+NativeWindowType    g_nativeWindow  = 0; /** Reference to the systems native window */
+EGLDisplay          g_eglDisplay    = NULL;	/** Reference to the EGL display */
+EGLConfig           g_eglConfig     = NULL; /** Reference to the EGL config */
+EGLContext          g_eglContext    = NULL; /** Reference to the EGL context */
+EGLSurface          g_eglSurface    = NULL; /** Reference to the EGL surface */
+
+#define     g_totalConfigsIn 20				/** Total number of configurations to request */
+EGLint      g_totalConfigsFound = 0;		/** Total number of configurations matching attributes */
+EGLConfig   g_allConfigs[g_totalConfigsIn];	/** Structure containing references to matching configurations */
+
+/** Private API */
+int8_t  ConfigureEGL                ( EGLConfig config );
+int8_t  FindAppropriateEGLConfigs   ( void );
+int8_t  CheckEGLErrors              ( const char* file, uint16_t line );
+
+int8_t	GetNativeDisplay			( void );
+int8_t	GetNativeWindow				( void );
+void	FreeNativeDisplay			( void );
+void	FreeNativeWindow			( void );
+
+void    Platform_Open               ( void );
+void    Platform_Close              ( void );
+void    Platform_VSync              ( void );
+
+/** @brief Release all EGL and system resources
+ */
+void EGL_Close( void )
+{
+    if (g_eglDisplay != NULL)
+    {
+        peglMakeCurrent( g_eglDisplay, NULL, NULL, EGL_NO_CONTEXT );
+        if (g_eglContext != NULL) {
+            peglDestroyContext( g_eglDisplay, g_eglContext );
+        }
+        if (g_eglSurface != NULL) {
+            peglDestroySurface( g_eglDisplay, g_eglSurface );
+        }
+        peglTerminate( g_eglDisplay );
+    }
+
+    g_eglSurface = NULL;
+    g_eglContext = NULL;
+    g_eglDisplay = NULL;
+
+	FreeNativeWindow();
+	FreeNativeDisplay();
+    Platform_Close();
+
+    CheckEGLErrors( __FILE__, __LINE__ );
+
+    printf( "EGL Closed\n" );
+}
+
+/** @brief Configure EGL for use on the system
+ * @return : 0 if the function passed, else 1
+ */
+int8_t EGL_Init( void )
+{
+    int configIndex = 0;
+
+    if (FindAppropriateEGLConfigs() != 0)
+    {
+        printf( "EGL ERROR: Unable to configure EGL. See previous error.\n" );
+        return 1;
+    }
+
+    printf( "EGL Using Config %d\n", configIndex );
+    if ( ConfigureEGL(g_allConfigs[configIndex]) != 0)
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to configure EGL. See previous error.\n" );
+        return 1;
+    }
+
+    return 0;
+}
+
+/** @brief Swap the surface buffer onto the display
+ */
+void EGL_SwapBuffers( void )
+{
+    if (useVsync != 0) {
+        Platform_VSync();
+    }
+    peglSwapBuffers( g_eglDisplay, g_eglSurface );
+}
+
+
+/** @brief Obtain the system display and initialize EGL
+ * @return : 0 if the function passed, else 1
+ */
+int8_t EGL_Open( void )
+{
+	EGLint eglMajorVer, eglMinorVer;
+    EGLBoolean result;
+    const char* output;
+
+    // Setup any platform specific bits
+    Platform_Open();
+
+    printf( "EGL Opening EGL display\n" );
+	if (GetNativeDisplay() != 0)
+	{
+        printf( "EGL ERROR: Unable to obtain native display!\n" );
+        return 1;
+	}
+
+    g_eglDisplay = peglGetDisplay( g_nativeDisplay );
+    if (g_eglDisplay == EGL_NO_DISPLAY)
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to create EGL display.\n" );
+        return 1;
+    }
+
+    printf( "EGL Initializing\n" );
+    result = peglInitialize( g_eglDisplay, &eglMajorVer, &eglMinorVer );
+    if (result != EGL_TRUE )
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to initialize EGL display.\n" );
+        return 1;
+    }
+
+    // Get EGL Library Information
+	printf( "EGL Implementation Version: Major %d Minor %d\n", eglMajorVer, eglMinorVer );
+    output = peglQueryString( g_eglDisplay, EGL_VENDOR );
+    printf( "EGL_VENDOR: %s\n", output );
+    output = peglQueryString( g_eglDisplay, EGL_VERSION );
+    printf( "EGL_VERSION: %s\n", output );
+    output = peglQueryString( g_eglDisplay, EGL_EXTENSIONS );
+    printf( "EGL_EXTENSIONS: %s\n", output );
+
+    CheckEGLErrors( __FILE__, __LINE__ );
+
+    return 0;
+}
+
+/** @brief Use the EGL configuration to creat the context and surface and make them current
+ * @return : 0 if the function passed, else 1
+ */
+int8_t ConfigureEGL( EGLConfig config )
+{
+    EGLBoolean result;
+
+    static const EGLint s_contextAttribs[] =
+    {
+#if defined(USE_GLES2)
+          EGL_CONTEXT_CLIENT_VERSION,     2,
+#endif
+          EGL_NONE
+    };
+
+    // Cleanup in case of a reinit
+    if (g_eglDisplay != NULL)
+    {
+        peglMakeCurrent( g_eglDisplay, NULL, NULL, EGL_NO_CONTEXT );
+        if (g_eglContext != NULL) {
+            peglDestroyContext( g_eglDisplay, g_eglContext );
+        }
+        if (g_eglSurface != NULL) {
+            peglDestroySurface( g_eglDisplay, g_eglSurface );
+        }
+    }
+
+#if defined(EGL_VERSION_1_2)
+    // Bind GLES and create the context
+    printf( "EGL Binding API\n" );
+    result = peglBindAPI( EGL_OPENGL_ES_API );
+    if ( result == EGL_FALSE )
+    {
+		CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Could not bind EGL API.\n" );
+        return 1;
+    }
+#endif /* EGL_VERSION_1_2 */
+
+    printf( "EGL Creating Context\n" );
+    g_eglContext = peglCreateContext( g_eglDisplay, config, NULL, s_contextAttribs );
+    if (g_eglContext == EGL_NO_CONTEXT)
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to create GLES context!\n");
+        return 1;
+    }
+
+    printf( "EGL Creating window surface\n" );
+	if (GetNativeWindow() != 0)
+	{
+        printf( "EGL ERROR: Unable to obtain native window!\n" );
+        return 1;
+	}
+
+    g_eglSurface = peglCreateWindowSurface( g_eglDisplay, config, g_nativeWindow, 0 );
+    if (g_eglSurface == EGL_NO_SURFACE)
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to create EGL surface!\n" );
+        return 1;
+    }
+
+    printf( "EGL Making Current\n" );
+    result = peglMakeCurrent( g_eglDisplay,  g_eglSurface,  g_eglSurface, g_eglContext );
+    if (result != EGL_TRUE)
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to make GLES context current\n" );
+        return 1;
+    }
+
+    CheckEGLErrors( __FILE__, __LINE__ );
+    printf( "EGL Complete\n" );
+    return 0;
+}
+
+/** @brief Find a EGL configuration tht matches the defined attributes
+ * @return : 0 if the function passed, else 1
+ */
+int8_t FindAppropriateEGLConfigs( void )
+{
+    EGLBoolean result;
+    int attrib = 0;
+    EGLint ConfigAttribs[19];
+
+    ConfigAttribs[attrib++] = EGL_RED_SIZE;
+    ConfigAttribs[attrib++] = 5;
+    ConfigAttribs[attrib++] = EGL_GREEN_SIZE;
+    ConfigAttribs[attrib++] = 6;
+    ConfigAttribs[attrib++] = EGL_BLUE_SIZE;
+    ConfigAttribs[attrib++] = 5;
+    ConfigAttribs[attrib++] = EGL_DEPTH_SIZE;
+    ConfigAttribs[attrib++] = 16;
+    ConfigAttribs[attrib++] = EGL_STENCIL_SIZE;
+    ConfigAttribs[attrib++] = 0;
+    ConfigAttribs[attrib++] = EGL_SURFACE_TYPE;
+    ConfigAttribs[attrib++] = EGL_WINDOW_BIT;
+#if defined(EGL_VERSION_1_2)
+    ConfigAttribs[attrib++] = EGL_RENDERABLE_TYPE;
+#if defined(USE_GLES1)
+    ConfigAttribs[attrib++] = EGL_OPENGL_ES_BIT;
+#elif defined(USE_GLES2)
+    ConfigAttribs[attrib++] = EGL_OPENGL_ES2_BIT;
+#endif /* USE_GLES1 */
+#endif /* EGL_VERSION_1_2 */
+    ConfigAttribs[attrib++] = EGL_SAMPLE_BUFFERS;
+    ConfigAttribs[attrib++] = (useFSAA > 0) ? 1 : 0;
+    ConfigAttribs[attrib++] = EGL_SAMPLES;
+    ConfigAttribs[attrib++] = useFSAA;
+    ConfigAttribs[attrib++] = EGL_NONE;
+
+    result = peglChooseConfig( g_eglDisplay, ConfigAttribs, g_allConfigs, g_totalConfigsIn, &g_totalConfigsFound );
+    if (result != EGL_TRUE || g_totalConfigsFound == 0)
+    {
+        CheckEGLErrors( __FILE__, __LINE__ );
+        printf( "EGL ERROR: Unable to query for available configs, found %d.\n", g_totalConfigsFound );
+        return 1;
+    }
+    printf( "EGL Found %d available configs\n", g_totalConfigsFound );
+
+    return 0;
+}
+
+/** @brief Error checking function
+ * @param file : string reference that contains the source file that the check is occuring in
+ * @param line : numeric reference that contains the line number that the check is occuring in
+ * @return : 0 if the function passed, else 1
+ */
+int8_t CheckEGLErrors( const char* file, uint16_t line )
+{
+    EGLenum error;
+    const char* errortext;
+
+    error = eglGetError();
+
+    if (error != EGL_SUCCESS && error != 0)
+    {
+        switch (error)
+        {
+            case EGL_NOT_INITIALIZED:           errortext = "EGL_NOT_INITIALIZED"; break;
+            case EGL_BAD_ACCESS:                errortext = "EGL_BAD_ACCESS"; break;
+            case EGL_BAD_ALLOC:                 errortext = "EGL_BAD_ALLOC"; break;
+            case EGL_BAD_ATTRIBUTE:             errortext = "EGL_BAD_ATTRIBUTE"; break;
+            case EGL_BAD_CONTEXT:               errortext = "EGL_BAD_CONTEXT"; break;
+            case EGL_BAD_CONFIG:                errortext = "EGL_BAD_CONFIG"; break;
+            case EGL_BAD_CURRENT_SURFACE:       errortext = "EGL_BAD_CURRENT_SURFACE"; break;
+            case EGL_BAD_DISPLAY:               errortext = "EGL_BAD_DISPLAY"; break;
+            case EGL_BAD_SURFACE:               errortext = "EGL_BAD_SURFACE"; break;
+            case EGL_BAD_MATCH:                 errortext = "EGL_BAD_MATCH"; break;
+            case EGL_BAD_PARAMETER:             errortext = "EGL_BAD_PARAMETER"; break;
+            case EGL_BAD_NATIVE_PIXMAP:         errortext = "EGL_BAD_NATIVE_PIXMAP"; break;
+            case EGL_BAD_NATIVE_WINDOW:         errortext = "EGL_BAD_NATIVE_WINDOW"; break;
+            case EGL_CONTEXT_LOST:				errortext = "EGL_CONTEXT_LOST"; break;
+            default:                            errortext = "Unknown EGL Error"; break;
+        }
+
+        printf( "ERROR: EGL Error detected in file %s at line %d: %s (0x%X)\n", file, line, errortext, error );
+        return 1;
+    }
+
+    return 0;
+}
+
+/** @brief Obtain a reference to the system's native display
+ * @param window : pointer to save the display reference
+ * @return : 0 if the function passed, else 1
+ */
+int8_t GetNativeDisplay( void )
+{
+#if defined(USE_EGL_SDL)
+    printf( "EGL Opening X11 display\n" );
+
+    g_nativeDisplay = XOpenDisplay( NULL );
+    if (g_nativeDisplay == NULL)
+    {
+        printf( "EGL ERROR: unable to get display!\n" );
+        return 1;
+    }
+#else
+	g_nativeDisplay = EGL_DEFAULT_DISPLAY;
+#endif /* USE_EGL_SDL */
+
+	return 0;
+}
+
+/** @brief Obtain a reference to the system's native window
+ * @param window : pointer to save the window reference
+ * @return : 0 if the function passed, else 1
+ */
+int8_t GetNativeWindow( void )
+{
+    g_nativeWindow = 0;
+
+#if defined(WIZ) || defined(CAANOO)
+    g_nativeWindow = (NativeWindowType)malloc(16*1024);
+
+    if(g_nativeWindow == NULL) {
+        printf( "EGL ERROR: Memory for window Failed\n" );
+        return 1;
+    }
+#elif defined(RPI)
+	uint16_t screen_width, screen_height;
+	static EGL_DISPMANX_WINDOW_T nativewindow;
+	DISPMANX_ELEMENT_HANDLE_T dispman_element;
+	DISPMANX_DISPLAY_HANDLE_T dispman_display;
+	DISPMANX_UPDATE_HANDLE_T dispman_update;
+	VC_RECT_T dst_rect;
+	VC_RECT_T src_rect;
+
+	// create an EGL window surface
+	result = graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height);
+    if(result < 0) {
+        printf( "EGL ERROR: RPi graphics_get_display_size failed\n" );
+        return 1;
+    }
+
+	dst_rect.x = 0;
+	dst_rect.y = 0;
+	dst_rect.width = screen_width;
+	dst_rect.height = screen_height;
+
+	src_rect.x = 0;
+	src_rect.y = 0;
+	src_rect.width = screen_width << 16;
+	src_rect.height = screen_height << 16;
+
+	dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
+	dispman_update  = vc_dispmanx_update_start( 0 );
+	dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
+	  0 /*layer*/, &dst_rect, 0 /*src*/,
+	  &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0 /*clamp*/, 0 /*transform*/);
+
+	nativewindow.element = dispman_element;
+	nativewindow.width = screen_width;
+	nativewindow.height = screen_height;
+	vc_dispmanx_update_submit_sync( dispman_update );
+
+	g_nativeWindow = (NativeWindowType)nativewindow;
+#elif defined(USE_EGL_SDL)
+    // Get the SDL window handle
+    SDL_SysWMinfo sysInfo; //Will hold our Window information
+    SDL_VERSION(&sysInfo.version); //Set SDL version
+
+    if(SDL_GetWMInfo(&sysInfo) <= 0)
+    {
+        printf( "EGL ERROR: Unable to get SDL window handle: %s\n", SDL_GetError() );
+        return 1;
+    }
+    g_nativeWindow = sysInfo.info.x11.window;
+#endif /* WIZ / CAANOO */
+
+	return 0;
+}
+
+/** @brief Release the system's native display
+ */
+void FreeNativeDisplay( void )
+{
+#if defined(USE_EGL_SDL)
+    if (g_nativeDisplay != NULL) {
+        XCloseDisplay( g_nativeDisplay );
+    }
+    g_nativeDisplay = NULL;
+#endif /* USE_EGL_SDL */
+}
+
+/** @brief Release the system's native window
+ */
+void FreeNativeWindow( void )
+{
+#if defined(WIZ) || defined(CAANOO)
+    if (g_nativeWindow != NULL) {
+        free( g_nativeWindow );
+    }
+    g_nativeWindow = NULL;
+#endif /* WIZ / CAANOO */
+}
+
+/** @brief Open any system specific resources
+ */
+void Platform_Open( void )
+{
+#if defined(PANDORA)
+    /* Pandora VSync */
+    fbdev = open ("/dev/fb0", O_RDONLY /* O_RDWR */ );
+    if ( fbdev < 0 ) {
+      printf( "EGL Couldn't open /dev/fb0 for vsync\n" );
+    }
+#elif defined(RPI)
+	bcm_host_init();
+#endif /* PANDORA */
+}
+
+/** @brief Release any system specific resources
+ */
+void Platform_Close( void )
+{
+#if defined(PANDORA)
+    /* Pandora VSync */
+    close(fbdev);
+    fbdev = -1;
+#endif /* PANDORA */
+}
+
+/** @brief Check the systems vsync state
+ */
+void Platform_VSync( void )
+{
+#if defined(PANDORA)
+    /* Pandora VSync */
+    if ( fbdev >= 0 ) {
+        int arg = 0;
+        ioctl( fbdev, FBIO_WAITFORVSYNC, &arg );
+    }
+#endif /* PANDORA */
+}
Index: eglport.h
===================================================================
--- eglport.h	(révision 0)
+++ eglport.h	(copie de travail)
@@ -0,0 +1,110 @@
+/**
+ *
+ *  EGLPORT.H
+ *  Copyright (C) 2011-2012 Scott R. Smith
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
+ *  of this software and associated documentation files (the "Software"), to deal
+ *  in the Software without restriction, including without limitation the rights
+ *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ *  copies of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ *  THE SOFTWARE.
+ *
+ */
+
+#ifndef EGLPORT_H
+#define EGLPORT_H
+
+#if defined(USE_EGL_SDL)
+#define SUPPORT_X11 1
+#endif
+
+#include <stdint.h>
+#include "EGL/egl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Defines (in every case choose only one) */
+/**     DEBUG : enable additional error monitoring per EGL function call */
+/**   Native display and window system for use with EGL */
+/**     USE_EGL_RAW : used for direct access to the framebuffer */
+/**     USE_EGL_SDL : used for access to a X window */
+/**   GLES Version */
+/**     USE_GLES1 : EGL for use with OpenGL-ES 1.X contexts */
+/**     USE_GLES2 : EGL for use with OpenGL-ES 2.0 contexts */
+/**   Platform: settings that are specific to that device */
+/**     PANDORA (use USE_EGL_SDL and USE_GLES1 or USE_GLES2)*/
+/**     WIZ     (use USE_EGL_RAW and USE_GLES1)*/
+/**     CAANOO  (use USE_EGL_RAW and USE_GLES1)*/
+/**     RPI     (use USE_EGL_RAW and USE_GLES1 or USE_GLES2)*/
+
+/** Public API */
+void    EGL_Close                   ( void );
+int8_t  EGL_Open                    ( void );
+int8_t  EGL_Init                    ( void );
+void    EGL_SwapBuffers             ( void );
+
+/**   Simple Examples  */
+/**     Raw mode:
+          EGL_Open();
+          EGL_Init();
+          do while(!quit) {
+            ... run app
+            EGL_SwapBuffers();
+          }
+		  EGL_Close();
+*/
+/**     X/SDL mode:
+		  SDL_Init( SDL_INIT_VIDEO );
+          EGL_Open();
+		  SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE|SDL_FULLSCREEN);
+          EGL_Init();
+          do while(!quit) {
+            ... run app
+            EGL_SwapBuffers();
+          }
+		  EGL_Close();
+		  SDL_Quit();
+*/
+
+#if defined(DEBUG)
+#define GET_EGLERROR(FUNCTION)               \
+    FUNCTION;                                \
+    {                                        \
+        CheckEGLErrors(__FILE__, __LINE__);  \
+    }
+#else
+#define GET_EGLERROR(FUNCTION) FUNCTION;
+#endif
+
+#define peglQueryString(A,B)                    GET_EGLERROR(eglQueryString(A,B))
+#define peglDestroyContext(A,B)                 GET_EGLERROR(eglDestroyContext(A,B))
+#define peglDestroySurface(A,B)                 GET_EGLERROR(eglDestroySurface(A,B))
+#define peglTerminate(A)                        GET_EGLERROR(eglTerminate(A))
+#define peglSwapBuffers(A,B)                    GET_EGLERROR(eglSwapBuffers(A,B))
+#define peglGetDisplay(A)                       GET_EGLERROR(eglGetDisplay(A))
+#define peglBindAPI(A)                          GET_EGLERROR(eglBindAPI(A))
+#define peglCreateContext(A,B,C,D)              GET_EGLERROR(eglCreateContext(A,B,C,D))
+#define peglCreateWindowSurface(A,B,C,D)        GET_EGLERROR(eglCreateWindowSurface(A,B,C,D))
+#define peglInitialize(A,B,C)                   GET_EGLERROR(eglInitialize(A,B,C))
+#define peglMakeCurrent(A,B,C,D)                GET_EGLERROR(eglMakeCurrent(A,B,C,D))
+#define peglChooseConfig(A,B,C,D,E)             GET_EGLERROR(eglChooseConfig(A,B,C,D,E))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // EGLPORT_H
Index: gl_textures.c
===================================================================
--- gl_textures.c	(révision 11832)
+++ gl_textures.c	(copie de travail)
@@ -81,6 +81,7 @@
 textypeinfo_t;
 
 #ifdef USE_GLES2
+#define GL_BGRA GL_RGBA
 // framebuffer texture formats
 // GLES2 devices rarely support depth textures, so we actually use a renderbuffer there
 static textypeinfo_t textype_shadowmap16_comp            = {"shadowmap16_comp",         TEXTYPE_SHADOWMAP16_COMP     ,  2,  2,  2.0f, GL_DEPTH_COMPONENT16              , GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT};
@@ -268,13 +269,19 @@
 {
 	switch(textype)
 	{
+#ifndef USE_GLES2
 	case TEXTYPE_DXT1: return &textype_dxt1;
 	case TEXTYPE_DXT1A: return &textype_dxt1a;
 	case TEXTYPE_DXT3: return &textype_dxt3;
 	case TEXTYPE_DXT5: return &textype_dxt5;
+#endif
 	case TEXTYPE_PALETTE: return (flags & TEXF_ALPHA) ? &textype_palette_alpha : &textype_palette;
+#ifndef USE_GLES2
 	case TEXTYPE_RGBA: return ((flags & TEXF_COMPRESS) && vid.support.ext_texture_compression_s3tc) ? ((flags & TEXF_ALPHA) ? &textype_rgba_alpha_compress : &textype_rgba_compress) : ((flags & TEXF_ALPHA) ? &textype_rgba_alpha : &textype_rgba);
 	case TEXTYPE_BGRA: return ((flags & TEXF_COMPRESS) && vid.support.ext_texture_compression_s3tc) ? ((flags & TEXF_ALPHA) ? &textype_bgra_alpha_compress : &textype_bgra_compress) : ((flags & TEXF_ALPHA) ? &textype_bgra_alpha : &textype_bgra);
+#else
+	case TEXTYPE_RGBA: return &textype_rgba;
+#endif
 	case TEXTYPE_ALPHA: return &textype_alpha;
 	case TEXTYPE_COLORBUFFER: return &textype_colorbuffer;
 	case TEXTYPE_COLORBUFFER16F: return &textype_colorbuffer16f;
@@ -286,6 +293,7 @@
 	case TEXTYPE_SHADOWMAP16_RAW: return &textype_shadowmap16_raw;
 	case TEXTYPE_SHADOWMAP24_COMP: return &textype_shadowmap24_comp;
 	case TEXTYPE_SHADOWMAP24_RAW: return &textype_shadowmap24_raw;
+#ifndef USE_GLES2
 	case TEXTYPE_SRGB_DXT1: return &textype_sRGB_dxt1;
 	case TEXTYPE_SRGB_DXT1A: return &textype_sRGB_dxt1a;
 	case TEXTYPE_SRGB_DXT3: return &textype_sRGB_dxt3;
@@ -293,6 +301,7 @@
 	case TEXTYPE_SRGB_PALETTE: return (flags & TEXF_ALPHA) ? &textype_sRGB_palette_alpha : &textype_sRGB_palette;
 	case TEXTYPE_SRGB_RGBA: return ((flags & TEXF_COMPRESS) && vid.support.ext_texture_compression_s3tc) ? ((flags & TEXF_ALPHA) ? &textype_sRGB_rgba_alpha_compress : &textype_sRGB_rgba_compress) : ((flags & TEXF_ALPHA) ? &textype_sRGB_rgba_alpha : &textype_sRGB_rgba);
 	case TEXTYPE_SRGB_BGRA: return ((flags & TEXF_COMPRESS) && vid.support.ext_texture_compression_s3tc) ? ((flags & TEXF_ALPHA) ? &textype_sRGB_bgra_alpha_compress : &textype_sRGB_bgra_compress) : ((flags & TEXF_ALPHA) ? &textype_sRGB_bgra_alpha : &textype_sRGB_bgra);
+#endif
 	default:
 		Host_Error("R_GetTexTypeInfo: unknown texture format");
 		break;
@@ -371,7 +380,9 @@
 		if (glt->renderbuffernum)
 		{
 			CHECKGLERROR
+#ifndef USE_GLES2
 			qglDeleteRenderbuffers(1, (GLuint *)&glt->renderbuffernum);CHECKGLERROR
+#endif
 		}
 		break;
 	case RENDERPATH_D3D9:
@@ -1111,6 +1122,7 @@
 		qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, gl_filter_mag);CHECKGLERROR
 	}
 
+#ifndef USE_GLES2
 	switch(textype)
 	{
 	case TEXTYPE_SHADOWMAP16_COMP:
@@ -1128,6 +1140,7 @@
 	default:
 		break;
 	}
+#endif
 
 	CHECKGLERROR
 }
@@ -1949,11 +1962,13 @@
 	case RENDERPATH_GLES1:
 	case RENDERPATH_GLES2:
 		CHECKGLERROR
+#ifndef USE_GLES2
 		qglGenRenderbuffers(1, (GLuint *)&glt->renderbuffernum);CHECKGLERROR
 		qglBindRenderbuffer(GL_RENDERBUFFER, glt->renderbuffernum);CHECKGLERROR
 		qglRenderbufferStorage(GL_RENDERBUFFER, glt->glinternalformat, glt->tilewidth, glt->tileheight);CHECKGLERROR
 		// note we can query the renderbuffer for info with glGetRenderbufferParameteriv for GL_WIDTH, GL_HEIGHt, GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_GL_ALPHA_SIZE, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_INTERNAL_FORMAT
 		qglBindRenderbuffer(GL_RENDERBUFFER, 0);CHECKGLERROR
+#endif
 		break;
 	case RENDERPATH_D3D9:
 #ifdef SUPPORTD3D
Index: gl_backend.c
===================================================================
--- gl_backend.c	(révision 11832)
+++ gl_backend.c	(copie de travail)
@@ -1257,6 +1257,7 @@
 	case RENDERPATH_GL20:
 	case RENDERPATH_GLES1:
 	case RENDERPATH_GLES2:
+#ifndef USE_GLES2
 		if (vid.support.arb_framebuffer_object)
 		{
 			int temp;
@@ -1361,6 +1362,7 @@
 			}
 			return temp;
 		}
+#endif
 		return 0;
 	case RENDERPATH_D3D9:
 	case RENDERPATH_D3D10:
@@ -1381,8 +1383,10 @@
 	case RENDERPATH_GL20:
 	case RENDERPATH_GLES1:
 	case RENDERPATH_GLES2:
+#ifndef USE_GLES2
 		if (fbo)
 			qglDeleteFramebuffers(1, (GLuint*)&fbo);
+#endif
 		break;
 	case RENDERPATH_D3D9:
 	case RENDERPATH_D3D10:
@@ -1449,7 +1453,9 @@
 		if (gl_state.framebufferobject != fbo)
 		{
 			gl_state.framebufferobject = fbo;
+#ifndef USE_GLES2
 			qglBindFramebuffer(GL_FRAMEBUFFER, gl_state.framebufferobject ? gl_state.framebufferobject : gl_state.defaultframebufferobject);
+#endif
 		}
 		break;
 	case RENDERPATH_D3D9:
@@ -1606,7 +1612,9 @@
 		if (vid.support.ext_framebuffer_object)
 		{
 			//qglBindRenderbuffer(GL_RENDERBUFFER, 0);
+#ifndef USE_GLES2
 			qglBindFramebuffer(GL_FRAMEBUFFER, 0);
+#endif
 		}
 
 		qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), NULL);CHECKGLERROR
@@ -1675,8 +1683,10 @@
 			qglBindBufferARB(GL_ARRAY_BUFFER, 0);
 			qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
 		}
+#ifndef USE_GLES2
 		if (vid.support.ext_framebuffer_object)
 			qglBindFramebuffer(GL_FRAMEBUFFER, gl_state.defaultframebufferobject);
+#endif
 		qglEnableVertexAttribArray(GLSLATTRIB_POSITION);
 		qglVertexAttribPointer(GLSLATTRIB_POSITION, 3, GL_FLOAT, false, sizeof(float[3]), NULL);CHECKGLERROR
 		qglDisableVertexAttribArray(GLSLATTRIB_COLOR);
@@ -1747,12 +1757,14 @@
 		case RENDERPATH_GL11:
 		case RENDERPATH_GL13:
 		case RENDERPATH_GLES1:
+#ifndef USE_GLES2
 			if (qglActiveTexture)
 			{
 				CHECKGLERROR
 				qglClientActiveTexture(GL_TEXTURE0 + gl_state.clientunit);
 				CHECKGLERROR
 			}
+#endif
 			break;
 		case RENDERPATH_D3D9:
 		case RENDERPATH_D3D10:
@@ -2393,7 +2405,11 @@
 		case RENDERPATH_GL13:
 		case RENDERPATH_GLES1:
 			CHECKGLERROR
+#ifndef USE_GLES2
 			qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);
+#else
+			qglVertexAttrib4f(GLSLATTRIB_COLOR, cr, cg, cb, ca);
+#endif
 			CHECKGLERROR
 			break;
 		case RENDERPATH_D3D9:
@@ -2553,7 +2569,9 @@
 	case RENDERPATH_GLES1:
 	case RENDERPATH_GLES2:
 		CHECKGLERROR
+#ifndef USE_GLES2
 		qglReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, outpixels);CHECKGLERROR
+#endif
 		break;
 	case RENDERPATH_D3D9:
 #ifdef SUPPORTD3D
@@ -2635,7 +2653,8 @@
 			for (j = 0;strings[i][j];j++)
 				if (strings[i][j] == '\n')
 					pretextlines++;
-		Con_Printf("%s shader compile log:\n%s\n(line offset for any above warnings/errors: %i)\n", shadertype, compilelog, pretextlines);
+		//Con_Printf("%s shader compile log:\n%s\n(line offset for any above warnings/errors: %i)\n", shadertype, compilelog, pretextlines);
+		printf("#### %s shader compile log:\n%s\n(line offset for any above warnings/errors: %i)\n", shadertype, compilelog, pretextlines);
 	}
 	if (!shadercompiled)
 	{
@@ -2655,8 +2674,10 @@
 	CHECKGLERROR
 
 	programobject = qglCreateProgram();CHECKGLERROR
+printf("GL_Backend_CompileProgram\n");
 	if (!programobject)
 		return 0;
+printf("#### GL_Backend_CompileProgram\n");
 
 	qglBindAttribLocation(programobject, GLSLATTRIB_POSITION , "Attrib_Position" );
 	qglBindAttribLocation(programobject, GLSLATTRIB_COLOR    , "Attrib_Color"    );
@@ -3430,7 +3451,9 @@
 			gl_state.pointer_vertex_offset = bufferoffset;
 			CHECKGLERROR
 			GL_BindVBO(bufferobject);
+#ifndef USE_GLES2
 			qglVertexPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+#endif
 		}
 		break;
 	case RENDERPATH_GL20:
Index: gl_rmain.c
===================================================================
--- gl_rmain.c	(révision 11832)
+++ gl_rmain.c	(copie de travail)
@@ -1246,7 +1246,9 @@
 		Con_DPrintf("^5GLSL shader %s compiled (%i textures).\n", permutationname, sampler);
 	}
 	else
+	{
 		Con_Printf("^1GLSL shader %s failed!  some features may not work properly.\n", permutationname);
+	}
 
 	// free the strings
 	if (vertexstring)
@@ -5387,7 +5389,9 @@
 		case RENDERPATH_GL11:
 		case RENDERPATH_GL13:
 		case RENDERPATH_GLES1:
+#ifndef USE_GLES2
 			qglLoadMatrixf(gl_modelview16f);CHECKGLERROR
+#endif
 			break;
 		case RENDERPATH_SOFT:
 			DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM1, 1, false, gl_modelviewprojection16f);
Index: vid_sdl.c
===================================================================
--- vid_sdl.c	(révision 11832)
+++ vid_sdl.c	(copie de travail)
@@ -2058,6 +2058,9 @@
 		Con_Printf("Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError());
 		return false;
 	}
+#elif defined(USE_EGLPORT)
+#include "eglport.h"
+	if (EGL_Open()) return 0;
 #endif
 
 #ifdef __IPHONEOS__
@@ -2129,6 +2132,7 @@
 	video_bpp = mode->bitsperpixel;
 #if SDL_MAJOR_VERSION == 1
 	video_flags = flags;
+#ifndef USE_EGLPORT
 	screen = VID_WrapSDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, flags);
 	if (screen == NULL)
 	{
@@ -2136,6 +2140,11 @@
 		VID_Shutdown();
 		return false;
 	}
+#else
+        screen = SDL_SetVideoMode( 800, 480, 0, SDL_SWSURFACE | SDL_FULLSCREEN );
+        video_bpp = mode->bitsperpixel = 16;
+        EGL_Init();
+#endif
 	mode->width = screen->w;
 	mode->height = screen->h;
 #else
@@ -2338,6 +2347,9 @@
 	window = NULL;
 #endif
 
+#ifdef USE_EGLPORT
+	EGL_Close();
+#endif
 	SDL_QuitSubSystem(SDL_INIT_VIDEO);
 
 	gl_driver[0] = 0;
@@ -2405,8 +2417,12 @@
 }
 #endif
 #if SDL_MAJOR_VERSION == 1
+#ifndef USE_EGLPORT
 			SDL_GL_SwapBuffers();
 #else
+			EGL_SwapBuffers();
+#endif
+#else
 			SDL_GL_SwapWindow(window);
 #endif
 			break;
