From 243787d19a5c58ebb32a0a020e7ed785eff67096 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jun 2018 08:26:14 +0200 Subject: [PATCH 01/12] Fixed: End of file detection in MAPINFO parser was not correct It should check for the special "End" flag instead of trusting that if the last token was a closing brace, all was correct. This can fail if the last token in a multiline string is a brace. --- src/g_mapinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 72fab5071..d73056843 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -557,7 +557,7 @@ void FMapInfoParser::SkipToNext() void FMapInfoParser::CheckEndOfFile(const char *block) { - if (format_type == FMT_New && !sc.Compare("}")) + if (format_type == FMT_New && (sc.End || !sc.Compare("}"))) { sc.ScriptError("Unexpected end of file in %s definition", block); } From 211bd0b1b0d2c2b751a0bf26508dd5887e7432ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jun 2018 08:51:33 +0200 Subject: [PATCH 02/12] Remove unnecessary check for the ending brace. --- src/g_mapinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index d73056843..9eb80ae09 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -557,7 +557,7 @@ void FMapInfoParser::SkipToNext() void FMapInfoParser::CheckEndOfFile(const char *block) { - if (format_type == FMT_New && (sc.End || !sc.Compare("}"))) + if (format_type == FMT_New && sc.End) { sc.ScriptError("Unexpected end of file in %s definition", block); } From 720bb485bebed0cc8ad4dd2a90996a4b55254447 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Mon, 18 Jun 2018 12:46:52 +0200 Subject: [PATCH 03/12] - Disabled position independent executable for MinGW This broke MinGW-w64 but was ignored with tdm-gcc. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb3beeea9..1328491d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,7 +244,7 @@ else() # If we're compiling with a custom GCC on the Mac (which we know since g++-4.2 doesn't support C++11) statically link libgcc. set( ALL_C_FLAGS "-static-libgcc" ) endif() - else() + elseif( NOT MINGW ) # Generic GCC/Clang requires position independent executable to be enabled explicitly set( ALL_C_FLAGS "${ALL_C_FLAGS} -fPIE" ) set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie" ) From 703d2bc0cd674bad280592982898607002918052 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Mon, 18 Jun 2018 13:39:23 +0200 Subject: [PATCH 04/12] - Fixed missing include due to non conformant preprocessor in VS. --- src/d_main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_main.cpp b/src/d_main.cpp index 668dcf1ce..6542b950a 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -28,6 +28,10 @@ // HEADER FILES ------------------------------------------------------------ +#ifdef _WIN32 +#include +#endif + #ifdef HAVE_FPU_CONTROL #include #endif From d8a1d1b89c047816adb760e29f25f173a7aa08d7 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Mon, 18 Jun 2018 13:44:23 +0200 Subject: [PATCH 05/12] - Missing formatting macro definitions for MinGW. --- src/d_net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_net.cpp b/src/d_net.cpp index 453a1ff32..2e8e9aca2 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -26,6 +26,7 @@ //----------------------------------------------------------------------------- #include +#define __STDC_FORMAT_MACROS #include #include "version.h" From 9a4ae6eb80a3678301ee370909f05fcd54dd5be5 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Mon, 18 Jun 2018 14:10:37 +0200 Subject: [PATCH 06/12] - Missing include again due to the VS preprocessor. --- src/textures/hires/hirestex.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/textures/hires/hirestex.cpp b/src/textures/hires/hirestex.cpp index c5aed1624..dae7654a0 100644 --- a/src/textures/hires/hirestex.cpp +++ b/src/textures/hires/hirestex.cpp @@ -24,6 +24,12 @@ ** */ +#ifdef _MSC_VER +#include +#else +#include +#endif + #include "w_wad.h" #include "m_png.h" #include "sbar.h" @@ -32,7 +38,6 @@ #include "bitmap.h" #ifndef _WIN32 -#include #define _access(a,b) access(a,b) #endif From b38e67a53ddb07ffad696adc0780ec9589c7c7f4 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Mon, 18 Jun 2018 14:16:47 +0200 Subject: [PATCH 07/12] - Applied Blzut3's patch to compile with MinGW. --- src/textures/hires/hqresize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/hires/hqresize.cpp b/src/textures/hires/hqresize.cpp index 9c176974d..eb121ced8 100644 --- a/src/textures/hires/hqresize.cpp +++ b/src/textures/hires/hqresize.cpp @@ -235,7 +235,7 @@ static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char* } #endif -static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, int, int ), +static unsigned char *hqNxHelper( void (HQX_CALLCONV *hqNxFunction) ( unsigned*, unsigned*, int, int ), const int N, unsigned char *inputBuffer, const int inWidth, From aef4003de2b9446965fa4d36983c429f099dfca3 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Sun, 22 Apr 2018 18:50:12 +0200 Subject: [PATCH 08/12] - Restored dependency on dxguid library for MinGW. --- src/CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 56eb85364..cea058af9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,11 @@ if( WIN32 ) find_library( DX_dinput8_LIBRARY dinput8 PATHS ENV DXSDK_DIR PATH_SUFFIXES Lib Lib/${XBITS} ) + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + find_library( DX_dxguid_LIBRARY dxguid + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Lib Lib/${XBITS} ) + endif() # Modern versions of the Windows SDK include dinput8.lib. Unfortunately, # CMake cannot find these libraries via find_library. @@ -89,6 +94,13 @@ if( WIN32 ) set( DX_dinput8_LIBRARY dinput8 ) endif() + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + # Modern versions of the Windows SDK do NOT include dxguid.lib. Its contents + # were moved to dinput8.lib. + if( NOT DX_dxguid_LIBRARY ) + message( STATUS "Could not find dxguid.lib. Build may fail on old Windows SDKs.") + endif() + endif() endif() set( ZDOOM_LIBS @@ -109,6 +121,11 @@ if( WIN32 ) set( ZDOOM_LIBS ${ZDOOM_LIBS} DelayImp ) endif() + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + if( DX_dxguid_LIBRARY ) + list( APPEND ZDOOM_LIBS "${DX_dxguid_LIBRARY}" ) + endif() + endif() else() if( APPLE ) set( NO_GTK ON ) From 958b3c303a8808c7ae933a1d03ac96a89e45bc14 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Sun, 22 Apr 2018 19:25:36 +0200 Subject: [PATCH 09/12] - Fixed missing manifest for MinGW. --- src/win32/zdoom.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index b8a8e446c..e80228a32 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -474,7 +474,7 @@ IDB_DEADGUY BITMAP "deadguy.bmp" // Generated from the TEXTINCLUDE 3 resource. // #ifndef NO_MANIFEST -// CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "zdoom.exe.manifest" + CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "zdoom.exe.manifest" #endif ///////////////////////////////////////////////////////////////////////////// From 8afd33127570c9043535f2c882cff1a56e1bfe29 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Sat, 12 May 2018 11:32:53 +0200 Subject: [PATCH 10/12] - Fixed -iwad parameter working only with VS on Windows. --- src/d_iwad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index af8047a3d..bb2c091a3 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -534,7 +534,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, FixPathSeperator(custwad); DefaultExtension(custwad, ext); bool isAbsolute = (custwad[0] == '/'); -#ifdef WINDOWS +#ifdef _WIN32 isAbsolute |= (custwad.Len() >= 2 && custwad[1] == ':'); #endif if (isAbsolute) From 42bb9b7e5915b637bb68dfc7e46e1902b8a70355 Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Mon, 18 Jun 2018 19:04:20 +0200 Subject: [PATCH 11/12] - Fixed zdoom.rc for MinGW. --- src/win32/zdoom.rc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index e80228a32..325c1d064 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -75,7 +75,7 @@ BEGIN " VALUE ""FileDescription"", ""GZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" " VALUE ""InternalName"", ""GZDoom""\r\n" - " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" + " VALUE ""LegalCopyright"", ""Copyright © 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" " VALUE ""ProductName"", ""GZDoom""\r\n" @@ -224,6 +224,7 @@ IDD_IWADDIALOG DIALOGEX 0, 0, 224, 249 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "Welcome" +#ifndef __MINGW32__ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US FONT 8, "MS Shell Dlg" { @@ -243,6 +244,26 @@ FONT 8, "MS Shell Dlg" CONTROL "Play GZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 CONTROL "Exit", IDCANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 228, 50, 14 } +#else +// [SP] Upstreamed from Zandronum +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + ICON IDI_ICON1,IDC_STATIC,7,7,21,20 + LTEXT "Welcome to GZDoom!",IDC_STATIC,42,8,180,8 + LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 + GROUPBOX "IWAD selection",IDC_STATIC,8,32,208,102 + LTEXT "Select which game file (IWAD) to run.",IDC_STATIC,12,44,190,8 + LISTBOX IDC_IWADLIST,12,56,200,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Video settings",IDC_STATIC,8,138,208,28 + CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,124,150,48,10 + CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,39,65,10 + CONTROL "Lights.pk3",IDC_WELCOME_LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,46,182,51,10 + CONTROL "Brightmaps.pk3",IDC_WELCOME_BRIGHTMAPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,111,182,65,10 + CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,73,201,87,10 + DEFPUSHBUTTON "Play GZDoom",IDOK,8,228,90,14 + PUSHBUTTON "Exit",IDCANCEL,166,228,50,14 +END +#endif IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VSCROLL @@ -505,7 +526,7 @@ BEGIN VALUE "FileDescription", "GZDoom" VALUE "FileVersion", RC_FILEVERSION2 VALUE "InternalName", "GZDoom" - VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." + VALUE "LegalCopyright", "Copyright © 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." VALUE "OriginalFilename", "gzdoom.exe" VALUE "ProductName", "GZDoom" From 01bda6348ed346223a296a77bd4292f13c571693 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 18 Jun 2018 21:15:52 +0200 Subject: [PATCH 12/12] - change swrender mapping to use two buffers/textures and glTexSubImage2D for uploads --- src/gl/textures/gl_hwtexture.cpp | 8 ++++++-- src/swrenderer/r_swscene.cpp | 32 +++++++++++++++++--------------- src/swrenderer/r_swscene.h | 6 ++++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 36feab0b7..ef069114d 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -192,7 +192,8 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int } */ TranslatedTexture * glTex=GetTexID(translation); - if (glTex->glTexID==0) glGenTextures(1,&glTex->glTexID); + bool firstCall = glTex->glTexID == 0; + if (firstCall) glGenTextures(1,&glTex->glTexID); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); glBindTexture(GL_TEXTURE_2D, glTex->glTexID); FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name); @@ -256,7 +257,10 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int sourcetype = GL_BGRA; } - glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, sourcetype, GL_UNSIGNED_BYTE, buffer); + if (!firstCall && glBufferID > 0) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rw, rh, sourcetype, GL_UNSIGNED_BYTE, buffer); + else + glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, sourcetype, GL_UNSIGNED_BYTE, buffer); if (deletebuffer && buffer) free(buffer); else if (glBufferID) diff --git a/src/swrenderer/r_swscene.cpp b/src/swrenderer/r_swscene.cpp index 214fb2a0c..8e2522266 100644 --- a/src/swrenderer/r_swscene.cpp +++ b/src/swrenderer/r_swscene.cpp @@ -86,38 +86,40 @@ public: SWSceneDrawer::SWSceneDrawer() { - PaletteTexture = new FSWPaletteTexture; + PaletteTexture.reset(new FSWPaletteTexture); } SWSceneDrawer::~SWSceneDrawer() { - if (PaletteTexture != nullptr) delete PaletteTexture; - if (FBTexture != nullptr) delete FBTexture; } sector_t *SWSceneDrawer::RenderView(player_t *player) { + // Avoid using the pixel buffer from the last frame + FBTextureIndex = (FBTextureIndex + 1) % 2; + auto &fbtex = FBTexture[FBTextureIndex]; + DCanvas buffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()); - if (FBTexture == nullptr || FBTexture->SystemTexture[0] == nullptr || - FBTexture->GetWidth() != screen->GetWidth() || - FBTexture->GetHeight() != screen->GetHeight() || - (V_IsTrueColor() ? 1:0) != FBTexture->WidthBits) + if (fbtex == nullptr || fbtex->SystemTexture[0] == nullptr || + fbtex->GetWidth() != screen->GetWidth() || + fbtex->GetHeight() != screen->GetHeight() || + (V_IsTrueColor() ? 1:0) != fbtex->WidthBits) { // This manually constructs its own material here. - if (FBTexture != nullptr) delete FBTexture; - FBTexture = new FSWSceneTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()); - FBTexture->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); - auto mat = FMaterial::ValidateTexture(FBTexture, false); - mat->AddTextureLayer(PaletteTexture); + fbtex.reset(); + fbtex.reset(new FSWSceneTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); + fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); + auto mat = FMaterial::ValidateTexture(fbtex.get(), false); + mat->AddTextureLayer(PaletteTexture.get()); } - auto buf = FBTexture->SystemTexture[0]->MapBuffer(); + auto buf = fbtex->SystemTexture[0]->MapBuffer(); if (!buf) I_FatalError("Unable to map buffer for software rendering"); buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf); SWRenderer->RenderView(player, &buffer); - FBTexture->SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); + fbtex->SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); - screen->DrawTexture(FBTexture, 0, 0, DTA_SpecialColormap, map, TAG_DONE); + screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE); SWRenderer->DrawRemainingPlayerSprites(); return r_viewpoint.sector; } diff --git a/src/swrenderer/r_swscene.h b/src/swrenderer/r_swscene.h index ef52c20c6..9c6921ee4 100644 --- a/src/swrenderer/r_swscene.h +++ b/src/swrenderer/r_swscene.h @@ -6,13 +6,15 @@ #include "hwrenderer/scene/hw_clipper.h" #include "r_utility.h" #include "c_cvars.h" +#include class FSWSceneTexture; class SWSceneDrawer { - FTexture *PaletteTexture = nullptr; - FSWSceneTexture *FBTexture = nullptr; + std::unique_ptr PaletteTexture; + std::unique_ptr FBTexture[2]; + int FBTextureIndex = 0; bool FBIsTruecolor = false; public: