Commit graph

320 commits

Author SHA1 Message Date
Yamagi Burmeister
10bdaaec06 Move stb_image_write.h into vid. It's used there, only. 2018-08-07 11:45:26 +02:00
Yamagi Burmeister
af703e8cd9 Remove the old SDL 1.2 version of the icon. 2018-08-07 10:35:18 +02:00
Yamagi Burmeister
1fcd0324e0 Move the icon into the vid interface.
It's only used there.
2018-08-07 10:30:11 +02:00
Yamagi Burmeister
5bff7e1568 Move refresh.c into the client and rename to glimp_sdl.c.
The GL backends have been an integral part of the vid interface for
years.
2018-08-07 10:08:20 +02:00
Yamagi Burmeister
b805b4e044 Move vid.c and dependencies into the client.
The vid interface has been exclusive to the client for years, trace
that in the file hierarchy.
2018-08-07 10:00:21 +02:00
Yamagi Burmeister
61400d1ae8 Move input.c and input.h into the client and rename to sdl.c.
The input system backend was once used in the client and the renderers,
but for some years now it has been an integral part of the client only.
Move it there.
2018-08-07 09:43:34 +02:00
Yamagi Burmeister
956902538f Move sound.c into the sound system source and rename to sdl.c.
The OpenAL backend was already part of the sound system source. And
there's no need for the SDL backend to be part of the generic backends.
2018-08-07 09:31:08 +02:00
Yamagi Burmeister
5501c38736 Move qal.c and qal.h to the other sound system sources.
The OpenAL backends used only by the sound system, there no need to
have them in the generic part of the sources.
2018-08-07 09:23:07 +02:00
Yamagi Burmeister
63350c418e Clearify some FIXMEs and bump the renderer API.
The last commits did some bigger changes to the interaction between the
GL renderers and the client. The code is now SDL 2.0 conformant, window
and context creation are strictly distinct operations. SDL is only
initialized when necessary. Since this broke the client <-> renderer
API, bump it's version.

There a lot of things left to do for dark and cold winter evenings:

* The software renderer implements it's own window handling and
  reinitialized SDL whenever vid_restart is called. This is highly
  problematic.
* vid_fullscreen is abused to communicate changes to renderer config
  throughout the code. That's a very ugly, messy and potential very
  problematic hack. But not easy to remove.
* Some funtion calls between the client and the renderer are
  unnecessary.

The changes to the client <-> renderer interaction fixed issue #302.
2018-07-31 18:57:13 +02:00
Yamagi Burmeister
6855f97487 Reset SDLs GL state before reinitializing the renderer.
In the old world we deinitialized and reinitialized SDL each time we
restarted or changed the renderer. That would clear the whole GL state.
In the new world we let SDL running and just recreate the windows. In
some cases parts of the old renderers state would leak into the new
renderer, leading to strange problems.
2018-07-31 14:32:13 +02:00
Yamagi Burmeister
bef21c101e General cleanup of vid.c
* Reformat code and reorder functions.
* Remove unnecessary stuff.
* Move everything possible into headers.
* Implement a clean fallback logic, gl3 -> gl1 -> soft.
2018-07-31 14:32:13 +02:00
Yamagi Burmeister
b8a062e36b Cleanup and refactor gl3_sdl.c.
* Another round of general cleanup.
* Introduce gl3_libgl cvar to force a libGL.
* Fix stencil buffer tests.
* Further untangle window <-> context stuff.

The window is now fully at client side, the context at renderer side.
This is another break of the renderer API. And at least GL1 needs to
track this, it's broken for now.
2018-07-31 14:32:13 +02:00
Yamagi Burmeister
5db73a795b General cleanup of refresh.c.
* Even more syntax and code style fixes.
* Rename functions to match their actual purpose.
* Fix comments.
* SDL initialization and shutdown is now client side only. With
  SDL 1.2 finally gone there's no need to involve the renderers
  in it.

This breaks the client <-> renderer API. I haven't bumped the API
version with this commit because there're likely more changes when
I'm going through the renderer side of things. The VID backend also
needs a lot of love...

It might be a good idea to move this SDL backend files into the client
and rename them. We'll decide that at a later time.
2018-07-31 14:32:13 +02:00
Yamagi Burmeister
2099626b7b Remove SDL 1.2 support from the client side render backend. 2018-07-31 14:24:28 +02:00
Yamagi Burmeister
cc15f0c10c Remove SDL 1.2 support from the SDL sound backend.
While at it do some minor cleanup.
2018-07-31 14:24:28 +02:00
Yamagi Burmeister
3f65f7254b Some general cleanup to the input backup.
* Some globals could be made static.
* Add comments were appropriate.
* And format the file to one coding stile. What is so hard with
  keeping to one style?! MY IDE is even able to interfere the
  style from existing code...
