From 57eabc80f9714dd553427d8da4a7b8808deb11f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 7 Feb 2024 09:20:36 +0100 Subject: [PATCH 01/17] switchable native keyboard input taken from chaoskart this is completely non invasive --- src/d_netcmd.c | 1 + src/keys.h | 4 ++ src/sdl/i_video.c | 158 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 162 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c64804fef..1d031cded 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -817,6 +817,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); + CV_RegisterVar(&cv_nativekeyboard); CV_RegisterVar(&cv_cechotoggle); } diff --git a/src/keys.h b/src/keys.h index cf3a0d060..d78ff574d 100644 --- a/src/keys.h +++ b/src/keys.h @@ -13,6 +13,10 @@ #ifndef __KEYS_H__ #define __KEYS_H__ +#include "console.h" + +extern consvar_t cv_nativekeyboard; + // These are the key codes as posted by the keyboard handler, // ascii codes are 0->127, // scancodes are 0x80 + 0->127 diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 89c7bf555..61f30b436 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -109,6 +109,7 @@ boolean a2c = false; #endif boolean highcolor = false; +consvar_t cv_nativekeyboard = {"nativekeyboard", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void Impl_SetVsync(void); @@ -382,6 +383,156 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) return 0; } +// Get the equivalent ASCII (Unicode?) character for a keypress. +static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) +{ + SDL_Event next_event; + + // Special cases, where we always return a fixed value. + switch (sym->sym) + { + case SDLK_BACKSPACE: return KEY_BACKSPACE; + case SDLK_RETURN: return KEY_ENTER; + default: + break; + } + + // The following is a gross hack, but I don't see an easier way + // of doing this within the SDL2 API (in SDL1 it was easier). + // We want to get the fully transformed input character associated + // with this keypress - correct keyboard layout, appropriately + // transformed by any modifier keys, etc. So peek ahead in the SDL + // event queue and see if the key press is immediately followed by + // an SDL_TEXTINPUT event. If it is, it's reasonable to assume the + // key press and the text input are connected. Technically the SDL + // API does not guarantee anything of the sort, but in practice this + // is what happens and I've verified it through manual inspect of + // the SDL source code. + // + // In an ideal world we'd split out ev_keydown into a separate + // ev_textinput event, as SDL2 has done. But this doesn't work + // (I experimented with the idea), because lots of Doom's code is + // based around different responders "eating" events to stop them + // being passed on to another responder. If code is listening for + // a text input, it cannot block the corresponding keydown events + // which can affect other responders. + // + // So we're stuck with this as a rather fragile alternative. + + if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, + SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 + && next_event.type == SDL_TEXTINPUT) + { + // If an SDL_TEXTINPUT event is found, we always assume it + // matches the key press. The input text must be a single + // ASCII character - if it isn't, it's possible the input + // char is a Unicode value instead; better to send a null + // character than the unshifted key. + if (strlen(next_event.text.text) == 1 + && (next_event.text.text[0] & 0x80) == 0) + { + return next_event.text.text[0]; + } + else + { + // wtf + if (strcmp(next_event.text.text, "ç")) + return 'n'; + else if (strcmp(next_event.text.text, "ñ")) + return 'c'; + } + } + + if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9) + { + return code - SDL_SCANCODE_1 + '1'; + } + else if (code == SDL_SCANCODE_0) + { + return '0'; + } + if (code >= SDL_SCANCODE_F1 && code <= SDL_SCANCODE_F10) + { + return KEY_F1 + (code - SDL_SCANCODE_F1); + } + + switch (code) + { + // F11 and F12 are separated from the rest of the function keys + case SDL_SCANCODE_F11: return KEY_F11; + case SDL_SCANCODE_F12: return KEY_F12; + + case SDL_SCANCODE_KP_0: return KEY_KEYPAD0; + case SDL_SCANCODE_KP_1: return KEY_KEYPAD1; + case SDL_SCANCODE_KP_2: return KEY_KEYPAD2; + case SDL_SCANCODE_KP_3: return KEY_KEYPAD3; + case SDL_SCANCODE_KP_4: return KEY_KEYPAD4; + case SDL_SCANCODE_KP_5: return KEY_KEYPAD5; + case SDL_SCANCODE_KP_6: return KEY_KEYPAD6; + case SDL_SCANCODE_KP_7: return KEY_KEYPAD7; + case SDL_SCANCODE_KP_8: return KEY_KEYPAD8; + case SDL_SCANCODE_KP_9: return KEY_KEYPAD9; + + case SDL_SCANCODE_RETURN: return KEY_ENTER; + case SDL_SCANCODE_ESCAPE: return KEY_ESCAPE; + case SDL_SCANCODE_BACKSPACE: return KEY_BACKSPACE; + case SDL_SCANCODE_TAB: return KEY_TAB; + case SDL_SCANCODE_SPACE: return KEY_SPACE; + case SDL_SCANCODE_MINUS: return KEY_MINUS; + case SDL_SCANCODE_EQUALS: return KEY_EQUALS; + case SDL_SCANCODE_LEFTBRACKET: return '['; + case SDL_SCANCODE_RIGHTBRACKET: return ']'; + case SDL_SCANCODE_BACKSLASH: return '\\'; + case SDL_SCANCODE_NONUSHASH: return '#'; + case SDL_SCANCODE_SEMICOLON: return ';'; + case SDL_SCANCODE_APOSTROPHE: return '\''; + case SDL_SCANCODE_GRAVE: return '`'; + case SDL_SCANCODE_COMMA: return ','; + case SDL_SCANCODE_PERIOD: return '.'; + case SDL_SCANCODE_SLASH: return '/'; + case SDL_SCANCODE_CAPSLOCK: return KEY_CAPSLOCK; + case SDL_SCANCODE_PRINTSCREEN: return 0; // undefined? + case SDL_SCANCODE_SCROLLLOCK: return KEY_SCROLLLOCK; + case SDL_SCANCODE_PAUSE: return KEY_PAUSE; + case SDL_SCANCODE_INSERT: return KEY_INS; + case SDL_SCANCODE_HOME: return KEY_HOME; + case SDL_SCANCODE_PAGEUP: return KEY_PGUP; + case SDL_SCANCODE_DELETE: return KEY_DEL; + case SDL_SCANCODE_END: return KEY_END; + case SDL_SCANCODE_PAGEDOWN: return KEY_PGDN; + case SDL_SCANCODE_RIGHT: return KEY_RIGHTARROW; + case SDL_SCANCODE_LEFT: return KEY_LEFTARROW; + case SDL_SCANCODE_DOWN: return KEY_DOWNARROW; + case SDL_SCANCODE_UP: return KEY_UPARROW; + case SDL_SCANCODE_NUMLOCKCLEAR: return KEY_NUMLOCK; + case SDL_SCANCODE_KP_DIVIDE: return KEY_KPADSLASH; + case SDL_SCANCODE_KP_MULTIPLY: return '*'; // undefined? + case SDL_SCANCODE_KP_MINUS: return KEY_MINUSPAD; + case SDL_SCANCODE_KP_PLUS: return KEY_PLUSPAD; + case SDL_SCANCODE_KP_ENTER: return KEY_ENTER; + case SDL_SCANCODE_KP_PERIOD: return KEY_KPADDEL; + case SDL_SCANCODE_NONUSBACKSLASH: return '\\'; + + case SDL_SCANCODE_LSHIFT: return KEY_LSHIFT; + case SDL_SCANCODE_RSHIFT: return KEY_RSHIFT; + case SDL_SCANCODE_LCTRL: return KEY_LCTRL; + case SDL_SCANCODE_RCTRL: return KEY_RCTRL; + case SDL_SCANCODE_LALT: return KEY_LALT; + case SDL_SCANCODE_RALT: return KEY_RALT; + case SDL_SCANCODE_LGUI: return KEY_LEFTWIN; + case SDL_SCANCODE_RGUI: return KEY_RIGHTWIN; + default: break; + } + + if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z) + { + // get lowercase ASCII + return code - SDL_SCANCODE_A + 'a'; + } + + return 0; +} + static void SDLdoGrabMouse(void) { SDL_ShowCursor(SDL_DISABLE); @@ -696,7 +847,12 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) { return; } - event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + + if (cv_nativekeyboard.value) + event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); + else + event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + if (event.data1) D_PostEvent(&event); } -- 2.54.0 From 015cf95f4eb0531d13aa85f6702583b558eb6487 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 22:31:06 +0100 Subject: [PATCH 02/17] stimky ugly --- src/m_menu.c | 67 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 922841404..5cf720be7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1516,13 +1516,13 @@ static const char* OP_OpenGLTooltips[] = static menuitem_t OP_SoundOptionsMenu[] = { - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "SFX Volume", &cv_soundvolume, 18}, + NULL, "SFX Volume", &cv_soundvolume, 18}, - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "Music Volume", &cv_digmusicvolume, 38}, + NULL, "Music Volume", &cv_digmusicvolume, 38}, /* -- :nonnathisshit: {IT_STRING|IT_CVAR, NULL, "MIDI", &cv_gamemidimusic, 50}, @@ -1532,19 +1532,19 @@ static menuitem_t OP_SoundOptionsMenu[] = //{IT_STRING|IT_CALL, NULL, "Restart Audio System", M_RestartAudio, 50}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, - {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, + {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, - {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, - {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, - {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, - {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} }; static const char* OP_SoundTooltips[] = @@ -1571,17 +1571,17 @@ static menuitem_t OP_SoundAdvancedMenu[] = #ifdef HAVE_OPENMPT {IT_HEADER, NULL, "Tracker Module Options", NULL, 10}, - {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 - {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, #endif - {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, + {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, #endif - {IT_HEADER, NULL, "Misc", NULL, 105}, + {IT_HEADER, NULL, "Misc", NULL, 105}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, }; static const char* OP_SoundAdvancedTooltips[] = @@ -1604,11 +1604,10 @@ static const char* OP_SoundAdvancedTooltips[] = static menuitem_t OP_DataOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10}, {IT_STRING | IT_CALL, NULL, "Addon Options...", M_AddonsOptions, 20}, {IT_STRING | IT_SUBMENU, NULL, "Replay Options...", &MISC_ReplayOptionsDef, 30}, - {IT_STRING | IT_SUBMENU, NULL, "Protocol options...", &OP_ProtocolDef, 40}, + {IT_STRING | IT_SUBMENU, NULL, "Protocol options...", &OP_ProtocolDef, 40}, #ifdef HAVE_DISCORDRPC {IT_STRING | IT_SUBMENU, NULL, "Discord Options...", &OP_DiscordOptionsDef, 50}, @@ -1624,21 +1623,21 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 20}, {IT_HEADER, NULL, "Screenshots (F8)", NULL, 50}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, }; enum -- 2.54.0 From 8223ab07e40469753b7f3664c81fefcb6471e93e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 01:50:35 +0100 Subject: [PATCH 03/17] shader stuffs --- src/hardware/r_opengl/r_opengl.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8f91d5ed9..55689d976 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -822,6 +822,11 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) EXPORT void HWRAPI(SetShader) (int slot) { + if (slot == SHADER_NONE) + { + UnSetShader(); + return; + } if (gl_allowshaders) { gl_shader_t *next_shader = &gl_shaders[slot]; // the gl_shader_t we are going to switch to @@ -842,21 +847,26 @@ EXPORT void HWRAPI(SetShader) (int slot) return; } + gl_shadersenabled = false; } EXPORT void HWRAPI(UnSetShader) (void) { - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed + { + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); + if (pglUseProgram) + pglUseProgram(0); + } gl_shadersenabled = false; } + // -----------------+ // SetNoTexture : Disable texture // -----------------+ -- 2.54.0 From 4a1eab5ccd2fb6c689154f455f4d9c9ee66b142a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 01:53:11 +0100 Subject: [PATCH 04/17] more shader stuff --- src/hardware/hw_shaders.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index f9c755b0d..427bd1540 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -439,7 +439,7 @@ void HWR_LoadAllCustomShaders(void) // read every custom shader for (i = 0; i < numwadfiles; i++) - HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3)); + HWR_LoadCustomShadersFromFile(i, W_FileHasFolders(wadfiles[i])); } void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) @@ -454,7 +454,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) int i; boolean modified_shaders[NUMSHADERTARGETS] = {0}; - if (!HWR_UseShader()) + if (!gr_shadersavailable) return; lump = HWR_FindShaderDefs(wadnum); -- 2.54.0 From a0ae10018657222441b1ca57a6d2ec9eb69e89a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:02:03 +0100 Subject: [PATCH 05/17] more stuffs --- src/hardware/r_opengl/r_opengl.c | 72 +++++++++++--------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 55689d976..3a07860ed 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -8,7 +8,7 @@ // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- -/// \file +/// \file r_opengl.c /// \brief OpenGL API for Sonic Robo Blast 2 #if defined (_WIN32) @@ -26,7 +26,7 @@ #include "../../r_local.h" // For rendertimefrac, used for the leveltime shader uniform #include "r_opengl.h" #include "r_vbo.h" - +#include "../hw_shaders.h" #include "../hw_main.h" // Eeeeh not sure is this right way, but it works < sry :c < sry again it had to go :c @@ -674,29 +674,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; // -// Generic vertex shader -// - -#define GLSL_FALLBACK_VERTEX_SHADER \ - "void main()\n" \ - "{\n" \ - "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_FrontColor = gl_Color;\n" \ - "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ - "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "}\0" - -// -// Generic fragment shader -// - -#define GLSL_FALLBACK_FRAGMENT_SHADER \ - "uniform sampler2D tex;\n" \ - "uniform vec4 poly_color;\n" \ - "void main(void) {\n" \ - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ - "}\0" - void SetupGLFunc4(void) { @@ -894,7 +871,7 @@ static void GLPerspective(GLfloat fovy, GLfloat aspect) const GLfloat zNear = NEAR_CLIPPING_PLANE; const GLfloat zFar = FAR_CLIPPING_PLANE; const GLfloat radians = (GLfloat)(fovy / 2.0f * M_PIl / 180.0f); - const GLfloat sine = sin(radians); + const GLfloat sine = (GLfloat)sin(radians); const GLfloat deltaZ = zFar - zNear; GLfloat cotangent; @@ -1666,9 +1643,9 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF if (Surface != NULL) { - UNIFORM_1(shader->uniforms[gluniform_lighting], Surface->LightInfo.light_level, pglUniform1f); - UNIFORM_1(shader->uniforms[gluniform_fade_start], Surface->LightInfo.fade_start, pglUniform1f); - UNIFORM_1(shader->uniforms[gluniform_fade_end], Surface->LightInfo.fade_end, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_lighting], (GLfloat)Surface->LightInfo.light_level, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_start], (GLfloat)Surface->LightInfo.fade_start, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_end], (GLfloat)Surface->LightInfo.fade_end, pglUniform1f); } UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f); @@ -1824,31 +1801,32 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD SetBlend(PolyFlags); //TODO: inline (#pragma..) - // PolyColor if (pSurf) { - // If Modulated, mix the surface colour to the texture + // If modulated, mix the surface colour to the texture if (CurrentPolyFlags & PF_Modulated) - { - // Poly color - poly.red = byte2float[pSurf->PolyColor.s.red]; - poly.green = byte2float[pSurf->PolyColor.s.green]; - poly.blue = byte2float[pSurf->PolyColor.s.blue]; - poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; - pglColor4ubv((GLubyte*)&pSurf->PolyColor.s); + + // If the surface is either modulated or colormapped, or both + if (CurrentPolyFlags & (PF_Modulated | PF_ColorMapped)) + { + poly.red = byte2float[pSurf->PolyColor.s.red]; + poly.green = byte2float[pSurf->PolyColor.s.green]; + poly.blue = byte2float[pSurf->PolyColor.s.blue]; + poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; } - // Tint color - tint.red = byte2float[pSurf->TintColor.s.red]; - tint.green = byte2float[pSurf->TintColor.s.green]; - tint.blue = byte2float[pSurf->TintColor.s.blue]; - tint.alpha = byte2float[pSurf->TintColor.s.alpha]; + // Only if the surface is colormapped + if (CurrentPolyFlags & PF_ColorMapped) + { + tint.red = byte2float[pSurf->TintColor.s.red]; + tint.green = byte2float[pSurf->TintColor.s.green]; + tint.blue = byte2float[pSurf->TintColor.s.blue]; + tint.alpha = byte2float[pSurf->TintColor.s.alpha]; - // Fade color - fade.red = byte2float[pSurf->FadeColor.s.red]; - fade.green = byte2float[pSurf->FadeColor.s.green]; - fade.blue = byte2float[pSurf->FadeColor.s.blue]; + fade.red = byte2float[pSurf->FadeColor.s.red]; + fade.green = byte2float[pSurf->FadeColor.s.green]; + fade.blue = byte2float[pSurf->FadeColor.s.blue]; fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) -- 2.54.0 From f6f5b5caec8022a3ad6b9bd37e7a6ef2d6e04160 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:03:22 +0100 Subject: [PATCH 06/17] a --- src/hardware/r_opengl/r_opengl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3a07860ed..77a17cb80 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -673,7 +673,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; -// void SetupGLFunc4(void) { @@ -1827,14 +1826,15 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD fade.red = byte2float[pSurf->FadeColor.s.red]; fade.green = byte2float[pSurf->FadeColor.s.green]; fade.blue = byte2float[pSurf->FadeColor.s.blue]; - fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; - - if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) - { - pglActiveTexture(GL_TEXTURE2); - pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); - pglActiveTexture(GL_TEXTURE0); - lt_downloaded = pSurf->LightTableId; + fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; + + if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) + { + pglActiveTexture(GL_TEXTURE2); + pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); + pglActiveTexture(GL_TEXTURE0); + lt_downloaded = pSurf->LightTableId; + } } } -- 2.54.0 From 8cc71fb13ab66d659cdf5bb7beb8aa9f7b6aca71 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:07:54 +0100 Subject: [PATCH 07/17] e --- src/hardware/r_opengl/r_opengl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 77a17cb80..1cb3153a4 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -829,15 +829,12 @@ EXPORT void HWRAPI(SetShader) (int slot) EXPORT void HWRAPI(UnSetShader) (void) { - if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed - { - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); - } + if (pglUseProgram) + pglUseProgram(0); gl_shadersenabled = false; } -- 2.54.0 From ef076b457691c012aae07818ea2e692fbc0bb622 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:15:28 +0100 Subject: [PATCH 08/17] unhack palrendering screentex stuff --- src/hardware/r_opengl/r_opengl.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1cb3153a4..d1e04f331 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -829,12 +829,15 @@ EXPORT void HWRAPI(SetShader) (int slot) EXPORT void HWRAPI(UnSetShader) (void) { - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed + { + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); + if (pglUseProgram) + pglUseProgram(0); + } gl_shadersenabled = false; } @@ -3253,7 +3256,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height) pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); if (HWR_ShouldUsePaletteRendering()) - UnSetShader(); + pglUseProgram(0); tex_downloaded = screenTextures[tex]; } -- 2.54.0 From bfddbcde6dd20973f2246e343153f6f2cd5ae30f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:43:53 +0100 Subject: [PATCH 09/17] fix compiler complains those were for coronas code which we dont even have --- 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 d1e04f331..bb5c1fe3d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1792,7 +1792,7 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) // code that is common between DrawPolygon and DrawIndexedTriangles // DrawScreenTexture also can use this function for fancier screen texture drawing // the corona thing is there too, i have no idea if that stuff works with DrawIndexedTriangles and batching -static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD PolyFlags) +static void PreparePolygon(FSurfaceInfo *pSurf, FBITFIELD PolyFlags) { static GLRGBAFloat poly = {0,0,0,0}; static GLRGBAFloat tint = {0,0,0,0}; @@ -1846,7 +1846,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD // -----------------+ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags) { - PreparePolygon(pSurf, pOutVerts, PolyFlags); + PreparePolygon(pSurf, PolyFlags); pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s); @@ -1864,7 +1864,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray) { - PreparePolygon(pSurf, pOutVerts, PolyFlags); + PreparePolygon(pSurf, PolyFlags); pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s); @@ -2946,7 +2946,7 @@ EXPORT void HWRAPI(DrawScreenTexture)(int tex, FSurfaceInfo *surf, FBITFIELD pol pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - PreparePolygon(surf, NULL, surf ? polyflags : (PF_NoDepthTest)); + PreparePolygon(surf, surf ? polyflags : (PF_NoDepthTest)); if (!surf) pglColor4ubv(white); -- 2.54.0 From a4f52ebd101d4e4e44e84b3062687ec995680a01 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 21:56:39 +0100 Subject: [PATCH 10/17] move sprite mobj checks first --- src/hardware/hw_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4d379fe85..1fe0c8990 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4198,12 +4198,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) FSurfaceInfo Surf; INT32 shader = SHADER_NONE; - - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); - if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); if (!spr->mobj) return; @@ -4217,6 +4211,12 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) return; } + const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); + if (spr->mobj) + this_scale = FIXED_TO_FLOAT(spr->mobj->scale); + if (hires) + this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); + // cache sprite graphics //12/12/99: Hurdler: // OK, I don't change anything for MD2 support because I want to be @@ -4342,7 +4342,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) shader = SHADER_SPRITE; // sprite shader blend |= PF_ColorMapped; } - + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } } -- 2.54.0 From 46da9bf98bba9a459a40e9bad1e5dc38dc8af5b7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 22:30:25 +0100 Subject: [PATCH 11/17] we have functions for that dont check for slopes everywhere the functions already do it for us anyways --- src/hardware/hw_main.c | 49 ++++++++++-------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1fe0c8990..fdf0bb729 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -236,7 +236,6 @@ static float gr_windowcentery; static float gr_pspritexscale, gr_pspriteyscale; - static seg_t *gr_curline; static side_t *gr_sidedef; static line_t *gr_linedef; @@ -684,10 +683,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc slope = gr_frontsector->c_slope; } - // Set fixedheight to the slope's height from our viewpoint, if we have a slope - if (slope) - fixedheight = P_GetZAt(slope, viewx, viewy); - height = FIXED_TO_FLOAT(fixedheight); // Allocate plane-vertex buffer if we need to @@ -767,7 +762,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc } } - if (angle) // Only needs to be done if there's an altered angle { angle = InvAngle(angle)>>ANGLETOFINESHIFT; @@ -1151,23 +1145,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; - if (list[i].slope) - { - height = FixedToFloat(P_GetZAt(list[i].slope, v1x, v1y)); - endheight = FixedToFloat(P_GetZAt(list[i].slope, v2x, v2y)); - } - else - height = endheight = FIXED_TO_FLOAT(list[i].height); - + height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); + endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); + if (solid) { - if (*list[i].caster->b_slope) - { - bheight = FixedToFloat(P_GetZAt(*list[i].caster->b_slope, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(*list[i].caster->b_slope, v2x, v2y)); - } - else - bheight = endbheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); + height = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); + endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); } if (endheight >= endtop && height >= top) @@ -1181,13 +1165,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (i + 1 < sector->numlights) { - if (list[i+1].slope) - { - bheight = FixedToFloat(P_GetZAt(list[i+1].slope, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(list[i+1].slope, v2x, v2y)); - } - else - bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); + bheight = FixedToFloat(P_GetLightZAt(&list[i+1], v1x, v1y)); + endbheight = FixedToFloat(P_GetLightZAt(&list[i+1], v2x, v2y)); } else { @@ -4077,15 +4056,10 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (i + 1 < sector->numlights) { - if (list[i+1].slope) - { - temp = P_GetZAt(list[i+1].slope, v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); - temp = P_GetZAt(list[i+1].slope, v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); - } - else - bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); + temp = P_GetLightZAt(&list[i+1], v1x, v1y); + bheight = FIXED_TO_FLOAT(temp); + temp = P_GetLightZAt(&list[i+1], v2x, v2y); + endbheight = FIXED_TO_FLOAT(temp); } else { @@ -4238,7 +4212,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) wallVerts[2].y = wallVerts[3].y = spr->gzt; wallVerts[0].y = wallVerts[1].y = spr->gz; - // make a wall polygon (with 2 triangles), using the floor/ceiling heights, // and the 2d map coords of start/end vertices wallVerts[0].z = wallVerts[3].z = spr->z1; -- 2.54.0 From e211afa9dd89fa13d6e288f0c91a570426660de7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 22:56:26 +0100 Subject: [PATCH 12/17] dont need to check if we dont use it --- src/hardware/hw_main.c | 14 ++++++++++---- src/r_things.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fdf0bb729..f3872c488 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3819,8 +3819,10 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts // uncapped/interpolation interpmobjstate_t interp = {0}; float basey, lowy; + INT32 dist = -1; - INT32 dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) @@ -4944,10 +4946,11 @@ void HWR_ProjectSprite(mobj_t *thing) UINT8 flip; boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - + angle_t ang, camang; const boolean papersprite = (thing->frame & FF_PAPERSPRITE); INT32 heightsec, phs; + INT32 dist = -1; fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; @@ -4964,7 +4967,8 @@ void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; - INT32 dist = R_QuickCamDist(thing->x, thing->y); + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -5303,11 +5307,13 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) size_t lumpoff; unsigned rot = 0; UINT8 flip; + INT32 dist = -1; if (!thing) return; - INT32 dist = R_QuickCamDist(thing->x, thing->y); + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); // uncapped/interpolation interpmobjstate_t interp = {0}; diff --git a/src/r_things.c b/src/r_things.c index 2d9b880e0..98d2dc53a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1183,12 +1183,17 @@ static void R_ProjectSprite(mobj_t *thing) #endif fixed_t ang_scale = FRACUNIT; + + INT32 dist = -1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(thing->x, thing->y) < cv_grmaxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(oldthing, rendertimefrac, &interp); } @@ -1708,11 +1713,16 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //SoM: 3/17/2000 fixed_t gz ,gzt; + INT32 dist = 1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); + // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(thing->x, thing->y) < cv_grmaxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } -- 2.54.0 From 9f2624021163715b5cff16082c365b0bcd6f6bb2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 23:36:48 +0100 Subject: [PATCH 13/17] fix this --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f3872c488..45ad96d12 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3317,8 +3317,8 @@ void HWR_Subsector(size_t num) centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && - ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz < bottomCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { @@ -3361,8 +3361,8 @@ void HWR_Subsector(size_t num) if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && - ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz > topCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { -- 2.54.0 From 774caadc79d886d778c321fbdeb2a5118d40dbb5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 Mar 2024 17:46:45 +0100 Subject: [PATCH 14/17] only use this for text inputs not gameplay --- src/m_menu.c | 5 ++++- src/m_menu.h | 2 ++ src/sdl/i_video.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 922841404..0ff11513c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -147,6 +147,8 @@ boolean browselocalskins = false; boolean menuactive = false; boolean fromlevelselect = false; +boolean menu_text_input = false; + static INT32 coolalphatimer = 9; typedef enum @@ -3514,6 +3516,7 @@ boolean M_Responder(event_t *ev) // Handle menuitems which need a specific key handling if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) { + menu_text_input = true; if (shiftdown && ch >= 32 && ch <= 127) ch = shiftxform[ch]; routine(ch); @@ -3554,7 +3557,7 @@ boolean M_Responder(event_t *ev) { if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING) { - + menu_text_input = true; if (shiftdown && ch >= 32 && ch <= 127) ch = shiftxform[ch]; if (M_ChangeStringCvar(ch)) diff --git a/src/m_menu.h b/src/m_menu.h index 8d1ebb723..9a4cc1e92 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -91,6 +91,8 @@ void M_QuitResponse(INT32 ch); // Determines whether to show a level in the list boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); +extern boolean menu_text_input; + // flags for items in the menu // menu handle (what we do when key is pressed #define IT_TYPE 14 // (2+4+8) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 61f30b436..2b3d6d365 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -75,6 +75,7 @@ #include "../command.h" #include "sdlmain.h" #include "../i_system.h" +#include "../hu_stuff.h" // for chat_on #ifdef HWRENDER #include "../hardware/hw_main.h" #include "../hardware/hw_drv.h" @@ -848,7 +849,7 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } - if (cv_nativekeyboard.value) + if (cv_nativekeyboard.value && (chat_on || CON_Ready() || menu_text_input)) //only use this this if on chat or console event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); else event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); -- 2.54.0 From 19253f8c356c7f38aaa1c4461aadd31f6f85137b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 Mar 2024 18:13:18 +0100 Subject: [PATCH 15/17] dont use it for control setup --- src/m_menu.c | 1 + src/sdl/i_video.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 0ff11513c..324b8dc67 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3752,6 +3752,7 @@ boolean M_Responder(event_t *ev) case KEY_BACKSPACE: if ((currentMenu->menuitems[itemOn].status) == IT_CONTROL) { + menu_text_input = false; //never use native layout for control setup // detach any keys associated with the game control G_ClearControlKeys(setupcontrols, currentMenu->menuitems[itemOn].alphaKey); S_StartSound(NULL, sfx_shldls); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2b3d6d365..00400f6cb 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -849,7 +849,7 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } - if (cv_nativekeyboard.value && (chat_on || CON_Ready() || menu_text_input)) //only use this this if on chat or console + if (cv_nativekeyboard.value && (chat_on || CON_Ready() || (menu_text_input && menuactive))) //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); else event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); -- 2.54.0 From 48cd09889fa693056bb67819f078f76ae5eaddf8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 Mar 2024 18:34:09 +0100 Subject: [PATCH 16/17] dont do stuff for anything thats not in normal us ascii or smth --- src/sdl/i_video.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 00400f6cb..5a93297c5 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -429,19 +429,12 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) // ASCII character - if it isn't, it's possible the input // char is a Unicode value instead; better to send a null // character than the unshifted key. - if (strlen(next_event.text.text) == 1 - && (next_event.text.text[0] & 0x80) == 0) - { - return next_event.text.text[0]; - } - else - { - // wtf - if (strcmp(next_event.text.text, "ç")) - return 'n'; - else if (strcmp(next_event.text.text, "ñ")) - return 'c'; - } + if (strlen(next_event.text.text) == 1 && + (next_event.text.text[0] >= ' ' && next_event.text.text[0] <= '~')) { + return next_event.text.text[0]; + } else { + return '\0'; + } } if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9) @@ -483,10 +476,10 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) case SDL_SCANCODE_EQUALS: return KEY_EQUALS; case SDL_SCANCODE_LEFTBRACKET: return '['; case SDL_SCANCODE_RIGHTBRACKET: return ']'; - case SDL_SCANCODE_BACKSLASH: return '\\'; + case SDL_SCANCODE_BACKSLASH: return KEY_BACKSLASH; case SDL_SCANCODE_NONUSHASH: return '#'; case SDL_SCANCODE_SEMICOLON: return ';'; - case SDL_SCANCODE_APOSTROPHE: return '\''; + case SDL_SCANCODE_APOSTROPHE: return '\''; case SDL_SCANCODE_GRAVE: return '`'; case SDL_SCANCODE_COMMA: return ','; case SDL_SCANCODE_PERIOD: return '.'; -- 2.54.0 From a96e74d02dffb6df294c80a444e4c5be1881d842 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 Mar 2024 19:04:51 +0100 Subject: [PATCH 17/17] oops --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 5a93297c5..dbdfee229 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -476,7 +476,7 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) case SDL_SCANCODE_EQUALS: return KEY_EQUALS; case SDL_SCANCODE_LEFTBRACKET: return '['; case SDL_SCANCODE_RIGHTBRACKET: return ']'; - case SDL_SCANCODE_BACKSLASH: return KEY_BACKSLASH; + case SDL_SCANCODE_BACKSLASH: return '\\'; case SDL_SCANCODE_NONUSHASH: return '#'; case SDL_SCANCODE_SEMICOLON: return ';'; case SDL_SCANCODE_APOSTROPHE: return '\''; -- 2.54.0