Commit graph

1559 commits

Author SHA1 Message Date
Yamagi Burmeister
f9c7d57180 Bump version number to 7.03pre. 2017-09-25 19:39:46 +02:00
Yamagi Burmeister
a8aad9a38a Bump version number to 7.02. 2017-09-25 19:21:04 +02:00
Yamagi Burmeister
ce2c3292c6 Force the x87 FPU to double precision mode.
The original client used single precision mode on Windows and the
default mode on all other platforms. Most platform (at least OS X,
FreeBSD, NetBSD up to 6.0, OpenBSD and Solaris) set double precision
as default, Linux sets extended double precision... When playing a
network game there're several possibilities:

* Same precision on both sides: This one is okay, of course.
* single precision <-> double precision: This one is okay, too. I guess
  this is because the code allows a small deviation between client and
  server to work around imprecisions introduced be the network protocol.
* double precision <-> extended double precision: This one is okay,
  likely for the same reasons given above.
* single precision <-> extended double precision: This one gives a lot
  of misspredictions at client side.

All of these are more or less academic these days. Yamagi Quake II used
the platforms default mode for ages. And both gcc and clang default to
SSE2 math (with double precision as default on all platforms) when
compiling for amd64. So the only reasonable case is Linux/i386 on one
side and the original client or another source port on Windows/i386 at
the other side.

Work around this by forcing the x87 to double precision mode.
2017-09-20 21:55:43 +02:00
Denis Pauk
e7199f5c41 Add support for joystick/gamecontroller(axis/buttons/hats)/haptic.
By default joystick "in_joystick" and haptic feedback haptic ("joy_haptic_magnitude")
are disabled. And can be anabled by menu in options section. Joystick/Haptic
options are showed only if have found any.

By default axis is mapped in such way:
 * Left X(joy_axis_leftx): sidemove
 * Left Y(joy_axis_lefty): forwardmove
 * Right X(joy_axis_rightx): yaw
 * Right Y(joy_axis_righty): pitch
 * Trigger Left(joy_axis_triggerleft): triggerleft
 * Trigger Right(joy_axis_triggerright): triggerright

Joystick sensitivity varibales:
 * joy_yawsensitivity,
 * joy_pitchsensitivity,
 * joy_forwardsensitivity,
 * joy_sidesensitivity,
 * joy_upsensitivity.

For change joystick axis mapping to gamecontoller axis export SDL_GAMECONTROLLERCONFIG before run,
e.g.: SDL_GAMECONTROLLERCONFIG='<joystick guid>,<joystick name>,leftx:a0,lefty:a1,rightx:a2,righty:a3,'

Add menu navigation by dpad and thresholds:
 * Add threshold for axis (based on ioquake3), 0.15 by defaults.
 * Navigate in menus by dpad (up/down, left/right, any joystick button for enter).

Defaults:
 * in_joystick "0.0"
 * joy_haptic_magnitude "0.0"
 * joy_axis_leftx "sidemove"
 * joy_axis_leftx_threshold "0.15"
 * joy_axis_lefty "forwardmove"
 * joy_axis_lefty_threshold "0.15"
 * joy_axis_rightx "yaw"
 * joy_axis_rightx_threshold "0.15"
 * joy_axis_righty "pitch"
 * joy_axis_righty_threshold "0.15"
 * joy_axis_triggerleft "triggerleft"
 * joy_axis_triggerleft_threshold "0.15"
 * joy_axis_triggerright "triggerright"
 * joy_axis_triggerright_threshold "0.15"
 * joy_forwardsensitivity "1.0"
 * joy_pitchsensitivity "1.0"
 * joy_sidesensitivity "1.0"
 * joy_upsensitivity "1.0"
 * joy_yawsensitivity "1.0"
