diff --git a/src/d_main.cpp b/src/d_main.cpp index f203e9a85f..14766fe092 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2274,6 +2274,39 @@ static void CheckCmdLine() } } +//========================================================================== +// +// +// +//========================================================================== + +extern int currentrenderer; +EXTERN_CVAR(Int, vid_renderer) +FRenderer *gl_CreateInterface(); +FRenderer *CreateSWRenderer(); + +static void DeleteRenderer() +{ + if (Renderer != NULL) delete Renderer; + if (SWRenderer != NULL) delete SWRenderer; +} + +void D_CreateRenderer() +{ + currentrenderer = vid_renderer; + if (currentrenderer == 1) + Printf("Renderer: OpenGL\n"); + else + Printf("Renderer: Software on OpenGL\n"); + + if (Renderer == NULL) + { + Renderer = gl_CreateInterface(); + SWRenderer = CreateSWRenderer(); + atterm(DeleteRenderer); + } +} + //========================================================================== // // D_DoomMain @@ -2458,7 +2491,7 @@ void D_DoomMain (void) { if (!batchrun) Printf ("I_Init: Setting up machine state.\n"); I_Init (); - I_CreateRenderer(); + D_CreateRenderer(); } if (!batchrun) Printf ("V_Init: allocate screen.\n"); diff --git a/src/d_stats.cpp b/src/d_stats.cpp index fc49e665f9..d607a8a5b7 100644 --- a/src/d_stats.cpp +++ b/src/d_stats.cpp @@ -36,9 +36,6 @@ extern int sys_ostype; #include "version.h" #include "v_video.h" -#ifdef _WIN32 -EXTERN_CVAR(Bool, vid_glswfb) -#endif extern int currentrenderer; CVAR(Int, sys_statsenabled, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOSET) CVAR(String, sys_statshost, "gzstats.drdteam.org", CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET) @@ -254,20 +251,10 @@ static int GetCoreInfo() static int GetRenderInfo() { - if (currentrenderer == 0) - { -#ifdef _WIN32 - if (vid_glswfb) return 2; -#endif - return 1; - } - else - { - auto info = gl_getInfo(); - if (info.first < 3.3) return 3; // Legacy OpenGL. Don't care about Intel HD 3000 on Windows being run in 'risky' mode. - if (!info.second) return 4; - return 5; - } + auto info = gl_getInfo(); + if (info.first < 3.3) return 3; // Legacy OpenGL. Don't care about Intel HD 3000 on Windows being run in 'risky' mode. + if (!info.second) return 4; + return 5; } static void D_DoHTTPRequest(const char *request) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 9dee7a58e8..036565f258 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -844,28 +844,6 @@ void I_InitGraphics() } -static void I_DeleteRenderer() -{ - delete Renderer; - Renderer = NULL; -} - -void I_CreateRenderer() -{ - currentrenderer = vid_renderer; - - if (NULL == Renderer) - { - extern FRenderer* gl_CreateInterface(); - - Renderer = 1 == currentrenderer - ? gl_CreateInterface() - : new FSoftwareRenderer; - atterm(I_DeleteRenderer); - } -} - - DFrameBuffer* I_SetMode(int &width, int &height, DFrameBuffer* old) { return Video->CreateFrameBuffer(width, height, swtruecolor, fullscreen, old); diff --git a/src/posix/hardware.h b/src/posix/hardware.h index 3c06cb6c6d..5f10dc25fc 100644 --- a/src/posix/hardware.h +++ b/src/posix/hardware.h @@ -86,7 +86,6 @@ class IVideo void I_InitGraphics (); void I_ShutdownGraphics (); -void I_CreateRenderer(); extern Semaphore FPSLimitSemaphore; void I_SetFPSLimit(int limit); diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 32837ea84f..57bafcd3df 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -128,23 +128,6 @@ void I_InitGraphics () Video->SetWindowedScale (vid_winscale); } -static void I_DeleteRenderer() -{ - if (Renderer != NULL) delete Renderer; -} - -void I_CreateRenderer() -{ - currentrenderer = vid_renderer; - if (Renderer == NULL) - { - if (currentrenderer==1) Renderer = gl_CreateInterface(); - else Renderer = new FSoftwareRenderer; - atterm(I_DeleteRenderer); - } -} - - /** Remaining code is common to Win32 and Linux **/ // VIDEO WRAPPERS --------------------------------------------------------- diff --git a/src/r_renderer.h b/src/r_renderer.h index 6ab9aaa9a8..1853e7f3a2 100644 --- a/src/r_renderer.h +++ b/src/r_renderer.h @@ -5,6 +5,8 @@ struct FRenderer; extern FRenderer *Renderer; +extern FRenderer *SWRenderer; + class FSerializer; class FTexture; class AActor; @@ -15,16 +17,6 @@ class FileWriter; struct FRenderer { - FRenderer() - { - Renderer = this; - } - - virtual ~FRenderer() - { - Renderer = NULL; - } - // precache one texture virtual void Precache(uint8_t *texhitlist, TMap &actorhitlist) = 0; diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index a8114dc698..17038521a3 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -85,10 +85,12 @@ FSoftwareRenderer::FSoftwareRenderer() InitSWColorMaps(); } -FSoftwareRenderer::~FSoftwareRenderer() +FRenderer *CreateSWRenderer() { + return new FSoftwareRenderer; } + void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache) { bool isbgra = screen->IsBgra(); diff --git a/src/swrenderer/r_swrenderer.h b/src/swrenderer/r_swrenderer.h index 4a83c0b8c2..e5ac436286 100644 --- a/src/swrenderer/r_swrenderer.h +++ b/src/swrenderer/r_swrenderer.h @@ -7,7 +7,6 @@ struct FSoftwareRenderer : public FRenderer { FSoftwareRenderer(); - ~FSoftwareRenderer(); // precache textures void Precache(uint8_t *texhitlist, TMap &actorhitlist) override; @@ -34,3 +33,5 @@ private: swrenderer::RenderScene mScene; }; + +FRenderer *CreateSWRenderer(); diff --git a/src/v_video.cpp b/src/v_video.cpp index 00563d1bfc..1c4319813a 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -109,6 +109,7 @@ EXTERN_CVAR(Bool, r_blendmethod) int active_con_scale(); FRenderer *Renderer; +FRenderer *SWRenderer; EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Bool, fullscreen) diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 5d89cf43f9..87fffb280f 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -180,27 +180,6 @@ void I_InitGraphics () Video->SetWindowedScale (vid_winscale); } -static void I_DeleteRenderer() -{ - if (Renderer != NULL) delete Renderer; -} - -void I_CreateRenderer() -{ - currentrenderer = vid_renderer; - if (currentrenderer == 1) - Printf("Renderer: OpenGL\n"); - else - Printf("Renderer: Software on OpenGL\n"); - - if (Renderer == NULL) - { - if (currentrenderer==1) Renderer = gl_CreateInterface(); - else Renderer = new FSoftwareRenderer; - atterm(I_DeleteRenderer); - } -} - /** Remaining code is common to Win32 and Linux **/ // VIDEO WRAPPERS --------------------------------------------------------- diff --git a/src/win32/hardware.h b/src/win32/hardware.h index d996bf3944..a4885964b8 100644 --- a/src/win32/hardware.h +++ b/src/win32/hardware.h @@ -57,7 +57,6 @@ class IVideo void I_InitGraphics (); void I_ShutdownGraphics (); -void I_CreateRenderer(); void I_SaveWindowedPos (); void I_RestoreWindowedPos (); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index c0445fdffd..dcb2c981f6 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1868,10 +1868,6 @@ OptionMenu RendererMenu protected Option "$RNDMNU_RENDERER", "vid_renderer", "PolyDoom" Option "$RNDMNU_TRUECOLOR", "swtruecolor", "OnOff" Option "$RNDMNU_POLY", "r_polyrenderer", "OnOff" - IfOption(Windows) - { - Option "$RNDMNU_CANVAS", "vid_glswfb", "GLD3D" - } } /*=======================================