2018-07-31 14:24:28 +02:00
Yamagi Burmeister
4fb271c2df Remove SDL 1.2 from the input backend.
SdL 1.2 had it's time and is becoming a burden. This is the first
in a series of commits that'll remove it from Quake II.
2018-07-31 14:24:28 +02:00
Yamagi Burmeister
15898a2330 Remove CDA support from code. 2018-07-31 14:24:28 +02:00
Simon McVittie
b9aac1ad9b Fix spelling of "information", and re-word a comment with multiple typos 2018-07-21 12:03:23 +01:00
Yamagi Burmeister
176f95cc7c Enable backtrace printing on FreeBSD.
FreeBSD has supported printing backtraces for years. The API is the same
as on Linux, the only difference is that libexecinfo must be linked as a
seperate library. Since the last FreeBSD version with backtrace support
(FreeBSD 9.3) went out of support some time ago unconditionally enable
the printing.
2018-07-13 14:32:31 +02:00
Daniel Gibson
eb259d0c02 Exit game if loading fallback renderer failed
If loading gl3 fails, the game tries gl1 instead.
If that fails as well, the game should quit. Now it does.
2018-07-10 21:46:53 +02:00
Yamagi Burmeister
c2525a1e53 Remove lying comment. We don't rely on on DOS filenames anymore. 2018-06-12 18:22:35 +02:00
Daniel Gibson
8643c843ef Sys_IsDir() and Sys_IsFile() for Windows
I guess now the refactored Ogg/Vorbis code should work on Windows too.

Someone should test that though..
2018-06-12 18:22:35 +02:00
Daniel Gibson
c3af040f0c More ogg/vorbis refactoring, supports GOG-style tracks now
also removed lots of code.

Windows support still missing, needs Sys_IsDir() and Sys_IsFile().
2018-06-12 18:22:35 +02:00
Simon McVittie
c61e2983fc sdl/input: Fix spelling and grammar in a log message
The misspelling of "controller" was detected by Debian's Lintian tool.

Signed-off-by: Simon McVittie <smcv@debian.org>
2018-06-12 12:17:35 +01:00
Yamagi Burmeister
8e1f8fc7c6 Deprecate SDL 1.2.
We're going to remove support for SDL 1.2 shortly after the next
release. Give the last remaining users a very clear warning about
it, error out at force them to edit the code.
2018-06-07 07:39:20 +02:00
Denis Pauk
56ea94978d [-pedantic] fix compilation waring about static array initialization
warning: string length ‘16384’ is greater than the length ‘4095’
ISO C99 compilers are required to support [-Woverlength-strings]
2018-05-20 13:55:04 +03:00
David Carlier
2f0c2f8981 - Fix addrinfo leaks. 2018-05-01 10:17:20 +00:00
maxice8
2365d4705f fix compilation on musl libc. 2018-03-29 10:29:30 -03:00
Yamagi
c68aade396
Merge pull request #275 from 0lvin/3dhaptic
Use  SDL_HAPTIC_CARTESIAN as effect direction.
2018-02-15 07:35:58 +01:00
Daniel Gibson
3acf5f0cba VID_WriteScreenshot() PNG compression level must be < 10
10 is no valid zlib compression level, so make sure it's not used

Thanks to @maraakate for pointing this out!
2018-02-15 00:39:43 +01:00
Denis Pauk
c68fd0be5b Add 3d haptic/SDL_HAPTIC_CARTESIAN with distance and orientation 2018-02-14 23:07:20 +02:00
Yamagi Burmeister
832f3f6497 Implement vid_displayrefreshrate to override the displays refresh rate.
Modern LCD displays often haven't itegral refresh rates like 60hz but
fractional ones  like 59.95hz. SDL communicates the refresh rate as
integer. On X11 the rate is rounded up or down with round(), but on
Windows it's (at least on my system with an AMD Radeon) truncated...
So on an 59.95hz display it's just 59hz, Quake II renders 0.95 frames
too few and the user sees microstutters.

And return the actual / requested display frame rate increased by one
to work around inaccuracies in Quake IIs internal timing. It should be
a problem if we're running a little bit too fast.

This is belived to fix at least a part of issue #277.

