Commit graph

2831 commits

Author SHA1 Message Date
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
551fa6c797 OpenGL2: Fix issues running under WebGL 2024-06-06 19:49:17 -04:00
Zack Middleton
98b9008c0d OpenGL2: Use CPU vertex animation if too few vertex attributes
OpenGL ES has a minimum of 8 vertex attributes while desktop OpenGL has
a minimum of 16. Vertex animation uses attributes 10 to 12.
2024-06-05 21:36:48 -05:00
Zack Middleton
b25a3c6e4d OpenGL2: Add run-time support for unsigned short indexes
OpenGL ES 2 is only required to support unsigned short for indexes.
2024-06-05 21:36:05 -05: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
Alan Zhao
aecf3f55ce
Use nanosleep(2) instead of usleep(3)
usleep(3) was declared obsolete in POSIX.1-2001 and removed in
POSIX.1-2008 and nanosleep(2) was recommended to be used instead.
2024-05-15 18:14:52 -04:00
Zack Middleton
5a918bfa96 opengl1: Fix skybox in OpenGL 1.1
Fix six image skybox having a black border around the sides of the sky
when using OpenGL 1.1 (using CL_CLAMP instead of GL_CLAMP_TO_EDGE).

It's technically visible in q3dm10 but it's more obvious in Team Arena
maps such as mpteam6.
2024-04-18 00:04:33 -04:00
Zack Middleton
f9547e4533 OpenGL2: Don't mix drawing to default framebuffer and FBO
Don't draw the world scene to a separate FBO from the rest of the
screen.

This fixes the world scene having HOM instead of seeing through to the
previously drawn content. World of Padman uses this to have a separate
3D scene for the sky and world in wop_padship for dynamic skybox.

This also makes r_ext_framebuffer_multisample apply to HUD models
instead of depending on r_ext_multisample (which doesn't work on Linux
with some Intel graphics).
2024-03-02 06:09:59 -05:00
Zack Middleton
7d711f8121 Fix running on Windows XP
Newer mingw-w64 changed default Windows version compatibility.
Need to specify older behavior for EnumProcesses() to avoid "missing
K32EnumProcesses()" runtime error.
2024-02-17 17:01:44 -05:00
Zack Middleton
9881c561ad OpenGL2: Fix flares behind mirror being visible
When r_ext_framebuffer_multisample > 0 was used, flares behind the
mirror in q3tourney6 were incorrectly visible. This was because it
checks scene depth in the depth prepass which only drew opaque
surfaces. It also needs to contain depth for mirror/portal surfaces.
2024-02-13 09:11:35 -05:00
Zack Middleton
5d60f6035a OpenGL2: Fix hack for tcMod transform on merged lightmaps
When using merged lightmaps, only change tcMod transform for tcGen
lightmap.
2024-02-10 16:23:54 -05:00
Zack Middleton
e3abcffeb0 OpenGL2: Fix using merged lightmaps with tcGen environment
tcGen environment generates texcoords in range of 0.0 to 1.0 and they
need to be offset to the position/size in the merged lightmap atlas.

This also needs to be after tcMods so they apply for the original range.
This fixes tcMod scale used by main_q3abanner and shinygrate1_4.

This issue was visible on the blue monitor (comp3c) near the plasmagun
in q3dm0 and the Quake III Arena banner in q3dm17.

Affected shaders in Quake 3 and Team Arena maps:

textures/base_wall/comp3
textures/base_wall/comp3b
textures/base_wall/comp3b_dark
textures/base_wall/comp3c
textures/base_wall/main_q3abanner
textures/base_wall/shinygrate1_4
textures/sfx/teslacoil

All of the shaders are used by q3dm0 but other maps also use some.
2024-02-10 16:23:54 -05:00
Zack Middleton
eaefa35580 OpenGL2: Fix merged lightmap hacks to have real lightmap index
This fixes the texcoord range to be 0.0 to 1.0 for external lightmaps in
shaders that also have an internal lightmap. (Instead of 2.0 to 3.0 for
example.) This only affects clampMap as repeating wrapping sampled the
correct location. I haven't found such a shader but I need to get real
lightmap index for future merged lightmap hacks.
2024-02-10 16:23:54 -05:00
Zack Middleton
7426ac2176 OpenGL2: Fix sun rays being affected by the viewport size
Using r_drawSunRays 1, r_hdr 0, cg_viewsize 50 caused the sun rays to
only draw properly in the bottom right quarter of the world viewport.

