libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
193 stars 40 forks source link

Quake 2 XP black screen after loading a level #273

Closed mbriar closed 1 year ago

mbriar commented 1 year ago

Using sdl12-compat version 1.2.60 causes the linux build of Quake 2 XP to only display a black screen after loading a level, it works fine when using real libsdl1.2 on the same system. With a debug build of Mesa, these errors are generated:

Mesa: User error: GL_INVALID_OPERATION in glDrawBuffer(invalid buffer GL_BACK)
Mesa: User error: GL_INVALID_OPERATION in glUniform(location=23)
Mesa: 9 similar GL_INVALID_OPERATION errors

See this comment in the original Mesa bug report about this for how to build and run Quake 2 XP, thanks!

sulix commented 1 year ago

Could you make sure that SDL_VIDEODRIVER=x11: it looks like quake2xp uses X11 directly in a bunch of places. This is the default (except on Fedora, I think?), but it's worth double-checking…

Also, have you tried setting SDL12COMPAT_OPENGL_SCALING=0?

Or (though it's more of a stretch), SDL12COMPAT_FORCE_GL_SWAPBUFFER_CONTEXT=1.

That being said, it looks like quake2xp is doing a few dubious things, like loading the 'qgl' symbols by directly dlopen()ing libGL.so.1. I think that might cause issues with the newer libglvnd-based setups…?

mbriar commented 1 year ago

Hey, thanks for the quick response. I ran this on x11, so it couldn't have used the wayland driver. Setting SDL12COMPAT_OPENGL_SCALING=0 does fix the issue though 🎉 Since q2xp is open source, it might be a better idea to just properly port it to SDL2 directly, but i thought it might be still worth reporting to see if it uncovers something to fix in sdl12-compat.

mbriar commented 1 year ago

Just for completeness: SDL12COMPAT_FORCE_GL_SWAPBUFFER_CONTEXT=1 does not help.

sulix commented 1 year ago

Yeah: my guess here is that because q2xp uses dlopen and dlsym directly to get the OpenGL functions, instead of using SDL_GL_GetProcAddress(), sdl12-compat is unable to hook them to make the game render to our "fake" backbuffer.

Obviously porting to SDL2 is the ideal solution (and it looked like some attempts had been made at some point, from the code). In the meantime, using SDL_GL_GetProcAddress() might fix it. Otherwise (and this may make sense anyway), we could add an entry to the quirks table in sdl12-compat to automatically disable OpenGL scaling for q2xp.

r2rX commented 1 year ago

Hey, thanks for the quick response. I ran this on x11, so it couldn't have used the wayland driver. Setting SDL12COMPAT_OPENGL_SCALING=0 does fix the issue though tada Since q2xp is open source, it might be a better idea to just properly port it to SDL2 directly, but i thought it might be still worth reporting to see if it uncovers something to fix in sdl12-compat.

Just wanted to add that I ran this in Wayland and had the same black-screen issue but SDL12COMPAT_OPENGL_SCALING=0 did fix the issue.

icculus commented 1 year ago

Latest sdl12-compat now has a quirk listed for quake2xp, so it won't need manual intervention to make this work.

If they happen to fix this to use SDL_GL_GetProcAddress instead of dlsym, we can remove the quirk and OpenGL scaling can work.

r2rX commented 1 year ago

Hey @icculus . The quake2xp project was just updated to replace dlsym with SDL_GL_GetProcAddressas, as of v1391. So intervention is not required any longer and it shouldn't be necessary to add it in the quirks list. Cheers!

icculus commented 1 year ago

Oh, awesome! I'll remove the quirk. Thanks!!

icculus commented 1 year ago

Quirk removed. :)

r2rX commented 1 year ago

:smile: :+1: