]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_sdl.c
don't call ODE dWorldQuickStep with 0 step time
[xonotic/darkplaces.git] / vid_sdl.c
index 941b5c5f8457dea745bc40479227c1b3b5121c88..97433653fdeb9bfc8409aa6a2f4d1e951ed3c443 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -66,18 +66,18 @@ int cl_available = true;
 
 qboolean vid_supportrefreshrate = false;
 
-#ifdef USE_GLES2
-# define SETVIDEOMODE 0
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
+# define SETVIDEOMODE 1
 #else
-# if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
-#  define SETVIDEOMODE 1
+# ifdef USE_GLES2
+#  define SETVIDEOMODE 0
 # else
 // LordHavoc: SDL 1.3's SDL_CreateWindow API is not finished enough to use yet, but you can set this to 0 if you want to try it...
-#  ifndef SETVIDEOMODE
-#   define SETVIDEOMODE 1
+#   ifndef SETVIDEOMODE
+#    define SETVIDEOMODE 1
+#   endif
 #  endif
 # endif
-#endif
 
 static qboolean vid_usingmouse = false;
 static qboolean vid_usinghidecursor = false;
@@ -380,7 +380,7 @@ SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window);  // returns whether or
 int SDL_iPhoneKeyboardToggle(SDL_Window * window); // toggles the visibility of the onscreen keyboard.  Returns 0 on success and -1 on error.
 #endif
 
-void VID_ShowKeyboard(qboolean show)
+static void VID_ShowKeyboard(qboolean show)
 {
 #ifdef __IPHONEOS__
        if (show)
@@ -486,7 +486,7 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
 #define MAXFINGERS 11
 int multitouch[MAXFINGERS][3];
 
-qboolean VID_TouchscreenArea(int corner, float px, float py, float pwidth, float pheight, const char *icon, float *resultmove, qboolean *resultbutton, keynum_t key)
+static qboolean VID_TouchscreenArea(int corner, float px, float py, float pwidth, float pheight, const char *icon, float *resultmove, qboolean *resultbutton, keynum_t key)
 {
        int finger;
        float fx, fy, fwidth, fheight;
@@ -1305,6 +1305,10 @@ void wrapglGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) {PRECALL
 void wrapglGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer) {PRECALL;glGetVertexAttribPointerv(index, pname, pointer);POSTCALL;}
 #endif
 
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
+#define SDL_GL_ExtensionSupported(x) (strstr(gl_extensions, x) || strstr(gl_platformextensions, x))
+#endif
+
 void GLES_Init(void)
 {
 #ifndef qglClear
@@ -1568,6 +1572,7 @@ void GLES_Init(void)
        vid.support.ext_blend_subtract = true;
        vid.support.ext_draw_range_elements = true;
        vid.support.ext_framebuffer_object = false;//true;
+       vid.support.ext_packed_depth_stencil = false;
        vid.support.ext_stencil_two_side = false;
        vid.support.ext_texture_3d = SDL_GL_ExtensionSupported("GL_OES_texture_3D");
        vid.support.ext_texture_compression_s3tc = SDL_GL_ExtensionSupported("GL_EXT_texture_compression_s3tc");
@@ -1806,7 +1811,7 @@ static SDL_Surface *VID_WrapSDL_SetVideoMode(int screenwidth, int screenheight,
 
                        // reallocate with malloc, as this is in tempmempool (do not want)
                        xpm = data;
-                       data = malloc(width * height * 4);
+                       data = (char *) malloc(width * height * 4);
                        memcpy(data, xpm, width * height * 4);
                        Mem_Free(xpm);
                        xpm = NULL;
@@ -1960,6 +1965,7 @@ static SDL_Surface *VID_WrapSDL_SetVideoMode(int screenwidth, int screenheight,
                                static long netwm_icon[MAX_NETWM_ICON];
                                int pos = 0;
                                int i = 1;
+                               char vabuf[1024];
 
                                while(data)
                                {
@@ -1977,7 +1983,7 @@ static SDL_Surface *VID_WrapSDL_SetVideoMode(int screenwidth, int screenheight,
                                        }
                                        ++i;
                                        Mem_Free(data);
-                                       data = (char *) loadimagepixelsbgra(va("darkplaces-icon%d", i), false, false, false, NULL);
+                                       data = (char *) loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "darkplaces-icon%d", i), false, false, false, NULL);
                                }
 
                                info.info.x11.lock_func();
@@ -2007,7 +2013,7 @@ static void VID_OutputVersion(void)
                                        version->major, version->minor, version->patch );
 }
 
-qboolean VID_InitModeGL(viddef_mode_t *mode)
+static qboolean VID_InitModeGL(viddef_mode_t *mode)
 {
        int i;
 #if SETVIDEOMODE
@@ -2041,6 +2047,7 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
        notfirstvideomode = true;
 #endif
 
+#ifndef USE_GLES2
        // SDL usually knows best
        drivername = NULL;
 
@@ -2053,6 +2060,7 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
                Con_Printf("Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError());
                return false;
        }
+#endif
 
 #ifdef __IPHONEOS__
        // mobile platforms are always fullscreen, we'll get the resolution after opening the window
@@ -2192,7 +2200,7 @@ extern cvar_t gl_info_version;
 extern cvar_t gl_info_platform;
 extern cvar_t gl_info_driver;
 
-qboolean VID_InitModeSoft(viddef_mode_t *mode)
+static qboolean VID_InitModeSoft(viddef_mode_t *mode)
 {
 #if SETVIDEOMODE
        int flags = SDL_HWSURFACE;