2017-09-16 14:23:12 +03:00
Yamagi Burmeister
e1ec177dbe Remove miscframe altogether.
Miscframes are coupled to renderframes and are just checking for
renderer changes (very cheap) and advancing CD audio if implemented.
There's no reason not to that at every frame.
2017-09-09 09:39:56 +02:00
Yamagi Burmeister
eb4fdb56de Miscframes must be synchronized with renderframes.
Otherwise vid_restart triggers only if misc- and renderframes match by
luck.
2017-09-08 19:43:54 +02:00
Yamagi Burmeister
b88b3cb85d Add back function call to Cvar_Fini() removed by git in branch merge.
Don't know why git removed it.
2017-09-07 18:31:49 +02:00
Yamagi Burmeister
a0db877031 Merge remote-tracking branch 'memleak/small_mem_leak_fixes' 2017-09-07 18:30:03 +02:00
Yamagi Burmeister
6c7039af80 Revert "Remove empty function Qcommon_shutdown()."
This reverts commit ec428bb752. Looks like
the function is usefull for pull request #232.
2017-09-07 18:19:45 +02:00
Yamagi Burmeister
f3df541b79 Fix a potential crash in ai_run_melee() and ai_run_missile().
This was found and fixed by Maraakate.
2017-09-07 18:13:01 +02:00
Yamagi Burmeister
f107a77edb Fix an undefined function warning on Windows.
shared.h is needed on all platforms so include it unconditionally.
2017-09-07 18:02:31 +02:00
Yamagi Burmeister
42dfd3dbdd Refactor curtime to be set at one defined point.
Until now the curtime variable was set at every call Sys_*seconds().
That's a little bit unfortunate because calls to that functions are
scattered around the code. Instead set it once every frame in
Qcommon_Frame().
2017-09-07 17:12:58 +02:00
Yamagi Burmeister
5fa6fa9175 Sleep 850 microseconds between dedicated server frames.
The dedicated server runs at cl_maxfps frames per second. Een with very
large values one server frame can never be shorter than 1 milliseconds.
And the timing doesn't need to be very precise since the network
latency adds a lot of more jitter.
2017-09-07 14:53:00 +02:00
Yamagi Burmeister
950e581103 Untangle global variables between dedicated only and normal build. 2017-09-07 14:37:51 +02:00
Yamagi Burmeister
70f678fb80 Implement distinct versions of Qcommon_Frame() for both build types.
Yes, this duplicates some code. But it's at least 100 times more
readable to have two distinct functions for distinct purposes instead
of about 25 #ifdef.
2017-09-07 14:24:09 +02:00
Yamagi Burmeister
85890da3bb Cleanup Qcommon_Init(). 2017-09-07 13:51:52 +02:00
Yamagi Burmeister
1fc565a33b Remove unused "error" command.
"error" was a debug command to test emergency shutdowns. It's not needed
any more. Since users may complain that "error" crashes their game
remove it.
2017-09-07 13:36:17 +02:00
Yamagi Burmeister
6ab2b3227a Rename common/misc.c to common/frame.c.
Now that we moved the CRC stuff to crc.c only the frame handling is
left in this files.
2017-09-07 13:31:52 +02:00
Yamagi Burmeister
801695cf35 Move several CRC function from misc.c to crc.c.
While here remove several unused functions and variables.
2017-09-07 13:22:36 +02:00
Yamagi Burmeister
629683ab40 Also print errors when build with DEDICATED_ONLY. 2017-09-07 13:17:02 +02:00
Yamagi Burmeister
ec428bb752 Remove empty function Qcommon_shutdown(). 2017-09-07 13:05:49 +02:00
Yamagi Burmeister
d0cb89ff52 Change Windows mainloop to microseconds.
While at it have another look at it's Sys_*seconds() implementations.
Also add a Sys_Nanosleep() and use it to throttle the game a litte bit.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
0c3c2976cf Fix timedemos. 2017-09-06 18:36:51 +02:00
Yamagi Burmeister
5ece000c18 Insert 5 microseconds sleep time each frame.
This shouldn't have any noteable impact on timing (besides the machine
is way too slow for Quake II) and saves a lot of CPU cycles. 100% load
vs. 17% load on my desktop.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
a3ce70d2e3 Fix dedicated server build. 2017-09-06 18:36:51 +02:00
Yamagi Burmeister
465963a1a5 Reconnect the server to the global timing.
Having the server in an own timing zone seems to simplify things but
introduces slight timing discrepancies. The most visible effect is that
the game runs a little bit too fast, especially in the first cl_maxfps
frames.

Therefor: Remove timeframes, they're unnecessary. Track the time since
the last (client|server) frame instead and pass it to the client and
server when it's called.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
0a3c6f3786 Fix timing debug cvars and don't run the terminal console too often. 2017-09-06 18:36:51 +02:00
Yamagi Burmeister
4ac97f8a2b Remove the brake from the mainloop.
It's longer necessary now that we've refactored the global timing.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
c32f4b0e4a Move timing from CL_Frame() to Qcommon_Frame().
This allows us to implement the global timing without an artificial
brake slowing the game unnecessary down. This is only partial working,
more changes and fixes are coming.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
a0aa1c87c7 Change the global timing in main() from milli- to microseconds.
This is a no-op for now. We need this to get a much higher precision
when calculating the frame times. This changes the fixedtime cvar from
milli- to microseconds.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
f16242e923 Determine svs.realtime from curtime and not the global timing.
This is the same as the client does for it's realtime. It looks at least
somewhat more correct since it pevents rounding errors. And things are
simplified a litte bit since the server timing is now independent of the
global timing.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
79f73da62b Implement a much better / more accurate framecounter.
The old framecounter had two problems:

* It measured only the time of the current render frame, not the total
  time spend between the last and the current render frame. Therefor the
  calculated value was too high.
* It was based upon milliseconds and rather inaccurate.

This new frame counter solves both problems. The total time spend
between two render frames is measured and the measurement done in
microseconds.

There're three modes:

* cl_drawfps 1 displayes the average frame rate calculated over the last
  60 frames.
* cl_drawfps 2 displays a nice string with minimal framerate, maximum
  framerate and average framerate. All three values are calculated over
  the last 60 frames.
* cl_drawfps 3 is the same as number 2 but with a second line showing the
  raw values.

TODO:

* Discuss if cl_drawfps should be renamed to cl_showfps. All other
  status displays are named cl_show*.

While at it remove several unsused drawing functions.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
0fafaf735f Implement a Sys_Microsecond().
This is the same as the well known Sys_Milliseconds() but like the name
suggests with microsecond precision. To be used in the upcoming new
framecounter.
2017-09-06 18:36:51 +02:00
Yamagi Burmeister
406857f57a Make the Linux / Unix backend year 2038 compliant. 2017-09-06 18:36:51 +02:00
Denis Pauk
95e02d99cf update stb_image.h v2.02->v2.16 2017-09-05 21:30:37 +03:00
Daniel Gibson
0051c6b8d2 If renderer init fails and MSAA is on, disable it and try again
For some fucking reason, if you set an unsupported
SDL_GL_MULTISAMPLESAMPLES value on Windows (at least Win10 with Intel GPU
drivers, there 16 is unsupported), creating the Window and OpenGL context
will succeed, but you'll get Microsofts stupid GDI OpenGL software
implementation that only supports OpenGL 1.1.
Before these fixes, the GL3 renderer would just crash and the GL1 renderer
would fail to load, which caused the game to run in the background:
No Window, no Input, but sound was playing..

Now this problem should be handled properly and if initialization fails,
the rendering backend will be considered not working, and it will
try the gl1 backend next, and if that also fails it'll give up and exit
the game.
2017-09-04 00:21:10 +02:00
Daniel Gibson
36ef1e6bb8 Exit game if loading renderer fails
it's no fun without a  window, even if sound works you don't have input..
2017-09-04 00:18:13 +02:00
Yamagi Burmeister
aa5f63e0dc Since mkdir() isn't recursive we need to create .yq2/$moddir. 2017-08-31 17:26:32 +02:00
Yamagi Burmeister
503ab368a2 Decouple horplus and fov in the video menu.
Until now the video menu enforced:

