]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_sdl.c
Fix a typo in DrawQ_RotPic which broke it badly.
[xonotic/darkplaces.git] / vid_sdl.c
index 03af6eaf0bf2e5e8a19dd269f21111a95bc13ce8..70032371e1ad016e70d5fdce14226d6fbc709193 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 #include "image.h"
-#include "dpsoftrast.h"
 #include "utf8lib.h"
 
 #ifndef __IPHONEOS__
@@ -84,14 +83,13 @@ static int win_half_height = 50;
 static int video_bpp;
 
 #if SDL_MAJOR_VERSION == 1
-static SDL_Surface *screen;
+static SDL_Surface *video_screen;
 static int video_flags;
 #else
-static SDL_GLContext *context;
+static SDL_GLContext context;
 static SDL_Window *window;
 static int window_flags;
 #endif
-static SDL_Surface *vid_softsurface;
 static vid_mode_t desktop_mode;
 
 /////////////////////////
@@ -787,7 +785,6 @@ static void IN_Move_TouchScreen_SteelStorm(void)
        float move[3], aim[3];
        static qboolean oldbuttons[128];
        static qboolean buttons[128];
-       static keydest_t oldkeydest;
        keydest_t keydest = (key_consoleactive & KEY_CONSOLEACTIVE_USER) ? key_console : key_dest;
        memcpy(oldbuttons, buttons, sizeof(oldbuttons));
        memset(multitouchs, 0, sizeof(multitouchs));
@@ -810,17 +807,6 @@ static void IN_Move_TouchScreen_SteelStorm(void)
                multitouch[MAXFINGERS-1][0] = 0;
        }*/
 
-       if (oldkeydest != keydest)
-       {
-               switch(keydest)
-               {
-               case key_game: VID_ShowKeyboard(false);break;
-               case key_console: VID_ShowKeyboard(true);break;
-               case key_message: VID_ShowKeyboard(true);break;
-               default: break; /* qc extensions control the other cases */
-               }
-       }
-       oldkeydest = keydest;
        // TODO: make touchscreen areas controlled by a config file or the VMs. THIS IS A MESS!
        // TODO: can't just clear buttons[] when entering a new keydest, some keys would remain pressed
        // SS:BR menuqc has many peculiarities, including that it can't accept more than one command per frame and pressing and releasing on the same frame
@@ -979,11 +965,27 @@ void IN_Move( void )
 {
        static int old_x = 0, old_y = 0;
        static int stuck = 0;
+       static keydest_t oldkeydest;
+       static qboolean oldshowkeyboard;
        int x, y;
        vid_joystate_t joystate;
+       keydest_t keydest = (key_consoleactive & KEY_CONSOLEACTIVE_USER) ? key_console : key_dest;
 
        scr_numtouchscreenareas = 0;
 
+       // Only apply the new keyboard state if the input changes.
+       if (keydest != oldkeydest || !!vid_touchscreen_showkeyboard.integer != oldshowkeyboard)
+       {
+               switch(keydest)
+               {
+                       case key_console: VID_ShowKeyboard(true);break;
+                       case key_message: VID_ShowKeyboard(true);break;
+                       default: VID_ShowKeyboard(!!vid_touchscreen_showkeyboard.integer); break;
+               }
+       }
+       oldkeydest = keydest;
+       oldshowkeyboard = !!vid_touchscreen_showkeyboard.integer;
+
        if (vid_touchscreen.integer)
        {
                switch(gamemode)
@@ -1150,17 +1152,7 @@ void Sys_SendKeyEvents( void )
                                        vid.width = event.resize.w;
                                        vid.height = event.resize.h;
                                        if (!vid_isfullscreen)
-                                               screen = SDL_SetVideoMode(vid.width, vid.height, video_bpp, video_flags);
-                                       if (vid_softsurface)
-                                       {
-                                               SDL_FreeSurface(vid_softsurface);
-                                               vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, vid.width, vid.height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
-                                               SDL_SetAlpha(vid_softsurface, 0, 255);
-                                               vid.softpixels = (unsigned int *)vid_softsurface->pixels;
-                                               if (vid.softdepthpixels)
-                                                       free(vid.softdepthpixels);
-                                               vid.softdepthpixels = (unsigned int*)calloc(1, vid.width * vid.height * 4);
-                                       }
+                                               video_screen = SDL_SetVideoMode(vid.width, vid.height, video_bpp, video_flags);
 #ifdef SDL_R_RESTART
                                        // better not call R_Modules_Restart from here directly, as this may wreak havoc...
                                        // so, let's better queue it for next frame
@@ -1214,12 +1206,14 @@ void Sys_SendKeyEvents( void )
        static qboolean sound_active = true;
        int keycode;
        int i;
+       qboolean isdown;
        Uchar unicode;
        SDL_Event event;
 
        VID_EnableJoystick(true);
 
        while( SDL_PollEvent( &event ) )
+               loop_start:
                switch( event.type ) {
                        case SDL_QUIT:
 #ifdef DEBUGSDLEVENTS
@@ -1236,8 +1230,31 @@ void Sys_SendKeyEvents( void )
                                        Con_DPrintf("SDL_Event: SDL_KEYUP %i\n", event.key.keysym.sym);
 #endif
                                keycode = MapKey(event.key.keysym.sym);
+                               isdown = (event.key.state == SDL_PRESSED);
+                               unicode = 0;
+                               if(isdown)
+                               {
+                                       if(SDL_PollEvent(&event))
+                                       {
+                                               if(event.type == SDL_TEXTINPUT)
+                                               {
+                                                       // combine key code from SDL_KEYDOWN event and character
+                                                       // from SDL_TEXTINPUT event in a single Key_Event call
+#ifdef DEBUGSDLEVENTS
+                                                       Con_DPrintf("SDL_Event: SDL_TEXTINPUT - text: %s\n", event.text.text);
+#endif
+                                                       unicode = u8_getchar_utf8_enabled(event.text.text + (int)u8_bytelen(event.text.text, 0), NULL);
+                                               }
+                                               else
+                                               {
+                                                       if (!VID_JoyBlockEmulatedKeys(keycode))
+                                                               Key_Event(keycode, 0, isdown);
+                                                       goto loop_start;
+                                               }
+                                       }
+                               }
                                if (!VID_JoyBlockEmulatedKeys(keycode))
-                                       Key_Event(keycode, 0, (event.key.state == SDL_PRESSED));
+                                       Key_Event(keycode, unicode, isdown);
                                break;
                        case SDL_MOUSEBUTTONDOWN:
                        case SDL_MOUSEBUTTONUP:
@@ -1300,16 +1317,6 @@ void Sys_SendKeyEvents( void )
                                                {
                                                        vid.width = event.window.data1;
                                                        vid.height = event.window.data2;
-                                                       if (vid_softsurface)
-                                                       {
-                                                               SDL_FreeSurface(vid_softsurface);
-                                                               vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, vid.width, vid.height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
-                                                               SDL_SetSurfaceBlendMode(vid_softsurface, SDL_BLENDMODE_NONE);
-                                                               vid.softpixels = (unsigned int *)vid_softsurface->pixels;
-                                                               if (vid.softdepthpixels)
-                                                                       free(vid.softdepthpixels);
-                                                               vid.softdepthpixels = (unsigned int*)calloc(1, vid.width * vid.height * 4);
-                                                       }
 #ifdef SDL_R_RESTART
                                                        // better not call R_Modules_Restart from here directly, as this may wreak havoc...
                                                        // so, let's better queue it for next frame
@@ -1469,10 +1476,8 @@ GLint wrapglGetUniformLocation(GLuint programObj, const GLchar *name) {PRECALL;r
 const GLubyte* wrapglGetString(GLenum name) {PRECALL;return (const GLubyte*)glGetString(name);POSTCALL;}
 void wrapglActiveStencilFace(GLenum e) {PRECALL;Con_Printf("glActiveStencilFace(e)\n");POSTCALL;}
 void wrapglActiveTexture(GLenum e) {PRECALL;glActiveTexture(e);POSTCALL;}
-void wrapglAlphaFunc(GLenum func, GLclampf ref) {PRECALL;Con_Printf("glAlphaFunc(func, ref)\n");POSTCALL;}
 void wrapglArrayElement(GLint i) {PRECALL;Con_Printf("glArrayElement(i)\n");POSTCALL;}
 void wrapglAttachShader(GLuint containerObj, GLuint obj) {PRECALL;glAttachShader(containerObj, obj);POSTCALL;}
-//void wrapglBegin(GLenum mode) {PRECALL;Con_Printf("glBegin(mode)\n");POSTCALL;}
 //void wrapglBeginQuery(GLenum target, GLuint qid) {PRECALL;glBeginQuery(target, qid);POSTCALL;}
 void wrapglBindAttribLocation(GLuint programObj, GLuint index, const GLchar *name) {PRECALL;glBindAttribLocation(programObj, index, name);POSTCALL;}
 //void wrapglBindFragDataLocation(GLuint programObj, GLuint index, const GLchar *name) {PRECALL;glBindFragDataLocation(programObj, index, name);POSTCALL;}
@@ -1488,11 +1493,7 @@ void wrapglClear(GLbitfield mask) {PRECALL;glClear(mask);POSTCALL;}
 void wrapglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {PRECALL;glClearColor(red, green, blue, alpha);POSTCALL;}
 void wrapglClearDepth(GLclampd depth) {PRECALL;/*Con_Printf("glClearDepth(%f)\n", depth);glClearDepthf((float)depth);*/POSTCALL;}
 void wrapglClearStencil(GLint s) {PRECALL;glClearStencil(s);POSTCALL;}
-void wrapglClientActiveTexture(GLenum target) {PRECALL;Con_Printf("glClientActiveTexture(target)\n");POSTCALL;}
-void wrapglColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {PRECALL;Con_Printf("glColor4f(red, green, blue, alpha)\n");POSTCALL;}
-void wrapglColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) {PRECALL;Con_Printf("glColor4ub(red, green, blue, alpha)\n");POSTCALL;}
 void wrapglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {PRECALL;glColorMask(red, green, blue, alpha);POSTCALL;}
-void wrapglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) {PRECALL;Con_Printf("glColorPointer(size, type, stride, ptr)\n");POSTCALL;}
 void wrapglCompileShader(GLuint shaderObj) {PRECALL;glCompileShader(shaderObj);POSTCALL;}
 void wrapglCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border,  GLsizei imageSize, const void *data) {PRECALL;glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);POSTCALL;}
 void wrapglCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data) {PRECALL;Con_Printf("glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data)\n");POSTCALL;}
