diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp
index d4cbbfbf1..4beed9706 100644
--- a/source/blood/src/blood.cpp
+++ b/source/blood/src/blood.cpp
@@ -1096,39 +1096,12 @@ void ClockStrobe()
     //gGameClock++;
 }
 
-#if defined(_WIN32) && defined(DEBUGGINGAIDS)
-// See FILENAME_CASE_CHECK in cache1d.c
-static int32_t check_filename_casing(void)
-{
-    return 1;
-}
-#endif
-
 int GameInterface::app_main()
 {
     memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
 	gGameOptions.nMonsterSettings = !userConfig.nomonsters;
 	bQuickStart = userConfig.nologo;
-    ParseOptions();
     
-    CONFIG_ReadSetup();
-
-    if (enginePreInit())
-    {
-        I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
-    }
-    registerosdcommands();
-
-#if 0
-	// todo: Handle more intelligently.
-    OSD_Exec("autoexec.cfg");
-#endif
-
-    // Not neccessary ?
-    // CONFIG_SetDefaultKeys(keydefaults, true);
-
-    system_getcvars();
-
 #ifdef USE_QHEAP
     Resource::heap = new QHeap(nMaxAlloc);
 #endif
@@ -1187,7 +1160,7 @@ int GameInterface::app_main()
 
     initprintf("Initializing network users\n");
     netInitialize(true);
-    scrSetGameMode( ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP);
+    scrSetGameMode(0, 0, 0, 0);
     scrSetGamma(gGamma);
     hud_size.Callback();
     initprintf("Initializing sound system\n");
diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp
index 286b98282..1c49766d8 100644
--- a/source/blood/src/config.cpp
+++ b/source/blood/src/config.cpp
@@ -49,88 +49,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 BEGIN_BLD_NS
 
 
-int32_t gTurnSpeed;
-int32_t gDetail;
+int32_t gTurnSpeed = 92;
+int32_t gDetail = 4;
 int32_t cl_weaponswitch;
-int32_t gFollowMap;
-int32_t gOverlayMap;
-int32_t gRotateMap;
-int32_t gMessageCount;
-int32_t gMessageTime;
-int32_t gMessageFont;
-int32_t gbAdultContent;
-char gzAdultPassword[9];
+int32_t gFollowMap = 1;
+int32_t gOverlayMap = 0;
+int32_t gRotateMap = 0;
+int32_t gMessageCount = 4;
+int32_t gMessageTime = 5;
+int32_t gMessageFont = 0;
+int32_t gbAdultContent = 0;
 int32_t gMouseSensitivity;
 bool gNoClip;
 bool gInfiniteAmmo;
 bool gFullMap;
-int32_t gUpscaleFactor;
-int32_t gDeliriumBlur;
+int32_t gDeliriumBlur = 1;
 
 //////////
 int gWeaponsV10x;
 /////////
 
 
-
-
-
-
-void CONFIG_SetDefaults(void)
-{
-# if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1
-    uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO);
-    if (inited == 0)
-        SDL_Init(SDL_INIT_VIDEO);
-    else if (!(inited & SDL_INIT_VIDEO))
-        SDL_InitSubSystem(SDL_INIT_VIDEO);
-
-    SDL_DisplayMode dm;
-    if (SDL_GetDesktopDisplayMode(0, &dm) == 0)
-    {
-        ScreenWidth = dm.w;
-        ScreenHeight = dm.h;
-    }
-    else
-    {
-        ScreenWidth = 1024;
-        ScreenHeight = 768;
-    }
-#endif
-
-    gUpscaleFactor = 0;
-    gDeliriumBlur = 1;
-    gViewSize = 2;
-    gTurnSpeed = 92;
-    gDetail = 4;
-    gFollowMap = 1;
-    gOverlayMap = 0;
-    gRotateMap = 0;
-
-    gMessageCount = 4;
-    gMessageTime = 5;
-    gMessageFont = 0;
-    gbAdultContent = 0;
-    gzAdultPassword[0] = 0;
-}
-
-
-
-
-
-
-int CONFIG_ReadSetup(void)
-{
-    CONFIG_SetDefaults();
-    if (ScreenBPP < 8) ScreenBPP = 32;
-    return 0;
-}
-
-
-void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.cfg
-{
-}
-
-
-
 END_BLD_NS
diff --git a/source/blood/src/config.h b/source/blood/src/config.h
index da51e612b..aff4d3d8c 100644
--- a/source/blood/src/config.h
+++ b/source/blood/src/config.h
@@ -41,21 +41,16 @@ extern int32_t gMessageCount;
 extern int32_t gMessageTime;
 extern int32_t gMessageFont;
 extern int32_t gbAdultContent;
-extern char gzAdultPassword[9];
 extern int32_t gMouseSensitivity;
 extern bool gNoClip;
 extern bool gInfiniteAmmo;
 extern bool gFullMap;
-extern int32_t gUpscaleFactor;
 extern int32_t gDeliriumBlur;
 
 ///////
 extern int gWeaponsV10x;
 //////
 
-int  CONFIG_ReadSetup(void);
-void CONFIG_SetDefaults(void);
-
 END_BLD_NS
 
 #endif
diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp
index 11d09d5ed..115e5a63f 100644
--- a/source/blood/src/osdcmd.cpp
+++ b/source/blood/src/osdcmd.cpp
@@ -102,54 +102,6 @@ static int osdcmd_demo(osdcmdptr_t parm)
 }
 
 
-static int osdcmd_vidmode(osdcmdptr_t parm)
-{
-    int32_t newbpp = ScreenBPP, newwidth = ScreenWidth,
-            newheight = ScreenHeight, newfs = ScreenMode;
-    int32_t tmp;
-
-    if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
-
-    switch (parm->numparms)
-    {
-    case 1: // bpp switch
-        tmp = Batol(parm->parms[0]);
-        if (!(tmp==8 || tmp==16 || tmp==32))
-            return OSDCMD_SHOWHELP;
-        newbpp = tmp;
-        break;
-    case 2: // res switch
-        newwidth = Batol(parm->parms[0]);
-        newheight = Batol(parm->parms[1]);
-        break;
-    case 3: // res & bpp switch
-    case 4:
-        newwidth = Batol(parm->parms[0]);
-        newheight = Batol(parm->parms[1]);
-        tmp = Batol(parm->parms[2]);
-        if (!(tmp==8 || tmp==16 || tmp==32))
-            return OSDCMD_SHOWHELP;
-        newbpp = tmp;
-        if (parm->numparms == 4)
-            newfs = (Batol(parm->parms[3]) != 0);
-        break;
-    }
-
-    if (videoSetGameMode(newfs,newwidth,newheight,newbpp,upscalefactor))
-    {
-        initprintf("vidmode: Mode change failed!\n");
-        if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, upscalefactor))
-            ThrowError("vidmode: Reset failed!\n");
-    }
-    ScreenBPP = newbpp;
-    ScreenWidth = newwidth;
-    ScreenHeight = newheight;
-    ScreenMode = newfs;
-    onvideomodechange(ScreenBPP>8);
-    viewResizeView(gViewSize);
-    return OSDCMD_OK;
-}
-
 static int osdcmd_crosshaircolor(osdcmdptr_t parm)
 {
     if (parm->numparms != 3)
@@ -291,8 +243,6 @@ int32_t registerosdcommands(void)
     OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
     OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
 
-    OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
-
 
     return 0;
 }
diff --git a/source/blood/src/screen.cpp b/source/blood/src/screen.cpp
index de3cb35ba..3dfa137b5 100644
--- a/source/blood/src/screen.cpp
+++ b/source/blood/src/screen.cpp
@@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "config.h"
 #include "resource.h"
 #include "screen.h"
+#include "rendering/v_video.h"
 
 BEGIN_BLD_NS
 
@@ -243,45 +244,7 @@ void scrUnInit(void)
 void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits)
 {
     videoResetMode();
-    //videoSetGameMode(vidMode, XRes, YRes, nBits, 0);
-    if (videoSetGameMode(vidMode, XRes, YRes, nBits, 0) < 0)
-    {
-        initprintf("Failure setting video mode %dx%dx%d %s! Trying next mode...\n", XRes, YRes,
-                    nBits, vidMode ? "fullscreen" : "windowed");
-
-        int resIdx = 0;
-
-        for (int i=0; i < validmodecnt; i++)
-        {
-            if (validmode[i].xdim == XRes && validmode[i].ydim == YRes)
-            {
-                resIdx = i;
-                break;
-            }
-        }
-
-        int const savedIdx = resIdx;
-        int bpp = nBits;
-
-        while (videoSetGameMode(0, validmode[resIdx].xdim, validmode[resIdx].ydim, bpp, 0) < 0)
-        {
-            initprintf("Failure setting video mode %dx%dx%d windowed! Trying next mode...\n",
-                        validmode[resIdx].xdim, validmode[resIdx].ydim, bpp);
-
-            if (++resIdx == validmodecnt)
-            {
-                if (bpp == 8)
-                    ThrowError("Fatal error: unable to set any video mode!");
-
-                resIdx = savedIdx;
-                bpp = 8;
-            }
-        }
-
-        ScreenWidth = validmode[resIdx].xdim;
-        ScreenHeight = validmode[resIdx].ydim;
-        ScreenBPP  = bpp;
-    }
+    V_Init2();
     videoClearViewableArea(0);
     scrNextPage();
     scrSetPalette(curPalette);
diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h
index 7432eb850..e2f546b03 100644
--- a/source/build/include/baselayer.h
+++ b/source/build/include/baselayer.h
@@ -16,12 +16,6 @@
 #include "zstring.h"
 #include "vectors.h"
 
-
-#ifdef DEBUGGINGAIDS
-# define DEBUG_MASK_DRAWING
-extern int32_t g_maskDrawMode;
-#endif
-
 extern char appactive;
 extern char modechange;
 extern char nogl;
@@ -49,26 +43,9 @@ void    videoResetMode(void);
 void    videoEndDrawing(void);
 void    videoShowFrame(int32_t);
 int32_t videoUpdatePalette(int32_t start, int32_t num);
-int32_t videoSetGamma(void);
-int32_t videoSetVsync(int32_t newSync);
 
-//#define DEBUG_FRAME_LOCKING
-#if !defined DEBUG_FRAME_LOCKING
 void videoBeginDrawing(void);
-#else
-void begindrawing_real(void);
-# define BEGINDRAWING_SIZE 256
-extern uint32_t begindrawing_line[BEGINDRAWING_SIZE];
-extern const char *begindrawing_file[BEGINDRAWING_SIZE];
-extern int32_t lockcount;
-# define videoBeginDrawing() do {                     \
-    if (lockcount < BEGINDRAWING_SIZE) {         \
-        begindrawing_line[lockcount] = __LINE__; \
-        begindrawing_file[lockcount] = __FILE__; \
-    }                                            \
-    begindrawing_real();                         \
-} while(0)
-#endif
+
 
 #define GAMMA_CALC ((int32_t)(min(max((float)((vid_gamma - 1.0f) * 10.0f), 0.f), 15.f)))
 
@@ -89,22 +66,6 @@ extern char inputdevices;
 // keys
 #define KEYFIFOSIZ 64
 
