Commit graph

192 commits

Author SHA1 Message Date
Zack Middleton
99be1151f7 Fix web client vid_restart with r_mode -2
If getting the display index of the existing window fails, fallback to
the default display size instead of falling back to 640x480.

emscripten r_mode -2 worked on window creation but vid_restart fellback
to 640x480.
2024-06-24 22:38:48 -04:00
Zack Middleton
f41bd37fde Add minimal emscripten support 2024-06-06 20:51:44 -04:00
Zack Middleton
f869bffe97 OpenGL2: Fallback to OpenGL ES if OpenGL fails 2024-06-06 19:49:17 -04:00
Zack Middleton
3b984d2b51 OpenGL2: Add OpenGL ES 2.0+ support
This mainly targets OpenGL ES 2.0 but it also supports compiling GLSL as
ESSL 3.00. It's missing support for framebuffer objects which should be
possible on ES 2. (Though using renderbuffers instead of textures.)

opengl1 cvars that are not supported will display a message and disable
the cvar. This has not been reviewed for new opengl2 cvars. Enabling
cvars may cause rendering issues. Some of the broken cvars may be
possible to support using OpenGL ES 3 features.

The game displays okay with the default cvars.
2024-06-05 21:33:08 -05:00
Zack Middleton
e452b7ac04 Fix macOS client/server failing to start from terminal
The macOS client and server were completely unusable when run from a
terminal. They blocked forever in `[NSApp run];` which was called by
Sys_InitProtocolHandler(). `applicationDidFinishLaunching` was never
called to exit the NSApp run loop.

Use SDL's SDL_DROPFILE event to receive URLs to handle on macOS instead.
This also handles URLs while the game is running (connect to new server)
instead of nothing happening when clicking a link while the game is
running.
2023-06-11 11:05:13 -04:00
Zack Middleton
84da6537c4 Fix in_availableJoysticks cvar not updating
When in_restart is called or SDL controller added/remove event is
received, IN_InitJoystick() tried to update the list but instead
of updating the cvar Cvar_Get() just printed a developer message:

  Warning: cvar "in_availableJoysticks" given initial values:
  "first joystick
  ", "first joystick
  second joystick
  "
2022-09-22 10:37:30 -05:00
Zack Middleton
f92c293f7b Add keys for SDL 2.0.14's new gamepad buttons
This fixes the additional buttons triggering binds for ioq3 left
and right joystick direction keys.
2022-09-22 09:18:22 -05:00
Zack Middleton
77d6cde137 Fix compiling against SDL 2.0.17
KMOD_RESERVED was replaced with KMOD_SCROLL.
2021-08-15 12:07:02 -04:00
Zack Middleton
eacb83a244 Allow using pulseaudio for SDL audio capture
Pulseaudio audio capture didn't stop when paused on Debian 8 but works
on Debian 9 when using the same manual SDL build. So it seems to have
been an issue in pulseaudio, not SDL.
2021-02-26 23:55:12 -05:00
Thomas Köppe
d1b7ab6b22 [sdl] Turn tentative definition into actual definition.
There is no need for a tentative definition in this case. By providing
an explicit initializer, the resulting definition has the same effect
as before, but is no longer tentative. This avoids easy errors
resulting from multiple tentative definitions in different translation
units. (Previous compilers permitted those common errors, but GCC 10
rejects them by default.)
2020-11-17 18:08:13 +00:00
Zack Middleton
350b8f9c7c Restore OpenGL 1.1 support (GL_CLAMP)
GL_CLAMP (clamp to border) was changed to GL_CLAMP_TO_EDGE in 2008
(f2baf359). In 2018 (ce1d5406) I made OpenGL 1.2 be required since
GL_CLAMP_TO_EDGE is used.

Restore support for GL_CLAMP in order to support OpenGL 1.1 like vanilla
Quake 3 does. This should allow using the default Microsoft Windows
GDI Generic OpenGL 1.1 driver (untested but it won't fail the version
check at least).

From gpuinfo.org, it looks like drivers stopped advertising support for
GL_SGIS_texture_edge_clamp so use a version check in addition to the
extension check.