@@ -1515,7 +1516,6 @@ void wrapglDepthMask(GLboolean flag) {PRECALL;glDepthMask(flag);POSTCALL;}
 void wrapglDepthRangef(GLclampf near_val, GLclampf far_val) {PRECALL;glDepthRangef(near_val, far_val);POSTCALL;}
 void wrapglDetachShader(GLuint containerObj, GLuint attachedObj) {PRECALL;glDetachShader(containerObj, attachedObj);POSTCALL;}
 void wrapglDisable(GLenum cap) {PRECALL;glDisable(cap);POSTCALL;}
-void wrapglDisableClientState(GLenum cap) {PRECALL;Con_Printf("glDisableClientState(cap)\n");POSTCALL;}
 void wrapglDisableVertexAttribArray(GLuint index) {PRECALL;glDisableVertexAttribArray(index);POSTCALL;}
 void wrapglDrawArrays(GLenum mode, GLint first, GLsizei count) {PRECALL;glDrawArrays(mode, first, count);POSTCALL;}
 void wrapglDrawBuffer(GLenum mode) {PRECALL;Con_Printf("glDrawBuffer(mode)\n");POSTCALL;}
@@ -1524,9 +1524,7 @@ void wrapglDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *i
 //void wrapglDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices) {PRECALL;glDrawRangeElements(mode, start, end, count, type, indices);POSTCALL;}
 //void wrapglDrawRangeElementsEXT(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices) {PRECALL;glDrawRangeElements(mode, start, end, count, type, indices);POSTCALL;}
 void wrapglEnable(GLenum cap) {PRECALL;glEnable(cap);POSTCALL;}
-void wrapglEnableClientState(GLenum cap) {PRECALL;Con_Printf("glEnableClientState(cap)\n");POSTCALL;}
 void wrapglEnableVertexAttribArray(GLuint index) {PRECALL;glEnableVertexAttribArray(index);POSTCALL;}