The scissor rectangle for the world viewport was applied to the first
FBO_FastBlit() in RB_SunRays().

Set glScissor() in FBO_FastBlit() as it's done in FBO_Blit() and
FBO_BlitFromTexture(). Sun rays probably worked correctly with r_hdr 1
because the blit for HDR changed the scissor state.
2024-02-08 16:34:05 -05:00
Zack Middleton
93abc60a5b OpenGL2: Fix applying tcMod turb
Shader stage tcMods for matrix and turb effects need to be applied in
order for turb to be correct and all tcMod turb need to be applied
instead of only the last one.

Quake 3's textures/liquids/slime1 had tcMod turb and then tcMod scale.
OpenGL2 applied the matrix first and then turb which had the wrong result.
2024-01-18 03:16:39 -05:00
Zack Middleton
5ede35d8dd Fix building QVMs on Linux with Windows line endings
On non-Windows, compiling QVM tools failed if dagcheck.md had CRLF line
endings and compiling QVMs failed if game source had CRLF line endings.

Also made Windows open the files as binary (no automatic CRLF to LF) so
it behaves the same as on non-Windows.
2023-12-26 23:26:47 -05:00
Zack Middleton
b07ff2a3ca OpenGL2: Fix parsing q3gl2_sun without two additional tokens
If mapLightScale and shadowScale weren't included at the end of
q3gl2_sun, the next shader line was skipped by SkipRestOfLine().

COM_ParseExt() with allowLineBreaks=qfalse, returns "" once and
then goes to the next line anyway. (Doesn't work well multiple
"optional" tokens. It looks like a vanilla bug.)
2023-12-23 14:31:47 -05:00
Zack Middleton
ae0878ca61 OpenGL2: Fix q3map2 lightstyles effects
Fixes World of Padman wop_trashmap.

For r_mergeLightmaps 1
- Fix tcMod transform on "map $lightmap" stages
- Fix external lightmap image texcoords if shader also has an internal
  lightmap

For r_sunlightMode 1
- Fix "tcGen lightmap" stages with blendFunc GL_SRC_ALPHA GL_ONE being
  converted to white image + modulate lightmap and drawing incorrectly
2023-12-23 14:31:47 -05:00
Zack Middleton
972635ea5a OpenGL2: Fix updating the loading screen with r_cubeMapping 1
Generating cubemaps set backEnd.viewParms.isMirror = qtrue while the
loading screen said 'loading... maps/q3dm1.bsp' and it just stayed like
that until done loading (no additional messages or item icons) because
all 2D drawing was culled due to flipped culling for isMirror.

This was noticed because a recent commit fixed RB_ShowImages() to be
drawn to the screen instead of draw into renderFbo and never blit to
the screen. Now the loading screen draws over it as expected.

Mentioned commit: a81df34905
"OpenGL2: Fix border for cg_viewsize using HDR/FB-MSAA w/postProcess"
2023-11-22 21:11:41 -05:00
Zack Middleton
03bc4eb810 OpenGL2: Fix FB-MSAA on AMD Windows driver
Fix r_ext_framebuffer_multisample > 0 causing the screen to always be
solid black when using AMD Windows driver.

The AMD Windows driver requires binding renderbuffer for it to be valid.
The OpenGL2 renderer uses GL_EXT_direct_state_access that shouldn't
require this. It would be required for Core/GL_ARB_direct_state_access.
It seems like a driver bug.
2023-11-20 18:30:12 -05:00
Zack Middleton
f7c12a1cf7 OpenGL2: Fix r_clear when using HDR/FB-MSAA 2023-11-18 22:03:22 -05:00
Zack Middleton
a81df34905 OpenGL2: Fix border for cg_viewsize using HDR/FB-MSAA w/postProcess
If using renderFBO (r_hdr 1 or r_ext_framebuffer_multisample > 0) and
r_postProcess 1, the viewport border (cg_viewsize < 100) which is drawn
before the world scene was drawn to the renderFBO but not copied to the
default framebuffer.

Now 2D before the world scene is drawn to the default framebuffer
directly for r_postProcess 1 like 2D drawn after the world scene.
2023-11-18 22:03:22 -05:00
rawr51919
d907e4781e
Merge branch 'ioquake:main' into master 2023-08-12 14:34:54 -03:00
Zack Middleton
10a45cbdc1 Don't list mod directories at Windows drive root
The mod list on Windows would search the root of the drive if
fs_basepath, fs_homepath, fs_steampath, or fs_gogpath are blank ("")
(which is usually the case).

