From 8e4b304bed833e73dcacb8abffdfcb77fe1ea07b Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 9 Jul 2025 23:15:33 -0400 Subject: [PATCH 01/12] CMake: don't configure before CPACK_PACKAGE_DESCRIPTION_SUMMARY is set --- CMakeLists.txt | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1acd092bc..2d8354b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,28 @@ if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") endif() +##### PACKAGE CONFIGURATION ##### + +if(${CMAKE_SYSTEM} MATCHES "Windows") + set(CPACK_GENERATOR "ZIP") +endif() +if(${CMAKE_SYSTEM} MATCHES "Linux") + set(CPACK_GENERATOR "TGZ") +endif() +if(${CMAKE_SYSTEM} MATCHES "Darwin") + set(CPACK_GENERATOR "DragNDrop") +endif() + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") +set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") +#set(CPACK_PACKAGE_DESCRIPTION_FILE ) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") +include(CPack) + # Set up CMAKE path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") @@ -100,16 +122,11 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -# Set EXE names so the assets CMakeLists can refer to its target -set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name") -set(SRB2_WIN_EXE_NAME srb2kartdd CACHE STRING "Executable binary output name for DirectDraw build") - include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) add_subdirectory(assets) - ## config.h generation set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") include(GitUtilities) @@ -118,25 +135,3 @@ git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) - -##### PACKAGE CONFIGURATION ##### - -if(${CMAKE_SYSTEM} MATCHES "Windows") - set(CPACK_GENERATOR "ZIP") -endif() -if(${CMAKE_SYSTEM} MATCHES "Linux") - set(CPACK_GENERATOR "TGZ") -endif() -if(${CMAKE_SYSTEM} MATCHES "Darwin") - set(CPACK_GENERATOR "DragNDrop") -endif() - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") -set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") -#set(CPACK_PACKAGE_DESCRIPTION_FILE ) -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") -set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) -set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") -include(CPack) -- 2.54.0 From 9f5a5a735b17cc74040ff3eea4c906cbf7decc7e Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 9 Jul 2025 23:22:57 -0400 Subject: [PATCH 02/12] Allow changing Cpak generator (from upstream) --- CMakeLists.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d8354b44..84aa73968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,9 @@ cmake_minimum_required(VERSION 3.5) + +if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) + message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") +endif() + # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # Version change is fine. project(SRB2 @@ -11,22 +16,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON) -if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) - message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") -endif() - ##### PACKAGE CONFIGURATION ##### -if(${CMAKE_SYSTEM} MATCHES "Windows") - set(CPACK_GENERATOR "ZIP") -endif() -if(${CMAKE_SYSTEM} MATCHES "Linux") - set(CPACK_GENERATOR "TGZ") -endif() -if(${CMAKE_SYSTEM} MATCHES "Darwin") - set(CPACK_GENERATOR "DragNDrop") +set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.") + +if("${SRB2_CPACK_GENERATOR}" STREQUAL "") + if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") + set(SRB2_CPACK_GENERATOR "ZIP") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(SRB2_CPACK_GENERATOR "TGZ") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + set(SRB2_CPACK_GENERATOR "TGZ") + endif() endif() +set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") #set(CPACK_PACKAGE_DESCRIPTION_FILE ) -- 2.54.0 From 346b1456cd1f6aed166272fa4d9a56c3712af087 Mon Sep 17 00:00:00 2001 From: PAS Date: Mon, 21 Apr 2025 16:51:31 -0400 Subject: [PATCH 03/12] CMake: Fix FindOPENMPT --- cmake/Modules/FindOPENMPT.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindOPENMPT.cmake b/cmake/Modules/FindOPENMPT.cmake index 2d334b6f0..305a55ee1 100644 --- a/cmake/Modules/FindOPENMPT.cmake +++ b/cmake/Modules/FindOPENMPT.cmake @@ -1,6 +1,6 @@ include(LibFindMacros) -libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT) +libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT) find_path(OPENMPT_INCLUDE_DIR NAMES libopenmpt.h @@ -8,6 +8,7 @@ find_path(OPENMPT_INCLUDE_DIR ${OPENMPT_PKGCONF_INCLUDE_DIRS} "/usr/include/libopenmpt" "/usr/local/include/libopenmpt" + PATH_SUFFIXES libopenmpt ) find_library(OPENMPT_LIBRARY @@ -20,4 +21,4 @@ find_library(OPENMPT_LIBRARY set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR) set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY) -libfind_process(OPENMPT) \ No newline at end of file +libfind_process(OPENMPT) -- 2.54.0 From e7efd464196cae77d694a5f6bb34fd662877c944 Mon Sep 17 00:00:00 2001 From: PAS Date: Mon, 21 Apr 2025 17:51:48 -0400 Subject: [PATCH 04/12] Fix FindGME pkg-config command, update LibFindMacros.cmake --- cmake/Modules/FindGME.cmake | 4 +-- cmake/Modules/LibFindMacros.cmake | 55 +++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/cmake/Modules/FindGME.cmake b/cmake/Modules/FindGME.cmake index ea80af454..641274e75 100644 --- a/cmake/Modules/FindGME.cmake +++ b/cmake/Modules/FindGME.cmake @@ -1,6 +1,6 @@ include(LibFindMacros) -libfind_pkg_check_modules(GME_PKGCONF GME) +libfind_pkg_check_modules(GME_PKGCONF LIBGME) find_path(GME_INCLUDE_DIR NAMES gme.h @@ -20,4 +20,4 @@ find_library(GME_LIBRARY set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR) set(GME_PROCESS_LIBS GME_LIBRARY) -libfind_process(GME) \ No newline at end of file +libfind_process(GME) diff --git a/cmake/Modules/LibFindMacros.cmake b/cmake/Modules/LibFindMacros.cmake index 81fef7d8e..0e29dea5e 100644 --- a/cmake/Modules/LibFindMacros.cmake +++ b/cmake/Modules/LibFindMacros.cmake @@ -1,4 +1,4 @@ -# Version 2.2 +# Version 2.4 # Public Domain, originally written by Lasse Kärkkäinen # Maintained at https://github.com/Tronic/cmake-modules # Please send your improvements as pull requests on Github. @@ -52,6 +52,10 @@ function (libfind_pkg_detect PREFIX) if (libraryargs) find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) endif() + # Read pkg-config version + if (${PREFIX}_PKGCONF_VERSION) + set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE) + endif() endfunction() # Extracts a version #define from a version.h file, output stored to _VERSION. @@ -125,24 +129,39 @@ function (libfind_process PREFIX) # Process deps to add to foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) - if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) + if (DEFINED ${i}_INCLUDE_OPTS) # The package seems to export option lists that we can use, woohoo! list(APPEND includeopts ${${i}_INCLUDE_OPTS}) + else() + if (DEFINED ${i}_INCLUDE_DIR) + # Singular forms can be used + list(APPEND includeopts ${i}_INCLUDE_DIR) + else() + if (DEFINED ${i}_INCLUDE_DIRS) + # Plural forms can be used + list(APPEND includeopts ${i}_INCLUDE_DIRS) + else() + # Oh no, we don't know the option names + message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes. Aieeh!") + endif() + endif() + endif() + + if (DEFINED ${i}_LIBRARY_OPTS) + # The package seems to export option lists that we can use, woohoo! list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) else() - # If plural forms don't exist or they equal singular forms - if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR - ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES)) + if (DEFINED ${i}_LIBRARY) # Singular forms can be used - if (DEFINED ${i}_INCLUDE_DIR) - list(APPEND includeopts ${i}_INCLUDE_DIR) - endif() - if (DEFINED ${i}_LIBRARY) - list(APPEND libraryopts ${i}_LIBRARY) - endif() + list(APPEND libraryopts ${i}_LIBRARY) else() - # Oh no, we don't know the option names - message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") + if (DEFINED ${i}_LIBRARIES) + # Plural forms can be used + list(APPEND libraryopts ${i}_LIBRARIES) + else() + # Oh no, we don't know the option names + message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!") + endif() endif() endif() endforeach() @@ -209,12 +228,12 @@ function (libfind_process PREFIX) message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") message(STATUS " ${PREFIX}_LIBRARIES=${libs}") endif() - set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) - set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) - set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) - set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) - set (${PREFIX}_FOUND TRUE PARENT_SCOPE) endif() + set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) + set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) + set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) + set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) + set (${PREFIX}_FOUND TRUE PARENT_SCOPE) return() endif() -- 2.54.0 From 96eaf8850eb5d70bf6c4a2e727091bfc075055fb Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 20 Aug 2025 02:23:20 -0400 Subject: [PATCH 05/12] Add path suffix for libgme cmake module --- cmake/Modules/FindGME.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/FindGME.cmake b/cmake/Modules/FindGME.cmake index 641274e75..7e9087247 100644 --- a/cmake/Modules/FindGME.cmake +++ b/cmake/Modules/FindGME.cmake @@ -8,6 +8,7 @@ find_path(GME_INCLUDE_DIR ${GME_PKGCONF_INCLUDE_DIRS} "/usr/include/gme" "/usr/local/include/gme" + PATH_SUFFIXES gme ) find_library(GME_LIBRARY -- 2.54.0 From d9a67faf4772fd9f6efaae2ea73c53c3de670b5a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 21:09:33 +0100 Subject: [PATCH 06/12] fix windoze compile --- src/sdl/i_system.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 1d1a8b00f..52a78232f 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -30,7 +30,10 @@ #endif #include + +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #include +#endif #ifdef _WIN32 #define RPC_NO_WINDOWS_H -- 2.54.0 From a3557fadef9712f70c66ba4e166f7ea43be06c71 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 21 Jan 2026 23:38:41 +0300 Subject: [PATCH 07/12] P_PlayRinglossSound from lua might desynch so print warning about that --- src/lua_baselib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 0da8abfae..bc94e2949 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1293,6 +1293,7 @@ static int lib_pPlayRinglossSound(lua_State *L) player_t *player = NULL; mobj_t *damager = NULL; NOHUD + LUA_UsageWarning(L, "P_PlayRinglossSound: using this function from lua might cause desynchs, consider using S_StartSound(origin, sfx_khurt1 + P_RandomKey(2)) as workaround"); if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) -- 2.54.0 From 4600da5782c5c5a6bcf25ef5d56a2ba40118e063 Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 21 Jan 2026 15:54:32 -0500 Subject: [PATCH 08/12] restore SRB2_SDL2_EXE_NAME --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84aa73968..3184252da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,9 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +# Set EXE names so the assets CMakeLists can refer to its target +set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name") + include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) -- 2.54.0 From 0f7001ef5c41eccfd9d64b8190f9899958ea8506 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 13:25:07 +0100 Subject: [PATCH 09/12] opengl: tiny optimiazation for vhs effect dont call rand within the loop, use xorshift instead while not massive, we dont need to call rand thousands of times, the xorshift is visually indistinguishable this is still rather slow due to the crapton of draw calls and should best be replaced by a shader or something --- src/hardware/r_opengl/r_opengl.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 2d1f8e255..e644f5bd0 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3591,22 +3591,29 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 1.0f, -1.0f, 1.0f }; - xfix = 1/((float)screen_texsizew/(float)screen_width); - yfix = 1/((float)screen_texsizeh/(float)screen_height); - const GLfloat scrwf = (float)screen_width; const GLfloat scrwh = (float)screen_height; + xfix = 1/((float)screen_texsizew/scrwf); + yfix = 1/((float)screen_texsizeh/scrwh); + + GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); + // Slight fuzziness GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); - GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); - const float stride = 2.f/scrwh; + uint32_t r = rand(); + const float stride = 2.f/scrwh; for (i = 0; i < 1; i += stride) { - fix[2] = (float)(rand() % 128) / -22000.f * xfix; + // avoid calling rand thousands of times + r ^= r >> 13; + r ^= r >> 11; + r ^= r << 21; + + fix[2] = (float)(r & 127) / -22000.f * xfix; fix[0] = fix[2]; fix[6] = fix[0] + xfix; fix[4] = fix[2] + xfix; @@ -3648,6 +3655,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 fix[1] = fix[7] += (fix[3] - fix[7])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; + pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -3673,6 +3681,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 fix[1] = fix[7] += (fix[3] - fix[7])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; + pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -3712,7 +3721,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh { float xfix, yfix; float origaspect, newaspect; - float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen + float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen static float off[12] = { @@ -3735,19 +3744,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh if (origaspect < newaspect) { xoff = origaspect / newaspect; - yoff = 1; + yoff = 1.0f; } else if (origaspect > newaspect) { - xoff = 1; + xoff = 1.0f; yoff = newaspect / origaspect; } // float off[12]; off[0] = off[3] = -xoff; off[1] = off[10] = -yoff; - off[4] = off[7] = yoff; - off[6] = off[9] = xoff; + off[4] = off[7] = yoff; + off[6] = off[9] = xoff; // float fix[8]; fix[3] = fix[5] = yfix; -- 2.54.0 From 2e0f5c02a41e5fd0daee9322125e40f1cea6a845 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 13:25:56 +0100 Subject: [PATCH 10/12] opengl: make vhs effect bars be affected by "fuzzines" makes stuff slightly slower, but matches the software effect --- src/hardware/r_opengl/r_opengl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e644f5bd0..0caf50636 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3631,8 +3631,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 } // Upward bar - //GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); - //pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); + pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); color[0] = color[1] = color[2] = 190; color[3] = 250; @@ -3661,8 +3661,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); // Downward bar - //GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); - //pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); + pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); fix[0] = 0.0f; fix[6] = xfix; -- 2.54.0 From a1f70b0b312fb00ee09beecf8e8f951ea0c3035b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:18:06 +0100 Subject: [PATCH 11/12] opengl: attempt to scale vhs effect "fuzzyness" this makes it appear more or less the same in all resolutions, similar to software, while also improving performance quite a bit on higher resolutions --- src/hardware/r_opengl/r_opengl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 0caf50636..8bc68d15e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3605,8 +3605,10 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 uint32_t r = rand(); - const float stride = 2.f/scrwh; - for (i = 0; i < 1; i += stride) + const float dup = min(scrwf / BASEVIDWIDTH, scrwh / BASEVIDHEIGHT); + const float ystep = 2.f/scrwh * dup/4.f; + + for (i = 0; i < 1; i += ystep) { // avoid calling rand thousands of times r ^= r >> 13; -- 2.54.0 From bbf06b3376c87383d5f473279ae6d4500d5e9a8b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:25:33 +0100 Subject: [PATCH 12/12] add "vid.udup" same as vid.dup but not scaled with "highreshudscale" --- src/hardware/r_opengl/r_opengl.c | 3 +-- src/screen.h | 1 + src/v_video.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8bc68d15e..eeb40a8dc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3605,8 +3605,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 uint32_t r = rand(); - const float dup = min(scrwf / BASEVIDWIDTH, scrwh / BASEVIDHEIGHT); - const float ystep = 2.f/scrwh * dup/4.f; + const float ystep = 2.f/scrwh * (float)vid.udup/4.f; for (i = 0; i < 1; i += ystep) { diff --git a/src/screen.h b/src/screen.h index 0a912e97a..bc42e4cd3 100644 --- a/src/screen.h +++ b/src/screen.h @@ -63,6 +63,7 @@ typedef struct viddef_s INT32 dup; // scale 1, 2, 3 value for menus & overlays INT32 fdup; // same as dup, but exact value when aspect ratio isn't 320/200 + INT32 udup; // same as dup but does not account for highreshudscale UINT8 smalldup; // factor for a little bit of scaling UINT8 meddup; // factor for moderate, but not full, scaling diff --git a/src/v_video.c b/src/v_video.c index b5be19a97..8a1f36c72 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1760,17 +1760,15 @@ void V_DrawVhsEffect(boolean rewind) if (cv_reducevfx.value) return; - const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT); - - barsize = dup << 5; - updistort = dup << (rewind ? 5 : 3); + barsize = vid.udup << 5; + updistort = vid.udup << (rewind ? 5 : 3); downdistort = updistort >> 1; if (rewind) V_DrawVhsEffect(false); // experimentation - upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f)); - downbary += renderdeltatics * (dup * (rewind ? 2 : 1)); + upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f)); + downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1)); if (upbary < -barsize*FRACUNIT) upbary = vid.height << FRACBITS; @@ -3930,6 +3928,8 @@ void V_Recalc(void) vid.fdup = (vid.height*FRACUNIT) / BASEVIDHEIGHT; } + vid.udup = vid.dup; + if (loaded_config // this could use a better name, since it is more and indicator that early startup is done and its safe to do sketchy shit now :chaosleep: && (vid.width > 720) && (vid.height > 1280)) // ehhhh well this thing has so many issues, so ill lock it to higher resolutions instead { -- 2.54.0