-//void wrapglEnd(void) {PRECALL;Con_Printf("glEnd()\n");POSTCALL;}
 //void wrapglEndQuery(GLenum target) {PRECALL;glEndQuery(target);POSTCALL;}
 void wrapglFinish(void) {PRECALL;glFinish();POSTCALL;}
 void wrapglFlush(void) {PRECALL;glFlush();POSTCALL;}
@@ -1565,16 +1563,7 @@ void wrapglGetTexParameteriv(GLenum target, GLenum pname, GLint *params) {PRECAL
 void wrapglGetUniformfv(GLuint programObj, GLint location, GLfloat *params) {PRECALL;glGetUniformfv(programObj, location, params);POSTCALL;}
 void wrapglGetUniformiv(GLuint programObj, GLint location, GLint *params) {PRECALL;glGetUniformiv(programObj, location, params);POSTCALL;}
 void wrapglHint(GLenum target, GLenum mode) {PRECALL;glHint(target, mode);POSTCALL;}
-void wrapglLineWidth(GLfloat width) {PRECALL;glLineWidth(width);POSTCALL;}
 void wrapglLinkProgram(GLuint programObj) {PRECALL;glLinkProgram(programObj);POSTCALL;}
-void wrapglLoadIdentity(void) {PRECALL;Con_Printf("glLoadIdentity()\n");POSTCALL;}
-void wrapglLoadMatrixf(const GLfloat *m) {PRECALL;Con_Printf("glLoadMatrixf(m)\n");POSTCALL;}
-void wrapglMatrixMode(GLenum mode) {PRECALL;Con_Printf("glMatrixMode(mode)\n");POSTCALL;}
-void wrapglMultiTexCoord1f(GLenum target, GLfloat s) {PRECALL;Con_Printf("glMultiTexCoord1f(target, s)\n");POSTCALL;}
-void wrapglMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t) {PRECALL;Con_Printf("glMultiTexCoord2f(target, s, t)\n");POSTCALL;}
-void wrapglMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r) {PRECALL;Con_Printf("glMultiTexCoord3f(target, s, t, r)\n");POSTCALL;}
-void wrapglMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {PRECALL;Con_Printf("glMultiTexCoord4f(target, s, t, r, q)\n");POSTCALL;}
-void wrapglNormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) {PRECALL;Con_Printf("glNormalPointer(type, stride, ptr)\n");POSTCALL;}
 void wrapglPixelStorei(GLenum pname, GLint param) {PRECALL;glPixelStorei(pname, param);POSTCALL;}
 void wrapglPointSize(GLfloat size) {PRECALL;Con_Printf("glPointSize(size)\n");POSTCALL;}
 //void wrapglPolygonMode(GLenum face, GLenum mode) {PRECALL;Con_Printf("glPolygonMode(face, mode)\n");POSTCALL;}
@@ -1590,14 +1579,6 @@ void wrapglStencilFuncSeparate(GLenum func1, GLenum func2, GLint ref, GLuint mas
 void wrapglStencilMask(GLuint mask) {PRECALL;glStencilMask(mask);POSTCALL;}
 void wrapglStencilOp(GLenum fail, GLenum zfail, GLenum zpass) {PRECALL;glStencilOp(fail, zfail, zpass);POSTCALL;}
 void wrapglStencilOpSeparate(GLenum e1, GLenum e2, GLenum e3, GLenum e4) {PRECALL;Con_Printf("glStencilOpSeparate(e1, e2, e3, e4)\n");POSTCALL;}
-void wrapglTexCoord1f(GLfloat s) {PRECALL;Con_Printf("glTexCoord1f(s)\n");POSTCALL;}
-void wrapglTexCoord2f(GLfloat s, GLfloat t) {PRECALL;Con_Printf("glTexCoord2f(s, t)\n");POSTCALL;}
-void wrapglTexCoord3f(GLfloat s, GLfloat t, GLfloat r) {PRECALL;Con_Printf("glTexCoord3f(s, t, r)\n");POSTCALL;}
-void wrapglTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) {PRECALL;Con_Printf("glTexCoord4f(s, t, r, q)\n");POSTCALL;}
-void wrapglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) {PRECALL;Con_Printf("glTexCoordPointer(size, type, stride, ptr)\n");POSTCALL;}
-void wrapglTexEnvf(GLenum target, GLenum pname, GLfloat param) {PRECALL;Con_Printf("glTexEnvf(target, pname, param)\n");POSTCALL;}
-void wrapglTexEnvfv(GLenum target, GLenum pname, const GLfloat *params) {PRECALL;Con_Printf("glTexEnvfv(target, pname, params)\n");POSTCALL;}
-void wrapglTexEnvi(GLenum target, GLenum pname, GLint param) {PRECALL;Con_Printf("glTexEnvi(target, pname, param)\n");POSTCALL;}
 void wrapglTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {PRECALL;glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);POSTCALL;}
 void wrapglTexImage3D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {PRECALL;Con_Printf("glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels)\n");POSTCALL;}
 void wrapglTexParameterf(GLenum target, GLenum pname, GLfloat param) {PRECALL;glTexParameterf(target, pname, param);POSTCALL;}