-char CONSTEXPR const g_keyAsciiTable[128] = {
-    0  ,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0,  0,   'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
-    '[', ']', 0,   0,   'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, '`', 0,   92,  'z', 'x', 'c', 'v', 'b', 'n', 'm', ',',
-    '.', '/', 0,   '*', 0,   32,  0,   0,   0,   0,   0,   0,   0,   0,   0,  0,   0,   0,   0,   '7', '8', '9', '-', '4', '5', '6',
-    '+', '1', '2', '3', '0', '.', 0,   0,   0,   0,   0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-    0  ,   0,   0,   0,   0,   0, 0,   0,   0,   0,   0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,   0,   0,   0,
-};
-
-char CONSTEXPR const g_keyAsciiTableShift[128] = {
-    0  ,   0,   '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0,  0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P',
-    '{', '}', 0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0,   '|',  'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<',
-    '>', '?', 0,   '*', 0,   32,  0,   0,   0,   0,   0,   0,   0,   0,   0,  0,   0,   0,   0,   '7', '8', '9', '-', '4', '5', '6',
-    '+', '1', '2', '3', '0', '.', 0,   0,   0,   0,   0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-    0  ,   0,   0,   0,   0,   0, 0,   0,   0,   0,   0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,   0,   0,   0,
-};
-
 // mouse
 
 // joystick
@@ -128,14 +89,13 @@ extern int32_t qsetmode;
 
 #define in3dmode() (qsetmode==200)
 
-void system_getcvars(void);
-
 extern int32_t g_logFlushWindow;
 
 void I_GetEvent();
 
 inline int32_t handleevents(void)
 {
+	timerUpdateClock();
 	I_GetEvent();
 	return 0;
 }
diff --git a/source/build/include/build.h b/source/build/include/build.h
index d745a7c98..65fffcc22 100644
--- a/source/build/include/build.h
+++ b/source/build/include/build.h
@@ -1088,7 +1088,6 @@ EXTERN_CVAR(Bool, hw_animsmoothing)
 EXTERN_CVAR(Bool, hw_hightile)
 EXTERN_CVAR(Bool, hw_models)
 EXTERN_CVAR(Float, hw_shadescale)
-EXTERN_CVAR(Int, vid_vsync)
 EXTERN_CVAR(Int, hw_anisotropy)
 EXTERN_CVAR(Int, hw_texfilter)
 EXTERN_CVAR(Bool, hw_useindexedcolortextures)
diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp
index 95532ba0d..c89de3540 100644
--- a/source/build/src/engine.cpp
+++ b/source/build/src/engine.cpp
@@ -34,6 +34,7 @@
 # include "hightile.h"
 # include "mdsprite.h"
 # include "polymost.h"
+#include "v_video.h"
 #include "../../glbackend/glbackend.h"
 #endif
 
@@ -98,7 +99,7 @@ static TArray<TArray<uint8_t>> voxelmemory;
 void (*loadvoxel_replace)(int32_t voxindex) = NULL;
 int16_t tiletovox[MAXTILES];
 #ifdef USE_OPENGL
-static char *voxfilenames[MAXVOXELS];
+char *voxfilenames[MAXVOXELS];
 #endif
 char g_haveVoxels;
 //#define kloadvoxel loadvoxel
@@ -9654,8 +9655,6 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t
 
         OSD_Exec(fn);
 #endif
-        system_getcvars();
-
         // Per-map ART
         artSetupMapArt(filename);
     }
@@ -9947,32 +9946,6 @@ static void videoAllocateBuffers(void)
 #endif
 }
 
-#ifdef USE_OPENGL
-void (*PolymostProcessVoxels_Callback)(void) = NULL;
-static void PolymostProcessVoxels(void)
-{
-	if (PolymostProcessVoxels_Callback)
-		PolymostProcessVoxels_Callback();
-
-    if (g_haveVoxels != 1)
-        return;
-
-    g_haveVoxels = 2;
-
-    OSD_Printf("Generating voxel models for Polymost. This may take a while...\n");
-    videoNextPage();
-
-    for (bssize_t i=0; i<MAXVOXELS; i++)
-    {
-        if (voxfilenames[i])
-        {
-            voxmodels[i] = voxload(voxfilenames[i]);
-            voxmodels[i]->scale = voxscale[i]*(1.f/65536.f);
-            DO_FREE_AND_NULL(voxfilenames[i]);
-        }
-    }
-}
-#endif
 
 //
 // setgamemode
@@ -9983,14 +9956,13 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups
 {
     int32_t j;
 
-#ifdef USE_OPENGL
-    if (nogl) dabpp = 8;
-#endif
+    if (dabpp != 32) return -1; // block software mode.
+
     daupscaledxdim = max(320, daupscaledxdim);
     daupscaledydim = max(200, daupscaledydim);
 
-    if (in3dmode() && videomodereset == 0 && (davidoption == fullscreen) &&
-        (xres == daupscaledxdim) && (yres == daupscaledydim) && (bpp == dabpp) && (upscalefactor == daupscalefactor))
+    if (in3dmode() && videomodereset == 0 &&
+        (xres == daupscaledxdim) && (yres == daupscaledydim) && (bpp == dabpp))
         return 0;
 
     Bstrcpy(kensmessage,"!!!! BUILD engine&tools programmed by Ken Silverman of E.G. RI."
@@ -10005,24 +9977,12 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups
     j = bpp;
 
     g_lastpalettesum = 0;
-    if (videoSetMode(daupscaledxdim,daupscaledydim,dabpp,davidoption) < 0) return -1;
 
-#ifdef USE_OPENGL
-    if (dabpp > 8) rendmode = glrendmode;    // GL renderer
-    else rendmode = REND_CLASSIC;
-#endif
+    rendmode = REND_POLYMOST;
 
-    upscalefactor = max(1, min(tabledivide32(yres, 200), daupscalefactor));
-    //POGOTODO: Polymost/Polymer could work with upscaling with a couple more changes
-    int32_t scalefactor = upscalefactor;
-#ifdef RENDERTYPESDL
-    if (bpp != 8)
-#endif
-    {
-        scalefactor = 1;
-    }
-    xdim = daupscaledxdim/scalefactor;
-    ydim = daupscaledydim/scalefactor;
+    upscalefactor = 1;
+    xdim = daupscaledxdim;
+    ydim = daupscaledydim;
 	V_UpdateModeSize(xdim, ydim);
 
 #ifdef USE_OPENGL
@@ -10056,16 +10016,6 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups
 
     if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); }
 
-#ifdef USE_OPENGL
-    if (videoGetRenderMode() >= REND_POLYMOST)
-    {
-        polymost_glreset();
-        polymost_glinit();
-
-        if (videoGetRenderMode() == REND_POLYMOST)
-            PolymostProcessVoxels();
-    }
-#endif
     qsetmode = 200;
     return 0;
 }
@@ -12243,4 +12193,9 @@ void renderSetRollAngle(int32_t rolla)
 }
 #endif
 
+void videoShowFrame(int32_t w)
+{
+    screen->Update();
+}
+
 
diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp
index cc9fa9bf3..0e88f9b0a 100644
--- a/source/build/src/palette.cpp
+++ b/source/build/src/palette.cpp
@@ -745,7 +745,6 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags)
 	const uint8_t* dapal;
 
 	int32_t paldidchange;
-	int32_t palsumdidchange;
 	//    uint32_t lastbright = curbrightness;
 
     // Bassert((flags&4)==0); // What is so bad about this flag?
@@ -792,21 +791,6 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags)
 	if ((flags & 16) && palfadedelta)  // keep the fade
 		paletteSetFade(palfadedelta >> 2);
 
-	// Don't waste time on this palette voodoo if we are hardware rendering. videoUpdatePalette is a strictly software rendering function.
-	if (videoGetRenderMode() < REND_POLYMOST)
-	{
-		static uint32_t lastpalettesum = 0;
-		uint32_t newpalettesum = SuperFastHash((char*)curpalettefaded, sizeof(curpalettefaded));
-
-		palsumdidchange = (newpalettesum != lastpalettesum);
-
-		if (palsumdidchange || newpalettesum != g_lastpalettesum)
-		{
-			videoUpdatePalette(0, 256);
-		}
-
-		g_lastpalettesum = lastpalettesum = newpalettesum;
-	}
 
 	if ((flags & 16) == 0)
 	{
@@ -851,18 +835,4 @@ void videoFadePalette(uint8_t r, uint8_t g, uint8_t b, uint8_t offset)
     palfadedelta = offset;
 
     paletteSetFade(offset);
-
-	// Don't waste time on this palette voodoo if we are hardware rendering. videoUpdatePalette is a strictly software rendering function.
-	if (videoGetRenderMode() < REND_POLYMOST)
-	{
-		static uint32_t lastpalettesum = 0;
-		uint32_t newpalettesum = SuperFastHash((char*)curpalettefaded, sizeof(curpalettefaded));
-
-		if (newpalettesum != lastpalettesum || newpalettesum != g_lastpalettesum)
-		{
-			videoUpdatePalette(0, 256);
-		}
-
-		g_lastpalettesum = lastpalettesum = newpalettesum;
-	}
 }
diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp
index 632d06c7f..9750d300c 100644
--- a/source/build/src/polymost.cpp
+++ b/source/build/src/polymost.cpp
@@ -30,16 +30,6 @@ CVARD(Bool, hw_shadeinterpolate, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable
 CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading")
 CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering")
 
-CUSTOM_CVAR(Int, vid_vsync, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
-{
-	static bool recursion;
-	if (!recursion)
-	{
-		recursion = true;
-		self = videoSetVsync(self);
-		recursion = false;
-	}
-}
 
 CUSTOM_CVARD(Int, hw_texfilter, TEXFILTER_ON, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "changes the texture filtering settings")
 {
@@ -5416,3 +5406,36 @@ void PrecacheHardwareTextures(int nTile)
 	// This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer.
 	polymost_precache(nTile, 0, 1);
 }
+
+extern char* voxfilenames[MAXVOXELS];
+void (*PolymostProcessVoxels_Callback)(void) = NULL;
+static void PolymostProcessVoxels(void)
+{
+    if (PolymostProcessVoxels_Callback)
+        PolymostProcessVoxels_Callback();
+
+    if (g_haveVoxels != 1)
+        return;
+
+    g_haveVoxels = 2;
+
+    OSD_Printf("Generating voxel models for Polymost. This may take a while...\n");
+    videoNextPage();
+
+    for (bssize_t i = 0; i < MAXVOXELS; i++)
+    {
+        if (voxfilenames[i])
+        {
+            voxmodels[i] = voxload(voxfilenames[i]);
+            voxmodels[i]->scale = voxscale[i] * (1.f / 65536.f);
+            DO_FREE_AND_NULL(voxfilenames[i]);
+        }
+    }
+}
+
+void Polymost_Startup()
+{
+    polymost_glreset();
+    polymost_glinit();
+    PolymostProcessVoxels();
+}
diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp
index 801f78ea5..1772be4f0 100644
--- a/source/build/src/sdlayer.cpp
+++ b/source/build/src/sdlayer.cpp
@@ -79,15 +79,6 @@ GameInterface* gi;
 
 void buildkeytranslationtable();;
 
-#if !defined STARTUP_SETUP_WINDOW
-int32_t startwin_open(void) { return 0; }
-int32_t startwin_close(void) { return 0; }
-int32_t startwin_puts(const char *s) { UNREFERENCED_PARAMETER(s); return 0; }
-int32_t startwin_idle(void *s) { UNREFERENCED_PARAMETER(s); return 0; }
-int32_t startwin_settitle(const char *s) { UNREFERENCED_PARAMETER(s); return 0; }
-int32_t startwin_run(void) { return 0; }
-#endif
-
 int myconnectindex, numplayers;
 int connecthead, connectpoint2[MAXMULTIPLAYERS];
 unsigned char syncstate;
@@ -272,1015 +263,11 @@ int32_t wm_msgbox(const char *name, const char *fmt, ...)
 #endif
 }
 
-int32_t wm_ynbox(const char *name, const char *fmt, ...)
-{
-    char buf[2048];
-    va_list va;
 
-    UNREFERENCED_PARAMETER(name);
 
-    va_start(va,fmt);
-    vsnprintf(buf,sizeof(buf),fmt,va);
-    va_end(va);
-
-#if defined EDUKE32_OSX
-    return osx_ynbox(name, buf);
-#elif defined _WIN32
-    return (MessageBoxA(win_gethwnd(),buf,name,MB_YESNO|MB_ICONQUESTION|MB_TASKMODAL) == IDYES);
-#elif defined EDUKE32_TOUCH_DEVICES
-    initprintf("wm_ynbox called, this is bad! Message: %s: %s",name,buf);
-    initprintf("Returning false..");
-    return 0;
-#elif defined GEKKO
-    puts(buf);
-    puts("Assuming yes...");
-    return 1;
-#else
-# if defined HAVE_GTK2
-    int ret = gtkbuild_ynbox(name, buf);
-    if (ret >= 0)
-        return ret;
-# endif
-# if SDL_MAJOR_VERSION > 1
-    int r = -1;
-
-    const SDL_MessageBoxButtonData buttons[] = {
-        {
-            SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
-            0,
-            "No"
-        },{
-            SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
-            1,
-            "Yes"
-        },
-    };
-
-    SDL_MessageBoxData data = {
-        SDL_MESSAGEBOX_INFORMATION,
-        NULL, /* no parent window */
-        name,
-        buf,
-        2,
-        buttons,
-        NULL /* Default color scheme */
-    };
-
-    SDL_ShowMessageBox(&data, &r);
-
-    return r;
-# else
-    char c;
-
-    puts(buf);
-    puts("   (type 'Y' or 'N', and press Return or Enter to continue)");
-    do c = getchar(); while (c != 'Y' && c != 'y' && c != 'N' && c != 'n');
-    return c == 'Y' || c == 'y';
-# endif
-#endif
-}
-
-void wm_setapptitle(const char *name)
-{
-#ifndef EDUKE32_TOUCH_DEVICES
-    if (name != apptitle)
-        Bstrncpyz(apptitle, name, sizeof(apptitle));
-
-#if !defined(__APPLE__)
-    if (!appicon)
-        appicon = loadappicon();
-#endif
-
-#if SDL_MAJOR_VERSION == 1
-    SDL_WM_SetCaption(apptitle, NULL);
-
-    if (appicon && sdl_surface)
-        SDL_WM_SetIcon(appicon, 0);
-#else
-    if (sdl_window)
-    {
-        SDL_SetWindowTitle(sdl_window, apptitle);
-
-        if (appicon)
-        {
-#if defined _WIN32
-        if (!EDUKE32_SDL_LINKED_PREREQ(linked, 2, 0, 5))
-#endif
-            SDL_SetWindowIcon(sdl_window, appicon);
-        }
-    }
-#endif
-
-#else
-    UNREFERENCED_PARAMETER(name);
-#endif
-}
-
-//==========================================================================
-//
-// win_buildargs
-//
-// This should be removed once everything can use the FArgs list.
-//
-//==========================================================================
-
-
-int32_t win_buildargs(char** argvbuf)
-{
-    int32_t buildargc = 0;
-
-    FString cmdline_utf8 = FString(GetCommandLineW());
-
-    *argvbuf = Xstrdup(cmdline_utf8.GetChars());
-
-    if (*argvbuf)
-    {
-        char quoted = 0, instring = 0, swallownext = 0;
-        char* wp;
-        for (const char* p = wp = *argvbuf; *p; p++)
-        {
-            if (*p == ' ')
-            {
-                if (instring)
-                {
-                    if (!quoted)
-                    {
-                        // end of a string
-                        *(wp++) = 0;
-                        instring = 0;
-                    }
-                    else
-                        *(wp++) = *p;
-                }
-            }
-            else if (*p == '"' && !swallownext)
-            {
-                if (instring)
-                {
-                    if (quoted && p[1] == ' ')
-                    {
-                        // end of a string
-                        *(wp++) = 0;
-                        instring = 0;
-                    }
-                    quoted = !quoted;
-                }
-                else
-                {
-                    instring = 1;
-                    quoted = 1;
-                    buildargc++;
-                }
-            }
-            else if (*p == '\\' && p[1] == '"' && !swallownext)
-                swallownext = 1;
-            else
-            {
-                if (!instring)
-                    buildargc++;
-
-                instring = 1;
-                *(wp++) = *p;
-                swallownext = 0;
-            }
-        }
-        *wp = 0;
-    }
-
-    // Figure out what directory the program resides in.
-
-    wchar_t buffer[256];
-    GetModuleFileNameW(0, buffer, 256);
-    progdir = buffer;
-    progdir.Substitute("\\", "/");
-    auto lastsep = progdir.LastIndexOf('/');
-    if (lastsep != -1)
-        progdir.Truncate(lastsep + 1);
-
-    return buildargc;
-}
-
-
-//
-//
-// ---------------------------------------
-//
-// System
-//
-// ---------------------------------------
-//
-//
-
-/* XXX: libexecinfo could be used on systems without gnu libc. */
-#if !defined _WIN32 && defined __GNUC__ && !defined __OpenBSD__ && !(defined __APPLE__ && defined __BIG_ENDIAN__) && !defined GEKKO && !defined EDUKE32_TOUCH_DEVICES && !defined __OPENDINGUX__
-# define PRINTSTACKONSEGV 1
-# include <execinfo.h>
-#endif
-
-char grabmouse_low(char a);
-
-#ifndef __ANDROID__
-static void attach_debugger_here(void) {}
-
-static void sighandler(int signum)
-{
-    UNREFERENCED_PARAMETER(signum);
-    //    if (signum==SIGSEGV)
-    {
-        grabmouse_low(0);
-#if PRINTSTACKONSEGV
-        {
-            void *addr[32];
-            int32_t errfd = fileno(stderr);
-            int32_t n=backtrace(addr, ARRAY_SIZE(addr));
-            backtrace_symbols_fd(addr, n, errfd);
-        }
-        // This is useful for attaching the debugger post-mortem. For those pesky
-        // cases where the program runs through happily when inspected from the start.
-        //        usleep(15000000);
-#endif
-        attach_debugger_here();
-		std::terminate();
-		// NOTE: It is not safe to call any of this from a signal handler!
-		//gi->app_crashhandler();
-        //uninitsystem();
-        //Bexit(EXIT_FAILURE);
-    }
-}
-#endif
-
-int GameMain();
-
-#if 0
-#ifdef _WIN32
-
-int WINAPI WinMain(HINSTANCE , HINSTANCE , LPSTR , int )
-#else
-int main(int argc, char *argv[])
-#endif
-{
-    buildkeytranslationtable();
-
-	if (initsystem()) Bexit(9);
-	SDL_StartTextInput();
-
-	r = GameMain();
-
-#if defined(HAVE_GTK2)
-    gtkbuild_exit(r);
-#endif
-	return r;
-}
-#endif
-
-// The resourge manager in cache1d is far too broken to add some arbitrary file without some adjustment.
-// For now, keep this file here, until the resource management can be redone in a more workable fashion.
-
-#if SDL_MAJOR_VERSION != 1
-int32_t videoSetVsync(int32_t newSync)
-{
-    if (vsync_renderlayer == newSync)
-        return newSync;
-
-#ifdef USE_OPENGL
-    if (sdl_context)
-    {
-        int result = SDL_GL_SetSwapInterval(newSync);
-
-        if (result == -1)
-        {
-            if (newSync == -1)
-            {
-                newSync = 1;
-                result = SDL_GL_SetSwapInterval(newSync);
-            }
-
-            if (result == -1)
-            {
-                newSync = 0;
-                Printf("Unable to enable VSync!\n");
-            }
-        }
-
-        vsync_renderlayer = newSync;
-    }
-    else
-#endif
-    {
-		/*
-        vsync_renderlayer = newSync;
-
-        videoResetMode();
-        if (videoSetGameMode(fullscreen, xres, yres, bpp, upscalefactor))
-            OSD_Printf("restartvid: Reset failed...\n");
-		*/
-    }
-
-    return newSync;
-}
-#endif
-
-//
-// system_getcvars() -- propagate any cvars that are read post-initialization
-//
-void system_getcvars(void)
-{
-    vid_vsync = videoSetVsync(vid_vsync);
-}
-
-
-
-
-//
-//
-// ---------------------------------------
-//
-// All things Input
-//
-// ---------------------------------------
-//
-//
-
-// static int32_t joyblast=0;
-static SDL_Joystick *joydev = NULL;
-#if SDL_MAJOR_VERSION >= 2
-static SDL_GameController *controller = NULL;
-
-static void LoadSDLControllerDB()
-{
-    FileReader fh;
-    if (!fh.OpenFile("gamecontrollerdb.txt"))
-        return;
-
-	int flen = fh.GetLength();
-    if (flen <= 0)
-    {
-        return;
-    }
-
-    char * dbuf = (char *)malloc(flen + 1);
-    if (!dbuf)
-    {
-        return;
-    }
-
-    if (fh.Read(dbuf, flen) != flen)
-    {
-        free(dbuf);
-        return;
-    }
-
-    dbuf[flen] = '\0';
-
-    SDL_RWops * rwops = SDL_RWFromConstMem(dbuf, flen);
-    if (!rwops)
-    {
-        free(dbuf);
-        return;
-    }
-
-    int i = SDL_GameControllerAddMappingsFromRW(rwops, 1);
-
-    free(dbuf);
-}
-#endif
-
-void joyScanDevices()
-{
-    inputdevices &= ~4;
-
-    if (controller)
-    {
-        SDL_GameControllerClose(controller);
-        controller = nullptr;
-    }
-    if (joydev)
-    {
-        SDL_JoystickClose(joydev);
-        joydev = nullptr;
-    }
-
-    int numjoysticks = SDL_NumJoysticks();
-    if (numjoysticks < 1)
-    {
-        initprintf("No game controllers found\n");
-    }
-    else
-    {
-        initprintf("Game controllers:\n");
-        for (int i = 0; i < numjoysticks; i++)
-        {
-            const char * name;
-#if SDL_MAJOR_VERSION >= 2
-            if (SDL_IsGameController(i))
-                name = SDL_GameControllerNameForIndex(i);
-            else
-#endif
-                name = SDL_JoystickNameForIndex(i);
-
-            buildprintf("  %d. %s\n", i+1, name);
-        }
-
-#if SDL_MAJOR_VERSION >= 2
-        for (int i = 0; i < numjoysticks; i++)
-        {
-            if ((controller = SDL_GameControllerOpen(i)))
-            {
-                buildprintf("Using controller %s\n", SDL_GameControllerName(controller));
-
-                joystick.numAxes    = SDL_CONTROLLER_AXIS_MAX;
-                joystick.numBalls   = 0;
-                joystick.numButtons = SDL_CONTROLLER_BUTTON_MAX;
-                joystick.numHats    = 0;
-
-                joystick.isGameController = 1;
-
-                Xfree(joystick.pAxis);
-                joystick.pAxis = (int32_t *)Xcalloc(joystick.numAxes, sizeof(int32_t));
-                Xfree(joystick.pHat);
-                joystick.pHat = nullptr;
-
-                inputdevices |= 4;
-
-                return;
-            }
-        }
-#endif
-
-        for (int i = 0; i < numjoysticks; i++)
-        {
-            if ((joydev = SDL_JoystickOpen(i)))
-            {
-                buildprintf("Using joystick %s\n", SDL_JoystickName(joydev));
-
-                // KEEPINSYNC duke3d/src/gamedefs.h, mact/include/_control.h
-                joystick.numAxes = min(9, SDL_JoystickNumAxes(joydev));
-                joystick.numBalls   = SDL_JoystickNumBalls(joydev);
-                joystick.numButtons = min(32, SDL_JoystickNumButtons(joydev));
-                joystick.numHats    = min((36 - joystick.numButtons) / 4, SDL_JoystickNumHats(joydev));
-
-                joystick.isGameController = 0;
-
-                buildprint("Joystick ", i+1, " has ", joystick.numAxes, " axes, ", joystick.numButtons, " buttons, ",
-                            (joystick.numHats ? std::to_string(joystick.numHats).c_str() : "no"), " hats, and ",
-                            (joystick.numBalls ? std::to_string(joystick.numBalls).c_str() : "no"), " balls.\n");
-
-                Xfree(joystick.pAxis);
-                joystick.pAxis = (int32_t *)Xcalloc(joystick.numAxes, sizeof(int32_t));
-
-                Xfree(joystick.pHat);
-                if (joystick.numHats)
-                    joystick.pHat = (int32_t *)Xcalloc(joystick.numHats, sizeof(int32_t));
-                else
-                    joystick.pHat = nullptr;
-
-                for (int j = 0; j < joystick.numHats; j++)
-                    joystick.pHat[j] = -1; // center
-
-                SDL_JoystickEventState(SDL_ENABLE);
-                inputdevices |= 4;
-
-                return;
-            }
-        }
-
-        initprintf("No controllers are usable\n");
-    }
-}
-
-//
-// initinput() -- init input system
-//
-int32_t initinput(void)
-{
-
-#if defined EDUKE32_OSX
-    // force OS X to operate in >1 button mouse mode so that LMB isn't adulterated
-    if (!getenv("SDL_HAS3BUTTONMOUSE"))
-    {
-        static char sdl_has3buttonmouse[] = "SDL_HAS3BUTTONMOUSE=1";
-        putenv(sdl_has3buttonmouse);
-    }
-#endif
-
-    inputdevices = 1 | 2;  // keyboard (1) and mouse (2)
-    g_mouseGrabbed = 0;
-
-    if (!SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER))
-    {
-        LoadSDLControllerDB();
-        joyScanDevices();
-    }
-
-    return 0;
-}
-
-//
-// uninitinput() -- uninit input system
-//
-void uninitinput(void)
-{
-    if (controller)
-    {
-        SDL_GameControllerClose(controller);
-        controller = NULL;
-    }
-
-    if (joydev)
-    {
-        SDL_JoystickClose(joydev);
-        joydev = NULL;
-    }
-}
-
-const char *joyGetName(int32_t what, int32_t num)
-{
-    static char tmp[64];
-
-    switch (what)
-    {
-        case 0:  // axis
-            if ((unsigned)num > (unsigned)joystick.numAxes)
-                return NULL;
-
-            if (controller)
-            {
-                static char const * axisStrings[] =
-                {
-                    "Left Stick X-Axis",
-                    "Left Stick Y-Axis",
-                    "Right Stick X-Axis",
-                    "Right Stick Y-Axis",
-                    "Left Trigger",
-                    "Right Trigger",
-                    NULL
-                };
-                return axisStrings[num];
-            }
-
-            Bsprintf(tmp, "Axis %d", num);
-            return (char *)tmp;
-
-        case 1:  // button
-            if ((unsigned)num > (unsigned)joystick.numButtons)
-                return NULL;
-
-            if (controller)
-            {
-                static char const * buttonStrings[] =
-                {
-                    "A",
-                    "B",
-                    "X",
-                    "Y",
-                    "Back",
-                    "Guide",
-                    "Start",
-                    "Left Stick",
-                    "Right Stick",
-                    "Left Shoulder",
-                    "Right Shoulder",
-                    "D-Pad Up",
-                    "D-Pad Down",
-                    "D-Pad Left",
-                    "D-Pad Right",
-                    NULL
-                };
-                return buttonStrings[num];
-            }
-
-            Bsprintf(tmp, "Button %d", num);
-            return (char *)tmp;
-
-        case 2:  // hat
-            if ((unsigned)num > (unsigned)joystick.numHats)
-                return NULL;
-            Bsprintf(tmp, "Hat %d", num);
-            return (char *)tmp;
-
-        default: return NULL;
-    }
-}
-
-
-//
-//
-// ---------------------------------------
-//
-// All things Video
-//
-// ---------------------------------------
-//
-//
-
-
-//
-// getvalidmodes() -- figure out what video modes are available
-//
-static int sortmodes(const void *a_, const void *b_)
-{
-    auto a = (const struct validmode_t *)b_;
-    auto b = (const struct validmode_t *)a_;
-
-    int x;
-
-    if ((x = a->fs   - b->fs)   != 0) return x;
-    if ((x = a->bpp  - b->bpp)  != 0) return x;
-    if ((x = a->xdim - b->xdim) != 0) return x;
-    if ((x = a->ydim - b->ydim) != 0) return x;
-
-    return 0;
-}
-
-static char modeschecked=0;
-
-void WindowMoved(int x, int y)
-{
-    if (windowpos)
-    {
-        windowx = x;
-        windowy = y;
-    }
-
-    r_displayindex = SDL_GetWindowDisplayIndex(sdl_window);
-    modeschecked = 0;
-    videoGetModes();
-}
-
-
-#if SDL_MAJOR_VERSION != 1
-void videoGetModes(void)
-{
-    int32_t i, maxx = 0, maxy = 0;
-    SDL_DisplayMode dispmode;
-    int const display = r_displayindex < SDL_GetNumVideoDisplays() ? r_displayindex : 0;
-
-    if (modeschecked || novideo)
-        return;
-
-    validmodecnt = 0;
-    //    initprintf("Detecting video modes:\n");
-
-    // do fullscreen modes first
-    for (i = 0; i < SDL_GetNumDisplayModes(display); i++)
-    {
-        SDL_GetDisplayMode(display, i, &dispmode);
-
-        if (!SDL_CHECKMODE(dispmode.w, dispmode.h) ||
-            (maxrefreshfreq && (dispmode.refresh_rate > maxrefreshfreq)))
-            continue;
-
-        // HACK: 8-bit == Software, 32-bit == OpenGL
-        SDL_ADDMODE(dispmode.w, dispmode.h, 8, 1);
-#ifdef USE_OPENGL
-        if (!nogl)
-            SDL_ADDMODE(dispmode.w, dispmode.h, 32, 1);
-#endif
-        if ((dispmode.w > maxx) || (dispmode.h > maxy))
-        {
-            maxx = dispmode.w;
-            maxy = dispmode.h;
-        }
-    }
-
-    SDL_CHECKFSMODES(maxx, maxy);
-
-    // add windowed modes next
-    // SDL sorts display modes largest to smallest, so we can just compare with mode 0
-    // to make sure we aren't adding modes that are larger than the actual screen res
-    SDL_GetDisplayMode(display, 0, &dispmode);
-
-    for (i = 0; g_defaultVideoModes[i].x; i++)
-    {
-        auto const &mode = g_defaultVideoModes[i];
-
-        if (mode.x > dispmode.w || mode.y > dispmode.h || !SDL_CHECKMODE(mode.x, mode.y))
-            continue;
-
-        // 8-bit == Software, 32-bit == OpenGL
-        SDL_ADDMODE(mode.x, mode.y, 8, 0);
-
-#ifdef USE_OPENGL
-        if (nogl)
-            continue;
-
-        SDL_ADDMODE(mode.x, mode.y, 32, 0);
-#endif
-    }
-
-    qsort((void *)validmode, validmodecnt, sizeof(struct validmode_t), &sortmodes);
-
-    modeschecked = 1;
-}
-#endif
-
-//
-// checkvideomode() -- makes sure the video mode passed is legal
-//
-int32_t videoCheckMode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t forced)
-{
-    int32_t i, nearest=-1, dx, dy, odx=9999, ody=9999;
-
-    videoGetModes();
-
-    if (c>8
-#ifdef USE_OPENGL
-            && nogl
-#endif
-       ) return -1;
-
-    // fix up the passed resolution values to be multiples of 8
-    // and at least 320x200 or at most MAXXDIMxMAXYDIM
-    *x = clamp(*x, 320, MAXXDIM);
-    *y = clamp(*y, 200, MAXYDIM);
-
-    for (i = 0; i < validmodecnt; i++)
-    {
-        if (validmode[i].bpp != c || validmode[i].fs != fs)
-            continue;
-
-        dx = klabs(validmode[i].xdim - *x);
-        dy = klabs(validmode[i].ydim - *y);
-
-        if (!(dx | dy))
-        {
-            // perfect match
-            nearest = i;
-            break;
-        }
-
-        if ((dx <= odx) && (dy <= ody))
-        {
-            nearest = i;
-            odx = dx;
-            ody = dy;
-        }
-    }
-
-#ifdef ANY_WINDOWED_SIZE
-    if (!forced && (fs&1) == 0 && (nearest < 0 || (validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)))
-        return 0x7fffffffl;
-#endif
-
-    if (nearest < 0)
-        return -1;
-
-    *x = validmode[nearest].xdim;
-    *y = validmode[nearest].ydim;
-
-    return nearest;
-}
-
-static void destroy_window_resources()
-{
-/* We should NOT destroy the window surface. This is done automatically
-   when SDL_DestroyWindow or SDL_SetVideoMode is called.             */
-
-#if SDL_MAJOR_VERSION == 2
-    if (sdl_context)
-        SDL_GL_DeleteContext(sdl_context);
-    sdl_context = NULL;
-    if (sdl_window)
-        SDL_DestroyWindow(sdl_window);
-    sdl_window = NULL;
-#endif
-}
-
-void sdlayer_setvideomode_opengl(int y)
-{
-    glsurface_destroy();
-    polymost_glreset();
-
-	GLInterface.Deinit();
-	GLInterface.Init(y);
-	GLInterface.InitGLState(4, glmultisample);
-
-	GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy);
-
-}
-
-//
-// setvideomode() -- set SDL video mode
-//
-
-int32_t setvideomode_sdlcommon(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t *regrab)
-{
-    if ((fs == fullscreen) && (*x == xres) && (*y == yres) && (c == bpp) && !videomodereset)
-        return 0;
-
-    if (videoCheckMode(x, y, c, fs, 0) < 0)
-        return -1;
-
-    if (g_mouseGrabbed)
-    {
-        *regrab = 1;
-        mouseGrabInput(0);
-    }
-
-    while (lockcount) videoEndDrawing();
-
-    if (sdl_surface)
-    {
-        if (bpp > 8)
-            polymost_glreset();
-    }
-    if (!nogl)
-    {
-        if (bpp == 8)
-            glsurface_destroy();
-        if ((fs == fullscreen) && (*x == xres) && (*y == yres) && (bpp != 0) && !videomodereset)
-            return 0;
-    }
-    else
-    {
-       softsurface_destroy();
-    }
-
-    return 1;
-}
-
-void setvideomode_sdlcommonpost(int32_t x, int32_t y, int32_t c, int32_t fs, int32_t regrab)
-{
-
-#ifdef USE_OPENGL
-    if (!nogl)
-        sdlayer_setvideomode_opengl(y);
-#endif
-
-    xres = x;
-    yres = y;
-    bpp = c;
-    fullscreen = fs;
-    // bytesperline = sdl_surface->pitch;
-    numpages = c > 8 ? 2 : 1;
-    frameplace = 0;
-    lockcount = 0;
-    modechange = 1;
-    videomodereset = 0;
-
-    videoFadePalette(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta);
-
-    if (regrab)
-        mouseGrabInput(g_mouseLockedToWindow);
-}
-
-#if SDL_MAJOR_VERSION!=1
-void setrefreshrate(void)
-{
-    int const display = r_displayindex < SDL_GetNumVideoDisplays() ? r_displayindex : 0;
-
-    SDL_DisplayMode dispmode;
-    SDL_GetCurrentDisplayMode(display, &dispmode);
-
-    dispmode.refresh_rate = maxrefreshfreq;
-
-    SDL_DisplayMode newmode;
-    SDL_GetClosestDisplayMode(display, &dispmode, &newmode);
-
-    char error = 0;
-
-    if (dispmode.refresh_rate != newmode.refresh_rate)
-    {
-        initprintf("Refresh rate: %dHz\n", newmode.refresh_rate);
-        error = SDL_SetWindowDisplayMode(sdl_window, &newmode);
-    }
-
-    if (!newmode.refresh_rate)
-        newmode.refresh_rate = 60;
-
-    refreshfreq = error ? -1 : newmode.refresh_rate;
-}
-
-int called = 0;
-int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs)
-{
-    int32_t regrab = 0, ret;
-
-	// SDL's fullscreen is a deadly trap in the debugger.
-#ifdef _DEBUG
-	if (fs)
-	{
-		fs = false;
-		x -= 10;
-		y -= 10;
-	}
-	if (called++)
-	{
-		//assert(0);
-		return 0;
-	}
-#endif
-
-
-    ret = setvideomode_sdlcommon(&x, &y, c, fs, &regrab);
-    if (ret != 1)
-    {
-        if (ret == 0)
-        {
-            setvideomode_sdlcommonpost(x, y, c, fs, regrab);
-        }
-        return ret;
-    }
-
-    // deinit
-    destroy_window_resources();
-
-    initprintf("Setting video mode %dx%d (%d-bpp %s)\n", x, y, c, ((fs & 1) ? "fullscreen" : "windowed"));
-
-    int const display = r_displayindex < SDL_GetNumVideoDisplays() ? r_displayindex : 0;
-
-    SDL_DisplayMode desktopmode;
-    SDL_GetDesktopDisplayMode(display, &desktopmode);
-
-    int const matchedResolution = (desktopmode.w == x && desktopmode.h == y);
-    int const borderless = (r_borderless == 1 || (r_borderless == 2 && matchedResolution)) ? SDL_WINDOW_BORDERLESS : 0;
-#ifdef USE_OPENGL
-    if (c > 8 || !nogl)
-    {
-        int32_t i;
-        int32_t multisamplecheck = (glmultisample > 0);
-        if (nogl)
-            return -1;
-
-        struct glattribs
-        {
-            SDL_GLattr attr;
-            int32_t value;
-        } sdlayer_gl_attributes[] =
-        {
-              { SDL_GL_DOUBLEBUFFER, 1 },
-              { SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 },
-              { SDL_GL_MULTISAMPLESAMPLES, glmultisample },
-              { SDL_GL_STENCIL_SIZE, 1 },
-              { SDL_GL_ACCELERATED_VISUAL, 1 },
-          };
-
-        do
-        {
-            SDL_GL_ATTRIBUTES(i, sdlayer_gl_attributes);
-
-            /* HACK: changing SDL GL attribs only works before surface creation,
-               so we have to create a new surface in a different format first
-               to force the surface we WANT to be recreated instead of reused. */
-
-
-            sdl_window = SDL_CreateWindow("", windowpos ? windowx : (int)SDL_WINDOWPOS_CENTERED_DISPLAY(display),
-                                          windowpos ? windowy : (int)SDL_WINDOWPOS_CENTERED_DISPLAY(display), x, y,
-                                          SDL_WINDOW_OPENGL | borderless);
-
-            if (sdl_window)
-                sdl_context = SDL_GL_CreateContext(sdl_window);
-
-            if (!sdl_window || !sdl_context)
-            {
-                initprintf("Unable to set video mode: %s failed: %s\n", sdl_window ? "SDL_GL_CreateContext" : "SDL_GL_CreateWindow",  SDL_GetError());
-                nogl = 1;
-                destroy_window_resources();
-                return -1;
-            }
-
-            SDL_SetWindowFullscreen(sdl_window, ((fs & 1) ? (matchedResolution ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN) : 0));
-            SDL_GL_SetSwapInterval(vsync_renderlayer);
-
-            setrefreshrate();
-        } while (multisamplecheck--);
-    }
-    else
-#endif  // defined USE_OPENGL
-    {
-        // init
-        sdl_window = SDL_CreateWindow("", windowpos ? windowx : (int)SDL_WINDOWPOS_CENTERED_DISPLAY(display),
-                                      windowpos ? windowy : (int)SDL_WINDOWPOS_CENTERED_DISPLAY(display), x, y,
-                                      borderless);
-        if (!sdl_window)
-            SDL2_VIDEO_ERR("SDL_CreateWindow");
-
-        setrefreshrate();
-
-        if (!sdl_surface)
-        {
-            sdl_surface = SDL_GetWindowSurface(sdl_window);
-            if (!sdl_surface)
-                SDL2_VIDEO_ERR("SDL_GetWindowSurface");
-        }
-
-        SDL_SetWindowFullscreen(sdl_window, ((fs & 1) ? (matchedResolution ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN) : 0));
-    }
-
-    SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
-    setvideomode_sdlcommonpost(x, y, c, fs, regrab);
-
-    return 0;
-}
-#endif
-
-//
-// resetvideomode() -- resets the video system
-//
 void videoResetMode(void)
 {
     videomodereset = 1;
-    modeschecked = 0;
 }
 
 //
@@ -1376,88 +363,7 @@ void videoEndDrawing(void)
 //
 // showframe() -- update the display
 //
-#if SDL_MAJOR_VERSION != 1
 
-void videoShowFrame(int32_t w)
-{
-    UNREFERENCED_PARAMETER(w);
-
-
-#ifdef USE_OPENGL
-    if (!nogl)
-    {
-        if (bpp == 8)
-        {
-            glsurface_blitBuffer();
-        }
-
-        static uint32_t lastSwapTime = 0;
-		glFinish();
-        SDL_GL_SwapWindow(sdl_window);
-
-        lastSwapTime = SDL_GetTicks();
-        return;
-    }
-#endif
-
-    if (offscreenrendering) return;
-
-    if (lockcount)
-    {
-        printf("Frame still locked %d times when showframe() called.\n", lockcount);
-        while (lockcount) videoEndDrawing();
-    }
-
-    if (SDL_MUSTLOCK(sdl_surface)) SDL_LockSurface(sdl_surface);
-    softsurface_blitBuffer((uint32_t*) sdl_surface->pixels, sdl_surface->format->BitsPerPixel);
-    if (SDL_MUSTLOCK(sdl_surface)) SDL_UnlockSurface(sdl_surface);
-
-    if (SDL_UpdateWindowSurface(sdl_window))
-    {
-        // If a fullscreen X11 window is minimized then this may be required.
-        // FIXME: What to do if this fails...
-        sdl_surface = SDL_GetWindowSurface(sdl_window);
-        SDL_UpdateWindowSurface(sdl_window);
-    }
-}
-#endif
-//
-// setpalette() -- set palette values
-//
-int32_t videoUpdatePalette(int32_t start, int32_t num)
-{
-    UNREFERENCED_PARAMETER(start);
-    UNREFERENCED_PARAMETER(num);
-
-    if (bpp > 8)
-        return 0;  // no palette in opengl
-
-#ifdef USE_OPENGL
-    if (!nogl)
-        glsurface_setPalette(curpalettefaded);
-    else
-#endif
-    {
-        if (sdl_surface)
-            softsurface_setPalette(curpalettefaded,
-                                   sdl_surface->format->Rmask,
-                                   sdl_surface->format->Gmask,
-                                   sdl_surface->format->Bmask);
-    }
-
-    return 0;
-}
-
-//
-// setgamma
-//
-int32_t videoSetGamma(void)
-{
-    if (novideo)
-        return 0;
-
-	return 1;
-}
 
 #if !defined __APPLE__ && !defined EDUKE32_TOUCH_DEVICES
 extern struct sdlappicon sdlappicon;
diff --git a/source/common/console/c_console.cpp b/source/common/console/c_console.cpp
index aaeff2b06..05ace1d53 100644
--- a/source/common/console/c_console.cpp
+++ b/source/common/console/c_console.cpp
@@ -56,6 +56,7 @@
 #include "i_time.h"
 #include "gamecvars.h"
 #include "baselayer.h"
+#include "i_system.h"
 
 
 #define LEFTMARGIN 8
@@ -897,9 +898,7 @@ int PrintString (int iprintlevel, const char *outline)
 
 		if (printlevel != PRINT_LOG)
 		{
-#if 0
 			I_PrintStr(outline);
-#endif
 
 			conbuffer->AddText(printlevel, outline);
 			if (vidactive && (iprintlevel & PRINT_NOTIFY))
diff --git a/source/common/fonts/v_font.cpp b/source/common/fonts/v_font.cpp
index f13e207b9..da2caa409 100644
--- a/source/common/fonts/v_font.cpp
+++ b/source/common/fonts/v_font.cpp
@@ -709,7 +709,6 @@ EColorRange V_ParseFontColor (const uint8_t *&color_value, int normalcolor, int
 
 void V_InitFonts()
 {
-	V_InitFontColors();
 	V_InitCustomFonts();
 
 	FFont *CreateHexLumpFont(const char *fontname, const char* lump);
diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp
index bbc11e7d8..08501e858 100644
--- a/source/common/gamecontrol.cpp
+++ b/source/common/gamecontrol.cpp
@@ -46,6 +46,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "quotemgr.h"
 #include "mapinfo.h"
 #include "s_soundinternal.h"
+#include "i_system.h"
+#include "inputstate.h"
+#include "v_video.h"
+#include "st_start.h"
 #ifndef NETCODE_DISABLE
 #include "enet.h"
 #endif
@@ -282,19 +286,6 @@ void ShutdownSystem()
 
 int GameMain()
 {
-	// Set up the console before anything else so that it can receive text.
-	C_InitConsole(1024, 768, true);
-	FStringf logpath("logfile %sdemolition.log", M_GetDocumentsPath().GetChars());
-	C_DoCommand(logpath);
-	//I_StartupJoysticks();
-	//mouseInit();
-
-#ifndef NETCODE_DISABLE
-	gHaveNetworking = !enet_initialize();
-	if (!gHaveNetworking)
-		initprintf("An error occurred while initializing ENet.\n");
-#endif
-
 	int r;
 	try
 	{
@@ -355,14 +346,8 @@ void SetDefaultStrings()
 //
 //==========================================================================
 
-int RunGame()
+static TArray<GrpEntry> SetupGame()
 {
-	SetClipshapes();
-
-	userConfig.ProcessOptions();
-
-	G_LoadConfig();
-
 	// Startup dialog must be presented here so that everything can be set up before reading the keybinds.
 
 	auto groups = GrpScan();
@@ -399,8 +384,8 @@ int RunGame()
 	if (groupno == -1 || userConfig.setupstate == 1)
 		groupno = ShowStartupWindow(groups);
 
-	if (groupno == -1) return 0;
-	auto &group = groups[groupno];
+	if (groupno == -1) return TArray<GrpEntry>();
+	auto& group = groups[groupno];
 
 	// Now filter out the data we actually need and delete the rest.
 
@@ -425,8 +410,8 @@ int RunGame()
 		if (ugroup.FileInfo.defname.IsNotEmpty()) selectedDef = ugroup.FileInfo.defname;
 
 		// CVAR has priority. This also overwrites the global variable each time. Init here is lazy so this is ok.
-		if (ugroup.FileInfo.rtsname.IsNotEmpty() && **rtsname == 0) RTS_Init(ugroup.FileInfo.rtsname); 
-		
+		if (ugroup.FileInfo.rtsname.IsNotEmpty() && **rtsname == 0) RTS_Init(ugroup.FileInfo.rtsname);
+
 		// For the game filter the last non-empty one wins.
 		if (ugroup.FileInfo.gamefilter.IsNotEmpty()) LumpFilter = ugroup.FileInfo.gamefilter;
 		g_gameType |= ugroup.FileInfo.flags;
@@ -445,8 +430,61 @@ int RunGame()
 	currentGame = LumpFilter;
 	currentGame.Truncate(currentGame.IndexOf("."));
 	CheckFrontend(g_gameType);
+	return usedgroups;
+}
+
+//==========================================================================
+//
+//
+//
+//==========================================================================
+
+int RunGame()
+{
+	// Set up the console before anything else so that it can receive text.
+	C_InitConsole(1024, 768, true);
+
+	// +logfile gets checked too late to catch the full startup log in the logfile so do some extra check for it here.
+	FString logfile = Args->TakeValue("+logfile");
+
+	// As long as this engine is still in prerelease mode let's always write a log file.
+	if (logfile.IsEmpty()) logfile.Format("%sdemolition.log", M_GetDocumentsPath().GetChars());
+
+	if (logfile.IsNotEmpty())
+	{
+		execLogfile(logfile);
+	}
+	I_DetectOS();
+	SetClipshapes();
+	userConfig.ProcessOptions();
+	G_LoadConfig();
+
+	//I_StartupJoysticks();
+	//mouseInit();
+
+
+#ifndef NETCODE_DISABLE
+	gHaveNetworking = !enet_initialize();
+	if (!gHaveNetworking)
+		initprintf("An error occurred while initializing ENet.\n");
+#endif
+
+	auto usedgroups = SetupGame();
+
 
 	InitFileSystem(usedgroups);
+	if (usedgroups.Size() == 0) return 0;
+
+	G_ReadConfig(currentGame);
+
+	V_InitFontColors();
+	GStrings.LoadStrings();
+
+	I_Init();
+	V_InitScreenSize();
+	V_InitScreen();
+	StartScreen = FStartupScreen::CreateInstance(100);
+
 	TArray<FString> addArt;
 	for (auto& grp : usedgroups)
 	{
@@ -461,10 +499,9 @@ int RunGame()
 	}
 	TileFiles.AddArt(addArt);
 
-	CONFIG_InitMouseAndController();
+	inputState.ClearAllInput();
 	CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt");
 	
-	G_ReadConfig(currentGame);
 	if (!GameConfig->IsInitialized())
 	{
 		CONFIG_ReadCombatMacros();
@@ -474,7 +511,6 @@ int RunGame()
 	{
 		playername = userConfig.CommandName;
 	}
-	GStrings.LoadStrings();
 	V_InitFonts();
 	C_CON_SetAliases();
 	sfx_empty = fileSystem.FindFile("demolition/dsempty.lmp"); // this must be done outside the sound code because it's initialized late.
@@ -484,6 +520,12 @@ int RunGame()
 	SetDefaultStrings();
 	if (g_gameType & GAMEFLAG_RR) InitRREndMap();	// this needs to be done better later
 	//C_DoCommand("stat sounddebug");
+
+	if (enginePreInit())
+	{
+		I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
+	}
+
 	return gi->app_main();
 }
 
@@ -554,14 +596,6 @@ int CONFIG_SetMapBestTime(uint8_t const* const mapmd4, int32_t tm)
 }
 
 
-void CONFIG_InitMouseAndController()
-{
-	inputState.ClearKeysDown();
-	inputState.keyFlushChars();
-	inputState.keyFlushScans();
-}
-
-
 CCMD(snd_reset)
 {
 	Mus_Stop();
diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h
index 0d84dc3f6..e0ab76c49 100644
--- a/source/common/gamecontrol.h
+++ b/source/common/gamecontrol.h
@@ -36,7 +36,6 @@ void CONFIG_SetDefaultKeys(const char *defbinds);
 
 
 void CONFIG_SetupJoystick(void);
-void CONFIG_InitMouseAndController();
 
 void CONFIG_SetGameControllerDefaultsClear();
 
diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp
index a072700c7..7057cf000 100644
--- a/source/common/gamecvars.cpp
+++ b/source/common/gamecvars.cpp
@@ -457,11 +457,6 @@ bool G_AllowAutoload()
 	return true;
 }
 
-CVAR(Int, ScreenMode, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
-CVAR(Int, ScreenWidth, 1024, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
-CVAR(Int, ScreenHeight, 768, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
-CVAR(Int, ScreenBPP, 32, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
-
 CVAR(Bool, adult_lockout, false, CVAR_ARCHIVE)
 CUSTOM_CVAR(String, playername, "Player", CVAR_ARCHIVE | CVAR_USERINFO)
 {
diff --git a/source/common/gamecvars.h b/source/common/gamecvars.h
index 69d50d834..8ac944c3a 100644
--- a/source/common/gamecvars.h
+++ b/source/common/gamecvars.h
@@ -101,11 +101,6 @@ EXTERN_CVAR(String, wchoice)
 EXTERN_CVAR(Bool, displaysetup)
 EXTERN_CVAR(Bool, noautoload)
 
-EXTERN_CVAR(Int, ScreenMode)
-EXTERN_CVAR(Int, ScreenWidth)
-EXTERN_CVAR(Int, ScreenHeight)
-EXTERN_CVAR(Int, ScreenBPP)
-
 EXTERN_CVAR(Bool, adult_lockout)
 EXTERN_CVAR(String, playername)
 EXTERN_CVAR(String, rtsname)
diff --git a/source/common/rendering/v_video.cpp b/source/common/rendering/v_video.cpp
index 1acbb696a..98ffe51f6 100644
--- a/source/common/rendering/v_video.cpp
+++ b/source/common/rendering/v_video.cpp
@@ -56,6 +56,8 @@
 #include "i_time.h"
 #include "version.h"
 #include "filesystem.h"
+#include "build.h"
+#include "glbackend/glbackend.h"
 
 EXTERN_CVAR(Int, menu_resolution_custom_width)
 EXTERN_CVAR(Int, menu_resolution_custom_height)
@@ -613,6 +615,13 @@ void V_Init2()
 	screen->SetGamma ();
 	FBaseCVar::ResetColors ();
 	C_NewModeAdjust();
+	videoSetGameMode(vid_fullscreen, SCREENWIDTH, SCREENHEIGHT, 32, 1);
+
+	polymost_glinit();
+	GLInterface.Init(SCREENHEIGHT);
+	GLInterface.InitGLState(4, glmultisample);
+	GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy);
+
 	//setsizeneeded = true;
 }
 
diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp
index 6922be453..663141361 100644
--- a/source/duke3d/src/config.cpp
+++ b/source/duke3d/src/config.cpp
@@ -27,93 +27,46 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "renderlayer.h"
 #include "cmdline.h"
 
-#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1
-# include "sdl_inc.h"
-#endif
-
-// we load this in to get default button and key assignments
-// as well as setting up function mappings
-
 BEGIN_DUKE_NS
 
 
 
-void CONFIG_SetDefaults(void)
-{
-
-# if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1
-    uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO);
-    if (inited == 0)
-        SDL_Init(SDL_INIT_VIDEO);
-    else if (!(inited & SDL_INIT_VIDEO))
-        SDL_InitSubSystem(SDL_INIT_VIDEO);
-
-    SDL_DisplayMode dm;
-    if (SDL_GetDesktopDisplayMode(0, &dm) == 0)
-    {
-        ScreenWidth = dm.w;
-        ScreenHeight = dm.h;
-    }
-    else
-# endif
-    {
-        ScreenWidth = 1024;
-        ScreenHeight = 768;
-    }
-
-    ScreenBPP = 32;
-
-
-	ud.camera_time    = 0;//4;
-
-    g_player[0].ps->aim_mode = 1;
-
-    ScreenMode       = 1;
-
-    ud.althud                 = 1;
-    ud.angleinterpolation     = 0;
-    ud.camerasprite           = -1;
-    ud.config.ShowWeapons     = 0;
-    ud.display_bonus_screen   = 1;
-
-    hud_position               = 0;
-    ud.menubackground         = 1;
-    ud.screen_size            = 4;
-    ud.screen_tilting         = 1;
-    ud.screenfade             = 1;
-    ud.shadow_pal             = 4;
-    ud.show_level_text        = 1;
-    ud.slidebar_paldisabled   = 1;
-    ud.statusbarflags         = 0;//STATUSBAR_NOSHRINK;
-    ud.statusbarmode          = 1;
-    ud.statusbarscale         = 100;
-
-	ud.god = 0;
-	ud.m_respawn_items = 0;
-	ud.m_respawn_monsters = 0;
-	ud.m_respawn_inventory = 0;
-	ud.warp_on = 0;
-	ud.cashman = 0;
-	m_ffire = 1;
-	ud.m_player_skill = ud.player_skill = 2;
-	memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
-	wchoice.Callback();
-}
-
-
-
 
 int CONFIG_ReadSetup(void)
 {
-    CONFIG_SetDefaults();
-    if (ScreenBPP < 8) ScreenBPP = 32;
+    ud.camera_time = 0;//4;
+
+    g_player[0].ps->aim_mode = 1;
+
+    ud.althud = 1;
+    ud.angleinterpolation = 0;
+    ud.camerasprite = -1;
+    ud.config.ShowWeapons = 0;
+    ud.display_bonus_screen = 1;
+
+    hud_position = 0;
+    ud.menubackground = 1;
+    ud.screen_size = 4;
+    ud.screen_tilting = 1;
+    ud.screenfade = 1;
+    ud.shadow_pal = 4;
+    ud.show_level_text = 1;
+    ud.slidebar_paldisabled = 1;
+    ud.statusbarflags = 0;//STATUSBAR_NOSHRINK;
+    ud.statusbarmode = 1;
+    ud.statusbarscale = 100;
+
+    ud.god = 0;
+    ud.m_respawn_items = 0;
+    ud.m_respawn_monsters = 0;
+    ud.m_respawn_inventory = 0;
+    ud.warp_on = 0;
+    ud.cashman = 0;
+    m_ffire = 1;
+    ud.m_player_skill = ud.player_skill = 2;
+    memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
+    wchoice.Callback();
     return 0;
 }
 
-
-void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.cfg
-{
-}
-
-
 END_DUKE_NS
diff --git a/source/duke3d/src/config.h b/source/duke3d/src/config.h
index b1d878503..53840e739 100644
--- a/source/duke3d/src/config.h
+++ b/source/duke3d/src/config.h
@@ -29,7 +29,6 @@ BEGIN_DUKE_NS
 
 
 int  CONFIG_ReadSetup(void);
-void CONFIG_SetDefaults(void);
 
 END_DUKE_NS
 #endif
diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp
index 297b775fc..41b9b40dd 100644
--- a/source/duke3d/src/game.cpp
+++ b/source/duke3d/src/game.cpp
@@ -49,6 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "statistics.h"
 #include "menu/menu.h"
 #include "mapinfo.h"
+#include "rendering/v_video.h"
 
 // Uncomment to prevent anything except mirrors from drawing. It is sensible to
 // also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
@@ -187,23 +188,6 @@ void G_HandleSpecialKeys(void)
         CONTROL_GetInput(&noshareinfo);
     }
 
-    if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && inputState.GetKeyStatus(sc_Enter))
-    {
-        if (videoSetGameMode(!ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, 1))
-        {
-            OSD_Printf(OSD_ERROR "Failed setting video mode!\n");
-
-            if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, 1))
-                G_GameExit("Fatal error: unable to recover from failure setting video mode!\n");
-        }
-        else
-            ScreenMode = !ScreenMode;
-
-        inputState.ClearKeyStatus(sc_Enter);
-        g_restorePalette = 1;
-        G_UpdateScreenArea();
-    }
-
     // only dispatch commands here when not in a game
     if ((myplayer.gm & MODE_GAME) != MODE_GAME)
         OSD_DispatchQueued();
@@ -267,7 +251,6 @@ void G_GameExit(const char *msg)
            g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm & MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ')
         {
             G_BonusScreen(1);
-            videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, 1);
         }
 
         // shareware and TEN screens
@@ -5800,10 +5783,6 @@ int GameInterface::app_main()
 
     CONFIG_ReadSetup();
 
-    if (enginePreInit())
-    {
-        I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
-    }
     hud_size.Callback();
     S_InitSound();
 
@@ -5940,53 +5919,9 @@ int GameInterface::app_main()
     g_clipMapFiles.clear();
 #endif
 
-#if 0
-    OSD_Exec("autoexec.cfg");
-#endif
-
-    system_getcvars();
-
-    if (g_networkMode != NET_DEDICATED_SERVER && validmodecnt > 0)
+    if (g_networkMode != NET_DEDICATED_SERVER)
     {
-        if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, 1) < 0)
-        {
-            initprintf("Failure setting video mode %dx%dx%d %s! Trying next mode...\n", *ScreenWidth, *ScreenHeight,
-                       *ScreenBPP, *ScreenMode ? "fullscreen" : "windowed");
-
-            int resIdx = 0;
-
-            for (int i=0; i < validmodecnt; i++)
-            {
-                if (validmode[i].xdim == ScreenWidth && validmode[i].ydim == ScreenHeight)
-                {
-                    resIdx = i;
-                    break;
-                }
-            }
-
-            int const savedIdx = resIdx;
-            int bpp = ScreenBPP;
-
-            while (videoSetGameMode(0, validmode[resIdx].xdim, validmode[resIdx].ydim, bpp, 1) < 0)
-            {
-                initprintf("Failure setting video mode %dx%dx%d windowed! Trying next mode...\n",
-                           validmode[resIdx].xdim, validmode[resIdx].ydim, bpp);
-
-                if (++resIdx >= validmodecnt)
-                {
-                    if (bpp == 8)
-                        G_GameExit("Fatal error: unable to set any video mode!");
-
-                    resIdx = savedIdx;
-                    bpp = 8;
-                }
-            }
-
-            ScreenWidth = validmode[resIdx].xdim;
-            ScreenHeight = validmode[resIdx].ydim;
-            ScreenBPP  = bpp;
-        }
-
+        V_Init2();
         videoSetPalette(0, myplayer.palette, 0);
     }
 
diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp
index 5279c2748..f82acb767 100644
--- a/source/duke3d/src/osdcmds.cpp
+++ b/source/duke3d/src/osdcmds.cpp
@@ -182,54 +182,6 @@ int osdcmd_restartmap(osdcmdptr_t UNUSED(parm))
     return OSDCMD_OK;
 }
 
-static int osdcmd_vidmode(osdcmdptr_t parm)
-{
-    int32_t newbpp = ScreenBPP, newwidth = ScreenWidth,
-            newheight = ScreenHeight, newfs = ScreenMode;
-    int32_t tmp;
-
-    if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
-
-    switch (parm->numparms)
-    {
-    case 1: // bpp switch
-        tmp = Batol(parm->parms[0]);
-        if (!(tmp==8 || tmp==16 || tmp==32))
-            return OSDCMD_SHOWHELP;
-        newbpp = tmp;
-        break;
-    case 2: // res switch
-        newwidth = Batol(parm->parms[0]);
-        newheight = Batol(parm->parms[1]);
-        break;
-    case 3: // res & bpp switch
-    case 4:
-        newwidth = Batol(parm->parms[0]);
-        newheight = Batol(parm->parms[1]);
-        tmp = Batol(parm->parms[2]);
-        if (!(tmp==8 || tmp==16 || tmp==32))
-            return OSDCMD_SHOWHELP;
-        newbpp = tmp;
-        if (parm->numparms == 4)
-            newfs = (Batol(parm->parms[3]) != 0);
-        break;
-    }
-
-    if (videoSetGameMode(newfs,newwidth,newheight,newbpp,upscalefactor))
-    {
-        initprintf("vidmode: Mode change failed!\n");
-        if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, upscalefactor))
-            G_GameExit("vidmode: Reset failed!\n");
-    }
-    ScreenBPP = newbpp;
-    ScreenWidth = newwidth;
-    ScreenHeight = newheight;
-    ScreenMode = newfs;
-    onvideomodechange(ScreenBPP>8);
-    G_UpdateScreenArea();
-    return OSDCMD_OK;
-}
-
 static int osdcmd_spawn(osdcmdptr_t parm)
 {
     int32_t picnum = 0;
@@ -806,9 +758,6 @@ int32_t registerosdcommands(void)
 
     OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
 
-    OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
-
-
     return 0;
 }
 
diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp
index 9955543d4..139569b6f 100644
--- a/source/duke3d/src/premap.cpp
+++ b/source/duke3d/src/premap.cpp
@@ -1778,7 +1778,6 @@ int G_EnterLevel(int gameMode)
         FX_StopAllSounds();
         S_ClearSoundLocks();
         FX_SetReverb(0);
-        videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, upscalefactor);
     }
 
     if (Menu_HaveUserMap())
diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp
index d827f7e04..72c4578b8 100644
--- a/source/glbackend/glbackend.cpp
+++ b/source/glbackend/glbackend.cpp
@@ -44,6 +44,7 @@
 #include "imgui_impl_sdl.h"
 #include "imgui_impl_opengl3.h"
 #include "baselayer.h"
+#include "gl_interface.h"
 
 extern int ydim;
 
@@ -77,17 +78,9 @@ void GLInstance::Init(int ydim)
 		memset(LastBoundTextures, 0, sizeof(LastBoundTextures));
 	}
 
-	glinfo.vendor = (const char*)glGetString(GL_VENDOR);
-	glinfo.renderer = (const char*)glGetString(GL_RENDERER);
-	glinfo.version = (const char*)glGetString(GL_VERSION);
-	glinfo.extensions = (const char*)glGetString(GL_EXTENSIONS);
-	glinfo.bufferstorage = !!strstr(glinfo.extensions, "GL_ARB_buffer_storage");
+	//glinfo.bufferstorage =  !!strstr(glinfo.extensions, "GL_ARB_buffer_storage");
 	glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy);
-	if (!glinfo.dumped)
-	{
-		//osdcmd_glinfo(NULL);
-		glinfo.dumped = 1;
-	}
+
 	new(&renderState) PolymostRenderState;	// reset to defaults.
 	LoadSurfaceShader();
 	LoadVPXShader();
diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h
index 632c27fa9..11c791c51 100644
--- a/source/glbackend/glbackend.h
+++ b/source/glbackend/glbackend.h
@@ -91,14 +91,7 @@ public:
 
 
 struct glinfo_t {
-	const char* vendor;
-	const char* renderer;
-	const char* version;
-	const char* extensions;
-
 	float maxanisotropy;
-	char bufferstorage;
-	char dumped;
 };
 
 struct BaseVertex
diff --git a/source/platform/win32/startwin.game.cpp b/source/platform/win32/startwin.game.cpp
index 49cefd927..9875f672b 100644
--- a/source/platform/win32/startwin.game.cpp
+++ b/source/platform/win32/startwin.game.cpp
@@ -131,48 +131,6 @@ static void PopulateForm(int32_t pgs)
 #endif
     }
 
-    if (pgs & POPULATE_VIDEO)
-    {
-        HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
-        int mode = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, settings.shared.bpp, settings.shared.fullscreen, 1);
-
-        if (mode < 0 || (settings.shared.bpp < 15))
-        {
-            int CONSTEXPR cd[] = { 32, 24, 16, 15, 8, 0 };
-            int i;
-
-            for (i=0; cd[i];)
-            {
-                if (cd[i] >= settings.shared.bpp) i++;
-                else break;
-            }
-            for (; cd[i]; i++)
-            {
-                mode = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, cd[i], settings.shared.fullscreen, 1);
-                if (mode < 0) continue;
-                settings.shared.bpp = cd[i];
-                break;
-            }
-        }
-
-        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.shared.fullscreen) ? BST_CHECKED : BST_UNCHECKED));
-        //Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? BST_CHECKED : BST_UNCHECKED));
-
-        (void)ComboBox_ResetContent(hwnd);
-
-        for (int i=0; i<validmodecnt; i++)
-        {
-            if (validmode[i].fs != (settings.shared.fullscreen)) continue;
-            if ((validmode[i].bpp < 15)) continue;
-
-            // all modes get added to the 3D mode list
-            Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL");
-            int const j = ComboBox_AddString(hwnd, buf);
-            (void)ComboBox_SetItemData(hwnd, j, i);
-            if (i == mode)(void)ComboBox_SetCurSel(hwnd, j);
-        }
-    }
-
 
     if (pgs & POPULATE_GAME)
     {
@@ -584,7 +542,7 @@ int32_t startwin_run(void)
     SetPage(TAB_CONFIG);
     EnableConfig(1);
 
-	settings.shared = { ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP };
+	settings.shared = { 0, 0, 0, 0 };
 	settings.grp = 0;
 
     PopulateForm(-1);
@@ -613,14 +571,6 @@ int32_t startwin_run(void)
     SetPage(TAB_MESSAGES);
     EnableConfig(0);
 
-    if (done)
-    {
-		ScreenWidth = settings.shared.xdim;
-		ScreenHeight = settings.shared.ydim;
-		ScreenMode = settings.shared.fullscreen;
-		ScreenBPP = settings.shared.bpp;
-    }
-
     return done;
 }
 
diff --git a/source/platform/win32/win32glvideo.cpp b/source/platform/win32/win32glvideo.cpp
index a1935a0f1..b32d24c82 100644
--- a/source/platform/win32/win32glvideo.cpp
+++ b/source/platform/win32/win32glvideo.cpp
@@ -405,7 +405,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
 	int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
 	const char *version = Args->CheckValue("-glversion");
 
-	if (version != nullptr && strtod(version, nullptr) < 3.0) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+	prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; // At the moment the renderer still needs the compatibility profile.
 
 	for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++)
 	{
@@ -413,8 +413,8 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
 		if (myWglCreateContextAttribsARB != NULL)
 		{
 			// let's try to get the best version possible. Some drivers only give us the version we request
-			// which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement.
-			static int versions[] = { 46, 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 };
+			// which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.3 is a requirement.
+			static int versions[] = { 46, 45, 44, 43, 42, 41, 40, 33, -1 };
 
 			for (int i = 0; versions[i] > 0; i++)
 			{
diff --git a/source/rr/src/config.cpp b/source/rr/src/config.cpp
index 351874c8e..261ff7f2f 100644
--- a/source/rr/src/config.cpp
+++ b/source/rr/src/config.cpp
@@ -36,66 +36,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 BEGIN_RR_NS
 
-void CONFIG_SetDefaults(void)
+int32_t CONFIG_ReadSetup(void)
 {
-
-# if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1
-    uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO);
-    if (inited == 0)
-        SDL_Init(SDL_INIT_VIDEO);
-    else if (!(inited & SDL_INIT_VIDEO))
-        SDL_InitSubSystem(SDL_INIT_VIDEO);
-
-    SDL_DisplayMode dm;
-    if (SDL_GetDesktopDisplayMode(0, &dm) == 0)
-    {
-        ScreenWidth = dm.w;
-        ScreenHeight = dm.h;
-    }
-    else
-# endif
-    {
-        ScreenWidth = 1024;
-        ScreenHeight = 768;
-    }
-
-    ScreenBPP = 32;
     g_player[0].ps->aim_mode = 1;
     ud.config.ShowOpponentWeapons = 0;
     ud.automsg = 0;
     ud.camerasprite = -1;
 
-	ud.camera_time = 0;//4;
+    ud.camera_time = 0;//4;
 
-	ud.screen_tilting = 1;
+    ud.screen_tilting = 1;
     ud.statusbarflags = STATUSBAR_NOSHRINK;
     ud.statusbarscale = 100;
     playerteam = 0;
     ud.angleinterpolation = 0;
 
-    ScreenMode = 1;
-
     ud.display_bonus_screen = 1;
     ud.show_level_text = 1;
     ud.screenfade = 1;
     ud.menubackground = 1;
     ud.slidebar_paldisabled = 1;
     ud.shadow_pal = 4;
-}
-
-
-int32_t CONFIG_ReadSetup(void)
-{
-    CONFIG_SetDefaults();
-    if (ScreenBPP < 8) ScreenBPP = 32;
     return 0;
 }
 
-
-void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.cfg
-{
-}
-
-
-
 END_RR_NS
diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp
index ae211edb9..33597f123 100644
--- a/source/rr/src/game.cpp
+++ b/source/rr/src/game.cpp
@@ -48,6 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "statistics.h"
 #include "c_dispatch.h"
 #include "mapinfo.h"
+#include "rendering/v_video.h"
 
 // Uncomment to prevent anything except mirrors from drawing. It is sensible to
 // also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
@@ -174,22 +175,6 @@ void G_HandleSpecialKeys(void)
         CONTROL_GetInput(&noshareinfo);
     }
 
-//    CONTROL_ProcessBinds();
-
-    if (/*g_networkMode != NET_DEDICATED_SERVER && */ALT_IS_PRESSED && inputState.GetKeyStatus(sc_Enter))
-    {
-        if (videoSetGameMode(!ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP,1))
-        {
-            OSD_Printf(OSD_ERROR "Failed setting fullscreen video mode.\n");
-            if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, 1))
-                G_GameExit("Failed to recover from failure to set fullscreen video mode.\n");
-        }
-        else ScreenMode = !ScreenMode;
-        inputState.ClearKeyStatus(sc_Enter);
-        g_restorePalette = 1;
-        G_UpdateScreenArea();
-    }
-
     // only dispatch commands here when not in a game
     if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
         OSD_DispatchQueued();
@@ -375,7 +360,6 @@ void G_GameExit(const char *msg)
         if (g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ')
         {
             G_BonusScreen(1);
-            videoSetGameMode(ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP,1);
         }
 
         // shareware and TEN screens
@@ -7256,10 +7240,6 @@ int GameInterface::app_main()
     CONFIG_ReadSetup();
 
 
-    if (enginePreInit())
-    {
-        I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
-    }
     hud_size.Callback();
     S_InitSound();
 
@@ -7395,55 +7375,8 @@ int GameInterface::app_main()
     g_clipMapFiles.clear();
 #endif
 
-#if 0
-    OSD_Exec("autoexec.cfg");
-#endif
-
-    system_getcvars();
-
-    //if (g_networkMode != NET_DEDICATED_SERVER)
-    {
-        if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, 1) < 0)
-        {
-            initprintf("Failure setting video mode %dx%dx%d %s! Trying next mode...\n", *ScreenWidth, *ScreenHeight,
-                       *ScreenBPP, *ScreenMode ? "fullscreen" : "windowed");
-
-            int resIdx = 0;
-
-            for (int i=0; i < validmodecnt; i++)
-            {
-                if (validmode[i].xdim == ScreenWidth && validmode[i].ydim == ScreenHeight)
-                {
-                    resIdx = i;
-                    break;
-                }
-            }
-
-            int const savedIdx = resIdx;
-            int bpp = ScreenBPP;
-
-            while (videoSetGameMode(0, validmode[resIdx].xdim, validmode[resIdx].ydim, bpp, 1) < 0)
-            {
-                initprintf("Failure setting video mode %dx%dx%d windowed! Trying next mode...\n",
-                           validmode[resIdx].xdim, validmode[resIdx].ydim, bpp);
-
-                if (++resIdx == validmodecnt)
-                {
-                    if (bpp == 8)
-                        G_GameExit("Fatal error: unable to set any video mode!");
-
-                    resIdx = savedIdx;
-                    bpp = 8;
-                }
-            }
-
-            ScreenWidth = validmode[resIdx].xdim;
-            ScreenHeight = validmode[resIdx].ydim;
-            ScreenBPP  = bpp;
-        }
-
-        videoSetPalette(0, g_player[myconnectindex].ps->palette, 0);
-    }
+    V_Init2();
+    videoSetPalette(0, g_player[myconnectindex].ps->palette, 0);
 
     // check if the minifont will support lowercase letters (3136-3161)
     // there is room for them in tiles012.art between "[\]^_." and "{|}~"
diff --git a/source/rr/src/osdcmds.cpp b/source/rr/src/osdcmds.cpp
index 66eecd058..ff66d9b2e 100644
--- a/source/rr/src/osdcmds.cpp
+++ b/source/rr/src/osdcmds.cpp
@@ -179,54 +179,6 @@ int osdcmd_restartmap(osdcmdptr_t UNUSED(parm))
     return OSDCMD_OK;
 }
 
-static int osdcmd_vidmode(osdcmdptr_t parm)
-{
-    int32_t newbpp = ScreenBPP, newwidth = ScreenWidth,
-            newheight = ScreenHeight, newfs = ScreenMode;
-    int32_t tmp;
-
-    if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
-
-    switch (parm->numparms)
-    {
-    case 1: // bpp switch
-        tmp = Batol(parm->parms[0]);
-        if (!(tmp==8 || tmp==16 || tmp==32))
-            return OSDCMD_SHOWHELP;
-        newbpp = tmp;
-        break;
-    case 2: // res switch
-        newwidth = Batol(parm->parms[0]);
-        newheight = Batol(parm->parms[1]);
-        break;
-    case 3: // res & bpp switch
-    case 4:
-        newwidth = Batol(parm->parms[0]);
-        newheight = Batol(parm->parms[1]);
-        tmp = Batol(parm->parms[2]);
-        if (!(tmp==8 || tmp==16 || tmp==32))
-            return OSDCMD_SHOWHELP;
-        newbpp = tmp;
-        if (parm->numparms == 4)
-            newfs = (Batol(parm->parms[3]) != 0);
-        break;
-    }
-
-    if (videoSetGameMode(newfs,newwidth,newheight,newbpp,upscalefactor))
-    {
-        initprintf("vidmode: Mode change failed!\n");
-        if (videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, upscalefactor))
-            G_GameExit("vidmode: Reset failed!\n");
-    }
-    ScreenBPP = newbpp;
-    ScreenWidth = newwidth;
-    ScreenHeight = newheight;
-    ScreenMode = newfs;
-    onvideomodechange(ScreenBPP>8);
-    G_UpdateScreenArea();
-    return OSDCMD_OK;
-}
-
 static int osdcmd_spawn(osdcmdptr_t parm)
 {
     int32_t picnum = 0;
@@ -659,8 +611,6 @@ int32_t registerosdcommands(void)
 
     OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
 
-    OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
-
     return 0;
 }
 
diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp
index bbaea8ba2..73bdd3d00 100644
--- a/source/rr/src/premap.cpp
+++ b/source/rr/src/premap.cpp
@@ -2306,7 +2306,6 @@ int G_EnterLevel(int gameMode)
         FX_StopAllSounds();
         S_ClearSoundLocks();
         FX_SetReverb(0);
-        videoSetGameMode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, upscalefactor);
     }
 
     if (Menu_HaveUserMap())
diff --git a/source/sw/src/config.cpp b/source/sw/src/config.cpp
index 284d7c52a..31e5edc3a 100644
--- a/source/sw/src/config.cpp
+++ b/source/sw/src/config.cpp
@@ -63,54 +63,6 @@ int32_t NumberPlayers,CommPort,PortSpeed,IrqNumber,UartAddress;
 int32_t UseMouse = 1, UseJoystick = 0;
 
 
-//
-// Screen variables
-//
-
-
-
-
-
-/*
-===================
-=
-= CONFIG_SetDefaults
-=
-===================
-*/
-
-void CONFIG_SetDefaults(void)
-{
-    ScreenMode = 1;
-
-#if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1
-    uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO);
-    if (inited == 0)
-        SDL_Init(SDL_INIT_VIDEO);
-    else if (!(inited & SDL_INIT_VIDEO))
-        SDL_InitSubSystem(SDL_INIT_VIDEO);
-
-    SDL_DisplayMode dm;
-    if (SDL_GetDesktopDisplayMode(0, &dm) == 0)
-    {
-        ScreenWidth = dm.w;
-        ScreenHeight = dm.h;
-    }
-    else
-#endif
-    {
-        ScreenWidth = 1024;
-        ScreenHeight = 768;
-    }
-
-    memcpy(&gs, &gs_defaults, sizeof(gs));
-}
-
-
-void SetDefaultKeyDefinitions(int style)
-{
-	CONFIG_SetDefaultKeys(style ? "demolition/defbinds.txt" : "demolition/origbinds.txt");
-}
 
 /*
 ===================
@@ -122,7 +74,7 @@ void SetDefaultKeyDefinitions(int style)
 
 int32_t CONFIG_ReadSetup(void)
 {
-    CONFIG_SetDefaults();
+    memcpy(&gs, &gs_defaults, sizeof(gs));
     return 0;
 }
 
diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp
index ad53274fc..db9dc7617 100644
--- a/source/sw/src/draw.cpp
+++ b/source/sw/src/draw.cpp
@@ -1537,133 +1537,10 @@ void SpriteSortList2D(int tx, int ty)
     }
 }
 
-int COVERsetgamemode(int mode, int xdim, int ydim, int bpp)
-{
-    ScreenHeight = ydim;
-    ScreenWidth  = xdim;
-    ScreenMode   = mode;
-    ScreenBPP    = bpp;
-
-    // [JM] Should I be using upscalefactor here, or some SW equivalent to Duke's ud.detail? !CHECKME!
-    return (int)videoSetGameMode(mode,xdim,ydim,bpp,upscalefactor);
-}
-
 void CheatResChange(void)
 {
-    /*
-    extern char permanentupdate;
-    int i;
-
-    // needs to be called from drawscreen - crashes otherwise
-
-    //cycle through all vesa modes, then screen-buffer mode
-    if (vidoption == 1)
-        {
-        for(i=0;i < validmodecnt;i++)
-            {
-            if ((validmodexdim[i] == xdim) && (validmodeydim[i] == ydim))
-                {
-                if (i == validmodecnt-1)
-                    COVERsetgamemode(2,320L,200L);
-                else
-                    COVERsetgamemode(1,validmodexdim[i+1],validmodeydim[i+1]);
-                break;
-                }
-            }
-        }
-    else
-        {
-        if (validmodecnt > 0)
-            COVERsetgamemode(1,validmodexdim[0],validmodeydim[0]);
-        }
-
-    permanentupdate = 0;
-
-    SetupAspectRatio();
-    SetRedrawScreen(Player + myconnectindex);
-
-    sprintf(ds,"%d x %d mode selected.", xdim, ydim);
-    PutStringInfo(Player + myconnectindex, ds);
-    */
-    PutStringInfo(Player + myconnectindex, "JonoF: Not now");
 }
 
-#if 0
-void ResChange(void)
-{
-    extern char permanentupdate;
-    int i;
-
-    static short sw_res[5];
-    static short res_ndx=0;
-
-    // clear pages before and after res set for good measure
-    for (i = 0; i < numpages; i++)
-    {
-        clearview(0);
-        videoNextPage();
-    }
-
-    // needs to be called from drawscreen - crashes otherwise
-
-    if (res_ndx == 0)
-    {
-        // choose resolutions for shadow warrior
-        for (i=0; i < validmodecnt; i++)
-        {
-            if (validmodexdim[i] + validmodeydim[i] == 320 + 200)
-                sw_res[res_ndx++] = i;
-            else if (validmodexdim[i] + validmodeydim[i] == 640 + 400)
-                sw_res[res_ndx++] = i;
-            else if (validmodexdim[i] + validmodeydim[i] == 640 + 480)
-                sw_res[res_ndx++] = i;
-            else if (validmodexdim[i] + validmodeydim[i] == 800 + 600)
-                sw_res[res_ndx++] = i;
-        }
-    }
-
-    //cycle through all sw modes, then screen-buffer mode
-    if (vidoption == 1)
-    {
-        for (i = 0; i < res_ndx; i++)
-        {
-            if ((validmodexdim[sw_res[i]] == xdim) && (validmodeydim[sw_res[i]] == ydim))
-            {
-                if (i >= res_ndx-1)
-                    COVERsetgamemode(2, 320L, 200L);
-                else
-                    COVERsetgamemode(1, validmodexdim[sw_res[i+1]], validmodeydim[sw_res[i+1]]);
-                break;
-            }
-        }
-
-
-        // if did not find current res then reset to 320x200
-        if (i >= res_ndx)
-            COVERsetgamemode(2, 320L, 200L);
-    }
-    else
-    {
-        if (validmodecnt > 0)
-            COVERsetgamemode(1, validmodexdim[0], validmodeydim[0]);
-    }
-
-    permanentupdate = 0;
-
-    for (i = 0; i < numpages; i++)
-    {
-        clearview(0);
-        videoNextPage();
-    }
-
-    SetupAspectRatio();
-    SetRedrawScreen(Player + myconnectindex);
-
-    sprintf(ds,"%d x %d mode selected.", xdim, ydim);
-    PutStringInfo(Player + myconnectindex, ds);
-}
-#endif
-
 void DrawCheckKeys(PLAYERp pp)
 {
     extern SWBOOL ResCheat;
diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp
index e396f461f..7790c2daa 100644
--- a/source/sw/src/game.cpp
+++ b/source/sw/src/game.cpp
@@ -96,6 +96,7 @@ Things required to make savegames work:
 #include "statistics.h"
 #include "gstrings.h"
 #include "mapinfo.h"
+#include "rendering/v_video.h"
 #include "sound/s_soundinternal.h"
 
 //#include "crc32.h"
@@ -697,18 +698,6 @@ void DisplayDemoText(void)
     }
 }
 
-
-void Set_GameMode(void)
-{
-    int result;
-    char ch;
-
-    //DSPRINTF(ds,"ScreenMode %d, ScreenWidth %d, ScreenHeight %d",ScreenMode, ScreenWidth, ScreenHeight);
-    //MONO_PRINT(ds);
-    result = COVERsetgamemode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP);
-
-}
-
 void MultiSharewareCheck(void)
 {
     if (!SW_SHAREWARE) return;
@@ -946,7 +935,7 @@ bool InitGame()
         DoTheCache();
     }
 
-    Set_GameMode();
+    V_Init2();
     GraphicsMode = TRUE;
     SetupAspectRatio();
 
@@ -2878,10 +2867,6 @@ int32_t GameInterface::app_main()
 
     CONFIG_ReadSetup();
 
-    if (enginePreInit())
-    {
-		I_Error("There was a problem initialising the Build engine: %s", engineerrstr);
-    }
     hud_size.Callback();
 
     if (!DetectShareware())