r_allowExtensions 0 disables using GL_CLAMP_TO_EDGE in the opengl1
renderer. GL_CLAMP support wasn't added to the opengl2 renderer.
2019-05-28 22:44:57 -05:00
Zack Middleton
0fbde293db Remove erroneous newlines from Com_Error in sdl_glimp.c 2019-05-28 21:01:28 -05:00
Zack Middleton
58b0fb07cd Fix SDL audio playback with 16-bit stereo sound
My commit last month "Fix SDL audio playback with surround sound" broke
16-bit stereo sound. S_TransferStereo16() still assumed that dma.samples
was a power of two. I also cleaned up code related to the previously
mentioned commit.
2018-10-01 22:28:51 -05:00
Zack Middleton
93dd14c9fb Disable pulseaudio capture regardless of SDL version
SDL changed version to 2.0.9 but the pulseaudio capture bug isn't fixed
yet. Remove my version check.
2018-09-30 14:53:18 -05:00
Zack Middleton
812a3dbfa5 Fix SDL audio playback with surround sound
If user has surround sound enabled, ioq3 would not play any sound.
Fix painting sound buffer for 4/5.1 audio channels. Extra channels
currently play no audio.
2018-09-13 12:58:23 -05:00
Zack Middleton
658165cfbb Don't check fixed function GL extensions when using shader pipeline
GL_TEXTURE_UNITS_ARB is not part of OpenGL ES 2 API and sets GL error.
It's not part of OpenGL 3.2 core profile either.
2018-07-20 23:40:26 -05:00
Zack Middleton
d861a4f427 Load OpenGL ES 2.0 function procs
Load functions procs supported by OpenGL ES 2.0, though there is not a
compatible renderer yet. Change argument for GLimp_Init from coreContext
to fixedFunction.
2018-07-20 23:40:21 -05:00
Zack Middleton
7391215bd4 Don't load non-core GL functions for OpenGL 3.2 core context
Also declare the GL functions in tr_local.h so there is compile error
for non-core GL functions instead of SEGFAULT from dereferencing a NULL
pointer.

Disable the non-functional stencil shadow code that hasn't been updated
to use OpenGL 3.2 core compatible drawing.
2018-07-20 23:40:17 -05:00
Zack Middleton
bead4aa8c7 Fix renderer not clearing some GL extension variables at vid_restart
If renderer is compiled into client (USE_RENDERER_DLOPEN=0) and after
start up set r_allowExtension to 0 and run vid_restart, some extension
were still used.
2018-07-20 23:40:02 -05:00
Zack Middleton
ce1d5406d5 Require OpenGL 1.2 for GL_CLAMP_TO_EDGE 2018-05-28 17:20:27 -05:00
Zack Middleton
77de5019b9 Don't create multiple windows when GL context creation fails 2018-05-28 17:07:38 -05:00
Zack Middleton
2326a060b9 Don't allow SDL audio capture using pulseaudio
When you start recording using SDL pulseaudio driver the client sends
all audio captured while not recording. 240 milliseconds of audio is
sent each frame until the capture buffer is empty. This is a problem for
privacy and causes confusing to debug VoIP playback issues on other
clients connected to server and when playing back demos.
2018-05-12 04:20:58 -05:00
Zack Middleton
92935df37b Enable SDL audio capture for SDL 2.0.5 and newer
The version check is required for supporting macOS PPC with SDL 2.0.1
and Travis-CI (Ubuntu Trusty) with SDL 2.0.2.

The client now requires SDL 2.0.5 runtime if compiled against SDL 2.0.5
or newer.
2018-04-26 11:21:36 -05:00
Ryan C. Gordon
8bd2c79109 Disable SDL audio capture until prebuilt SDL libraries are updated to 2.0.8. 2018-04-14 00:56:36 -04:00
Ryan C. Gordon
78c70d0afc Use the SDL2 audio device interface instead of the legacy 1.2 API.
This is a little bit of future-proofing, but also gives us a little more
flexibility in general; now we can add in the cvars to open a specific
device, etc, that the OpenAL codepath does.
2018-04-13 22:47:29 -04:00
Ryan C. Gordon
69f92daf08 Added audio capture support to SDL backend.
This lets you speak through VoIP when not using OpenAL. Previously you could
listen but not speak.
2018-04-13 22:38:17 -04:00
Ryan C. Gordon
2f62394174 There's no need to SDL_PauseAudio(1) before calling SDL_CloseAudio(). 2018-04-13 21:32:51 -04:00
Ryan C. Gordon
62acfb3348 sdl_snd.c should just initialize SDL audio without checking SDL_WasInit().
In SDL2, the initialized subsystems are referenced counted, so it's safe to
initialize them twice, and it makes the SDL_QuitSubSystem during our shutdown
correctly decrement the count. Before (as a probably-harmless bug), it would
not increment the refcount if the subsystem was already initialized, causing
problems when it decremented it later.
2018-04-13 21:30:26 -04:00
Ryan C. Gordon
4f8c7c2f2f Support SDL audio devices that require float32 samples.
Fixes missing audio when playing on Windows with SDL 2.0.7, which started
using WASAPI, which demands floating point audio.
2018-04-13 14:05:12 -04:00
Zack Middleton
7e9b92de12 Fix displayed color/depth/stencil bits values
The values passed to SDL are just the minimum required. Get actually
values of colorbits, depthbits, and stencilbits from SDL instead of
assuming that the engine got exactly what it asked for.
2018-04-11 01:26:00 -05:00
Zack Middleton
699cbed7c7 Fix mouse grab after toggling fullscreen
cls.glconfig.isFullscreen was not updated when changing r_fullscreen
without a vid_restart. Starting in fullscreen and switching to
windowed mode would not release the mouse.