@@ -1698,10 +1679,8 @@ void GLES_Init(void)
        qglGetString = wrapglGetString;
 //     qglActiveStencilFaceEXT = wrapglActiveStencilFace;
        qglActiveTexture = wrapglActiveTexture;
-       qglAlphaFunc = wrapglAlphaFunc;
        qglArrayElement = wrapglArrayElement;
        qglAttachShader = wrapglAttachShader;
-//     qglBegin = wrapglBegin;
 //     qglBeginQueryARB = wrapglBeginQuery;
        qglBindAttribLocation = wrapglBindAttribLocation;
 //     qglBindFragDataLocation = wrapglBindFragDataLocation;
@@ -1717,11 +1696,7 @@ void GLES_Init(void)
        qglClearColor = wrapglClearColor;
        qglClearDepth = wrapglClearDepth;
        qglClearStencil = wrapglClearStencil;
-       qglClientActiveTexture = wrapglClientActiveTexture;
-       qglColor4f = wrapglColor4f;
-       qglColor4ub = wrapglColor4ub;
        qglColorMask = wrapglColorMask;
-       qglColorPointer = wrapglColorPointer;
        qglCompileShader = wrapglCompileShader;
        qglCompressedTexImage2DARB = wrapglCompressedTexImage2D;
        qglCompressedTexImage3DARB = wrapglCompressedTexImage3D;
@@ -1743,7 +1718,6 @@ void GLES_Init(void)
        qglDepthRangef = wrapglDepthRangef;
        qglDetachShader = wrapglDetachShader;
        qglDisable = wrapglDisable;
-       qglDisableClientState = wrapglDisableClientState;
        qglDisableVertexAttribArray = wrapglDisableVertexAttribArray;
        qglDrawArrays = wrapglDrawArrays;
 //     qglDrawBuffer = wrapglDrawBuffer;
@@ -1751,9 +1725,7 @@ void GLES_Init(void)
        qglDrawElements = wrapglDrawElements;
 //     qglDrawRangeElements = wrapglDrawRangeElements;
        qglEnable = wrapglEnable;
-       qglEnableClientState = wrapglEnableClientState;
        qglEnableVertexAttribArray = wrapglEnableVertexAttribArray;
-//     qglEnd = wrapglEnd;
 //     qglEndQueryARB = wrapglEndQuery;
        qglFinish = wrapglFinish;
        qglFlush = wrapglFlush;
@@ -1792,16 +1764,7 @@ void GLES_Init(void)
        qglGetUniformfv = wrapglGetUniformfv;
        qglGetUniformiv = wrapglGetUniformiv;
        qglHint = wrapglHint;
-       qglLineWidth = wrapglLineWidth;
        qglLinkProgram = wrapglLinkProgram;
-       qglLoadIdentity = wrapglLoadIdentity;
-       qglLoadMatrixf = wrapglLoadMatrixf;
-       qglMatrixMode = wrapglMatrixMode;
-       qglMultiTexCoord1f = wrapglMultiTexCoord1f;
-       qglMultiTexCoord2f = wrapglMultiTexCoord2f;
-       qglMultiTexCoord3f = wrapglMultiTexCoord3f;
-       qglMultiTexCoord4f = wrapglMultiTexCoord4f;
-       qglNormalPointer = wrapglNormalPointer;
        qglPixelStorei = wrapglPixelStorei;
        qglPointSize = wrapglPointSize;
 //     qglPolygonMode = wrapglPolygonMode;