Refreshrate 2
2018-02-13 17:36:15 +01:00
Yamagi
f0240af308
Merge pull request #278 from DanielGibson/remember-addressbook
Don't forget entries of Multiplayer "Address Book"
2018-02-13 17:35:59 +01:00
Daniel Gibson
c2061e8c83 Use const char* instead of char* in NET_StringToAdr() 2018-02-12 13:37:58 +01:00
Yamagi Burmeister
1e6f790d51 Make the stdout and stderr redirects unicode aware. 2018-02-05 18:20:41 +01:00
Yamagi Burmeister
3b810ba51e Convert stb_image_write.h to Q_fopen() to be able to create screenshots. 2018-02-05 18:10:22 +01:00
Yamagi Burmeister
6b13d77c36 Change the current working directory before writing save games.
We can't rely on the game.dll being unicode conformant. Work around
that by changing the current working directory before calling into
the game.dll, pass a non unicode string to it and chang back after
we return.
2018-02-05 18:00:28 +01:00
Yamagi Burmeister
3634ed7013 Implement -datadir, deprecate the basedir cvar.
To be able to pass UTF-8 encoded pathes through cvars both the cvar
subsystem and the command parser would need a fair amount of UTF-8
understanding. And I'm not the poor soul that's going to implement
that. Therefor pass the datadir trough a global variable.
2018-02-05 16:19:02 +01:00
Yamagi Burmeister
efcaf17f69 Make SetExecutablePath() on Windows unicode compatible. 2018-02-05 10:01:21 +01:00
Yamagi Burmeister
37ea3e1d58 Introduce a wrapper Q_fopen() and replace fopen() with it.
On Unix platforms unicode is implemented through UTF-8 which is
transparent for applications. But on Windows a UTF-16 dialect is
used which needs alteration at application side. This wrapper is
another step to unicode support on Windows, now we can replace
fopen() by a function that converts our internal UTF-8 pathes to
Windows UTF-16 dialect.

This is a noop for Unix platforms. The Windows build is broken,
the compiler errors out in shared.h. This will be fixed in a
later commit.

Caveats:
* fopen() calls in 3rd party code (std_* and unzip) are not replaced.
  This may become a problem. We need to check that.
* In the Unix specific code fopen() isn't replaced since it's not
  necessayry.
2018-02-05 07:43:26 +01:00
Yamagi Burmeister
bcb7364507 Convert library loading to widechars. 2018-02-04 17:06:49 +01:00
Yamagi Burmeister
a1ba33e6d9 Declare is_portable only once in frame.c and not in each backend. 2018-02-04 16:48:40 +01:00
Yamagi Burmeister
b3562015b0 Remove Sys_SendKeyEvents().
That function did nothing, we can just call IN_Update() directly...
2018-02-04 16:45:32 +01:00
Yamagi Burmeister
54ab3f75db Don't use a DOS path for the home directory, but a UTF-8 path.
With this commit YQ2 is able to start and run on ReFS volumes. :) At
least as long as neither the binary path, the game data path nor the
path to the users home directory contain anything but ASCII characters.

Please note: This make break some corner cases with hore directories
containting unicode characters. They worked until now by pure luck.
A better solution providing full unicode support will be committed
in the next few days.
2018-02-04 13:22:27 +01:00
Yamagi Burmeister
4ca38f92fa Convert Sys_Mkdir from DOS to WinAPI.
With this we're able to create directorys with Unicode characters
anywhere in the path.
2018-02-04 13:04:31 +01:00
Yamagi Burmeister
e8c3686e4c Use MAX_OSPATH instead of MAX_QPATH.
Those are external pathes, not internal ones. MAX_QPATH with only 64
characters is much to small for them.
2018-02-04 12:59:10 +01:00
Yamagi Burmeister
0eca30cb96 Convert the Sys_Find*() functions from the old DOS interface to WinAPI.
This brings at least two big advantages:

* No more 8.3 filename fuckups. Until know base0.pak and base0.pak_bak
  was the same file for Quake II because only the first 3 characters of
  the file extension were taken into account.
* Search pathes can contain any Unicode character.
2018-02-04 12:53:50 +01:00
Yamagi Burmeister
e9615608a8 Remove CompareAtributes().
There's no need to exclude directories from search by flags. In fact
the Unix backend has worked nicely for years without it... Sadly we
can't remove the now superfluous 'canhave' and 'musthave' attributes
from Sys_FindFirst() and Sys_FindNext() since they're defined in
shared.h and may be used from custom game DLLs.
2018-02-04 11:49:03 +01:00
Yamagi Burmeister
a65401d1af Rename mem.c to hunk.c.
hunk.c better describes the purpose of the code and matches the unix
backend.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
2096d57eb8 Cleanup the system specific code.
* Remove a bunch of unnecessary functions.
* Reorder functions into logical groups. The orderig is now the same
  on Unix and Windows.

While at it add several TODOs to the code. There's not need for special
library loading functions for the game, the Windows backend still uses
a lot of old and fishy DOS functions, etc. All this will be done at a
later time.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
acb50c6907 Move the platform independent stuff from main() into Qcommon_*().
There's no need to duplicate machine independent parts of the client
initialization and the main loop for every platform.