Mods calling trap_GetGlconfig() after a fullscreen toggle now get
the correct value for isFullscreen. (Note: Mods already got the
correct value at start up and after vid_restart.)

Reported by Mickaël "mickael9" Thomas.
2018-04-09 00:05:43 -05:00
Zack Middleton
0d6edd227a Support Unicode characters greater than 0xFF in cl_consoleKeys
Unrelated: make '0x' value be -1 (invalid) instead of 0.

Reported by MAN-AT-ARMS.
2018-02-22 18:15:53 -06:00
Zack Middleton
a83ae01d93 Load OpenGL ES 1.1 function procs 2017-10-02 04:48:07 -05:00
Zack Middleton
da07a6dbd9 Support parsing OpenGL ES version strings
The renderers don't support OpenGL ES though.
2017-10-01 23:09:20 -05:00
Zack Middleton
c9d12aa3f3 Add common OpenGL version parsing + OpenGL 3 fixes
- Parse OpenGL version in sdl_glimp.c to share with both renderers.
- Add GL_VERSION_ATLEAST(major, minor) macro.
- Get address of glGetStringi if using OpenGL 3.
- Fix glConfig.extensions_string when using GL3 core context in
opengl2 renderer.
- Make opengl1 renderer's gfxinfo support qglGetStringi too.
2017-10-01 23:09:20 -05:00
Zack Middleton
20573bce43 Don't link to libGL at compile time
Get all OpenGL functions using SDL_GL_GetProcAddress(). This makes it
easier to cross-arch compile on Linux and add support for OpenGL ES
in the future.

Users still have to supply their own libSDL2 for cross-arch compiling
on Linux. But now the user does not have to re-install libgl1-mesa-dev
package for i386 or amd64 on Debian when switching between compiling
ioquake3 for x86 and x86_64.
2017-10-01 23:07:33 -05:00
Zack Middleton
098d97bdb0 Fix in_nograb not releasing the mouse cursor
Disable SDL relative mouse mode when in_nograb is enabled. Relative
mouse mode hides the cursor and it cannot exit the window regardless
of the window's grab state.

This wasn't always the case. SDL before 2.0.4 on GNU/Linux released
the mouse cursor in relative mode. However, SDL 2.0.3/4 on Windows
does not. (I did not test other Windows versions.) So I think SDL
2.0.4 made GNU/Linux X11 behavior consistent with other platforms.

This fixes mouse input being unusable when debuging client crashes
in gdb.
2017-09-10 19:11:36 -05:00
Eugene Molotov
e0a367451f ignore window resize event on fullscreen 2017-09-10 14:31:51 +05:00
Zack Middleton
63e07afae9 Make input events use earliest possible time
SDL doesn't provide exact the exact time that input events happen
so use the earliest possible time that an event could happen.

This make sub-frame input actions such as walking take affect
immediately instead of in the next frame.

Based on patch by Alexander "wareya" Nadeau.
2017-08-21 22:43:33 -05:00
Zack Middleton
34d0b78754 Improve keys using international key layouts
Always map number row to number keys for AZERTY.
Map Unicode character keys to world keys using scan code.

Based on patches by @mickael9.
2017-08-21 20:21:18 -05:00
SmileTheory
2955f8dadb Reject OpenGL contexts w/ software renderer when core context requested. 2017-08-03 14:20:33 -07:00
SmileTheory
d549b642bc OpenGL2: Use an OpenGL 3.2 core context if available. 2017-07-13 12:03:10 -07:00
Wolf
6b514ee532 Correct test for GL_EXT_texture_env_add support
The test string is missing the initial "GL_" so it is always failing the test even when supported on newer hardware.
2017-01-26 00:14:31 -08:00
SmileTheory
06b47ad2a9 GLimp_HaveExtension() -> SDL_GL_ExtensionSupported() 2016-12-10 00:35:17 -08:00
SmileTheory
c5c01e771a Fix joystick w/o controller mapping not working with SDL update. 2016-08-16 19:01:18 -07:00
SmileTheory
1cf0b21cda Fix black screen when in_joystick disabled but controller connected. 2016-08-11 00:46:43 -07:00
SmileTheory
6262972488 Fix stricmp usage in previous commit. 2016-08-08 02:43:02 -07:00
SmileTheory
b7f2ebd477 Better gamepad support. 2016-08-08 02:36:10 -07:00
SmileTheory
d09866861e Controller hot plug support. 2016-08-04 21:32:35 -07:00
Victor Roemer
398dea397c Fix Makefile for OSX
Bump base SDK from 10.5 -> 10.7
Just use the builtin __APPLE__
2016-06-12 17:17:33 -04:00