* fov set to 90 and horplus set to 1
* fov set to something other than 90 and horplus to 0

If the user hat configured another configuration through the console the
menu would reset it, even if only unrelated changes are applied. With
this change horplus is ignored by the menu and only fov is altered. The
rationale behind this is that most users want horplus enabled and all
others can disable it through the console.

This is believed to fix issue #225.
2017-08-30 15:05:02 +02:00
David Carlier
9f71d55258 fixing couple of small memory leaks 2017-08-27 01:00:57 +01:00
Yamagi Burmeister
7f46d808d2 Second part of Developer_searchpath() removal.
This was forgotten in the first commit. :(
2017-08-07 18:10:32 +02:00
Daniel Gibson
11b3a0515a Merge branch 'searchpath' 2017-08-05 18:40:44 +02:00
Yamagi Burmeister
db2cde0325 Remove disgusting and broken Developer_searchpath() function.
It's mush better and safer to query the "game" cvar instead. It's always
set to the mods name and get's the baseq2 special case right.
2017-08-04 09:20:44 +02:00
Yamagi Burmeister
ff7772f11d Don't let baseq2/pak0.pak/maps.lst shadow baseq2/maps.lst.
While here reimplement the same hack for baseq2/players, lost somewhere
on the way. This is just another searchpath f*ckup. For some reasons
paks have a higher priority than plain directories. We do not want that
for the maps.lst and players/ since id Software decided to put updated
versions of them directly into baseq2/...

This closes issue #217.
2017-08-02 20:08:05 +02:00
Yamagi Burmeister
86fd714788 Allow to choose the fullscreen mode through the menu.
There're 3 possible values:
* no -> vid_fullsceen == 0
* keep resolution -> vid_fullscreen == 1
* switch_resolution -> vid_fullscreen == 2
2017-08-01 18:32:44 +02:00
Yamagi Burmeister
911d225496 Pass an integer to SetMode_impl() instead of a qboolean.
The functions signature was changed several commits ago.
2017-08-01 18:20:30 +02:00
Yamagi Burmeister
3f8be88e84 Fix fullscreen switch through alt-enter. 2017-08-01 18:16:24 +02:00
Daniel Gibson
6d39da37ca Print system SDL version on startup 2017-08-01 18:14:31 +02:00
Yamagi Burmeister
5e61c23fd8 Only set SDL 1.2 fullscreen if it's requested. 2017-08-01 18:11:46 +02:00
Yamagi Burmeister
908fd30148 Switch from SDL_WINDOW_FULLSCREEN to SDL_WINDOW_FULLSCREEN_DESKTOP.
SDL_WINDOW_FULLSCREEN changes the display resolution if the requested
resolution is different to the actual resultion. SDL_WINDOW_FULLSCREEN_
DESKTOP doesn't do that, it places a smaller or bigger render area
somewhere inside the fullscreen area. This is somewhat nicer with modern
high resolution flatscreens.

This commit changes vid_fullscreen 1 from SDL_WINDOW_FULLSCREEN to
SDL_WINDOW_FULLSCREEN_DESKTOP. Additional vid_fullscreen 2 is
implemented, it uses SDL_WINDOW_FULLSCREEN to create the fullscreen
area.

TL;DR: Use vid_fullscreen 1 to keep the current resolution or use
vid_fullscreen 2 to switch the resolution.

Implementation details: The whole fullscreen stuff is a horrible mess.
Like generations of hackers before me I'm not desperated enough to clean
it up. GLimp_InitGraphics() is modified to take the fullscreen mode as
an integer and not as a boolean. That's a change to the renderer API.
In GLimp_InitGraphics() the needed SDL fullscreen mode flag is
determined once at the top and just used further down below. That saves
dome SDL1 <-> SDL2 compatibility cruft. IsFullscreen() was modified to
return the actual fullscreen mode and not just if fullscreen is enabled.
2017-08-01 10:08:24 +02:00
Yamagi Burmeister
f1a8c565f1 Implement a generic case in Sys_GetBinaryDir().
Several platforms - OpenBSD being a prominent example - don't provide a
way to get the executable path. Don't abort, just return the current
dir ./ executable dir. This is just a work around, of course. The user
needs to supply a script that calls ./quake2 in the correct directory.
2017-08-01 07:12:50 +02:00
Yamagi Burmeister
e71f267de6 Just create the screenshot directory in fs_gamepath.
While here set the fs_gamedir to the last directory of the generic
search path in case that the game is reset to baseq2.
2017-07-25 09:19:17 +02:00
Yamagi Burmeister
f311308713 Remove the portable cvar, use is_portable instead.
Having a command line option and a cvar is confusing, especially since
the cvar doesn't make the game really portable.
2017-07-24 18:45:42 +02:00
Yamagi Burmeister
383f667c46 Write stdout.txt into the same dir as the config when running portable. 2017-07-24 18:38:59 +02:00
Yamagi Burmeister
7d08906bca Reimplement the portable binaries stuff.
The big problem with the old implementation was that stdout.txt and
stderr.txt on Windows became available when nearly all the low level
initialization was already done. Regardless if the client was in
normal or in portable mode.

Solve this by scanning the command line for the string '-portable'. If
it's not found, stdout and stderr are redirected as early as possible.
If found the global variable (*sigh*) is_portable is set to true. It's
evaluated later on to set the cvar 'portable', which in turn is used
be the filesystem to decide if the home directory should be added to
the search path.

Maybe we should remove the cvar and stick to the global variable.

While at it change the maximum path length for qconsole.log from
MAX_QPATH to MAX_OSPATH. At least on my Linux laptop MAX_QPATH is
too short.

This commit is still untested on Windows!
2017-07-24 11:15:00 +02:00
Yamagi Burmeister
97f7625e49 This is C, not Python... :/
!binarydir[0] == '\0' works by accident, but let's do things right...
2017-07-24 10:23:00 +02:00
Yamagi Burmeister
3ba9729946 Build a raw search path at startup. Use it to build the actual paths.
A new linked list fs_rawPath with nodes of type fsRawPath_t is added.
The new function FS_BuildRawPath() fills it at filesystem initialization
with the raw search path directories. Later FS_BuildGenericSearchPath()
and FS_BuildGameSpecificSearchPath() use it to derive the actual search
directories.
2017-07-23 09:52:32 +02:00
Yamagi Burmeister
e4b9f6884f Fix problems pointed out by @DanielGibson.
* Check pointers against NULL instead of 0.
* Checks pathes for \\ (Windows) and / (everything else).
2017-07-23 08:55:07 +02:00
Yamagi Burmeister
9efd831312 Refactoring the search path magic, step 3: Remove now used code.
Remove all functions that are no longer used:

* FS_AddGameDirectory()
* FS_SetGameDir()
* FS_AddHomeAsGameDirectory()
* FS_AddBinaryDirAsGameDirectory()

While at it try remove as much global variables from filesystem.c as
possible. Also fix a small, longstandig bug: The download code should
treat .zip and .pk3 files as pak files and not as normal directories.
2017-07-23 08:47:41 +02:00
Yamagi Burmeister
0c8e65bb68 Refactoring the search path magic, step 2: Game specific search path.
Refactor FS_SetGamedir() into FS_BuildGameSpecificSearchPath(). The new
function removes the specialized part of the search path if necessary
and create a new specialized part based upon the given directory. It
uses the FS_AddDirToSearchpath() function added in the last commit.
2017-07-23 08:47:30 +02:00
Yamagi Burmeister
9f04bc0218 Refactoring the search path magic, step 1: Generic search path.
This moves the code used to add a directory and it's paks to the search
path into one well defined function FS_AddDirToSearchPath(). Also create
a new function FS_BuildGenericSearchPath() that builds the generic part
of the global search path. This obsoletes several other, specialized
functions. They'll be removed in a later commit.
2017-07-23 08:46:38 +02:00
Yamagi Burmeister
4f803aedd2 Correct some missindentions pointed out by recent GCC versions. 2017-06-30 13:52:09 +02:00
Yamagi Burmeister
e134ae578f Reset vod_renderer to gl1 if the requested lib couldn't be loaded.
This was reported in issue #209.
2017-06-30 13:43:37 +02:00
Yamagi Burmeister
815bc34646 Bump version to 7.02pre. 2017-06-24 08:49:11 +02:00
Yamagi Burmeister
e1aadc5796 Bump version to 7.01. 2017-06-23 15:46:41 +02:00
Yamagi Burmeister
dd41ff3601 Tell Windows that we're HighDPI aware.
This prevents Windows from scaling our (fullscreen) window to crap if
the whole desktop is scaled and we're rendering more than 1080p. This is
believed to fix #208.
2017-06-21 10:17:16 +02:00
Daniel Gibson
23ea2ea034 GL3: Square particles with cvar gl3_particle_square
if that cvar is set to 1, particles aren't rendered as nice circles, but
as squares, like in the software renderer or in Quake1.

Also documented it in cvarlist.md and fixed some typos there
2017-06-20 18:31:32 +02:00
Daniel Gibson
1da7ff5594 Fix Jennell Jaquays' name in credits and quit screen
the latter is done by identifying the baseq2 pics/quit.pcx in LoadPCX()
and changing some pixels
2017-06-12 18:32:56 +02:00
Daniel Gibson
36c880e105 GL3: Update HandMadeMath.h to include my non-SSE patch
from https://github.com/StrangeZak/Handmade-Math/pull/60

Hopefully fixes #204 (broken build on ARM)
2017-06-09 12:30:44 +02:00
Yamagi Burmeister
8fa861d8e9 Bump version to 7.01pre.
While here remove missleading comment.
2017-06-08 18:12:55 +02:00
Yamagi Burmeister
95b0c6a38b Bump the version number to 7.00. 2017-06-08 17:29:51 +02:00
Yamagi Burmeister
f6e3f1f4bc Hide OpenALs doppler effect behind s_doppler.
This allows it to disable the doppler effect by setting s_doppler to 0.
The default value 1 == enabled.
2017-05-25 09:11:47 +02:00
xorw
ff54b3ac1f use correct velocity scaling for openal audio sources 2017-05-20 07:23:24 +02:00
Daniel Gibson
865e97514d GL3: Render Model shadows last, reduce global variables in gl3_mesh.c
The model shadows are rendered after all entities are rendered.
This fixes them making entity brushes below them translucent (#194)

The model rendering code used lots of global variables, many of them
totally superfluous (esp. currententity, currentmodel).
I refactored the code to use less global variables (this was at least
partly needed to render the shadows later).
So this looks like lots of changes, but many of them are just using
"entity" instead of "currententity" or "model" instead of "currentmodel"
2017-05-15 12:34:38 +02:00
Yamagi Burmeister
6119591c6a Fix build with WITH_OPENAL disabled.
This closes issue #192.
2017-05-13 16:53:20 +02:00
xorw
29d109f8ef Finished doppler shift support (added listener's velocity update) 2017-05-10 12:21:56 +02:00
Yamagi
e6d46eb452 Merge pull request #193 from xorw/master
Add partial doppler shift support for 3D audio sources.
2017-05-09 21:38:30 +02:00
xorw
da5aea4929 Add partial doppler shift support for 3D audio sources.
In game noticeable when dodging blaster projectiles or missiles :)

See: https://en.wikipedia.org/wiki/Doppler_shift
2017-05-07 06:14:10 +02:00
Daniel Gibson
9751caac85 GL3: Optimize shadow rendering
now DrawAliasShadow() only uses one draw call per model, pretty much
like DrawAliasFrameLerp()
2017-05-02 06:25:04 +02:00
Daniel Gibson
b45a6d8ef9 GL3: Simple Stencil-Shadows
Like GL1 gl_shadows + gl_stencilshadows: no shadow volumes, but looks
ok apart from standing over edges

The gl_stencilshadows cvar isn't used in GL3, it always uses the stencil
buffer if available (and if gl_shadows != 0)

This still needs performance optimizations: Like the GL1 impl it takes
lots of draw calls per model, it could be done with one per model like
when rendering the actual model.
2017-05-02 06:25:04 +02:00
Yamagi Burmeister
a31c309f68 Scale entity alpha values by 0.666f.
This makes the black hole generator (the rotating circles) in command
looking great again. :)
2017-04-27 17:33:40 +02:00
Daniel Gibson
79e9c8c3d0 GL3: gl3_intensity_2D cvar for HUD, menu, console, video intensity
there have been complaints that those things look too bright, so let
people configure their intensity independently of the general intensity
used for levels, monsters etc.

fixes #189
2017-04-25 15:02:22 +02:00
Daniel Gibson
ff6e7ede26 GL3: Apply scroll offset to x also for transparent scroll surfs
no idea where this is used, but it should be correct this way
2017-04-24 15:22:02 +02:00
Yamagi Burmeister
dd007f340a Apply scroll offset the x coordinate and not to y.
When applied to y SURF_FLOWING textures are scrolled into the wrong
direction. I guess that in GL1 the offset is also applied to x.

This fixes issue #186.
2017-04-24 14:50:00 +02:00
Yamagi Burmeister
df85228ba4 Unqueue raw samples if Vorbis playback is paused.
Without this some samples will loop forever.
2017-04-23 21:55:27 +02:00
Yamagi Burmeister
98276aeb91 Empty SDLs event queue when starting cinematic playback.
Sometimes cinematics are skipped after the first frame even if the
player didn't press any key. I'm unable to reliable reproduce that,
so my educated guess is that one or more events are still waiting in
SDLs event queue.

For example, during intermission IN_Update() is not called for 5
seconds, key presses by impatient players are just added to the queue
and not processed. The first event is used to skip leave the
intermission, the second event skips the cinematic...

Fix this by implementing a new function IN_FlushQueue() to flush SDLs
event queue and calling it when starting cinematic playback. Yes, this
is just another layer violation. :(
2017-04-22 10:29:25 +02:00
Yamagi Burmeister
c0b768278f Fix build with SDL 1.2 2017-04-22 10:24:12 +02:00
Yamagi Burmeister
eb2a11f0b2 Unqueue raw samples when the menu is entered during cinematic playback
When the client is paused (either explicit or by entering the menu or
console) the cinematic is paused, too. Therefor no more sound samples
are generated and added to the playback queue, the existing samples are
played over and over again. Until now these samples weren't hearable,
because OpenAL marked them as processed and AL_StreamUpdate() removed
them from OpenALs playback queues. This changed in the previous commit,
now the stay in OpenALs queue and are hearable.

Fix this by calling AL_UnqueueRawSamples() when the menu or console is
entered during cinematic playback.
2017-04-22 09:50:52 +02:00
Yamagi Burmeister
12fba237c2 Fix raw samples playback with newer openal-soft versions.
Newer openal-soft versions changed the way how the processed buffers are
counted when in AL_STOPPED state. Previously only processed buffers were
counted, now all buffers are. Change our unqueue logic to match this new
behavior.

This was debugged and fixed @xorw, I'm just committing the patch. This
closes issue #185.
2017-04-22 09:42:56 +02:00
Yamagi Burmeister
9bc980811f Remove s_openal_maxgain. It's unused since the previous commit. 2017-04-21 17:14:19 +02:00
Daniel Gibson
fafc4d385e Don't set AL_MAX_GAIN for OpenAL listener
it's only for sources
2017-04-21 15:43:16 +02:00
Yamagi Burmeister
9359d6d51d Some more debug / log output at refresher startup
- Print which library is loaded.
- Print the client version against which the library was build.
2017-04-20 19:57:42 +02:00
Yamagi Burmeister
a47a9daf67 Fix crash if the requested gl_msaa_samples are unavailable.
For some reasons setting the MSAA fails at window creation and not at
GL context creation. And of course SDL is unable to detect before, that
the requested number of MSAA samples is invalid... Implement a work
around: Fall back to gl_msaa_samples == 0 if the window cannot be
created.
2017-04-18 20:56:54 +02:00
Yamagi
78ca79c602 Merge pull request #181 from DanielGibson/render_dll
Resurrect support for render / refresher loadable libraries and use them to implement  an experimental OpenGL 3.2 renderer. Please note that the new renderer interface is somewhat different from the original one, old render libraries will NOT work!
2017-04-18 17:12:40 +02:00
Daniel Gibson
6e7dc59622 GL3: Deactivate STUB_ONCE() messages 2017-04-18 17:08:42 +02:00
Daniel Gibson
7d53e6ebf2 Quirk map bug in waste3 (secret not counted)
there's a target_secret (with targetname "t117"), but no one triggers
it - that's why the help computer shows four secrets, but you can only
get three of them.
Now when you open the door in front of the hidden secret armor
(by shooting it), it'll trigger the target_secret and you can get all
four secrets.

fixes #182
2017-04-15 18:38:09 +02:00
Yamagi Burmeister
0608eed7c3 Fix order of the video menu items.
The internal order of the items is determined by Menu_AddItem() and
not the y position. Without this change the cursor didn't jump from
item to item, but from the mode list box to the aspect list box,
skipping the brightness slider.
2017-04-11 14:54:22 +02:00
Yamagi Burmeister
b48108cf37 Add the renderer selection back to the video menu.
Remove the 'viewsize' slider to free one row. Use this row for the new
renderer selection. While at it reorder the items.
2017-04-10 23:15:36 +02:00
Yamagi Burmeister
df86c46e57 Several adjustments to the visual impression.
- Bump vid_gamma to 1.2 in both GL1 and GL3. A default value of 1.0 is
  too dark.
- Lower gl3_overbrightbits to 1.3, the previous value of 1.5 was too
  bright. This can be seen in later units, for example on mine1 some
  textures blended into white.
- Lower gl3_particle_size to 40. A value of 60 may be okay, but with
  gl3_particle_fade_factor 1.2 the particles take up too much screen
  estate in close range combat.

With this changes GL3 looks (at least for me) nearly the same as GL1
rendered through the removed multitexturing path.
2017-04-10 19:28:46 +02:00
Yamagi Burmeister
8316dfe3d9 Change the dynamic light cuttoff from 64 to 52.
64 was the cutoff used by GL1. Testing showed that 52 is better suited
for GL3. Good levels to test this can be found in the Mines unit.
2017-04-10 19:28:46 +02:00
Yamagi Burmeister
0314eafdaa Cap dynamic light intensity / brightness to 3.
Without capping the brightness entity models may fade into pure white
which looks ugly. This can be seen when several flyer fire blaster
bolds onto the player or when multiple barrels are exploding. This
change was suggest by @DanielGibson, I'm just the messenger.
2017-04-10 19:28:46 +02:00
Yamagi Burmeister
8c665b826c Do not enforce the Vrect to have even width and heights.
I really don't see why this constraint was ever necessary. It leads to
one line of pixels not rendered either at the bottom or the right edge
of the screen. In GL1 for whatever reasons this line is just black, in
GL3 garbage is drawn.
2017-04-10 19:22:23 +02:00
Daniel Gibson
b916d11662 GL3: gl3_particle_fade_factor cvar to configure particle softness
the higher it is, the less soft (more like in GL1) the particles look

While at it, I removed lmOffset from uni3D, as it's not used.
2017-04-10 19:04:59 +02:00
Yamagi Burmeister
e510bfc281 Fix render artifacts around health points when the HUD is scaled.
In SCR_DrawFieldScaled() the HUD scale factor wasn't taken into account
when calculating the screen area affected by the change. Therefor wrong
coordinates were passed to SCR_AddDirtyPoint() and a part of the changed
area wasn't marked dirty, leading to render artifacts.

This bug was present since HUD scaling was first introduced.
2017-04-10 15:50:48 +02:00
Yamagi Burmeister
4bd263c4d4 Some cleanup to the Makefile.
- Rename REFGL to REFGL1 for consistency with REFGL3.
- Fix some comments.
- There's no need to link flash.c and rand.c into both renderer libs.
2017-04-10 15:50:25 +02:00
Daniel Gibson
5d3f024f82 GL3: Fix GL3_Draw_Flash() for viewsize < 100 and odd resolutions
the flash should only be drawn in the part of the window where actual
3D rendering happens, not in the borders added if viewsize < 100
(and apparently also for with 1 pixel width if the resolution is odd).
2017-04-10 01:38:30 +02:00
Daniel Gibson
264df420e3 Rename vid_ref cvar to vid_renderer 2017-04-09 00:00:36 +02:00
Daniel Gibson
7fe6412d70 Fix crash if gamedata (pics/colormap.pcx) isn't found 2017-04-03 14:54:46 +02:00
Daniel Gibson
b91b244431 GL3: Cleanup (remove TODOs, STUBs and old commented out code, ...) 2017-04-03 00:23:56 +02:00
Daniel Gibson
85c8c83c4b GL3: Make sure HandmadeMath also works without SSE 2017-04-02 20:04:27 +02:00
Daniel Gibson
dbf0563565 GL3: Update HandMadeMath.h 2017-04-02 19:18:40 +02:00
Daniel Gibson
ca5dccb881 GL3: Render dynamic lights on all brush-based entities
The GL1 renderer can't do this :)
2017-04-02 18:28:19 +02:00
Daniel Gibson
35daa08c23 GL3: Split up transModelViewMat4 matrix 2017-04-02 18:21:32 +02:00
Daniel Gibson
ea6dacbc12 GL3: Rename some CVars to gl3_*, fix water brightness
* gl3_particle_size: in GL3 the particles should be a bit bigger because
  the particles fade out towards the edge, so I put it in a seperate
  CVar
* gl3_intensity: in GL3 the intensity can have any floating point value,
  in GL1 only integers, so it gets its own CVar
* gl3_overbrightbits: gl_overbrightbits had to be 1, 2 or 4, in GL3 it
  can have any floating point value.

Changed the particle scaling a bit so they look bigger.
2017-04-02 17:16:26 +02:00
Daniel Gibson
182948fecc Rename ref_gl.* to ref_gl1.* 2017-04-02 16:23:00 +02:00
Daniel Gibson
a9093fdf98 Make it work with SDL1.2 again
Some things broke when moving the renderer into a DLL, and the GL3
renderer needed some more work to work with it.
2017-04-02 05:20:24 +02:00
Daniel Gibson
9044eb1370 Load ref_* lib with absolute path, fall back to ref_gl
.. if initializing the other renderer failed.
2017-04-02 05:19:01 +02:00
Daniel Gibson
bd5b8d0aea Don't crash if re.InitContext() fails before creating context
One problem was that GL3_Shutdown() called several functions that use
that gl* function pointers - not a good idea if InitContext() failed
and the function pointers are all NULL. So check for that.
Similarly in GL3/R_ShutdownWindow() calling glClear() etc.

Another problem was that R_SetMode() would, if R_SetMode_impl() failed,
try again with a "safe" resolution (640x480 unless  we had another
working resolution before) - which is bad if we're already using that
"safe" resolution because then GLimp_InitGraphics() would check mode
and fullscreen and decide it hasn't changed and do nothing and return
true, which would make SetMode() believe everything is fine and
afterwards all hell breaks loose.
2017-04-02 05:18:44 +02:00
Daniel Gibson
3503f91234 GL3: Use dlightbits/lightflags in shader
This makes the fragment shader faster by skipping lights that haven't
marked this surface in GL3_MarkLights()

This seems to improve performance at least slightly everywhere, but
it really helps *a lot* on integrated intel GPUs like the one on their
Sandy Bridge, Ivy Bride and Haswell CPUs (those are the ones we tested).
2017-04-01 16:17:22 +02:00
Daniel Gibson
5656345d1f GL3: Dyn. Lights: Factor in angle, make it work on Win/AMD and OSX
adding dot(surfaceNormal, lightToPixelOnSurfaceNormal) to the equation,
should be Phong-y now? Looks good at least.

The Windows AMD legacy driver needed its usual manual padding..

OSX was totally weird.. There were no errors or warnings from OpenGL
at all, but the dynamic lights were just not visible.
After (too long) debugging the shader I figured out that
dynLights[i].lightIntensity was always 1, and thus
'dynLights[i].lightIntensity - distLightToPos - 64' was negative and set
to 0 with max(0, ...).
I still have no idea why that happens, but removing lightIntensity from
the struct, making lightColor a vec4 and using .a for intensity works...
2017-03-27 22:43:10 +02:00
Daniel Gibson
d5cf8c2852 GL3: Support dynamic lights (mostly) + changes for that
Dynamic lights on normal world brushes work, on brush-based entities
probably not yet properly. For this I need the model matrix in the
shader to transform vertex positions and normals to worldspace
(they already are for world brushes, but not entities that might rotate
 and move etc).
Furthermore, while they dynamic lights look nice and smooth they might
need some fine tuning in the shader..

For this to work there are two bigger changes:
* the vertex data for brushes (gl3_3D_vtx_t) now also contains the
  vertex normal
  - glpoly_t contains array of gl3_3D_vtx_t instead of 7 floats
* 3D shaders now have in vec3 normal, bound to GL3_ATTRIB_NORMAL
* There's a new UBO for light data: uniLights, containing an array of
  up to 32 dynamic lights, with data copied from gl3_newrefdef.dlights
2017-03-27 01:02:54 +02:00
Daniel Gibson
6547e08c1a GL3: Upload UBOs with glBufferData(), make it build+work on Windows..
..with Radeon 6950 using AMDs legacy driver.

For uploading UBOs it turned out that glBufferData() is faster,
sometimes a lot faster, with several drivers, especially Intel/OSX.
2017-03-25 18:19:28 +01:00
Daniel Gibson
35285a0fcd GL3: Render each Model in one draw call (as GL_TRIANGLES w/ EBO)
this increases performance a lot.

Using DG_dynarr.h for dynamic arrays collecting all the vertices and
indices of a model.
2017-03-25 17:25:17 +01:00
Daniel Gibson
4bc3a68699 GL3: Bigger, fewer Lightmap textures, cleanups
if the lightmap textures are 1024x512 instead of 128x128, all original
Q2 levels will only need one lightmap texture (instead of max 26 or so)
and even maps that needed all 127 (the 128th was the dynamic lightmap)
won't need more than 4.
This should result in less glBindTexture() calls.

(Note: When I wrote "1 lightmap texture" I meant 4, because where the
 old renderer dynamically blended the up to 4 lightmaps/surface, I put
 them in 4 textures that belong together and are alle passed to and
 blended in the fragment shader)
2017-03-25 17:22:54 +01:00
Yamagi Burmeister
e229008b72 Another try to make this utterly piece of crap portable. 2017-03-22 18:03:44 +01:00
Daniel Gibson
2e31ae0ec5 Remove/Replace unprintable characters for printing to stdout/log
some chars draw lines etc in Q2's font (conchars.pcx), but aren't
printable in ASCII.
Now they're replaced with equivalent real chars or just spaces.
2017-03-19 19:17:20 +01:00
Daniel Gibson
6b3195e942 GL3: Remove some unused variables 2017-03-19 05:56:08 +01:00
Daniel Gibson
2dc7b6e6eb GL3: Multiple lightmaps/surface with lightstyles works
not sure if this is the very best solution..
Every surface can have up to 4 lightmaps.
I now always create 4 lightmaps (in separate textures, so the
corresponding texture coordinates are identical), the "fillers" are
set to 0, so in the shader they won't make a visible difference.
(The shader always adds up lightmaps from 4 textures, but how much
 they're actually visible depends on lmScales which also will be set to
 0 if "unused")

If all this turns out to be (too) slow, there could be a special case
for surfaces with only one lightmap, I /think/ that's the most common
case by far.
2017-03-19 05:45:10 +01:00
Daniel Gibson
5abf60de89 GL3: Reintroduce RenderLightmappedPoly from old multitexturing Code
adjusted to new GL3 stuff, of course.
Also, more code for light style/lightmap scale support.
Should probably (maybe) work once we have really have 4 textures
per lightmap id.

(And then of course dynamic lights are still missing)
2017-03-19 05:45:01 +01:00
Daniel Gibson
d034362809 R_RenderBrushPoly: Don't overflow msurface_t::styles
maps could be 4 at that point.
2017-03-18 20:05:07 +01:00
Daniel Gibson
f3c78fb1c5 GL3: Theoretically support 4 lightmaps with styles (in shaders)
practically those lightmaps must be created and uploaded as textures
etc
2017-03-18 20:02:31 +01:00
Daniel Gibson
e6a534aef2 Extra shaders for rendering with lightmaps vs transparent surfaces 2017-03-18 15:41:11 +01:00
Yamagi Burmeister
4d299e26d7 Don't write stdout.txt and stderr.txt when portable.
To be able to test if the game is running portable all checks of the
portable cvar must be done after Cvar_Init(). Instead of redirecting
stdout and stderr as early as possible, delay the redirection right
after Cvar_Init(). After this change the printf() in WinMain() aren't
printed into stdout.txt, but I guess that it isn't a big problem. All
interessting stuff like the search pathes is still there.

Rename fs_portable to portable. It's no longer filesystem specific.
2017-03-13 16:24:26 +01:00
Yamagi Burmeister
3032698f95 Put console_history.txt in the binary dir when fs_portable is 1. 2017-03-13 15:41:41 +01:00
Yamagi Burmeister
00758277f1 Add a missing sanity check. attacker->classname may be NULL.
This was reported by maraakate in issue #170.
2017-03-13 14:17:51 +01:00
Yamagi Burmeister
692b64ad38 Add a cvar fs_portable. When set to 1 the game is 'portable'.
Normally Q2 writes all persistent data (the configurations, saves, etc.)
into a subdirectory in the users $HOME. That can be a problem when the
game is installed onto an thumb drive or something like that. Therefor
provide a cvar fs_portable. When set to 1 the games uses it binary dir
as it's persistent storage location.

Examples:

./quake2 +set fs_portable 1
./quake2 +set basedir ~/games/quake2 +set fs_portable 1

fs_portable is _not_ saved into the config file. It must be set at
every start!

This closed issue #158.
2017-03-13 14:12:33 +01:00
Yamagi Burmeister
4a54fdd0ed Ensure that '+set game baseq2' doesn't break the search pathes.
This is the first step to fix issue #158, consistent behavior for all
cases. This problem was also reported by @lonkamikaze through IRC.
2017-03-13 13:52:11 +01:00
Yamagi Burmeister
45cc75d2d9 Add an undocumented option for forcing busy waits.
Some people complained about the usage of non busy waits:

  * I was told that there's an input lag with nanosleep(). I still doubt
    that, but since the problem is easy to solve...
  * Some Intel CPUs throttle the GPU if the selected CPU pstate is too
    low. This is especially a problem on Haswell mobile CPUs. Keeping
    a core busy works around that.
2017-03-13 13:39:03 +01:00
Daniel Gibson
b6f68cd532 Allow setting png compression level in screenshot command
The level is between 0 and 10, use like
screenshot png 6
2017-03-13 00:50:57 +01:00
Daniel Gibson
bbf36746c8 stb_image_write.h: allow using custom zlib compress function
the one from zlib compresses better than the builtin one and might even
be faster.
2017-03-13 00:50:57 +01:00
Daniel Gibson
a1a634b95a stb_image_write.h: configurable png compress level 2017-03-12 22:33:59 +01:00
Daniel Gibson
9462063869 Screenshots can be tga, bmp, png, jpg now, using stb_image_write.h
the screenshot command now supports the filetype as optional argument
(just "screenshot" will use tga like before):
"screenshot png" will save the screenshot as PNG, same with jpg, png
and tga.
For jpg, you can even specify the quality, like "screenshot jpg 90"
(the Quality is between 1 and 100, like with libjpeg).

To reduce duplicated code, I addeed Vid_WriteScreenshot() to refimport_t
and implement most of it in the client (vid.c).
The renderer still fetches the raw image data from OpenGL or whatever
and then calls re.VidWriteScreenshot() which will write it to disk in
the format requested by the user.
2017-03-12 03:28:06 +01:00
Daniel Gibson
516c417d91 Render lightmaps together with corresponding faces; gl_overbrightbits
pass both normal texture and lightmap to shader instead of rendering the
level geometry again with the lightmap and GL_BLEND.

This is not done, some translucent surfaces are buggy now and it's only
static lightmaps. For this to work properly I'll need to add some more
shaders with and without lightmaps and use them accordingly.
For example, translucent surfaces (SURF_TRANS33/66) never have
lightmaps, neither to pertubed ones (SURF_DRAWTURB) like water and lava,
but scrolling surfaces (SURF_FLOWING) like elevators do use lightmaps
(as long as they're not also transulcent or perturbed)...
2017-03-12 03:11:29 +01:00
Daniel Gibson
13789554ba GL3: Dynamic Lightmaps (via blending)
well, seems to work, but once the lightmaps are rendered with the normal
textured faces, maybe the dynamic part can be done in shader?
(Might even look less blocky, because it's not limited to lightmap
 resolution then)
2017-03-05 17:34:53 +01:00
Daniel Gibson
2932d995fe GL3: Static Lightmaps (via blending)
not *that* cool, I wanna render them together with the normal texture..

and dynamic lightmaps are missing so most things look shitty anyway
2017-03-05 03:08:05 +01:00
Daniel Gibson
a3865db4bb GL3: rip out gl_flashblend 2017-03-04 16:38:08 +01:00
Daniel Gibson
18bfa35f9b Allow switching VSync on/off without vid_restart (for SDL2) 2017-03-04 16:31:34 +01:00
Daniel Gibson
6b21811af8 GL3: DrawNullModel()
this is used if a model can't be found/loaded
2017-02-26 20:47:37 +01:00
Daniel Gibson
613071078a GL3: render beams; common struct gl3_3D_vtx_t for vertex arrays
that struct can/should be used with gl3state.vao3D which expects data
as 7 floats (x,y,z, s,t, lms,lmt) - this is used for brushes, sprites,
the sky and more (not for models though).
(For rendering brushes the struct isn't used, the data already is in
 that format in float arrays)

beams are now rendered, they are used by the BFG and in some levels for
lasers etc
2017-02-26 05:22:39 +01:00
Daniel Gibson
977c81db5d GL3: Render sprites
and some cleanup/small stuff.

Damn, my productivity today scares me :-P
2017-02-26 04:37:22 +01:00