jkxr/Projects/Android/jni/OpenJK/shared/sdl/sdl_window.cpp
Simon 0f7803e934 Squashed commit of the following:
commit 0c85ac4704
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 15 18:47:10 2023 +0200

    Menu updates

commit 35b89acc87
Author: Simon <simonbrown77@googlemail.com>
Date:   Sat Apr 15 12:32:35 2023 +0100

    Support for changeable fresh rate

commit 539bfa8956
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 15 00:02:59 2023 +0200

    Ensure proper menu defaults on the very first start

commit 216a225aa6
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Apr 14 22:41:24 2023 +0200

    Fix storing of force crosshair option

commit 48c2486aad
Merge: a72ca45 fcb9169
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Apr 14 22:23:24 2023 +0200

    Merge remote-tracking branch 'origin/main' into contributions

commit a72ca459c5
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Apr 14 22:19:47 2023 +0200

    Intern all default values; Remove no longer needed configuration files

commit 32c4e6eac1
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Apr 14 20:59:41 2023 +0200

    Ensure weapon adjustment is applied when resetting to defaults

commit fcb9169955
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Fri Apr 14 18:58:32 2023 +0200

    Increased default force motion trigger

commit 2433ae4110
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Fri Apr 14 18:55:56 2023 +0200

    Change Force Crosshair

commit 4ab6a6024a
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Fri Apr 14 17:01:16 2023 +0200

    Fixed player knockback.... hopefully

commit 7deeee7a6f
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Fri Apr 14 17:01:00 2023 +0200

    Increased Force Power Visibility

commit 1fdcb7c48f
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Fri Apr 14 15:16:34 2023 +0200

    Changed Brightness Range and Default

commit fada09a0bb
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Apr 13 20:38:13 2023 +0200

    Fix remote turret on-screen help

commit 82af313786
Merge: 7680cb1 d13176c
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Apr 13 18:59:46 2023 +0200

    Merge branch 'main' into contributions

commit d13176c9ba
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 13 13:29:49 2023 +0200

    New Quick Save / Load Video

commit 7680cb1288
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Wed Apr 12 22:26:44 2023 +0200

    Fix use action when controlling droid; fix droid view help

commit 4d90595139
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 12 18:21:10 2023 +0200

    Fencing Speed on Pico default

commit 37d5ac4184
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 12 18:12:07 2023 +0200

    Changes to TBDC

    Different menu text + added vanilla mode

commit d6e40ead64
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 12 17:44:29 2023 +0200

    Set Fencing Speed back to Default (by Default)

commit 3f7d116e25
Merge: 7424628 c7c66e4
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 12 14:50:26 2023 +0200

    Merge branch 'main' of https://github.com/DrBeef/JKXR

commit 7424628a5d
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 12 14:50:23 2023 +0200

    Updated Weapons

    + Shader fix for FX mod

commit c7c66e46a7
Author: Simon <simonbrown77@googlemail.com>
Date:   Wed Apr 12 08:37:36 2023 +0100

    Revert "Arrange quick save icons horizontally"

    This reverts commit 20f8fff3fe.

    Also make the icons white

commit fa54045159
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 11 21:02:29 2023 +0100

    Update .gitignore

commit 20f8fff3fe
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 11 21:00:09 2023 +0100

    Arrange quick save icons horizontally

commit d3dcac8f9d
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 11 20:58:56 2023 +0100

    Save game crash fix in JKO

commit 6314561b52
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 11 08:49:42 2023 +0100

    Switch selector on offhand using offhand thumbstick

commit 3b2ffd7289
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 11 08:39:32 2023 +0100

    Attempted fix for save game crash

    - Not really a proper fix, but might at least workaround it

commit c135eefa05
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 11 08:38:54 2023 +0100

    Fixed save/load icon image size

commit f51270a294
Merge: a2ff16b e243d0b
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Apr 10 19:42:11 2023 +0100

    Merge branch 'main' of https://github.com/DrBeef/JKXR

commit a2ff16b576
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Apr 10 19:42:06 2023 +0100

    Quick Save/Load in Selector

    Haven't been able to test yet!

commit e243d0bdfa
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Mon Apr 10 18:29:18 2023 +0200

    Update README.md

commit b9d0314a6a
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sun Apr 9 19:38:32 2023 +0200

    Make getting into AT-ST easier

commit d121206f83
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 8 22:49:28 2023 +0200

    Tune touch gesture distance; Improve use interaction in 3rd person.

commit 260d501776
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 8 22:34:59 2023 +0200

    Fix and improve weapon adjustment helper axes

commit a6318867bb
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 6 20:35:02 2023 +0200

    Update README.md

commit 4a1d90e729
Merge: 425db0f 821a56d
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Apr 6 19:12:07 2023 +0200

    Merge branch 'main' into contributions

commit 821a56d4b9
Author: Simon Brown <simonbrown77@googlemail.com>
Date:   Thu Apr 6 17:24:20 2023 +0100

    Update README.md

commit 67b7d26de8
Merge: b407932 ccd63d4
Author: Simon Brown <simonbrown77@googlemail.com>
Date:   Thu Apr 6 16:54:01 2023 +0100

    Merge pull request #4 from DrBeef/TBDC

    TBDC Scales in Code

commit b407932bb2
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 6 17:43:26 2023 +0200

    Update README.md

commit 174c3ce96c
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 6 17:33:33 2023 +0200

    Update README.md