@@ -1817,14 +1780,6 @@ void GLES_Init(void)
        qglStencilMask = wrapglStencilMask;
        qglStencilOp = wrapglStencilOp;
        qglStencilOpSeparate = wrapglStencilOpSeparate;
-       qglTexCoord1f = wrapglTexCoord1f;
-       qglTexCoord2f = wrapglTexCoord2f;
-       qglTexCoord3f = wrapglTexCoord3f;
-       qglTexCoord4f = wrapglTexCoord4f;
-       qglTexCoordPointer = wrapglTexCoordPointer;
-       qglTexEnvf = wrapglTexEnvf;
-       qglTexEnvfv = wrapglTexEnvfv;
-       qglTexEnvi = wrapglTexEnvi;
        qglTexImage2D = wrapglTexImage2D;
        qglTexImage3D = wrapglTexImage3D;
        qglTexParameterf = wrapglTexParameterf;
@@ -1948,7 +1903,8 @@ void GLES_Init(void)
                Calling them just threw an exception. Android developer relations confirmed that they forgot to implement these. (yeah...)
                It's apparently been fixed in 2.2, though I haven't tested."
        */
-       vid.support.ext_framebuffer_object = false;//true;
+       // LadyHavoc: Android 2.1 is way old now, enabling this again, it's going to be required soon.
+       vid.support.ext_framebuffer_object = true;
 
        vid.support.ext_packed_depth_stencil = false;
        vid.support.ext_stencil_two_side = false;
@@ -1957,6 +1913,9 @@ void GLES_Init(void)
        vid.support.ext_texture_edge_clamp = true; // GLES2 core
        vid.support.ext_texture_filter_anisotropic = false; // probably don't want to use it...
        vid.support.ext_texture_srgb = false;
+       vid.support.arb_texture_float = SDL_GL_ExtensionSupported("GL_OES_texture_float") != 0;
+       vid.support.arb_half_float_pixel = SDL_GL_ExtensionSupported("GL_OES_texture_half_float") != 0;
+       vid.support.arb_half_float_vertex = SDL_GL_ExtensionSupported("GL_OES_vertex_half_float") != 0;
 
        // NOTE: On some devices, a value of 512 gives better FPS than the maximum.
        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&vid.maxtexturesize_2d);
@@ -2453,7 +2412,7 @@ static void AdjustWindowBounds(viddef_mode_t *mode, RECT *rect)
        else 
        {
                rect->left = workArea.left + max(0, (workWidth - width) / 2);
-               rect->top = workArea.top + (0, (workHeight - height) / 2);
+               rect->top = workArea.top + max(0, (workHeight - height) / 2);
        }
 }
 #endif
@@ -2465,6 +2424,8 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
        int flags = SDL_OPENGL;
 #else
        int windowflags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
+       int xPos = SDL_WINDOWPOS_UNDEFINED;
+       int yPos = SDL_WINDOWPOS_UNDEFINED;
 #endif
 #ifndef USE_GLES2
        int i;
@@ -2547,8 +2508,6 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
                }
        }
 #else
-       int xPos = SDL_WINDOWPOS_UNDEFINED;
-       int yPos = SDL_WINDOWPOS_UNDEFINED;
        {
                if (mode->fullscreen) {
                        if (vid_desktopfullscreen.integer)
@@ -2615,15 +2574,15 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
        video_bpp = mode->bitsperpixel;
 #if SDL_MAJOR_VERSION == 1
        video_flags = flags;
-       screen = VID_WrapSDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, flags);
-       if (screen == NULL)
+       video_screen = VID_WrapSDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, flags);
+       if (video_screen == NULL)
        {
                Con_Printf("Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
                VID_Shutdown();
                return false;
        }
-       mode->width = screen->w;
-       mode->height = screen->h;
+       mode->width = video_screen->w;
+       mode->height = video_screen->h;
 #else
        window_flags = windowflags;
        window = SDL_CreateWindow(gamename, xPos, yPos, mode->width, mode->height, windowflags);
@@ -2643,9 +2602,6 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
        }
 #endif
 