While at it remove the nearly empty unix.h header and move Windows
main() into an own file. Not both platform have the same basic layout.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
7ee34acae8 Remove winquake.h
The only thing that header did was to include windows.h.
2018-02-04 11:35:10 +01:00
Yamagi Burmeister
cfddff132b Switch the windows backend SDLmain.
libSDLmain.a has to be linked and must run anyways. So there's no need
for us to reinvent the wheel, just rely on SDLs process setup, argument
parsing, message handling and so on. As a nice side effect this may fix
some strange bugs related to message handling and argument parsing...
2018-02-04 11:35:10 +01:00
Daniel Gibson
833738b7e7 Update stb_image_write.h to latest release (1.08)
My modifications (jpeg writing and supplying zlib compressor for better
PNG compression) have been merged upstream, so from now on updates
should be easy and painless.

(Sean renamed my stbi_png_level to stbi_write_png_compression_level)
2018-02-04 00:03:51 +01:00
Yamagi Burmeister
601a06f728 Introduce in_grab 3, always ungrap the mouse in console, menu, etc.
Until now we had 3 modes:
 0 -> never grab the mouse.
 1 -> always grab the mouse
 2 -> ungrab the mouse if the game is windowed and the console or the
      menu is opened or a cinematic is playing.

The 3rd mode is the same as the 2nd one, but without the "game is
windowed" constrained. Please note that release the mouse grab in
fullscreen may have side effects like the game loosing focus and being
unable to regain it. Especially under X11.

This was requested by @prg318 in issue #271.
2018-02-03 09:20:58 +01:00
Yamagi Burmeister
11ad28b711 Unify gl_mode and sw_mode in r_mode. 2018-01-09 14:03:45 +01:00
Yamagi Burmeister
03098715ee Rename gl_custom* to r_custom*. 2018-01-09 09:25:29 +01:00
Denis Pauk
5a24b969bc Merge commit '041d1c6cb6e1eff8d84ce883ff42c3c7f1c5f67e' into soft_render 2017-12-18 22:54:07 +02:00
Yamagi Burmeister
041d1c6cb6 Remove unused WinError() function. 2017-12-16 16:55:30 +01:00
Denis Pauk
c43e944a3d Rebase soft render from https://icculus.org/quake2/
* deleted asm code
* added support 2k+ resolutions
* SDL2 support
2017-12-11 23:33:19 +02:00
Daniel Gibson
c3d3e9fc76 Make viewing with joystick framerate-independent
otherwise looking around is faster with higher framerates, that sucks,
especially with unstable framerates (on RPi)
2017-12-02 18:54:31 +01:00
Yamagi
44da2aca3b
Merge pull request #262 from DanielGibson/fix-win-msaa-crash
Fix crash on Windows if MSAA is set to a value the driver doesn't support
2017-12-02 16:38:26 +01:00
Denis Pauk
9495fe4da9 Show real place of error and fix build with SDL1.2 2017-11-01 22:57:54 +02:00
Yamagi
7b6340ddff Merge pull request #245 from 0lvin/back_button_as_escape
Add support for use controller back button as ESC
2017-10-22 18:19:56 +02:00
Daniel Gibson
de5bd4c2c8 OSX: Fix usage of clock_get_time in Sys_Microseconds()
turns out clock_get_time() uses mach_timespec_t which is very similar
to POSIX timespec_t so we're back to just one Sys_Microseconds() function
with an #ifdef __APPLE__ for the (relatively small) differences
2017-10-22 17:54:19 +02:00
Yamagi Burmeister
3d459be4c1 Fix build on OS X that might not have clock_gettime().
Older versions of OS X don't implement clock_gettime() and no(?) version
seems to implement CLOCK_MONOTONIC. Work around this by implementing an
OS X specific variant of Sys_Microseconds() that relies on Mach APIs
provided by all OS X versions...

While at it alter the generic variant so that CLOCK_MONOTONIC is used
only if it's available. CLOCK_REALTIME as a fallback should be good
enough in most cases.

This is believed to fix issue #239.
2017-10-22 17:52:02 +02:00
Denis Pauk
61da3dffd1 Add support for use back button as ESC, as example first button in SDL_GAMECONTROLLERCONFIG 2017-10-14 18:58:19 +03:00
Yamagi Burmeister
8bfcfa7e70 Fix Sys_*seconds() on legacy Windows versions.
Returning 'microseconds / 1000ll' at the first call is wrong, the game
would thing that the first frame too way too much time. For some reason
this wirks in (my) Win10, but breaks on (my) Win7...
2017-10-02 20:48:47 +02:00
Yamagi
b1e3c90a51 Merge pull request #215 from 0lvin/joystick
Add joystick support
2017-09-25 19:41:15 +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
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
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
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
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
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
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
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
Daniel Gibson
11b3a0515a Merge branch 'searchpath' 2017-08-05 18:40:44 +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
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
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
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
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
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