commit e9af8e87c2
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 6 17:23:36 2023 +0200

    Update README.md

commit ccd63d4eec
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 6 16:57:36 2023 +0200

    Forced for Extended Menu

commit d6b3e8eb65
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Thu Apr 6 16:55:02 2023 +0200

    TBDC Scales in Code

commit a5f3adf725
Author: Simon Brown <simonbrown77@googlemail.com>
Date:   Thu Apr 6 15:04:07 2023 +0100

    Update README.md

commit 316c2a2904
Merge: 387c34b 90b694f
Author: Simon Brown <simonbrown77@googlemail.com>
Date:   Thu Apr 6 10:02:01 2023 +0100

    Merge pull request #2 from DrBeef/TBDC

    Team Beef Directors Cut

commit 387c34b53e
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Apr 6 09:59:18 2023 +0100

    Update Beef Crawl

commit a271b61ac7
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Apr 6 09:58:18 2023 +0100

    Switch to use Bummser's NPC file if TBDC is disabled

commit a2f1644d72
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Apr 6 08:39:02 2023 +0100

    Update version to 1.0.0 for release

commit f785fdc393
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Apr 6 08:00:11 2023 +0100

    update github banner

    Update README.md

    Update README.md

    Update README.md

    Update README.md

    Update README.md

    Added Team Beef Patreon banner

commit 90b694ff60
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 5 22:21:41 2023 +0200

    Last Cleanup

commit 70468332d6
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 5 22:19:45 2023 +0200

    TBDC Cleanup

commit 6660e8c984
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 5 21:58:00 2023 +0200

    Credits / NPC Scale

commit e1b03fdcc6
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 5 21:57:07 2023 +0200

    Fixing Quick Save

commit 95950f2390
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 5 20:08:10 2023 +0200

    Updated ratios per difficulty

commit d6235ef199
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Wed Apr 5 00:30:35 2023 +0200

    Darkened Menu GFX

commit a3fdb460c4
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Apr 4 23:03:31 2023 +0100

    Prevent crash when throwing Saber

    seems it is indexing the g2 model surface that doesn't exist, might be something to do with the new hilt and the old hilt being in the save. Not sure, but this stops it crashing.

commit 4c751fcb59
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Tue Apr 4 23:59:12 2023 +0200

    Y Close Datapad

commit a1216665c8
Merge: 1939a26 d841464
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Tue Apr 4 23:48:20 2023 +0200

    Merge pull request #1 from DrBeef/main

    Main -> TDBC

commit 1939a26542
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Tue Apr 4 23:37:41 2023 +0200

    TBDC

    Laser Saber deflections
    Guns balancing.

commit d841464924
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Apr 4 21:59:31 2023 +0200

    Update help resources and menu

commit 425db0f108
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Apr 4 21:59:31 2023 +0200

    Update help resources and menu

commit 3c895d27de
Merge: fe9e12a c3819fa
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Apr 4 21:05:48 2023 +0200

    Merge branch 'main' into contributions

commit c3819fa407
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Mon Apr 3 00:36:57 2023 +0200

    Demo folder assets fix

commit fe9e12a3f9
Merge: d79f57b 2b255ac
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Mon Apr 3 22:55:29 2023 +0200

    Merge branch 'main' into contributions

commit 2b255ac3ea
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Apr 3 21:26:39 2023 +0100

    Improved version string

commit 62284414d0
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Apr 3 21:26:20 2023 +0100

    Ensure intro vid can be skipped without having to press trigger first

commit 65674abe2a
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Mon Apr 3 21:36:35 2023 +0200

    Fix Controller Location Buzz for Quick Save / Load

commit ba2e726a79
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Mon Apr 3 00:36:57 2023 +0200

    Demo folder assets fix

commit 7175c872a9
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Mon Apr 3 00:36:46 2023 +0200

    Knockback settings TBDC

commit cc7e73d04a
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Apr 2 22:59:47 2023 +0100

    Update beef_crawl.tga

commit dd71a05e36
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Apr 2 22:51:49 2023 +0100

    Put version at the bottom of the main menu

commit cb52d310c1
Author: Grant Bagwell <general@grantbagwell.co.uk>
Date:   Sun Apr 2 23:18:28 2023 +0200

    TBDC Weapons

commit ac71f24e78
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sun Apr 2 18:43:10 2023 +0200

    Updated control scheme picture

commit 3f5c767e8d
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Apr 2 19:42:42 2023 +0100

    Update AndroidManifest.xml

commit 64ab392fc5
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Apr 2 19:42:39 2023 +0100

    JKA: Some CVAR change to increase performance

commit d43de53e8a
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Apr 2 19:41:50 2023 +0100

    Added missed saber blocking check

    might explain why some people find JKA a bit easy if it is auto-blocking in 1st person

commit 8b23e255d8
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Apr 2 19:41:16 2023 +0100

    Update open xr headers

commit d79f57ba2d
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sun Apr 2 18:43:10 2023 +0200

    Updated control scheme picture

commit e3524e8e48
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 1 18:48:42 2023 +0200

    Add use haptic feedback; Fix use in 3rd person mode

commit 05fc4d5ab4
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 1 12:07:13 2023 +0200

    Fix menu haptics

commit eec46c183d
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 1 18:48:42 2023 +0200

    Add use haptic feedback; Fix use in 3rd person mode

commit fe9891f8db
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 1 12:07:13 2023 +0200

    Fix menu haptics