-       vid_softsurface = NULL;
-       vid.softpixels = NULL;
-
 #if SDL_MAJOR_VERSION == 1
        // init keyboard
        SDL_EnableUNICODE( SDL_ENABLE );
@@ -2686,112 +2642,6 @@ extern cvar_t gl_info_version;
 extern cvar_t gl_info_platform;
 extern cvar_t gl_info_driver;
 
-static qboolean VID_InitModeSoft(viddef_mode_t *mode)
-{
-#if SDL_MAJOR_VERSION == 1
-       int flags = SDL_HWSURFACE;
-       if(!COM_CheckParm("-noasyncblit")) flags |= SDL_ASYNCBLIT;
-#else
-       int windowflags = SDL_WINDOW_SHOWN;
-#endif
-
-       win_half_width = mode->width>>1;
-       win_half_height = mode->height>>1;
-
-       if(vid_resizable.integer)
-#if SDL_MAJOR_VERSION == 1
-               flags |= SDL_RESIZABLE;
-#else
-               windowflags |= SDL_WINDOW_RESIZABLE;
-#endif
-
-       VID_OutputVersion();
-
-       vid_isfullscreen = false;
-       if (mode->fullscreen) {
-#if SDL_MAJOR_VERSION == 1
-               const SDL_VideoInfo *vi = SDL_GetVideoInfo();
-               mode->width = vi->current_w;
-               mode->height = vi->current_h;
-               mode->bitsperpixel = vi->vfmt->BitsPerPixel;
-               flags |= SDL_FULLSCREEN;
-#else
-               if (vid_desktopfullscreen.integer)
-                       windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
-               else
-                       windowflags |= SDL_WINDOW_FULLSCREEN;
-#endif
-               vid_isfullscreen = true;
-       }
-
-       video_bpp = mode->bitsperpixel;
-#if SDL_MAJOR_VERSION == 1
-       video_flags = flags;
-       screen = VID_WrapSDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, flags);
-       if (screen == NULL)
-       {
-               Con_Printf("Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
-               VID_Shutdown();
-               return false;
-       }
-       mode->width = screen->w;
-       mode->height = screen->h;
-#else
-       window_flags = windowflags;
-       window = SDL_CreateWindow(gamename, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, mode->width, mode->height, windowflags);
-       if (window == NULL)
-       {
-               Con_Printf("Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
-               VID_Shutdown();
-               return false;
-       }
-       SDL_GetWindowSize(window, &mode->width, &mode->height);
-#endif
-
-       // create a framebuffer using our specific color format, we let the SDL blit function convert it in VID_Finish
-       vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, mode->width, mode->height, 32, 0x00FF0000, 0x0000FF00, 0x00000000FF, 0xFF000000);
-       if (vid_softsurface == NULL)
-       {
-               Con_Printf("Failed to setup software rasterizer framebuffer %ix%ix32bpp: %s\n", mode->width, mode->height, SDL_GetError());
-               VID_Shutdown();
-               return false;
-       }
-#if SDL_MAJOR_VERSION == 1
-       SDL_SetAlpha(vid_softsurface, 0, 255);
-#else
-       SDL_SetSurfaceBlendMode(vid_softsurface, SDL_BLENDMODE_NONE);
-#endif
-
-       vid.softpixels = (unsigned int *)vid_softsurface->pixels;
-       vid.softdepthpixels = (unsigned int *)calloc(1, mode->width * mode->height * 4);
-       if (DPSOFTRAST_Init(mode->width, mode->height, vid_soft_threads.integer, vid_soft_interlace.integer, (unsigned int *)vid_softsurface->pixels, (unsigned int *)vid.softdepthpixels) < 0)
-       {
-               Con_Printf("Failed to initialize software rasterizer\n");
-               VID_Shutdown();
-               return false;
-       }
-
-#if SDL_MAJOR_VERSION == 1
-       // init keyboard
-       SDL_EnableUNICODE( SDL_ENABLE );
-       // enable key repeat since everyone expects it
-       SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-#endif
-
-       VID_Soft_SharedSetup();
-
-       vid_hidden = false;
-       vid_activewindow = false;
-       vid_hasfocus = true;
-       vid_usingmouse = false;
-       vid_usinghidecursor = false;
-
-#if SDL_MAJOR_VERSION == 1
-       SDL_WM_GrabInput(SDL_GRAB_OFF);
-#endif
-       return true;
-}
-
 qboolean VID_InitMode(viddef_mode_t *mode)
 {
        // GAME_STEELSTORM specific
@@ -2804,19 +2654,13 @@ qboolean VID_InitMode(viddef_mode_t *mode)
 #if SDL_MAJOR_VERSION != 1
        Cvar_SetValueQuick(&vid_touchscreen_supportshowkeyboard, SDL_HasScreenKeyboardSupport() ? 1 : 0);
 #endif
-#ifdef SSE_POSSIBLE
-       if (vid_soft.integer)
-               return VID_InitModeSoft(mode);
-       else
-#endif
-               return VID_InitModeGL(mode);
+       return VID_InitModeGL(mode);
 }
 
 void VID_Shutdown (void)
 {
        VID_EnableJoystick(false);
        VID_SetMouse(false, false, false);
-       VID_RestoreSystemGamma();
 
 #if SDL_MAJOR_VERSION == 1
 #ifndef WIN32
@@ -2828,14 +2672,6 @@ void VID_Shutdown (void)
 #endif
 #endif
 
-       if (vid_softsurface)
-               SDL_FreeSurface(vid_softsurface);
-       vid_softsurface = NULL;
-       vid.softpixels = NULL;
-       if (vid.softdepthpixels)
-               free(vid.softdepthpixels);
-       vid.softdepthpixels = NULL;
-
 #if SDL_MAJOR_VERSION != 1
        SDL_DestroyWindow(window);
        window = NULL;
@@ -2849,24 +2685,6 @@ void VID_Shutdown (void)
        gl_platformextensions = "";
 }
 