The issue is in the low-level Sys_ListFiles() but it only affects the
mod menu, on Windows. It cannot be abused by console commands to
list system files outside of the virtual filesystem.

---

If a directory at the root of the drive of the working directory
contained a pk3 file, the directory was listed in the mods menu. The
virtual filesystem doesn't add blank directory names to the search path
so it cannot load mods from the drive root. (Unless of course you set a
fs_*path cvar to "C:\".)

Sys_ListFiles() with blank directory caused Windows to use "\*" for the
search path and "\" prefix means root of drive. Unix opendir("") failed
so nothing was listed for blank directory.

Sys_ListFilteredFiles() with blank directory _and_ specifying subdirs
could access any directory (on Windows and Unix-like) but no code uses
this or makes it accessible.

These functions are only used for initializing the virtual filesystem
and listing mods. They are not accessible by anything else such as a
console command. Only the mods menu, on Windows, is affected.
2023-07-06 05:10:06 -04: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
ineed bots
47c9641939 Fix bad client reliableAcknowledge DOS exploit
Having a reliableAcknowledge of 0x7FFFFFFF causes a massive
loop to be executed in SV_UpdateServerCommandsToClient due to the + 1 overflow.
2023-04-19 14:10:29 +01:00
Stefan Sundin
31c6d2f9d5
Add protocol handler support
This lets the user click a link in a web browser to very easily join a Quake 3 multiplayer game. As browser-based matchmaking websites become more popular, this makes it a lot more convenient and simple to play Quake 3 with others.

The links have the following URI format: quake3://connect/example.com:27950. The format has been designed to be flexible to allow more types of links in the future and avoiding having to make a breaking change. At the moment, "connect" is the only supported command.
2023-04-19 13:48:26 +01:00
Zack Middleton
4610a2403a Update MSVC .lib files to SDL 2.24.0
Built with Visual Studio 2022 with PlatformToolSet v141_xp.
x64 built with TargetName SDL264 / SDL264main to use SDL264.dll.
2023-02-19 13:08:36 -05:00
Zack Middleton
819e9830d8 Update macOS UB1 to SDL 2.0.22
Fix crash when scrolling using touchpad on macOS 10.6 (I fixed it
in SDL 2.0.18) and fix failing to start on x86 due to ioq3 SDL dylib
having absolute path instead of "@executable_path/libSDL2-2.0.0.dylib".

SDL 2.24.0 removed macOS 10.6 support (last with x86). Offically at
least, they also dropped x86_64 on macOS 10.7 and 10.8. So ioq3 UB1
is limited to SDL 2.0.22.

- Update x86 and x86_64 to SDL 2.0.22. Compiled with 10.13 SDK as
  10.14 SDK dropped running on older than macOS 10.9 and I ran
  "strip -x" on the libraries. Ad-hoc signed with PyOxidizer rcodesign.
- PPC is still MAN-AT-ARMS' SDL 2.0.1 build but I ran "strip -x"
  on it to reduce the file size.
- ARM64 build was removed from UB1 as UB2 with SDL 2.24.0 should
  be used instead.
2023-02-19 13:08:36 -05:00
Zack Middleton
02a12f2dec Update to SDL 2.24.0 and add separate macOS UB2 dylib
Update mingw and macOS SDL libraries to 2.24.0. (MSVC .lib files and
Xcode project haven't been updated.)

There is now a separate SDL dylib for macOS Universal Binary 1 and 2
because SDL 2.24.0 dropped support for macOS 10.6 (which is last to
support x86). Documentation says SDL 2.24.0 also dropped macOS 10.7
and 10.8 too. So UB2 is now 10.9 or later while 10.5 to 10.8 live in
UB1.

Compiled using osxcross with macOS 11.3 SDK. Ran "strip -x" on Windows
and macOS libraries. Ad-hoc signed dylib using PyOxidizer rcodesign to
fix digest checksums after strip.
2023-02-19 13:08:36 -05:00
Zack Middleton
70d07d91d6 Fix (disabled) Wavelet sound decompression
The first chunk of Wavelet sound was decoded as ADPCM and then
following chunks were decoded as Wavelet. It played as static
noise.

Using Wavelet compression requires engine code changes to enable.
2022-11-23 12:23:50 -06: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
kungfooman
29b0cc3a4d vm_x86.c: Add defined(_M_IX86) || defined(_M_X64) (fix for VS2019) 2022-08-18 16:32:19 -04:00
Eugene
6d74896557 More predictable mesh normals generation 2022-03-21 18:07:23 +00:00
Jack Slater
d77a7d4c90 Revert "E2K: fixed build by MCST lcc compiler when using USE_CURL=1 option"
This reverts commit daae32ddfd.
2022-03-10 15:48:14 -08:00
Jack Slater
5630e61ee4 Revert "code/curl: update ifdef condition for MCST-LCC compiler"
This reverts commit 56c83c8a72.
2022-03-10 15:47:57 -08:00
r-a-sattarov
56c83c8a72 code/curl: update ifdef condition for MCST-LCC compiler
in mcst-lcc compiler => 1.25 added a new macro definition to determine compiler
2022-03-10 14:12:06 -05:00
Johan Mattsson
c0f29642a4 Fix uninitialized variable 2022-02-05 13:27:42 +00:00
Johan Mattsson
f7b7d48766 Fix hex digit 2022-02-05 13:27:42 +00:00
Johan Mattsson
c2a0a7d986 Fix memset 2022-02-05 13:27:42 +00:00
Mickaël Thomas
84daa28267 Fix memory corruption in S_TransferPaintBuffer
When using a non-default sound configuration (such as 6 channels), after
a long time (about 4.5hours for 6 channels at 22050 Hz) an overflow will
occur in `S_TransferPaintBuffer`, causing an out of bounds write into
the dma buffer.

The problematic line is:
```
out_idx = (s_paintedtime * dma.channels) % dma.samples;
```

With `s_paintedtime` large enough, the result of the multiplication will
overflow to a negative number (since `s_paintedtime` is signed), and the
index into the output buffer will be negative.
2021-12-08 18:46:58 +00:00
Zack Middleton
75ae9119e6 Fix passing arguments to VM dylib on Apple M1
The engine function pointer to vmMain used variadic arguments but
the vmMain function in the dylib has explicit arguments. Evidently
the arguments are stored on the stack and/or registers differently.

Found by fretn.
2021-11-19 14:54:59 -05:00
Zack Middleton
fe7325be29 Improve setting Microsoft Store path
Respect configured Program Files directory and use MSSTORE_PATH for
the directory name.
2021-11-06 21:04:06 -04:00
Zack Middleton
d1d5a89aad OpenGL2: GL_DEPTH_TEXTURE_MODE was removed from OpenGL 3.0/Core
GL_DEPTH_TEXTURE_MODE defaults to GL_LUMINANCE. Code sets it here as
part of a workaround old nvidia drivers (apparently? the URL in comment
is dead). GL_DEPTH_TEXTURE_MODE was removed in OpenGL 3.0 / 3.2 Core
contexts and may be treated as an error.
2021-10-23 12:49:48 -04:00
Zack Middleton
1c8b1122c5 Fix being unable to enter Team Arena CD key
The CD key defaulted to spaces. Q3 UI uses text overwrite mode by
default so typing the CD key writes over the spaces. Team Arena UI
uses text insert mode by default so to enter the CD key the user
had to delete the spaces or toggling overwrite mode by pressing
the insert key.

Now the CD key defaults to empty so in Team Arena you can just type
it in.
2021-10-23 08:36:10 -04:00
Zack Middleton
f734a2da9a Print full GL_EXTENSIONS list for OpenGL contexts before 3.0
Printing GL_EXTENSIONS list might be cut off for OpenGL contexts
before 3.0 due to glConfig.extensions_string being a limited length.
Instead get the full extensions list directly.

This was already fixed for OpenGL 3.0 and later contexts.
2021-10-23 07:31:38 -04:00
Zack Middleton
f9ba7c667d OpenGL2: Fix r_grayscale 1 making everything solid black
Using LUMINANCE with OpenGL 3.2 Core contex results in all images being
solid black (in the menu, world, and the console). In the end the whole
screen was solid black except the intro video.

Store images in RGB and RGBA instead. This doesn't affect r_grayscale
visually. If there is issues with it now possibly using compressed
formats, then it would already be an issue for r_grayscale 0.9.
2021-10-23 06:36:45 -04:00
Tom Kidd
de055995d0
Merge pull request #482 from tomkidd/vs2019
Upgrade to build and run from VS2019
2021-10-22 16:38:11 -05:00