commit 21483d0d5a
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 1 11:25:11 2023 +0200

    Make weapon adjustment mode independent for each weapon; Optimize loading of weapon adjustments

commit baec8832ab
Merge: 82706df 52fcc8a
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Sat Apr 1 11:15:25 2023 +0200

    Merge branch 'main' into contributions

commit 52fcc8a49e
Author: Simon <simonbrown77@googlemail.com>
Date:   Sat Apr 1 09:47:48 2023 +0100

    Revert "Removed the no-backface-culling for weapons as it is no longer needed"

    This reverts commit b899b99178.

commit 5e66ebf6fc
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Mar 31 15:40:54 2023 +0200

    Allow to skip cinematics also by triggers

commit 587277fa7f
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Mar 31 14:52:40 2023 +0200

    Fix use/crouch buttons on switched control schemes

commit 82706df34f
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Mar 31 15:40:54 2023 +0200

    Allow to skip cinematics also by triggers

commit 1111766032
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Mar 31 14:52:40 2023 +0200

    Fix use/crouch buttons on switched control schemes

commit 822d1ddbba
Merge: a1a7d54 5f56cf4
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Fri Mar 31 08:43:50 2023 +0200

    Merge branch 'main' into contributions

commit 5f56cf48fc
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Mar 30 22:16:37 2023 +0100

    Camera shake fix part 2

commit 3dd7833cd0
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Mar 30 22:06:18 2023 +0100

    Disable camera shake when charging a weapon's alt fire

commit 6202017b6a
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 21:52:44 2023 +0200

    Fix virtual gun stock

commit 6d49f87150
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 19:26:36 2023 +0200

    Do not check angle on non-facing triggers

commit 926c64c691
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 17:54:33 2023 +0200

    Add angle check for triggers touched by hand

commit 78f7d9bcfc
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Wed Mar 29 22:59:27 2023 +0200

    JKA mod menu warning

commit 4219f996e9
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Wed Mar 29 22:42:11 2023 +0200

    JKO mod menu warning

commit b899b99178
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Mar 30 21:45:10 2023 +0100

    Removed the no-backface-culling for weapons as it is no longer needed

    used only for hand models now

commit 9877859676
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Mar 30 21:44:36 2023 +0100

    Update to the VC+Elin weapons pack

    includes a sweet new saber hilt

commit a1a7d541fa
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 21:52:44 2023 +0200

    Fix virtual gun stock

commit 15d932c75f
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 19:26:36 2023 +0200

    Do not check angle on non-facing triggers

commit 402277e717
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 17:54:33 2023 +0200

    Add angle check for triggers touched by hand

commit 9b22378c88
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Thu Mar 30 17:52:26 2023 +0200

    Add special delay for re-triggering security cameras

commit c4cc218f8b
Author: Simon <simonbrown77@googlemail.com>
Date:   Wed Mar 29 22:44:50 2023 +0100

    Turn the stun baton into an "always active" weapon

    movement still triggers the sound, but it will always shock an enemy when it makes contact

commit a4e99c20f9
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Wed Mar 29 22:59:27 2023 +0200

    JKA mod menu warning

commit 442a1fc8e2
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Wed Mar 29 22:42:11 2023 +0200

    JKO mod menu warning

commit 02261c57f0
Merge: 3c64fa7 51c703a
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Wed Mar 29 20:51:42 2023 +0200

    Merge branch 'contributions' of github.com:DrBeef/JKXR into contributions

commit 3c64fa7e3e
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 23:19:29 2023 +0100

    Lowered Stun Baton trigger velocity

commit 43192a355d
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 23:03:17 2023 +0100

    Move beef_crawl back into the game specific assets

    as we will be fixing the JKO one on release, but updating JKA

commit 94e82c2da3
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Mar 28 23:21:28 2023 +0200

    Fix subtitles rendering; Fix rendering of other centered texts

commit 40128567be
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Mar 28 18:02:08 2023 +0200

    Add help to menu

commit 4f1b6b5f07
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Mar 28 17:36:13 2023 +0200

    Split vr asset packs to avoid duplicates

commit 51c703a481
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Mar 28 23:21:28 2023 +0200

    Fix subtitles rendering; Fix rendering of other centered texts

commit 04a539f890
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Mar 28 18:02:08 2023 +0200

    Add help to menu

commit d9126738d3
Author: Petr Bartos <petr.bartos@plus4u.net>
Date:   Tue Mar 28 17:36:13 2023 +0200

    Split vr asset packs to avoid duplicates

commit 62b9a0bfab
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 13:52:45 2023 +0100

    Hide force power aura when item selector is shown

commit 0a9206642e
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 13:52:23 2023 +0100

    Slight adjustment to muzzle position based on whether scoped/two-handed

commit f452b9cf06
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 13:51:49 2023 +0100

    Slight tweak to NPC Combat

commit 20de6ec478
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 13:50:54 2023 +0100

    Added simple readme and license

commit 77672f612b
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 07:20:22 2023 +0100

    Updated website link to be the patreon

commit 2a1cd0e6e7
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Mar 28 07:20:10 2023 +0100

    Don't send roll to the server, this might be causing gradual roll drift

commit 1b22652e5c
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Mar 27 21:38:46 2023 +0100

    Fixed aiming of bowcaster and demp alt fire

commit 895b09041f
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Mar 27 21:38:25 2023 +0100

    JKA - Ensure UseVR Position is only true when in first person

commit 3897531544
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Mar 27 21:38:17 2023 +0100

    JKO - Ensure UseVR Position is only true when in first person

commit 3b5121e349
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Mar 27 21:37:49 2023 +0100

    Render Special Effects on hand/weapon when force power is activated for protection etc

commit 50db9039df
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Mar 26 16:33:52 2023 +0100

    Separate no copy file flag for JK3

commit 1968a7d8ba
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Mar 26 16:33:22 2023 +0100

    Always use right hand as saber home

commit 74dcd955d2
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Mar 26 16:32:49 2023 +0100

    Fix crash in JKA

commit 1e4692d04a
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Mar 26 16:32:16 2023 +0100

    Update z_Crusty_and_Elin_vr_weapons.pk3

commit 134dec8264
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Mar 26 16:31:53 2023 +0100

    Fix possible crash on JK2

commit f6dc432f6a
Author: Simon <simonbrown77@googlemail.com>
Date:   Sat Mar 25 15:36:01 2023 +0000

    Copy mods to jk2demo if it exists

    to resolve the issue with mods not being picked up from the base folder
2023-04-16 09:38:26 +01:00

887 lines
22 KiB
C++

/*
===========================================================================
Copyright (C) 2005 - 2015, ioquake3 contributors
Copyright (C) 2013 - 2015, OpenJK contributors
This file is part of the OpenJK source code.
OpenJK is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/
#include <SDL.h>
#include <SDL_syswm.h>
#include "qcommon/qcommon.h"
#include "rd-common/tr_types.h"
#include "sys/sys_local.h"
#include "sdl_icon.h"
enum rserr_t
{
RSERR_OK,
RSERR_INVALID_FULLSCREEN,
RSERR_INVALID_MODE,
RSERR_UNKNOWN
};
static SDL_Window *screen = NULL;
static SDL_GLContext opengl_context;
static float displayAspect;
cvar_t *r_sdlDriver;
cvar_t *r_allowSoftwareGL;
// Window cvars
cvar_t *r_fullscreen = 0;
cvar_t *r_noborder;
cvar_t *r_centerWindow;
cvar_t *r_customwidth;
cvar_t *r_customheight;
cvar_t *r_swapInterval;
cvar_t *r_stereo;
cvar_t *r_mode;
cvar_t *r_displayRefresh;
// Window surface cvars
cvar_t *r_stencilbits;
cvar_t *r_depthbits;
cvar_t *r_colorbits;
cvar_t *r_ignorehwgamma;
cvar_t *r_ext_multisample;
/*
** R_GetModeInfo
*/
typedef struct vidmode_s
{
const char *description;
int width, height;
} vidmode_t;
const vidmode_t r_vidModes[] = {
{ "Mode 0: 320x240", 320, 240 },
{ "Mode 1: 400x300", 400, 300 },
{ "Mode 2: 512x384", 512, 384 },
{ "Mode 3: 640x480", 640, 480 },
{ "Mode 4: 800x600", 800, 600 },
{ "Mode 5: 960x720", 960, 720 },
{ "Mode 6: 1024x768", 1024, 768 },
{ "Mode 7: 1152x864", 1152, 864 },
{ "Mode 8: 1280x1024", 1280, 1024 },
{ "Mode 9: 1600x1200", 1600, 1200 },
{ "Mode 10: 2048x1536", 2048, 1536 },
{ "Mode 11: 856x480 (wide)", 856, 480 },
{ "Mode 12: 2400x600(surround)",2400,600 }
};
static const int s_numVidModes = ARRAY_LEN( r_vidModes );
#define R_MODE_FALLBACK (4) // 640x480
qboolean R_GetModeInfo( int *width, int *height, int mode ) {
const vidmode_t *vm;
if ( mode < -1 ) {
return qfalse;
}
if ( mode >= s_numVidModes ) {
return qfalse;
}
if ( mode == -1 ) {
*width = r_customwidth->integer;
*height = r_customheight->integer;
return qtrue;
}
vm = &r_vidModes[mode];
*width = vm->width;
*height = vm->height;
return qtrue;
}
/*
** R_ModeList_f
*/
static void R_ModeList_f( void )
{
int i;
Com_Printf( "\n" );
Com_Printf( "Mode -2: Use desktop resolution\n" );
Com_Printf( "Mode -1: Use r_customWidth and r_customHeight variables\n" );
for ( i = 0; i < s_numVidModes; i++ )
{
Com_Printf( "%s\n", r_vidModes[i].description );
}
Com_Printf( "\n" );
}
/*
===============
GLimp_Minimize
Minimize the game so that user is back at the desktop
===============
*/
void GLimp_Minimize(void)
{
SDL_MinimizeWindow( screen );
}
void WIN_Present( window_t *window )
{
if ( window->api == GRAPHICS_API_OPENGL )
{
SDL_GL_SwapWindow(screen);
if ( r_swapInterval->modified )
{
r_swapInterval->modified = qfalse;
if ( SDL_GL_SetSwapInterval( r_swapInterval->integer ) == -1 )
{
Com_DPrintf( "SDL_GL_SetSwapInterval failed: %s\n", SDL_GetError() );
}
}
}
if ( r_fullscreen->modified )
{
bool fullscreen;
bool needToToggle;
bool sdlToggled = qfalse;
// Find out the current state
fullscreen = (SDL_GetWindowFlags( screen ) & SDL_WINDOW_FULLSCREEN) != 0;
if ( r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ) )
{
Com_Printf( "Fullscreen not allowed with in_nograb 1\n" );
Cvar_Set( "r_fullscreen", "0" );
r_fullscreen->modified = qfalse;
}
// Is the state we want different from the current state?
needToToggle = !!r_fullscreen->integer != fullscreen;
if ( needToToggle )
{
sdlToggled = SDL_SetWindowFullscreen( screen, r_fullscreen->integer ) >= 0;
// SDL_WM_ToggleFullScreen didn't work, so do it the slow way
if ( !sdlToggled )
Cbuf_AddText( "vid_restart\n" );
IN_Restart();
}
r_fullscreen->modified = qfalse;
}
}
/*
===============
GLimp_CompareModes
===============
*/
static int GLimp_CompareModes( const void *a, const void *b )
{
const float ASPECT_EPSILON = 0.001f;
SDL_Rect *modeA = (SDL_Rect *)a;
SDL_Rect *modeB = (SDL_Rect *)b;
float aspectA = (float)modeA->w / (float)modeA->h;
float aspectB = (float)modeB->w / (float)modeB->h;
int areaA = modeA->w * modeA->h;
int areaB = modeB->w * modeB->h;
float aspectDiffA = fabs( aspectA - displayAspect );
float aspectDiffB = fabs( aspectB - displayAspect );
float aspectDiffsDiff = aspectDiffA - aspectDiffB;
if( aspectDiffsDiff > ASPECT_EPSILON )
return 1;
else if( aspectDiffsDiff < -ASPECT_EPSILON )
return -1;
else
return areaA - areaB;
}
/*
===============
GLimp_DetectAvailableModes
===============
*/
static bool GLimp_DetectAvailableModes(void)
{
int i, j;
char buf[ MAX_STRING_CHARS ] = { 0 };
SDL_Rect *modes;
int numModes = 0;
int display = SDL_GetWindowDisplayIndex( screen );
if ( display < 0 )
{
Com_Printf( S_COLOR_YELLOW "WARNING: Couldn't get window display index, no resolutions detected: %s\n", SDL_GetError() );
return false;
}
SDL_DisplayMode windowMode;
if( SDL_GetWindowDisplayMode( screen, &windowMode ) < 0 )
{
Com_Printf( S_COLOR_YELLOW "WARNING: Couldn't get window display mode, no resolutions detected (%s).\n", SDL_GetError() );
return false;
}
int numDisplayModes = SDL_GetNumDisplayModes( display );
if ( numDisplayModes < 0 )
Com_Error( ERR_FATAL, "SDL_GetNumDisplayModes() FAILED (%s)", SDL_GetError() );
modes = (SDL_Rect *)SDL_calloc( (size_t)numDisplayModes, sizeof( SDL_Rect ) );
if ( !modes )
Com_Error( ERR_FATAL, "Out of memory" );
for( i = 0; i < numDisplayModes; i++ )
{
SDL_DisplayMode mode;
if( SDL_GetDisplayMode( display, i, &mode ) < 0 )
continue;
if( !mode.w || !mode.h )
{
Com_Printf( "Display supports any resolution\n" );
SDL_free( modes );
return true;
}
if( windowMode.format != mode.format )
continue;
// SDL can give the same resolution with different refresh rates.
// Only list resolution once.
for( j = 0; j < numModes; j++ )
{
if( mode.w == modes[ j ].w && mode.h == modes[ j ].h )
break;
}
if( j != numModes )
continue;
modes[ numModes ].w = mode.w;
modes[ numModes ].h = mode.h;
numModes++;
}
if( numModes > 1 )
qsort( modes, numModes, sizeof( SDL_Rect ), GLimp_CompareModes );
for( i = 0; i < numModes; i++ )
{
const char *newModeString = va( "%ux%u ", modes[ i ].w, modes[ i ].h );
if( strlen( newModeString ) < (int)sizeof( buf ) - strlen( buf ) )
Q_strcat( buf, sizeof( buf ), newModeString );
else
Com_Printf( "Skipping mode %ux%u, buffer too small\n", modes[ i ].w, modes[ i ].h );
}
if( *buf )
{
buf[ strlen( buf ) - 1 ] = 0;
Com_Printf( "Available modes: '%s'\n", buf );
Cvar_Set( "r_availableModes", buf );
}
SDL_free( modes );
return true;
}
/*
===============
GLimp_SetMode
===============
*/
static rserr_t GLimp_SetMode(glconfig_t *glConfig, const windowDesc_t *windowDesc, const char *windowTitle, int mode, qboolean fullscreen, qboolean noborder)
{
int perChannelColorBits;
int colorBits, depthBits, stencilBits;
int samples;
int i = 0;
SDL_Surface *icon = NULL;
Uint32 flags = SDL_WINDOW_SHOWN;
SDL_DisplayMode desktopMode;
int display = 0;
int x = SDL_WINDOWPOS_UNDEFINED, y = SDL_WINDOWPOS_UNDEFINED;
if ( windowDesc->api == GRAPHICS_API_OPENGL )
{
flags |= SDL_WINDOW_OPENGL;
}
Com_Printf( "Initializing display\n");
icon = SDL_CreateRGBSurfaceFrom(
(void *)CLIENT_WINDOW_ICON.pixel_data,
CLIENT_WINDOW_ICON.width,
CLIENT_WINDOW_ICON.height,
CLIENT_WINDOW_ICON.bytes_per_pixel * 8,
CLIENT_WINDOW_ICON.bytes_per_pixel * CLIENT_WINDOW_ICON.width,
#ifdef Q3_LITTLE_ENDIAN
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
#else
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
#endif
);
// If a window exists, note its display index
if ( screen != NULL )
{
display = SDL_GetWindowDisplayIndex( screen );
if ( display < 0 )
{
Com_DPrintf( "SDL_GetWindowDisplayIndex() failed: %s\n", SDL_GetError() );
}
}
if( display >= 0 && SDL_GetDesktopDisplayMode( display, &desktopMode ) == 0 )
{
displayAspect = (float)desktopMode.w / (float)desktopMode.h;
Com_Printf( "Display aspect: %.3f\n", displayAspect );
}
else
{
Com_Memset( &desktopMode, 0, sizeof( SDL_DisplayMode ) );
Com_Printf( "Cannot determine display aspect, assuming 1.333\n" );
}
Com_Printf( "...setting mode %d:", mode );
if (mode == -2)
{
// use desktop video resolution
if( desktopMode.h > 0 )
{
glConfig->vidWidth = desktopMode.w;
glConfig->vidHeight = desktopMode.h;
}
else
{
glConfig->vidWidth = 640;
glConfig->vidHeight = 480;
Com_Printf( "Cannot determine display resolution, assuming 640x480\n" );
}
//glConfig.windowAspect = (float)glConfig.vidWidth / (float)glConfig.vidHeight;
}
else if ( !R_GetModeInfo( &glConfig->vidWidth, &glConfig->vidHeight, /*&glConfig.windowAspect,*/ mode ) )
{
Com_Printf( " invalid mode\n" );
SDL_FreeSurface( icon );
return RSERR_INVALID_MODE;
}
Com_Printf( " %d %d\n", glConfig->vidWidth, glConfig->vidHeight);
// Center window
if( r_centerWindow->integer && !fullscreen )
{
x = ( desktopMode.w / 2 ) - ( glConfig->vidWidth / 2 );
y = ( desktopMode.h / 2 ) - ( glConfig->vidHeight / 2 );
}
// Destroy existing state if it exists
if( opengl_context != NULL )
{
SDL_GL_DeleteContext( opengl_context );
opengl_context = NULL;
}
if( screen != NULL )
{
SDL_GetWindowPosition( screen, &x, &y );
Com_DPrintf( "Existing window at %dx%d before being destroyed\n", x, y );
SDL_DestroyWindow( screen );
screen = NULL;
}
if( fullscreen )
{
flags |= SDL_WINDOW_FULLSCREEN;
glConfig->isFullscreen = qtrue;
}
else
{
if( noborder )
flags |= SDL_WINDOW_BORDERLESS;
glConfig->isFullscreen = qfalse;
}
colorBits = r_colorbits->integer;
if ((!colorBits) || (colorBits >= 32))
colorBits = 24;
if (!r_depthbits->integer)
depthBits = 24;
else
depthBits = r_depthbits->integer;
stencilBits = r_stencilbits->integer;
samples = r_ext_multisample->integer;
if ( windowDesc->api == GRAPHICS_API_OPENGL )
{
for (i = 0; i < 16; i++)
{
int testColorBits, testDepthBits, testStencilBits;
// 0 - default
// 1 - minus colorBits
// 2 - minus depthBits
// 3 - minus stencil
if ((i % 4) == 0 && i)
{
// one pass, reduce
switch (i / 4)
{
case 2 :
if (colorBits == 24)
colorBits = 16;
break;
case 1 :
if (depthBits == 24)
depthBits = 16;
else if (depthBits == 16)
depthBits = 8;
case 3 :
if (stencilBits == 24)
stencilBits = 16;
else if (stencilBits == 16)
stencilBits = 8;
}
}
testColorBits = colorBits;
testDepthBits = depthBits;
testStencilBits = stencilBits;
if ((i % 4) == 3)
{ // reduce colorBits
if (testColorBits == 24)
testColorBits = 16;
}
if ((i % 4) == 2)
{ // reduce depthBits
if (testDepthBits == 24)
testDepthBits = 16;
else if (testDepthBits == 16)
testDepthBits = 8;
}
if ((i % 4) == 1)
{ // reduce stencilBits
if (testStencilBits == 24)
testStencilBits = 16;
else if (testStencilBits == 16)
testStencilBits = 8;
else
testStencilBits = 0;
}
if (testColorBits == 24)
perChannelColorBits = 8;
else
perChannelColorBits = 4;
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, perChannelColorBits );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, perChannelColorBits );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, perChannelColorBits );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, testDepthBits );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, testStencilBits );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, samples );
if ( windowDesc->gl.majorVersion )
{
int compactVersion = windowDesc->gl.majorVersion * 100 + windowDesc->gl.minorVersion * 10;
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, windowDesc->gl.majorVersion );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, windowDesc->gl.minorVersion );
if ( windowDesc->gl.profile == GLPROFILE_ES || compactVersion >= 320 )
{
int profile;
switch ( windowDesc->gl.profile )
{
default:
case GLPROFILE_COMPATIBILITY:
profile = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY;
break;
case GLPROFILE_CORE:
profile = SDL_GL_CONTEXT_PROFILE_CORE;
break;
case GLPROFILE_ES:
profile = SDL_GL_CONTEXT_PROFILE_ES;
break;
}
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, profile );
}
}
if ( windowDesc->gl.contextFlags & GLCONTEXT_DEBUG )
{
SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
}
if(r_stereo->integer)
{
glConfig->stereoEnabled = qtrue;
SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
}
else
{
glConfig->stereoEnabled = qfalse;
SDL_GL_SetAttribute(SDL_GL_STEREO, 0);
}
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, !r_allowSoftwareGL->integer );
if( ( screen = SDL_CreateWindow( windowTitle, x, y,
glConfig->vidWidth, glConfig->vidHeight, flags ) ) == NULL )
{
Com_DPrintf( "SDL_CreateWindow failed: %s\n", SDL_GetError( ) );
continue;
}
#ifndef MACOS_X
SDL_SetWindowIcon( screen, icon );
#endif
if( fullscreen )
{
SDL_DisplayMode mode;
switch( testColorBits )
{
case 16: mode.format = SDL_PIXELFORMAT_RGB565; break;
case 24: mode.format = SDL_PIXELFORMAT_RGB24; break;
default: Com_DPrintf( "testColorBits is %d, can't fullscreen\n", testColorBits ); continue;
}
mode.w = glConfig->vidWidth;
mode.h = glConfig->vidHeight;
mode.refresh_rate = glConfig->displayFrequency = r_displayRefresh->integer;
mode.driverdata = NULL;
if( SDL_SetWindowDisplayMode( screen, &mode ) < 0 )
{
Com_DPrintf( "SDL_SetWindowDisplayMode failed: %s\n", SDL_GetError( ) );
continue;
}
}
if( ( opengl_context = SDL_GL_CreateContext( screen ) ) == NULL )
{
Com_Printf( "SDL_GL_CreateContext failed: %s\n", SDL_GetError( ) );
continue;
}
if ( SDL_GL_SetSwapInterval( r_swapInterval->integer ) == -1 )
{
Com_DPrintf( "SDL_GL_SetSwapInterval failed: %s\n", SDL_GetError() );
}
glConfig->colorBits = testColorBits;
glConfig->depthBits = testDepthBits;
glConfig->stencilBits = testStencilBits;
Com_Printf( "Using %d color bits, %d depth, %d stencil display.\n",
glConfig->colorBits, glConfig->depthBits, glConfig->stencilBits );
break;
}
if (opengl_context == NULL) {
SDL_FreeSurface(icon);
return RSERR_UNKNOWN;
}
}
else
{
// Just create a regular window
if( ( screen = SDL_CreateWindow( windowTitle, x, y,
glConfig->vidWidth, glConfig->vidHeight, flags ) ) == NULL )
{
Com_DPrintf( "SDL_CreateWindow failed: %s\n", SDL_GetError( ) );
}
else
{
#ifndef MACOS_X
SDL_SetWindowIcon( screen, icon );
#endif
if( fullscreen )
{
if( SDL_SetWindowDisplayMode( screen, NULL ) < 0 )
{
Com_DPrintf( "SDL_SetWindowDisplayMode failed: %s\n", SDL_GetError( ) );
}
}
}
}
SDL_FreeSurface( icon );
if (!GLimp_DetectAvailableModes())
{
return RSERR_UNKNOWN;
}
return RSERR_OK;
}
/*
===============
GLimp_StartDriverAndSetMode
===============
*/
static qboolean GLimp_StartDriverAndSetMode(glconfig_t *glConfig, const windowDesc_t *windowDesc, int mode, qboolean fullscreen, qboolean noborder)
{
rserr_t err;
if (!SDL_WasInit(SDL_INIT_VIDEO))
{
const char *driverName;
if (SDL_Init(SDL_INIT_VIDEO) == -1)
{
Com_Printf( "SDL_Init( SDL_INIT_VIDEO ) FAILED (%s)\n", SDL_GetError());
return qfalse;
}
driverName = SDL_GetCurrentVideoDriver();
if (!driverName)
{
Com_Error( ERR_FATAL, "No video driver initialized" );
return qfalse;
}
Com_Printf( "SDL using driver \"%s\"\n", driverName );
Cvar_Set( "r_sdlDriver", driverName );
}
if (SDL_GetNumVideoDisplays() <= 0)
{
Com_Error( ERR_FATAL, "SDL_GetNumVideoDisplays() FAILED (%s)", SDL_GetError() );
}
if (fullscreen && Cvar_VariableIntegerValue( "in_nograb" ) )
{
Com_Printf( "Fullscreen not allowed with in_nograb 1\n");
Cvar_Set( "r_fullscreen", "0" );
r_fullscreen->modified = qfalse;
fullscreen = qfalse;
}
err = GLimp_SetMode(glConfig, windowDesc, CLIENT_WINDOW_TITLE, mode, fullscreen, noborder);
switch ( err )
{
case RSERR_INVALID_FULLSCREEN:
Com_Printf( "...WARNING: fullscreen unavailable in this mode\n" );
return qfalse;
case RSERR_INVALID_MODE:
Com_Printf( "...WARNING: could not set the given mode (%d)\n", mode );
return qfalse;
case RSERR_UNKNOWN:
Com_Printf( "...ERROR: no display modes could be found.\n" );
return qfalse;
default:
break;
}
return qtrue;
}
window_t WIN_Init( const windowDesc_t *windowDesc, glconfig_t *glConfig )
{
Cmd_AddCommand("modelist", R_ModeList_f);
Cmd_AddCommand("minimize", GLimp_Minimize);
r_sdlDriver = Cvar_Get( "r_sdlDriver", "", CVAR_ROM );
r_allowSoftwareGL = Cvar_Get( "r_allowSoftwareGL", "0", CVAR_ARCHIVE_ND|CVAR_LATCH );
// Window cvars
r_fullscreen = Cvar_Get( "r_fullscreen", "0", CVAR_ARCHIVE|CVAR_LATCH );
r_noborder = Cvar_Get( "r_noborder", "0", CVAR_ARCHIVE|CVAR_LATCH );
r_centerWindow = Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE|CVAR_LATCH );
r_customwidth = Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE|CVAR_LATCH );
r_customheight = Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE|CVAR_LATCH );
r_swapInterval = Cvar_Get( "r_swapInterval", "0", CVAR_ARCHIVE_ND );
r_stereo = Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE_ND|CVAR_LATCH );
r_mode = Cvar_Get( "r_mode", "4", CVAR_ARCHIVE|CVAR_LATCH );
r_displayRefresh = Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH );
Cvar_CheckRange( r_displayRefresh, 0, 240, qtrue );
// Window render surface cvars
r_stencilbits = Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE_ND|CVAR_LATCH );
r_depthbits = Cvar_Get( "r_depthbits", "24", CVAR_ARCHIVE_ND|CVAR_LATCH );
r_colorbits = Cvar_Get( "r_colorbits", "32", CVAR_ARCHIVE_ND|CVAR_LATCH );
r_ignorehwgamma = Cvar_Get( "r_ignorehwgamma", "1", CVAR_ARCHIVE|CVAR_LATCH );
r_ext_multisample = Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE_ND|CVAR_LATCH );
Cvar_Get( "r_availableModes", "", CVAR_ROM );
// Create the window and set up the context
if(!GLimp_StartDriverAndSetMode( glConfig, windowDesc, r_mode->integer,
(qboolean)r_fullscreen->integer, (qboolean)r_noborder->integer ))
{
if( r_mode->integer != R_MODE_FALLBACK )
{
Com_Printf( "Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK );
if (!GLimp_StartDriverAndSetMode( glConfig, windowDesc, R_MODE_FALLBACK, qfalse, qfalse ))
{
// Nothing worked, give up
Com_Error( ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem" );
}
}
}
glConfig->deviceSupportsGamma =
(qboolean)(!r_ignorehwgamma->integer && SDL_SetWindowBrightness( screen, 1.0f ) >= 0);
// This depends on SDL_INIT_VIDEO, hence having it here
IN_Init( screen );
// window_t is only really useful for Windows if the renderer wants to create a D3D context.
window_t window = {};
window.api = windowDesc->api;
#if defined(_WIN32)
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWindowWMInfo(screen, &info) )
{
switch(info.subsystem) {
case SDL_SYSWM_WINDOWS:
window.handle = info.info.win.window;
break;
default:
break;
}
}
#endif
return window;
}
/*
===============
GLimp_Shutdown
===============
*/
void WIN_Shutdown( void )
{
Cmd_RemoveCommand("modelist");
Cmd_RemoveCommand("minimize");
IN_Shutdown();
SDL_QuitSubSystem( SDL_INIT_VIDEO );
screen = NULL;
}
void GLimp_EnableLogging( qboolean enable )
{
}
void GLimp_LogComment( char *comment )
{
}
void WIN_SetGamma( glconfig_t *glConfig, byte red[256], byte green[256], byte blue[256] )
{
Uint16 table[3][256];
int i, j;
if( !glConfig->deviceSupportsGamma || r_ignorehwgamma->integer > 0 )
return;
for (i = 0; i < 256; i++)
{
table[0][i] = ( ( ( Uint16 ) red[i] ) << 8 ) | red[i];
table[1][i] = ( ( ( Uint16 ) green[i] ) << 8 ) | green[i];
table[2][i] = ( ( ( Uint16 ) blue[i] ) << 8 ) | blue[i];
}
#if defined(_WIN32)
// Win2K and newer put this odd restriction on gamma ramps...
{
OSVERSIONINFO vinfo;
vinfo.dwOSVersionInfoSize = sizeof( vinfo );
GetVersionEx( &vinfo );
if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
{
Com_DPrintf( "performing gamma clamp.\n" );
for( j = 0 ; j < 3 ; j++ )
{
for( i = 0 ; i < 128 ; i++ )
{
table[j][i] = Q_min(table[j][i], (128 + i) << 8);
}
table[j][127] = Q_min(table[j][127], 254 << 8);
}
}
}
#endif
// enforce constantly increasing
for (j = 0; j < 3; j++)
{
for (i = 1; i < 256; i++)
{
if (table[j][i] < table[j][i-1])
table[j][i] = table[j][i-1];
}
}
if ( SDL_SetWindowGammaRamp( screen, table[0], table[1], table[2] ) < 0 )
{
Com_DPrintf( "SDL_SetWindowGammaRamp() failed: %s\n", SDL_GetError() );
}
}
void *WIN_GL_GetProcAddress( const char *proc )
{
return SDL_GL_GetProcAddress( proc );
}
qboolean WIN_GL_ExtensionSupported( const char *extension )
{
return SDL_GL_ExtensionSupported( extension ) == SDL_TRUE ? qtrue : qfalse;
}