-int VID_SetGamma (unsigned short *ramps, int rampsize)
-{
-#if SDL_MAJOR_VERSION == 1
-       return !SDL_SetGammaRamp (ramps, ramps + rampsize, ramps + rampsize*2);
-#else
-       return !SDL_SetWindowGammaRamp (window, ramps, ramps + rampsize, ramps + rampsize*2);
-#endif
-}
-
-int VID_GetGamma (unsigned short *ramps, int rampsize)
-{
-#if SDL_MAJOR_VERSION == 1
-       return !SDL_GetGammaRamp (ramps, ramps + rampsize, ramps + rampsize*2);
-#else
-       return !SDL_GetWindowGammaRamp (window, ramps, ramps + rampsize, ramps + rampsize*2);
-#endif
-}
-
 void VID_Finish (void)
 {
 #if SDL_MAJOR_VERSION == 1
@@ -2880,16 +2698,13 @@ void VID_Finish (void)
 #endif
        vid_activewindow = !vid_hidden && vid_hasfocus;
 
-       VID_UpdateGamma(false, 256);
+       VID_UpdateGamma();
 
        if (!vid_hidden)
        {
                switch(vid.renderpath)
                {
-               case RENDERPATH_GL11:
-               case RENDERPATH_GL13:
                case RENDERPATH_GL20:
-               case RENDERPATH_GLES1:
                case RENDERPATH_GLES2:
                        CHECKGLERROR
                        if (r_speeds.integer == 2 || gl_finish.integer)
@@ -2915,28 +2730,6 @@ void VID_Finish (void)
                        SDL_GL_SwapWindow(window);
 #endif
                        break;
-               case RENDERPATH_SOFT:
-                       DPSOFTRAST_Finish();
-#if SDL_MAJOR_VERSION == 1
-//             if (!r_test.integer)
-               {
-                       SDL_BlitSurface(vid_softsurface, NULL, screen, NULL);
-                       SDL_Flip(screen);
-               }
-#else
-                       {
-                               SDL_Surface *screen = SDL_GetWindowSurface(window);
-                               SDL_BlitSurface(vid_softsurface, NULL, screen, NULL);
-                               SDL_UpdateWindowSurface(window);
-                       }
-#endif
-                       break;
-               case RENDERPATH_D3D9:
-               case RENDERPATH_D3D10:
-               case RENDERPATH_D3D11:
-                       if (r_speeds.integer == 2 || gl_finish.integer)
-                               GL_Finish();
-                       break;
                }
        }
 }