Compare commits

..

142 Commits

Author SHA1 Message Date
Alibek Omarov
bd969f3594 wscript: fix system opus detection, it didn't compile due to nonnull argument 2023-11-01 01:35:39 +03:00
Alibek Omarov
fb87d7c0b3 readme: wording, add icon, add donate.md link [skip ci] 2023-10-31 21:54:23 +03:00
Alibek Omarov
a69fc87940 Documentation: donate: add sponsorship information 2023-10-31 21:54:23 +03:00
Alibek Omarov
e481e1d73e ref: gl: enable GL waves with r_ripple 2023-10-31 21:52:00 +03:00
Alibek Omarov
6c0eed1b2b ref: gl: allow viewing water textures in their full glory with enabled r_ripple 2 2023-10-31 21:52:00 +03:00
Alibek Omarov
a6c67fdf9f ref: gl: upload only part of texture we're using, i.e. 64x64 for 64x64, 128x128 for 128x128 2023-10-31 21:52:00 +03:00
Alibek Omarov
03f838e37e mainui: update 2023-10-31 21:52:00 +03:00
Alibek Omarov
e21fa4a910 engine: add cvar r_refdll_loaded to indicate currently loaded renderer (for menu options and etc) 2023-10-31 21:52:00 +03:00
Alibek Omarov
46889ed453 ref: gl: libc rand() does better job at randomizing 2023-10-31 21:52:00 +03:00
Alibek Omarov
882fcc152c ref: gl: always scale down texture to 64x64, like sw.dll does 2023-10-31 21:52:00 +03:00
Alibek Omarov
a41902bd46 engine: mod_bmodel: detect water textures by texture name like LoadSurfaces does 2023-10-31 21:52:00 +03:00
Alibek Omarov
a6af32dafd ref: gl: connect ripply water to others parts of renderer (init, reset, animation and rendering) 2023-10-31 21:52:00 +03:00
Alibek Omarov
d6dfb83be7 ref: gl: ripply water implementation (bugfixed version from my Quake-2 patches) 2023-10-31 21:52:00 +03:00
Alibek Omarov
597429cf41 engine, filesystem: unify GetNativeObject between all the APIs. Allow getting filesystem APIs through GetNativeObject 2023-10-31 21:25:11 +03:00
Alibek Omarov
5ea074a1fd engine: fix build issues pointed by @Velaron 2023-10-31 21:01:42 +03:00
Alibek Omarov
29c9393da3 wscript: enable faster builds with gccdeps/msvcdeps 2023-10-31 04:30:27 +03:00
Alibek Omarov
bf6829189e wscript: move XASH_BUILD_COMMIT definition to libpublic, as this is the only place where it's used, for faster builds 2023-10-31 04:30:27 +03:00
Alibek Omarov
a62a9429c9 engine: launcher: remove Windows code from single binary launcher, as Windows completely supports running from external launcher and don't need dedicated builds 2023-10-31 04:30:22 +03:00
mittorn
f2c080e736 gl2shim: fix broken matrix update when fog attribute enabled (32 bit shift overflow) 2023-10-30 22:34:34 +03:00
Alibek Omarov
ea55e78855 ref: _inline -> static 2023-10-29 23:38:43 +03:00
Alibek Omarov
f7c536b81c engine: server: allow loading maps from subdirectories as this is used by some Half-Life mods 2023-10-29 02:44:46 +03:00
Alibek Omarov
6c40104c66 public: better fix for ExtractFilePath 2023-10-28 19:31:17 +03:00
Alibek Omarov
4d7d592918 engine: mod_bmodel: completely get rid of global loadmodel pointer 2023-10-28 16:06:00 +03:00
Alibek Omarov
c5e91f299b engine: mod_studio: reduce dependency on global loadmodel pointer, make it private for brush model loader 2023-10-28 15:38:40 +03:00
Alibek Omarov
cff276db71 engine: client: mod_dbghulls: reduce dependency on global loadmodel pointer 2023-10-28 15:35:20 +03:00
Alibek Omarov
30d1492b93 engine: remove Set/GetCurrentLoadingModel from RefAPI 2023-10-28 15:22:21 +03:00
Alibek Omarov
f07eea5073 engine: server: allow server unloading for Win32 targets until we figure out the issues with MetaMod 2023-10-28 11:14:12 +03:00
Alibek Omarov
fe407fbe00 public: workaround when empty string is passed to COM_ExtractFilePath (should make safe COM_ExtractFilePath) 2023-10-28 11:06:18 +03:00
Alibek Omarov
78bc177e05 engine: server: remove unused host struct field 2023-10-28 11:06:18 +03:00
Alibek Omarov
8fb908e3d4 engine: server: disable SV_UnloadProgs, only call it when shutting down engine 2023-10-28 11:06:18 +03:00
Alibek Omarov
d8b261370a engine: common: do not probe server to collect cvars for game.cfg (CHECK THIS) 2023-10-28 11:06:18 +03:00
Alibek Omarov
a2c9ac5b1f engine: client: disable server DLL probe for GameUI, check it's existence instead 2023-10-28 11:06:18 +03:00
Alibek Omarov
7f9025e178 engine: server: sv_pmove: use model name for physent name to avoid crash when classname isn't initialized yet 2023-10-28 11:04:43 +03:00
Alibek Omarov
8647110a10 Revert "engine: wscript: move libasound uselib under linux condition, as the ALSA interface is only relevant for Linux"
This reverts commit 48e44f0057.
2023-10-28 10:10:03 +03:00
Alibek Omarov
48e44f0057 engine: wscript: move libasound uselib under linux condition, as the ALSA interface is only relevant for Linux 2023-10-27 17:03:04 +03:00
Alibek Omarov
e3934af7d1 wscript: always load cmakelists generation tool 2023-10-27 16:57:22 +03:00
Alibek Omarov
a5ee631191 engine: server: sv_game: disable searching closer to server library memory region for Android 2023-10-27 14:31:16 +03:00
Alibek Omarov
ce39255ef0 engine: host: set rootdir on Android SDL port 2023-10-27 14:25:16 +03:00
Alibek Omarov
5aac5d2a52 filesystem: VFileSystem009: add pathid support to RemoveFile method 2023-10-27 08:02:45 +03:00
Alibek Omarov
061b50404d engine: server: register dummy cvar sv_allow_dlfile for GoldSrc compatibility 2023-10-27 08:02:10 +03:00
Alibek Omarov
279cec5ae9 engine: rename cl/sv_allowdownload for GoldSrc compatibility 2023-10-27 07:25:09 +03:00
Alibek Omarov
83a5648335 filesystem: only allow setting true or false for boolean type keys in gameinfo/liblist.gam 2023-10-27 07:24:42 +03:00
Alibek Omarov
a8fc9a4c5a waf: update to latest waifu 2023-10-27 07:24:18 +03:00
Alibek Omarov
6f6ddbce28 engine: add argument -timedemo that makes engine run timedemo and exit 2023-10-27 03:49:00 +03:00
Alibek Omarov
4cb425d2bb engine: console: do not draw console and do not draw notify in timedemo 2023-10-27 03:47:52 +03:00
mittorn
bf5fd40d64 gl2shim: workaround empty rgb5/rgb8 textures 2023-10-26 23:08:02 +03:00
mittorn
6bc613bdb4 ref_gl: force gles2 on non-nanogl until we support gles1 directly 2023-10-26 23:07:39 +03:00
mittorn
a982562658 ref_gl: Fix missing DebugOutput functions on GLES 2023-10-26 23:07:22 +03:00
Alibek Omarov
96a9172e36 engine: platform: sdl: check that we're handling SDL errors according to it's documentation 2023-10-26 23:06:50 +03:00
Alibek Omarov
34d7664342 ref: gl: disable TGA flip for detail textures, GoldSrc ignores it, so we will too 2023-10-26 05:12:38 +03:00
Alibek Omarov
b0a79df86f ref: change r_traceglow to 0, as GoldSrc does 2023-10-26 04:59:01 +03:00
Alibek Omarov
9e107e900c engine: network: fix async NS resolve
If we're currently running NS resolving thread, any request would block.

Co-Authored-by: mittorn <mittorn@sibmail.com>
2023-10-24 18:11:31 +03:00
Alibek Omarov
8f819a2fde engine: platform: sdl: fix forgotten icon setup call 2023-10-23 00:31:30 +03:00
Alibek Omarov
3251b68df5 ref: gl: more simple search of GL func with alternative name (EXT, OES suffixes or no suffix) 2023-10-22 20:02:14 +03:00
Alibek Omarov
3ac8ad9484 engine: fixup endianness found by -Werror=strict-aliasing in old armv7hf compiler (d259421111) 2023-10-22 20:02:14 +03:00
Alibek Omarov
b9ca0d4563 engine: common: network: more simple IP address copying from sockaddr to netadr_t and back 2023-10-22 20:02:14 +03:00
mittorn
dcb3da53b0 engine/client: fallback to defaults in touch_reloadconfig if config not exist 2023-10-22 20:02:14 +03:00
mittorn
e68b19ed1a engine/client: handle touch config aspect ratio, try correctly handle touch aspect on resizeable windows 2023-10-22 20:02:14 +03:00
mittorn
14c7a84482 engine/client: always save touch config if it was resetted manually (helps after writing broken/empty config) 2023-10-22 20:02:14 +03:00
mittorn
c1d1aa6787 ref_gl: rewrite ARB workaround to check EXT/OES names, notify user that function found with different name 2023-10-22 20:02:14 +03:00
mittorn
bee81e9723 engine: Make SDL_GetBasePath error not fatal 2023-10-22 20:02:14 +03:00
mittorn
1bfb6c560a platform/sdl: add check for missing hint defines 2023-10-22 20:02:14 +03:00
mittorn
24d6f1788a platform/sdl: workaround ubuntu SDL2 bug preventing resolving any extensions on EGL 2023-10-22 20:02:14 +03:00
mittorn
fb95cc9a97 engine/client: respect m_ignore in mouse client code as grabbing window breaks touch input 2023-10-22 20:02:14 +03:00
mittorn
b949da291e engine: fix strict aliasing issues found by an old armv7hf compiler 2023-10-22 20:02:14 +03:00
Alibek Omarov
2ecbe5b67e engine: add testing master server at mentality.rip:27011 2023-10-22 19:39:58 +03:00
Andrey Akhmichin
6634e0487c Documentation: opensource-mods.md: update. 2023-10-22 19:21:13 +03:00
Alibek Omarov
7d61b5317c engine: client: add random key to the query, so we can validate master server response 2023-10-22 18:16:42 +03:00
Alibek Omarov
201258dc9e engine: client: allow passing additional filter through internetservers command arguments 2023-10-22 17:58:28 +03:00
Alibek Omarov
0330569537 engine: client: remove master server queries from NetAPI, they are never used by mods 2023-10-22 17:49:52 +03:00
Alibek Omarov
a1ab84a2ca mainui: update 2023-10-22 17:38:44 +03:00
Alibek Omarov
2d79f3ef7a engine: common: sys_con: enable writing build commit, os and arch to the engine.log 2023-10-22 17:37:09 +03:00
Alibek Omarov
99a7e9ad87 wscript: enable -Werror=nonnull 2023-10-22 17:37:09 +03:00
Alibek Omarov
02b8037f33 common: xash3d_types: add NONNULL attribute 2023-10-22 17:37:09 +03:00
Andrey Akhmichin
fc55a685e3 utils: mdldec: small optimizations. 2023-10-22 16:00:01 +03:00
Alibek Omarov
b76a75d6b4 ref: gl: respect gl_texture_nearest value for skyboxes 2023-10-20 18:55:22 +03:00
Ivan Avdeev
a251600c8a engine: common: imagelib: add KTX2 support (#1455)
* engine: common: imagelib: add KTX2 support

Adds basic KTX2 support for a few compressed formats. KTX2 essentially
is a Vulkan-centric texture format that supports literally hundreds of
pixel formats.
For now only support for these is added:
- `VK_FORMAT_BC4_UNORM_BLOCK`
- `VK_FORMAT_BC4_SNORM_BLOCK`
- `VK_FORMAT_BC5_UNORM_BLOCK`
- `VK_FORMAT_BC5_SNORM_BLOCK`
- `VK_FORMAT_BC6H_UFLOAT_BLOCK`
- `VK_FORMAT_BC6H_SFLOAT_BLOCK`
- `VK_FORMAT_BC7_UNORM_BLOCK`
- `VK_FORMAT_BC7_SRGB_BLOCK`

Adding more formats is relatively straightforward:
- Copy format definition from `VkFormat` enum in `vulkan_core.h`
- Add a new definition into `pixformat_t` enum.
- Add format size calculation into `Image_ComputeSize()`

While we're at it, also adds a few new formats to DDS:
- BC4_UNORM -- PF_BC4_UNSIGNED
- BC4_SNORM -- PF_BC4_SIGNED
- BC5_UNORM -- PF_BC5_UNSIGNED
- BC5_SNORM -- PF_BC5_SIGNED
- BC7 is expanded into BC7_UNORM and BC7_SRGB

ref_gl and ref_soft code is updated where it made sense. But not tested
really. Support for these formats has been tested with ref_vk.

* address spaces-vs-parentheses formatting where noticed

* parenthesize sizeofs

* move ktx2.h to imagelib as img_ktx2.h; massage it a bit

* use SetBits() instead of |=

* remove stale TODO comments
2023-10-18 10:31:40 +03:00
Andrey Akhmichin
c551aefd77 utils: mdldec: add boneweights support. 2023-10-18 10:12:48 +03:00
Andrey Akhmichin
f343f0da41 utils: mdldec: return different errorcodes on error. 2023-10-16 09:36:26 +03:00
Andrey Akhmichin
6d318a4102 utils: mdldec: smd.c: replace loop with VectorMA. 2023-10-16 09:35:51 +03:00
mittorn
a2b992d865 ref_gl: fix codestyle 2023-10-16 06:47:55 +03:00
mittorn
ddf3f2ffdb gl2shim: Allow drawing huge QUADS sequences by splitting drawcalls on overflow 2023-10-16 06:47:55 +03:00
Alibek Omarov
2454e87509 ref_gl: gl2shim: refactoring, add missing spaces in parentheses and ternary ops, remove singleline multiple assignments, use bitset macros 2023-10-16 06:47:55 +03:00
mittorn
0dc44249a2 ref_gl: fix XASH_GL_STATIC build 2023-10-16 06:47:55 +03:00
mittorn
150cbfa4de ref_gl: do not trust REFAPI context version, get it from OpenGL anyway 2023-10-16 06:47:55 +03:00
mittorn
c0b068d81b ref_gl: add workarounds for detecting extensions correctly on gles1/gles2 without wrapper (swiftshader works now) 2023-10-16 06:47:55 +03:00
mittorn
fbc312b6cf gl2shim: remove float suffix in shaders, that makes glsl100 work in swiftshader 2023-10-16 06:47:55 +03:00
mittorn
342e0d3e2e gl2shim: add glsl100 support 2023-10-16 06:47:55 +03:00
mittorn
202b228691 gl2shim: correct allocation/cleanup 2023-10-16 06:47:55 +03:00
mittorn
c9c1286803 ref_gl: fix typo 2023-10-16 06:47:55 +03:00
mittorn
eab98b0eda gl2shim: dynamic extension checking and autoconfiguration 2023-10-16 06:47:55 +03:00
mittorn
35be80fc21 ref_gl: request gl1.1 if compatibility profile unavailiable, this fixes launching with GL <= 2.0, improve old version extension detection 2023-10-16 06:47:55 +03:00
mittorn
6041bb0a43 platform/sdl: fix safegl 2023-10-16 06:47:55 +03:00
mittorn
c7dd9d6437 ref_gl: init r_temppool before InitExtensions, fix extension string allocation 2023-10-16 06:47:55 +03:00
mittorn
d378878c91 gl2shim: try fix getting program link log 2023-10-16 06:47:55 +03:00
mittorn
4a2f8cafcd gl2shim: try fix errors in ViZual ZtudiO 2023-10-16 06:47:55 +03:00
mittorn
d254bac16b ref_gl: integrate gl2shim extensions 2023-10-16 06:47:55 +03:00
mittorn
e23b632ce5 ref_gl: add missing non-arb shader functions 2023-10-16 06:47:55 +03:00
mittorn
2f321b1471 ref_gl: implement minimum inclusion version for GL extensions, implement quering extensions on core profile 2023-10-16 06:47:55 +03:00
mittorn
0265e88d8f gl2shim: fix wrong color vertex 2023-10-16 06:47:55 +03:00
mittorn
4114d2f24d gl2shim: more refactoring 2023-10-16 06:47:55 +03:00
mittorn
8124035763 ref_gl: try fix psvita 2023-10-16 06:47:55 +03:00
mittorn
96127c6eb0 gl2shim: make shaders code more portable 2023-10-16 06:47:55 +03:00
mittorn
cf65a39b83 gl2shim: refactoring 2023-10-16 06:47:55 +03:00
mittorn
0341f96b70 gl2shim: use IBO for quads 2023-10-16 06:47:55 +03:00
mittorn
c95d91cfe3 gl2shim: limit begin-end chain length, cycle incremental buffers 2023-10-16 06:47:55 +03:00
mittorn
cbd10c6279 gl2shim: improve shader version handling, fix particle issues 2023-10-16 06:47:55 +03:00
mittorn
5df9e57743 gl2shim: support incremental non-persistent buffers for arrays 2023-10-16 06:47:55 +03:00
mittorn
c178022fb5 gl2shim: persistent incremental streaming buffers, buffer cycling support 2023-10-16 06:47:55 +03:00
mittorn
724c29d711 gl2shim: implement fallback vbo, glDrawRangeElements with non-vbo buffer works now on core contexts 2023-10-16 06:47:55 +03:00
mittorn
74a2dbeb91 gl2shim: batcher experiments (UGLY, DO NOT USE), fix bad shader bindings, Draw QUADS with TRIFAN when possible 2023-10-16 06:47:55 +03:00
mittorn
5d20d24ebc gl2shim: simple matrix invalidation, do not calculate MVP every drawcall 2023-10-16 06:47:55 +03:00
mittorn
0e2fc277c8 gl2shim: bind dummy VAO on DrawElements implementation on glcore, this generates GL Errors, but renders fine on mesa 2023-10-16 06:47:55 +03:00
mittorn
1505740b73 ref_gl: fix enabling multitexturing on GLES 2023-10-16 06:47:55 +03:00
mittorn
6bad07b39d gl2shim: support low (<130) shaders 2023-10-16 06:47:55 +03:00
mittorn
f85437dfc5 gl2shim: implement client arrays (not in glcore/vao mode), make studio/world array render work 2023-10-16 06:47:55 +03:00
mittorn
c765261db6 ref_gl: fix late studio cvars registration, enable DrawRangeElements in GLES contexts 2023-10-16 06:47:55 +03:00
mittorn
73087ead2d ref_gl: fix build with XASH_GL_STATIC, avoid using ARB shader extension on core context 2023-10-16 06:47:55 +03:00
mittorn
8c88e82709 gl2shim: support more GLSL versions 2023-10-16 06:47:55 +03:00
mittorn
40dd6e0234 gl2shim: Cleanup warnings, use APIENTRY declarations, stub unsupported functions 2023-10-16 06:47:55 +03:00
mittorn
eb23b226cc Workaround core context issues 2023-10-16 06:47:55 +03:00
mittorn
676526a518 ref_gl: fix creating core context, support core in gl2shim by creating dumb array object 2023-10-16 06:47:55 +03:00
mittorn
7e0bd86b65 ref_gl: allow enabling XASH_GLES without wrapper, add ref_gles3compat, wrap gles functions in gl2wrap when XASH_GLES enabled 2023-10-16 06:47:55 +03:00
mittorn
97489635af gl2shim: limited matrix support 2023-10-16 06:47:55 +03:00
mittorn
a9ea3976a7 ref_gl: introduce gl2_shim based on vgl_shim for future limited core/gles context support (SLOW, still needs ffp for matrix operations) 2023-10-16 06:47:55 +03:00
Alibek Omarov
5501ca927a engine: client: respect cl_allow_download and cl_download_ingame for legacy servers 2023-10-16 06:47:55 +03:00
Andrey Akhmichin
a19fb82d66 utils: mdldec: smd.c: add leading zero to number in sequence filenames. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
9d032e953f utils: mdldec: qc.c: avoid to use brackets with conclusions. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
38587151a9 utils: mdldec: qc.c: add missing refence meshes count. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
02d5bab04b utils: mdldec: qc.c: put every sequence property to separate line. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
d8f3e53b1f utils: mdldec: qc.c: add missing quotes. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
877ed8a92a utils: mdldec: qc.c: put every texture name to separate line. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
487a652aa8 utils: mdldec: qc.c: calculate sequence group size. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
64c5d141af utils: mdldec: qc.c: put controller name instead of index for mouth controller. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
16db8a8008 utils: mdldec: qc.c: put tabs where possible. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
b6b14da102 utils: mdldec: qc.c: reorder output. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
a575605c75 utils: mdldec: qc.c: always put $flags keyword with value. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
a205a3e878 utils: mdldec: qc.c: remove useless backward slashes from output. 2023-10-16 06:18:06 +03:00
Andrey Akhmichin
26ef3e274c utils: mdldec: smd.c: linear movement loss fix. 2023-10-14 17:38:48 +03:00
Alibek Omarov
33be1b7591 engine: client: let time flow in Xash demos 2023-10-14 15:11:26 +03:00
Alibek Omarov
de19d78571 ref: fix late registration of studio cvars (thanks, @mittorn) 2023-10-14 08:11:25 +03:00
mittorn
287381d5ca ref_gl: remove complete useless macro, enable VBO under option 2023-10-14 08:04:17 +03:00
89 changed files with 4202 additions and 1068 deletions

24
Documentation/donate.md Normal file
View File

@@ -0,0 +1,24 @@
# Developers donation page
On this page you can find links where you can support each developer individually, who has provided public sponsorship information.
### [a1batross](https://github.com/a1batross)
* Initial Xash3D SDL2/Linux port author, Xash3D FWGS engine maintainer, creator of non-commercial Flying With Gauss organization.
* Boosty page: https://boosty.to/a1ba
### [nekonomicon](https://github.com/nekonomicon)
* [hlsdk-portable](https://github.com/FWGS/hlsdk-portable), [mdldec](../utils/mdldec), [opensource-mods.md](opensource-mods.md) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=nekonomicon) (*BSD/clang port, PNG support, etc).
* Boosty page: https://boosty.to/nekonomicon
### [Velaron](https://github.com/Velaron)
* [cs16-client](https://github.com/Velaron/cs16-client) & [tf15-client](https://github.com/Velaron/tf15-client) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=Velaron) (Android port, voice chat, etc).
* BuyMeACoffee page: https://www.buymeacoffee.com/velaron
### [SNMetamorph](https://github.com/SNMetamorph)
* [PrimeXT](https://github.com/SNMetamorph/PrimeXT) & [GoldSrc Monitor](https://github.com/SNMetamorph/goldsrc-monitor) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=SNMetamorph) (Windows port, voice chat, etc).
* BTC: `16GAzK3qei5AwBW7sggXp3yNcFHBtdpxXj`
* ETH (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
* USDT (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
* USDC (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`

View File

@@ -133,22 +133,8 @@ Available in mod archive on ModDB - https://www.moddb.com/mods/overturn
## Oz Deathmatch ## Oz Deathmatch
Mirrored on github - https://github.com/nekonomicon/OZDM Mirrored on github - https://github.com/nekonomicon/OZDM
## Spirit of Half-Life
[Logic&Trick's](https://github.com/LogicAndTrick) mirror - https://files.logic-and-trick.com/#/Half-Life/Mods/Spirit%20of%20Half-Life
## Threewave CTF
*Unfinished mod by Valve Software*
Available in Valve's Half-Life repository with Deathmatch Classic sources - https://github.com/ValveSoftware/halflife/tree/master/dmc
## Trinity Render
Available on ModDB: https://www.moddb.com/mods/half-life-episode-two/downloads/trinity-rendering-engine-v308f
## Tyrian: Ground Assault
Available on ModDB: https://www.moddb.com/mods/tyriangroundassault/downloads/tyrianga-v1-0-src
## Paranoia ## Paranoia
Available on ModDB: https://www.moddb.com/mods/paranoia/downloads/paranoia-toolkit Available on ModDB - https://www.moddb.com/mods/paranoia/downloads/paranoia-toolkit
## Paranoia 2: The Savior ## Paranoia 2: The Savior
Prealpha, mirrored on github - https://github.com/a1batross/Paranoia2_ancient Prealpha, mirrored on github - https://github.com/a1batross/Paranoia2_ancient
@@ -163,12 +149,37 @@ Was found on HLFX - http://hlfx.ru/forum/showthread.php?s=2c892dfc52f72be52a89c3
## Ricochet ## Ricochet
Available in Valve's Half-Life repository - https://github.com/ValveSoftware/halflife/tree/master/ricochet Available in Valve's Half-Life repository - https://github.com/ValveSoftware/halflife/tree/master/ricochet
## Spirit of Half-Life
[Logic&Trick's](https://github.com/LogicAndTrick) mirror - https://files.logic-and-trick.com/#/Half-Life/Mods/Spirit%20of%20Half-Life
## The Wastes
Version 1.5: mirrored on code.idtech.space - https://code.idtech.space/vera/halflife-thewastes-sdk
## Threewave CTF
*Unfinished mod by Valve Software*
Available in Valve's Half-Life repository with Deathmatch Classic sources - https://github.com/ValveSoftware/halflife/tree/master/dmc
## Trinity Render
Available on ModDB - https://www.moddb.com/mods/half-life-episode-two/downloads/trinity-rendering-engine-v308f
## Tyrian: Ground Assault
Available on ModDB - https://www.moddb.com/mods/tyriangroundassault/downloads/tyrianga-v1-0-src
## Wasteland
Mirrored on code.idtech.space - https://code.idtech.space/vera/halflife-wasteland-sdk
## Wizard Wars ## Wizard Wars
Download page on official site - http://www.thothie.com/ww/ Download page on official site - http://www.thothie.com/ww/
## XashXT ## XashXT
Mirrored on github - https://github.com/a1batross/XashXT_original Mirrored on github - https://github.com/a1batross/XashXT_original
## Xen-Warrior
*Source code is a part of Spirit of Half-Life 1.0-1.2 under XENWARRIOR macro*
[Logic&Trick's](https://github.com/LogicAndTrick) mirror - https://files.logic-and-trick.com/#/Half-Life/Mods/Spirit%20of%20Half-Life
## Zombie-X ## Zombie-X
Available in mod archive on ModDB - https://www.moddb.com/mods/zombie-x-10-final/downloads/zombie-x-10-dle-beta6-last-version Available in mod archive on ModDB - https://www.moddb.com/mods/zombie-x-10-final/downloads/zombie-x-10-dle-beta6-last-version
@@ -190,12 +201,12 @@ malortie's recreation - https://github.com/malortie/hl-aom
Branch **aom** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aom Branch **aom** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aom
## Afraid of Monsters: Director's cut ## Afraid of Monsters: Director's cut
Reverse-engineered code, branch **aomdc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aomdc Reverse-engineered code: branch **aomdc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aomdc
## Azure Sheep ## Azure Sheep
malortie's recreation - https://github.com/malortie/hl-asheep malortie's recreation - https://github.com/malortie/hl-asheep
Reverse-engineered code, branch **asheep** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/asheep Reverse-engineered code: branch **asheep** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/asheep
## Big Lolly ## Big Lolly
malortie's recreation - https://github.com/malortie/hl-biglolly malortie's recreation - https://github.com/malortie/hl-biglolly
@@ -232,12 +243,17 @@ Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_lif
## Escape from the Darkness ## Escape from the Darkness
malortie's recreation - https://github.com/malortie/hl-eftd malortie's recreation - https://github.com/malortie/hl-eftd
Reverse-engineered code, branch **eftd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/eftd Reverse-engineered code: branch **eftd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/eftd
## Half-Life: Black Guard
*This mod uses dlls from Cleaner's Adventures*
Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd
## Half-Life: Blue Shift ## Half-Life: Blue Shift
Unkle Mike's recreation - https://hlfx.ru/forum/showthread.php?s=&threadid=5253 Unkle Mike's recreation - https://hlfx.ru/forum/showthread.php?s=&threadid=5253
Reverse-engineered code, branch **bshift** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/bshift Reverse-engineered code: branch **bshift** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/bshift
## Half-Life: Induction ## Half-Life: Induction
Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/induction Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/induction
@@ -245,12 +261,12 @@ Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/
## Half-Life: Opposing Force ## Half-Life: Opposing Force
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/hlsdk-xash3d Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/hlsdk-xash3d
Reverse-engineered code, clean branch **opfor** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/opfor Reverse-engineered code: clean branch **opfor** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/opfor
Spirit of Half Life: Opposing-Force Edition - https://github.com/Hammermaps-DEV/SOHL-V1.9-Opposing-Force-Edition Spirit of Half Life: Opposing-Force Edition - https://github.com/Hammermaps-DEV/SOHL-V1.9-Opposing-Force-Edition
## Half-Life: Rebellion ## Half-Life: Rebellion
Reverse-engineered code, branch **rebellion** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/rebellion Reverse-engineered code: branch **rebellion** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/rebellion
## Half-Life: Urbicide ## Half-Life: Urbicide
Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hl_urbicide Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hl_urbicide
@@ -258,7 +274,7 @@ Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portabl
## Half-Life: Visitors ## Half-Life: Visitors
malortie's recreation - https://github.com/malortie/hl-visitors malortie's recreation - https://github.com/malortie/hl-visitors
Reverse-engineered code, branch **visitors** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/visitors Reverse-engineered code: branch **visitors** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/visitors
## Half-Secret ## Half-Secret
Branch **half-secret** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-secret Branch **half-secret** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-secret
@@ -271,18 +287,18 @@ Branch **noffice** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tr
## Poke 646 ## Poke 646
malortie's recreation - https://github.com/malortie/hl-poke646 malortie's recreation - https://github.com/malortie/hl-poke646
Reverse-engineered code, branch **poke646** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646 Reverse-engineered code: branch **poke646** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646
## Poke 646: Vendetta ## Poke 646: Vendetta
malortie's recreation - https://github.com/malortie/hl-poke646-vendetta malortie's recreation - https://github.com/malortie/hl-poke646-vendetta
Reverse-engineered code, branch **poke646_vendetta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646_vendetta Reverse-engineered code: branch **poke646_vendetta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646_vendetta
## Residual Life ## Residual Life
Reverse-engineered code, branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point Reverse-engineered code: branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point
## Residual Point ## Residual Point
Reverse-engineered code, branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point Reverse-engineered code: branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point
## Sewer Beta ## Sewer Beta
Branch **sewer_beta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sewer_beta Branch **sewer_beta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sewer_beta
@@ -293,12 +309,12 @@ Reverse-engineered code by Velaron - https://github.com/Velaron/tf15-client
## The Gate ## The Gate
malortie's recreation - https://github.com/malortie/hl-thegate malortie's recreation - https://github.com/malortie/hl-thegate
Reverse-engineered code, branch **thegate** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/thegate Reverse-engineered code: branch **thegate** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/thegate
## They Hunger ## They Hunger
malortie's recreation - https://github.com/malortie/hl-theyhunger malortie's recreation - https://github.com/malortie/hl-theyhunger
Reverse-engineered code, branch **theyhunger** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/theyhunger Reverse-engineered code: branch **theyhunger** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/theyhunger
They Hunger: Tactical - https://www.moddb.com/mods/they-hunger-tactical/downloads/tht-source-code-documentation They Hunger: Tactical - https://www.moddb.com/mods/they-hunger-tactical/downloads/tht-source-code-documentation
@@ -341,16 +357,22 @@ Branch **half-screwed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portab
Port to Linux - https://github.com/fmoraw/NS Port to Linux - https://github.com/fmoraw/NS
## Spirit of Half-Life ## Spirit of Half-Life
Version 1.2, branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2 Version 1.2: branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2
## Swiss Cheese Halloween 2002 ## Swiss Cheese Halloween 2002
Just more playable version by malortie - https://github.com/malortie/hl-shall Just more playable version by malortie - https://github.com/malortie/hl-shall
Branch **halloween** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/halloween Branch **halloween** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/halloween
## The Wastes
Version 1.5: Port to Linux - https://git.mentality.rip/a1batross/halflife-thewastes-sdk
## Threewave CTF ## Threewave CTF
Branch **dmc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/dmc Branch **dmc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/dmc
## Xen-Warrior
Branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2
## Zombie-X ## Zombie-X
Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x

View File

@@ -1,33 +1,27 @@
# Xash3D FWGS Engine # Xash3D FWGS Engine <img align="right" width="128" height="128" src="https://github.com/FWGS/xash3d-fwgs/raw/master/game_launch/icon-xash-material.png" alt="Xash3D FWGS icon" />
[![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \ [![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
[![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) [![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike with extended features and crossplatform. Xash3D FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
``` Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike.
Xash3D is a game engine, aimed to provide compatibility with Half-Life Engine,
as well as to give game developers well known workflow and extend it. ## Donate
Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine [![Donate to FWGS button](https://img.shields.io/badge/Donate_to_FWGS-%3C3-magenta)](Documentation/donate.md) \
``` If you like Xash3D FWGS, consider supporting individual engine maintainers. By supporting us, you help to continue developing this game engine further. The sponsorship links are available in [documentation](Documentation/donate.md).
## Fork features ## Fork features
* HLSDK 2.4 support. * Steam Half-Life (HLSDK 2.4) support.
* Crossplatform: supported x86 and ARM on Windows/Linux/BSD/Android. ([see docs for more info](Documentation/ports.md)) * Crossplatform and modern compilers support: supports Windows, Linux, BSD & Android on x86 & ARM and [many more](Documentation/ports.md).
* Modern compilers support: say no more to MSVC6. * Better multiplayer support: multiple master servers, headless dedicated server, voice chat and IPv6 support.
* Better multiplayer support: multiple master servers, headless dedicated server. * Multiple renderers support: OpenGL, GLESv1, GLESv2 and Software.
* Mobility API: allows better game integration on mobile devices(vibration, touch controls) * Advanced virtual filesystem: `.pk3` and `.pk3dir` support, compatibility with GoldSrc FS module, fast case-insensitivity emulation for crossplatform.
* Different input methods: touch, gamepad and classic mouse & keyboard. * Mobility API: better game integration on mobile devices (vibration, touch controls)
* Different input methods: touch and gamepad in addition to mouse & keyboard.
* TrueType font rendering, as a part of mainui_cpp. * TrueType font rendering, as a part of mainui_cpp.
* Multiple renderers support: OpenGL, GLESv1, GLESv2, Software. * External VGUI support module.
* Voice support. * PNG & KTX2 image format support.
* External filesystem module like in GoldSrc engine. * [A set of small improvements](Documentation/), without broken compatibility.
* External vgui support module.
* PNG image format support.
* A set of small improvements, without broken compatibility.
## Planned fork features
* Virtual Reality support and game API.
* Vulkan renderer.
## Installation & Running ## Installation & Running
0) Get Xash3D FWGS binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code. 0) Get Xash3D FWGS binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code.

View File

@@ -9,7 +9,20 @@ NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 ==
======================================================================== ========================================================================
*/ */
#define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24 || type == PF_LUMINANCE) #define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24 || type == PF_LUMINANCE)
#define ImageDXT( type ) (type == PF_DXT1 || type == PF_DXT3 || type == PF_DXT5 || type == PF_ATI2 || type == PF_BC6H_SIGNED || type == PF_BC6H_UNSIGNED || type == PF_BC7) #define ImageCompressed( type ) \
( type == PF_DXT1 \
|| type == PF_DXT3 \
|| type == PF_DXT5 \
|| type == PF_ATI2 \
|| type == PF_BC4_SIGNED \
|| type == PF_BC4_UNSIGNED \
|| type == PF_BC5_SIGNED \
|| type == PF_BC5_UNSIGNED \
|| type == PF_BC6H_SIGNED \
|| type == PF_BC6H_UNSIGNED \
|| type == PF_BC7_UNORM \
|| type == PF_BC7_SRGB \
|| type == PF_KTX2_RAW )
typedef enum typedef enum
{ {
@@ -25,9 +38,15 @@ typedef enum
PF_DXT3, // s3tc DXT3/BC2 format PF_DXT3, // s3tc DXT3/BC2 format
PF_DXT5, // s3tc DXT5/BC3 format PF_DXT5, // s3tc DXT5/BC3 format
PF_ATI2, // latc ATI2N/BC5 format PF_ATI2, // latc ATI2N/BC5 format
PF_BC4_SIGNED,
PF_BC4_UNSIGNED,
PF_BC5_SIGNED,
PF_BC5_UNSIGNED,
PF_BC6H_SIGNED, // bptc BC6H signed FP16 format PF_BC6H_SIGNED, // bptc BC6H signed FP16 format
PF_BC6H_UNSIGNED, // bptc BC6H unsigned FP16 format PF_BC6H_UNSIGNED, // bptc BC6H unsigned FP16 format
PF_BC7, // bptc BC7 format PF_BC7_UNORM, // bptc BC7 format
PF_BC7_SRGB,
PF_KTX2_RAW, // Raw KTX2 data, used for yet unsupported KTX2 subformats
PF_TOTALCOUNT, // must be last PF_TOTALCOUNT, // must be last
} pixformat_t; } pixformat_t;
@@ -50,6 +69,7 @@ typedef enum
IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals
IL_OVERVIEW = BIT(6), // overview required some unque operations IL_OVERVIEW = BIT(6), // overview required some unque operations
IL_LOAD_PLAYER_DECAL = BIT(7), // special mode for player decals IL_LOAD_PLAYER_DECAL = BIT(7), // special mode for player decals
IL_KTX2_RAW = BIT(8), // renderer can consume raw KTX2 files (e.g. ref_vk)
} ilFlags_t; } ilFlags_t;
// goes into rgbdata_t->encode // goes into rgbdata_t->encode

View File

@@ -57,6 +57,7 @@ typedef uint64_t longtime_t;
#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions #define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions
#define BIT( n ) ( 1U << ( n )) #define BIT( n ) ( 1U << ( n ))
#define BIT64( n ) ( 1ULL << ( n ))
#define GAMMA ( 2.2f ) // Valve Software gamma #define GAMMA ( 2.2f ) // Valve Software gamma
#define INVGAMMA ( 1.0f / 2.2f ) // back to 1.0 #define INVGAMMA ( 1.0f / 2.2f ) // back to 1.0
#define TEXGAMMA ( 0.9f ) // compensate dim textures #define TEXGAMMA ( 0.9f ) // compensate dim textures
@@ -86,16 +87,19 @@ typedef uint64_t longtime_t;
#endif #endif
#define _format(x) __attribute__((format(printf, x, x+1))) #define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport ) #define EXPORT __declspec( dllexport )
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL
#else #else
#define EXPORT #define EXPORT
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL
#endif #endif
#if ( __GNUC__ >= 3 ) #if ( __GNUC__ >= 3 )
@@ -177,6 +181,7 @@ typedef struct dll_info_s
} dll_info_t; } dll_info_t;
typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs ); typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs );
typedef void *(*pfnCreateInterface_t)( const char *, int * );
// config strings are a general means of communication from // config strings are a general means of communication from
// the server to all connected clients. // the server to all connected clients.

View File

@@ -1124,7 +1124,10 @@ void CL_FinishTimeDemo( void )
time = host.realtime - cls.td_starttime; time = host.realtime - cls.td_starttime;
if( !time ) time = 1.0; if( !time ) time = 1.0;
Con_Printf( "%i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time ); Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time );
if( Sys_CheckParm( "-timedemo" ))
CL_Quit_f();
} }
/* /*

View File

@@ -3336,6 +3336,9 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX ) if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX )
return; // IPX no longer support return; // IPX no longer support
if( request == NETAPI_REQUEST_SERVERLIST )
return; // no support for server list requests
// find a free request // find a free request
for( i = 0; i < MAX_REQUESTS; i++ ) for( i = 0; i < MAX_REQUESTS; i++ )
{ {
@@ -3372,28 +3375,9 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
nr->resp.remote_address = *remote_address; nr->resp.remote_address = *remote_address;
nr->flags = flags; nr->flags = flags;
if( request == NETAPI_REQUEST_SERVERLIST )
{
char fullquery[512];
size_t len;
len = CL_BuildMasterServerScanRequest( fullquery, sizeof( fullquery ), false );
// make sure that port is specified
if( !nr->resp.remote_address.port )
nr->resp.remote_address.port = MSG_BigShort( PORT_MASTER );
// grab the list from the master server
NET_SendPacket( NS_CLIENT, len, fullquery, nr->resp.remote_address );
clgame.request_type = NET_REQUEST_CLIENT;
clgame.master_request = nr; // holds the master request unitl the master acking
}
else
{
// local servers request // local servers request
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request ); Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req ); Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req );
}
} }
/* /*
@@ -3421,13 +3405,6 @@ static void GAME_EXPORT NetAPI_CancelRequest( int context )
nr->pfnFunc( &nr->resp ); nr->pfnFunc( &nr->resp );
} }
if( clgame.net_requests[i].resp.type == NETAPI_REQUEST_SERVERLIST && &clgame.net_requests[i] == clgame.master_request )
{
if( clgame.request_type == NET_REQUEST_CLIENT )
clgame.request_type = NET_REQUEST_CANCEL;
clgame.master_request = NULL;
}
memset( &clgame.net_requests[i], 0, sizeof( net_request_t )); memset( &clgame.net_requests[i], 0, sizeof( net_request_t ));
break; break;
} }
@@ -3456,8 +3433,6 @@ void GAME_EXPORT NetAPI_CancelAllRequests( void )
} }
memset( clgame.net_requests, 0, sizeof( clgame.net_requests )); memset( clgame.net_requests, 0, sizeof( clgame.net_requests ));
clgame.request_type = NET_REQUEST_CANCEL;
clgame.master_request = NULL;
} }
/* /*

View File

@@ -982,28 +982,21 @@ pfnCheckGameDll
*/ */
int GAME_EXPORT pfnCheckGameDll( void ) int GAME_EXPORT pfnCheckGameDll( void )
{ {
string dllpath; #ifdef XASH_INTERNAL_GAMELIBS
void *hInst;
#if TARGET_OS_IPHONE
// loading server library drains too many ram
// so 512MB iPod Touch cannot even connect to
// to servers in cstrike
return true; return true;
#endif #else
string dllpath;
if( svgame.hInstance ) if( svgame.hInstance )
return true; return true;
COM_GetCommonLibraryPath( LIBRARY_SERVER, dllpath, sizeof( dllpath )); COM_GetCommonLibraryPath( LIBRARY_SERVER, dllpath, sizeof( dllpath ));
if(( hInst = COM_LoadLibrary( dllpath, true, false )) != NULL ) if( FS_FileExists( dllpath, false ))
{
COM_FreeLibrary( hInst ); // don't increase linker's reference counter
return true; return true;
}
Con_Reportf( S_WARN "Could not load server library: %s\n", COM_GetLibraryError() );
return false; return false;
#endif
} }
/* /*

View File

@@ -34,7 +34,7 @@ GNU General Public License for more details.
CVAR_DEFINE_AUTO( mp_decals, "300", FCVAR_ARCHIVE, "decals limit in multiplayer" ); CVAR_DEFINE_AUTO( mp_decals, "300", FCVAR_ARCHIVE, "decals limit in multiplayer" );
CVAR_DEFINE_AUTO( dev_overview, "0", 0, "draw level in overview-mode" ); CVAR_DEFINE_AUTO( dev_overview, "0", 0, "draw level in overview-mode" );
CVAR_DEFINE_AUTO( cl_resend, "6.0", 0, "time to resend connect" ); CVAR_DEFINE_AUTO( cl_resend, "6.0", 0, "time to resend connect" );
CVAR_DEFINE_AUTO( cl_allow_download, "1", FCVAR_ARCHIVE, "allow to downloading resources from the server" ); CVAR_DEFINE( cl_allow_download, "cl_allowdownload", "1", FCVAR_ARCHIVE, "allow to downloading resources from the server" );
CVAR_DEFINE_AUTO( cl_allow_upload, "1", FCVAR_ARCHIVE, "allow to uploading resources to the server" ); CVAR_DEFINE_AUTO( cl_allow_upload, "1", FCVAR_ARCHIVE, "allow to uploading resources to the server" );
CVAR_DEFINE_AUTO( cl_download_ingame, "1", FCVAR_ARCHIVE, "allow to downloading resources while client is active" ); CVAR_DEFINE_AUTO( cl_download_ingame, "1", FCVAR_ARCHIVE, "allow to downloading resources while client is active" );
CVAR_DEFINE_AUTO( cl_logofile, "lambda", FCVAR_ARCHIVE, "player logo name" ); CVAR_DEFINE_AUTO( cl_logofile, "lambda", FCVAR_ARCHIVE, "player logo name" );
@@ -92,7 +92,7 @@ client_t cl;
client_static_t cls; client_static_t cls;
clgame_static_t clgame; clgame_static_t clgame;
void CL_InternetServers_f( void ); static void CL_SendMasterServerScanRequest( void );
//====================================================================== //======================================================================
int GAME_EXPORT CL_Active( void ) int GAME_EXPORT CL_Active( void )
@@ -1081,7 +1081,7 @@ void CL_CheckForResend( void )
qboolean bandwidthTest; qboolean bandwidthTest;
if( cls.internetservers_wait ) if( cls.internetservers_wait )
CL_InternetServers_f(); CL_SendMasterServerScanRequest();
// if the local server is running and we aren't then connect // if the local server is running and we aren't then connect
if( cls.state == ca_disconnected && SV_Active( )) if( cls.state == ca_disconnected && SV_Active( ))
@@ -1574,10 +1574,10 @@ void CL_LocalServers_f( void )
CL_BuildMasterServerScanRequest CL_BuildMasterServerScanRequest
================= =================
*/ */
size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat ) static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, uint32_t *key, qboolean nat, const char *filter )
{ {
size_t remaining; size_t remaining;
char *info; char *info, temp[32];
if( unlikely( size < sizeof( MS_SCAN_REQUEST ))) if( unlikely( size < sizeof( MS_SCAN_REQUEST )))
return 0; return 0;
@@ -1587,7 +1587,9 @@ size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat )
info = buf + sizeof( MS_SCAN_REQUEST ) - 1; info = buf + sizeof( MS_SCAN_REQUEST ) - 1;
remaining = size - sizeof( MS_SCAN_REQUEST ); remaining = size - sizeof( MS_SCAN_REQUEST );
info[0] = 0; Q_strncpy( info, filter, remaining );
*key = COM_RandomLong( 0, 0x7FFFFFFF );
#ifndef XASH_ALL_SERVERS #ifndef XASH_ALL_SERVERS
Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining ); Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining );
@@ -1595,9 +1597,24 @@ size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat )
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining ); Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );
Q_snprintf( temp, sizeof( temp ), "%x", *key );
Info_SetValueForKey( info, "key", temp, remaining );
return sizeof( MS_SCAN_REQUEST ) + Q_strlen( info ); return sizeof( MS_SCAN_REQUEST ) + Q_strlen( info );
} }
/*
=================
CL_SendMasterServerScanRequest
=================
*/
static void CL_SendMasterServerScanRequest( void )
{
cls.internetservers_wait = NET_SendToMasters( NS_CLIENT,
cls.internetservers_query_len, cls.internetservers_query );
cls.internetservers_pending = true;
}
/* /*
================= =================
CL_InternetServers_f CL_InternetServers_f
@@ -1605,26 +1622,24 @@ CL_InternetServers_f
*/ */
void CL_InternetServers_f( void ) void CL_InternetServers_f( void )
{ {
char fullquery[512];
size_t len;
qboolean nat = cl_nat.value != 0.0f; qboolean nat = cl_nat.value != 0.0f;
uint32_t key;
len = CL_BuildMasterServerScanRequest( fullquery, sizeof( fullquery ), nat ); if( Cmd_Argc( ) > 2 || ( Cmd_Argc( ) == 2 && !Info_IsValid( Cmd_Argv( 1 ))))
{
Con_Printf( S_USAGE "internetservers [filter]\n" );
return;
}
cls.internetservers_query_len = CL_BuildMasterServerScanRequest(
cls.internetservers_query, sizeof( cls.internetservers_query ),
&cls.internetservers_key, nat, Cmd_Argv( 1 ));
Con_Printf( "Scanning for servers on the internet area...\n" ); Con_Printf( "Scanning for servers on the internet area...\n" );
NET_Config( true, true ); // allow remote NET_Config( true, true ); // allow remote
cls.internetservers_wait = NET_SendToMasters( NS_CLIENT, len, fullquery ); CL_SendMasterServerScanRequest();
cls.internetservers_pending = true;
if( !cls.internetservers_wait )
{
// now we clearing the vgui request
if( clgame.master_request != NULL )
memset( clgame.master_request, 0, sizeof( net_request_t ));
clgame.request_type = NET_REQUEST_GAMEUI;
}
} }
/* /*
@@ -2152,6 +2167,25 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
return; return;
} }
// check the extra header
if( MSG_ReadByte( msg ) == 0x7f )
{
uint32_t key = MSG_ReadDword( msg );
if( cls.internetservers_key != key )
{
Con_Printf( S_WARN "unexpected server list packet from %s (invalid key)\n", NET_AdrToString( from ));
return;
}
MSG_ReadByte( msg ); // reserved byte
}
else
{
Con_Printf( S_WARN "invalid server list packet from %s (missing extra header)\n", NET_AdrToString( from ));
return;
}
// serverlist got from masterserver // serverlist got from masterserver
while( MSG_GetNumBitsLeft( msg ) > 8 ) while( MSG_GetNumBitsLeft( msg ) > 8 )
{ {
@@ -2161,59 +2195,11 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
// list is ends here // list is ends here
if( !servadr.port ) if( !servadr.port )
{
if( clgame.request_type == NET_REQUEST_CLIENT && clgame.master_request != NULL )
{
net_request_t *nr = clgame.master_request;
net_adrlist_t *list, **prev;
// setup the answer
nr->resp.remote_address = from;
nr->resp.error = NET_SUCCESS;
nr->resp.ping = host.realtime - nr->timesend;
if( nr->timeout <= host.realtime )
SetBits( nr->resp.error, NET_ERROR_TIMEOUT );
Con_Printf( "serverlist call: %s\n", NET_AdrToString( from ));
nr->pfnFunc( &nr->resp );
// throw the list, now it will be stored in user area
prev = (net_adrlist_t**)&nr->resp.response;
while( 1 )
{
list = *prev;
if( !list ) break;
// throw out any variables the game created
*prev = list->next;
Mem_Free( list );
}
memset( nr, 0, sizeof( *nr )); // done
clgame.request_type = NET_REQUEST_CANCEL;
clgame.master_request = NULL;
}
break; break;
}
if( clgame.request_type == NET_REQUEST_CLIENT && clgame.master_request != NULL )
{
net_request_t *nr = clgame.master_request;
net_adrlist_t *list;
// adding addresses into list
list = Z_Malloc( sizeof( *list ));
list->remote_address = servadr;
list->next = nr->resp.response;
nr->resp.response = list;
}
else if( clgame.request_type == NET_REQUEST_GAMEUI )
{
NET_Config( true, false ); // allow remote NET_Config( true, false ); // allow remote
Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION ); Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION );
} }
}
if( cls.internetservers_pending ) if( cls.internetservers_pending )
{ {
@@ -2261,10 +2247,13 @@ void CL_ReadNetMessage( void )
while( CL_GetMessage( net_message_buffer, &curSize )) while( CL_GetMessage( net_message_buffer, &curSize ))
{ {
if( cls.legacymode && *((int *)&net_message_buffer) == 0xFFFFFFFE ) const int split_header = LittleLong( 0xFFFFFFFE );
if( cls.legacymode && !memcmp( &split_header, net_message_buffer, sizeof( split_header )))
{
// Will rewrite existing packet by merged // Will rewrite existing packet by merged
if( !NetSplit_GetLong( &cls.netchan.netsplit, &net_from, net_message_buffer, &curSize ) ) if( !NetSplit_GetLong( &cls.netchan.netsplit, &net_from, net_message_buffer, &curSize ) )
continue; continue;
}
MSG_Init( &net_message, "ServerData", net_message_buffer, curSize ); MSG_Init( &net_message, "ServerData", net_message_buffer, curSize );
@@ -2341,7 +2330,7 @@ void CL_ReadPackets( void )
// decide the simulation time // decide the simulation time
cl.oldtime = cl.time; cl.oldtime = cl.time;
if( cls.demoplayback != DEMO_XASH3D && !cl.paused ) if( !cl.paused )
cl.time += host.frametime; cl.time += host.frametime;
// demo time // demo time

View File

@@ -87,15 +87,6 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
return CL_DrawCharacter( x, y, number, color, &g_scaled_font, flags ); return CL_DrawCharacter( x, y, number, color, &g_scaled_font, flags );
} }
static void *pfnGetNativeObject( const char *obj )
{
if( !obj )
return NULL;
// Backend should consider that obj is case-sensitive
return Platform_GetNativeObject( obj );
}
static void pfnTouch_HideButtons( const char *name, byte state ) static void pfnTouch_HideButtons( const char *name, byte state )
{ {
Touch_HideButtons( name, state, true ); Touch_HideButtons( name, state, true );
@@ -124,7 +115,7 @@ static mobile_engfuncs_t gpMobileEngfuncs =
Touch_ResetDefaultButtons, Touch_ResetDefaultButtons,
pfnDrawScaledCharacter, pfnDrawScaledCharacter,
Sys_Warn, Sys_Warn,
pfnGetNativeObject, Sys_GetNativeObject,
ID_SetCustomClientID, ID_SetCustomClientID,
pfnParseFileSafe pfnParseFileSafe
}; };

View File

@@ -1534,7 +1534,8 @@ void CL_SendConsistencyInfo( sizebuf_t *msg )
{ {
case force_exactfile: case force_exactfile:
MD5_HashFile( md5, filename, NULL ); MD5_HashFile( md5, filename, NULL );
pc->value = *(int *)md5; memcpy( &pc->value, md5, sizeof( pc->value ));
LittleLongSW( pc->value );
if( user_changed_diskfile ) if( user_changed_diskfile )
MSG_WriteUBitLong( msg, 0, 32 ); MSG_WriteUBitLong( msg, 0, 32 );

View File

@@ -265,8 +265,18 @@ void CL_LegacyParseResourceList( sizebuf_t *msg )
} }
if( CL_IsPlaybackDemo() ) if( CL_IsPlaybackDemo() )
{
return; return;
if( !cl_allow_download.value )
{
Con_DPrintf( "Refusing new resource, cl_allow_download set to 0\n" );
reslist.rescount = 0;
}
if( cls.state == ca_active && !cl_download_ingame.value )
{
Con_DPrintf( "Refusing new resource, cl_download_ingame set to 0\n" );
reslist.rescount = 0;
} }
HTTP_ResetProcessState(); HTTP_ResetProcessState();

View File

@@ -726,6 +726,7 @@ void SCR_VidInit( void )
// restart console size // restart console size
Con_VidInit (); Con_VidInit ();
Touch_NotifyResize();
} }
/* /*

View File

@@ -423,13 +423,6 @@ typedef struct
float applied_angle; float applied_angle;
} screen_shake_t; } screen_shake_t;
typedef enum
{
NET_REQUEST_CANCEL = 0, // request was cancelled for some reasons
NET_REQUEST_GAMEUI, // called from GameUI
NET_REQUEST_CLIENT, // called from Client
} net_request_type_t;
typedef struct typedef struct
{ {
net_response_t resp; net_response_t resp;
@@ -491,9 +484,7 @@ typedef struct
client_textmessage_t *titles; // title messages, not network messages client_textmessage_t *titles; // title messages, not network messages
int numTitles; int numTitles;
net_request_type_t request_type; // filter the requests
net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more
net_request_t *master_request; // queued master request
efrag_t *free_efrags; // linked efrags efrag_t *free_efrags; // linked efrags
cl_entity_t viewent; // viewmodel cl_entity_t viewent; // viewmodel
@@ -627,7 +618,10 @@ typedef struct
file_t *demofile; file_t *demofile;
file_t *demoheader; // contain demo startup info in case we record a demo on this level file_t *demoheader; // contain demo startup info in case we record a demo on this level
qboolean internetservers_wait; // internetservers is waiting for dns request qboolean internetservers_wait; // internetservers is waiting for dns request
qboolean internetservers_pending; // internetservers is waiting for dns request qboolean internetservers_pending; // if true, clean master server pings
uint32_t internetservers_key; // compare key to validate master server reply
char internetservers_query[512]; // cached query
uint32_t internetservers_query_len;
// legacy mode support // legacy mode support
qboolean legacymode; // one-way 48 protocol compatibility qboolean legacymode; // one-way 48 protocol compatibility
@@ -765,7 +759,6 @@ int CL_IsDevOverviewMode( void );
void CL_PingServers_f( void ); void CL_PingServers_f( void );
void CL_SignonReply( void ); void CL_SignonReply( void );
void CL_ClearState( void ); void CL_ClearState( void );
size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat );
// //
// cl_demo.c // cl_demo.c

View File

@@ -1983,7 +1983,7 @@ void Con_DrawConsole( void )
if( cls.state == ca_connecting || cls.state == ca_connected ) if( cls.state == ca_connecting || cls.state == ca_connected )
{ {
if( !cl_allow_levelshots.value ) if( !cl_allow_levelshots.value && !cls.timedemo )
{ {
if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console ) if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console )
con.vislines = con.showlines = 0; con.vislines = con.showlines = 0;
@@ -1993,7 +1993,7 @@ void Con_DrawConsole( void )
{ {
con.showlines = 0; con.showlines = 0;
if( host_developer.value >= DEV_EXTENDED ) if( host_developer.value >= DEV_EXTENDED && !cls.timedemo )
Con_DrawNotify(); // draw notify lines Con_DrawNotify(); // draw notify lines
} }
} }
@@ -2025,7 +2025,7 @@ void Con_DrawConsole( void )
{ {
if( con.vislines ) if( con.vislines )
Con_DrawSolidConsole( con.vislines ); Con_DrawSolidConsole( con.vislines );
else if( cls.state == ca_active && ( cls.key_dest == key_game || cls.key_dest == key_message )) else if( cls.state == ca_active && ( cls.key_dest == key_game || cls.key_dest == key_message ) && !cls.timedemo )
Con_DrawNotify(); // draw notify lines Con_DrawNotify(); // draw notify lines
} }
break; break;

View File

@@ -132,6 +132,8 @@ static struct touch_s
int whitetexture; int whitetexture;
int joytexture; // touch indicator int joytexture; // touch indicator
qboolean configchanged; qboolean configchanged;
float actual_aspect_ratio; // maximum aspect ratio from launch, or aspect ratio when entering editor
float config_aspect_ratio; // aspect ratio set by command from config or after entering editor
} touch; } touch;
// private to the engine flags // private to the engine flags
@@ -168,13 +170,42 @@ CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate
#define B(x) (button->x) #define B(x) (button->x)
#define SCR_W ((float)refState.width) #define SCR_W ((float)refState.width)
#define SCR_H ((float)refState.height) #define SCR_H ((float)refState.height)
#define TO_SCRN_Y(x) (refState.height * (x)) #define TO_SCRN_Y(x) (refState.width * (x) * Touch_AspectRatio())
#define TO_SCRN_X(x) (refState.width * (x)) #define TO_SCRN_X(x) (refState.width * (x))
static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 ); static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 );
static void IN_TouchEditClear( void ); static void IN_TouchEditClear( void );
static void Touch_InitConfig( void ); static void Touch_InitConfig( void );
void Touch_NotifyResize( void )
{
if( refState.width && refState.height && ( !touch.configchanged || !touch.actual_aspect_ratio ))
{
float aspect_ratio = SCR_H/SCR_W;
if( aspect_ratio < 0.99 && aspect_ratio > touch.actual_aspect_ratio )
touch.actual_aspect_ratio = aspect_ratio;
}
}
static inline float Touch_AspectRatio( void )
{
if( touch.config_aspect_ratio )
return touch.config_aspect_ratio;
else if( touch.actual_aspect_ratio )
return touch.actual_aspect_ratio;
else if( refState.width && refState.height )
return SCR_H/SCR_W;
else
return 9.0f / 16.0f;
}
static void Touch_ConfigAspectRatio_f( void )
{
touch.config_aspect_ratio = Q_atof( Cmd_Argv( 1 ));
}
/* /*
========================== ==========================
Touch_ExportButtonToConfig Touch_ExportButtonToConfig
@@ -206,7 +237,7 @@ static inline int Touch_ExportButtonToConfig( file_t *f, touch_button_t *button,
if( keepAspect ) if( keepAspect )
{ {
float aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(SCR_H/SCR_W) ); float aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(Touch_AspectRatio()) );
FS_Printf( f, " %f\n", aspect ); FS_Printf( f, " %f\n", aspect );
} }
else FS_Printf( f, "\n" ); else FS_Printf( f, "\n" );
@@ -271,6 +302,8 @@ qboolean Touch_DumpConfig( const char *name, const char *profilename )
FS_Printf( f, "touch_setclientonly 0\n" ); FS_Printf( f, "touch_setclientonly 0\n" );
FS_Printf( f, "\n// touch buttons\n" ); FS_Printf( f, "\n// touch buttons\n" );
FS_Printf( f, "touch_removeall\n" ); FS_Printf( f, "touch_removeall\n" );
FS_Printf( f, "touch_aspectratio %f\n", Touch_AspectRatio());
for( button = touch.list_user.first; button; button = button->next ) for( button = touch.list_user.first; button; button = button->next )
{ {
@@ -376,7 +409,7 @@ static void Touch_GenerateCode_f( void )
if( FBitSet( flags, TOUCH_FL_DEF_HIDE )) if( FBitSet( flags, TOUCH_FL_DEF_HIDE ))
SetBits( flags, TOUCH_FL_HIDE ); SetBits( flags, TOUCH_FL_HIDE );
aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(SCR_H/SCR_W) ); aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(Touch_AspectRatio()) );
if( memcmp( &c, &B(color), sizeof( rgba_t ) ) ) if( memcmp( &c, &B(color), sizeof( rgba_t ) ) )
{ {
Con_Printf( "unsigned char color[] = { %d, %d, %d, %d };\n", B(color[0]), B(color[1]), B(color[2]), B(color[3]) ); Con_Printf( "unsigned char color[] = { %d, %d, %d, %d };\n", B(color[0]), B(color[1]), B(color[2]), B(color[3]) );
@@ -549,6 +582,7 @@ static void Touch_RemoveAll_f( void )
{ {
IN_TouchEditClear(); IN_TouchEditClear();
Touch_ClearList( &touch.list_user ); Touch_ClearList( &touch.list_user );
touch.config_aspect_ratio = 0.0f;
} }
static void Touch_SetColor( touchbuttonlist_t *list, const char *name, byte *color ) static void Touch_SetColor( touchbuttonlist_t *list, const char *name, byte *color )
@@ -726,6 +760,8 @@ static void Touch_SetCommand_f( void )
Con_Printf( S_USAGE "touch_setcommand <name> <command>\n" ); Con_Printf( S_USAGE "touch_setcommand <name> <command>\n" );
} }
static void Touch_LoadDefaults_f( void );
static void Touch_ReloadConfig_f( void ) static void Touch_ReloadConfig_f( void )
{ {
touch.state = state_none; touch.state = state_none;
@@ -735,8 +771,15 @@ static void Touch_ReloadConfig_f( void )
touch.selection->finger = -1; touch.selection->finger = -1;
touch.edit = touch.selection = NULL; touch.edit = touch.selection = NULL;
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1; touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
if( FS_FileExists( touch_config_file.string, true ) )
Cbuf_AddTextf( "exec %s\n", touch_config_file.string ); {
Cbuf_AddTextf( "exec \"%s\"\n", touch_config_file.string );
}
else
{
Touch_LoadDefaults_f();
touch.configchanged = true;
}
} }
static touch_button_t *Touch_AddButton( touchbuttonlist_t *list, static touch_button_t *Touch_AddButton( touchbuttonlist_t *list,
@@ -784,7 +827,7 @@ void Touch_AddClientButton( const char *name, const char *texture, const char *c
IN_TouchCheckCoords( &x1, &y1, &x2, &y2 ); IN_TouchCheckCoords( &x1, &y1, &x2, &y2 );
if( round == round_aspect ) if( round == round_aspect )
{ {
y2 = y1 + ( x2 - x1 ) * (SCR_W/SCR_H) * aspect; y2 = y1 + ( x2 - x1 ) / (Touch_AspectRatio()) * aspect;
} }
button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true ); button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true );
button->flags |= flags | TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT; button->flags |= flags | TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT;
@@ -809,7 +852,7 @@ static void Touch_LoadDefaults_f( void )
if( g_DefaultButtons[i].texturefile[0] == '#' ) if( g_DefaultButtons[i].texturefile[0] == '#' )
y2 = y1 + ( (float)clgame.scrInfo.iCharHeight / (float)clgame.scrInfo.iHeight ) * g_DefaultButtons[i].aspect + touch.swidth*2/SCR_H; y2 = y1 + ( (float)clgame.scrInfo.iCharHeight / (float)clgame.scrInfo.iHeight ) * g_DefaultButtons[i].aspect + touch.swidth*2/SCR_H;
else else
y2 = y1 + ( x2 - x1 ) * (SCR_W/SCR_H) * g_DefaultButtons[i].aspect; y2 = y1 + (( x2 - x1 ) / Touch_AspectRatio()) * g_DefaultButtons[i].aspect;
} }
IN_TouchCheckCoords( &x1, &y1, &x2, &y2 ); IN_TouchCheckCoords( &x1, &y1, &x2, &y2 );
@@ -817,6 +860,7 @@ static void Touch_LoadDefaults_f( void )
button->flags |= g_DefaultButtons[i].flags; button->flags |= g_DefaultButtons[i].flags;
button->aspect = g_DefaultButtons[i].aspect; button->aspect = g_DefaultButtons[i].aspect;
} }
touch.configchanged = true;
} }
// Add default button from client // Add default button from client
@@ -909,7 +953,7 @@ static void Touch_AddButton_f( void )
if( aspect ) if( aspect )
{ {
if( B( texturefile )[0] != '#' ) if( B( texturefile )[0] != '#' )
B( y2 ) = B( y1 ) + ( B( x2 ) - B( x1 )) * ( SCR_W / SCR_H ) * aspect; B( y2 ) = B( y1 ) + (( B( x2 ) - B( x1 )) / Touch_AspectRatio() ) * aspect;
B( aspect ) = aspect; B( aspect ) = aspect;
} }
} }
@@ -917,11 +961,39 @@ static void Touch_AddButton_f( void )
static void Touch_EnableEdit_f( void ) static void Touch_EnableEdit_f( void )
{ {
touch_button_t *button;
float current_ratio = SCR_H/SCR_W;
if( touch.state == state_none ) if( touch.state == state_none )
touch.state = state_edit; touch.state = state_edit;
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1; touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
touch.move_button = NULL; touch.move_button = NULL;
touch.configchanged = true; touch.configchanged = true;
/* try determine the best ratio
* User enters editor. Window now have correct size. Need to fix aspect ratio in some cases */
// Case A: no config was loaded, touch was generated with lower height, but window was resized higher, reset it to actual size
if( touch.actual_aspect_ratio > current_ratio )
touch.actual_aspect_ratio = current_ratio;
if( !touch.config_aspect_ratio )
touch.config_aspect_ratio = touch.actual_aspect_ratio;
// Case B: config was loaded, but window may be resized later, so keep y coordinate as is
touch.actual_aspect_ratio = current_ratio;
// convert coordinates to actual aspect ratio after it was updated
if( touch.config_aspect_ratio != touch.actual_aspect_ratio )
{
for( button = touch.list_user.first; button; button = button->next )
{
B(y1) /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
B(y2) /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
// clamp positions to make buttons visible by user
if( B(y2) > 1.0f )
{
B(y1) -= B(y2) - 1.0f;
B(y2) -= B(y2) - 1.0f;
}
}
touch.config_aspect_ratio = touch.actual_aspect_ratio;
}
} }
static void Touch_DisableEdit_f( void ) static void Touch_DisableEdit_f( void )
@@ -956,7 +1028,7 @@ static void Touch_DeleteProfile_f( void )
static void Touch_InitEditor( void ) static void Touch_InitEditor( void )
{ {
float x = 0.1f * (SCR_H/SCR_W); float x = 0.1f * (Touch_AspectRatio());
float y = 0.05f; float y = 0.05f;
touch_button_t *temp; touch_button_t *temp;
rgba_t color; rgba_t color;
@@ -1051,6 +1123,7 @@ void Touch_Init( void )
Cmd_AddRestrictedCommand( "touch_generate_code", Touch_GenerateCode_f, "create code sample for mobility API" ); Cmd_AddRestrictedCommand( "touch_generate_code", Touch_GenerateCode_f, "create code sample for mobility API" );
Cmd_AddCommand( "touch_fade", Touch_Fade_f, "start fade animation for selected buttons" ); Cmd_AddCommand( "touch_fade", Touch_Fade_f, "start fade animation for selected buttons" );
Cmd_AddRestrictedCommand( "touch_toggleselection", Touch_ToggleSelection_f, "toggle vidibility on selected button in editor" ); Cmd_AddRestrictedCommand( "touch_toggleselection", Touch_ToggleSelection_f, "toggle vidibility on selected button in editor" );
Cmd_AddRestrictedCommand( "touch_aspectratio", Touch_ConfigAspectRatio_f, "set current aspect ratio" );
// not saved, just runtime state for scripting // not saved, just runtime state for scripting
Cvar_RegisterVariable( &touch_in_menu ); Cvar_RegisterVariable( &touch_in_menu );
@@ -1087,7 +1160,7 @@ void Touch_Init( void )
#if SDL_VERSION_ATLEAST( 2, 0, 10 ) #if SDL_VERSION_ATLEAST( 2, 0, 10 )
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" ); SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" );
SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" ); SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" );
#else #elif defined(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH)
SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" ); SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" );
#endif #endif
@@ -1170,9 +1243,9 @@ static void Touch_DrawTexture ( float x1, float y1, float x2, float y2, int text
} }
#define GRID_COUNT_X ((int)touch_grid_count.value) #define GRID_COUNT_X ((int)touch_grid_count.value)
#define GRID_COUNT_Y (((int)touch_grid_count.value) * SCR_H / SCR_W) #define GRID_COUNT_Y (((int)touch_grid_count.value) * Touch_AspectRatio())
#define GRID_X (1.0f/GRID_COUNT_X) #define GRID_X (1.0f/GRID_COUNT_X)
#define GRID_Y (SCR_W/SCR_H/GRID_COUNT_X) #define GRID_Y (1.0f/Touch_AspectRatio()/GRID_COUNT_X)
#define GRID_ROUND_X(x) ((float)round( x * GRID_COUNT_X ) / GRID_COUNT_X) #define GRID_ROUND_X(x) ((float)round( x * GRID_COUNT_X ) / GRID_COUNT_X)
#define GRID_ROUND_Y(x) ((float)round( x * GRID_COUNT_Y ) / GRID_COUNT_Y) #define GRID_ROUND_Y(x) ((float)round( x * GRID_COUNT_Y ) / GRID_COUNT_Y)
@@ -1250,7 +1323,7 @@ static float Touch_DrawText( float x1, float y1, float x2, float y2, const char
{ {
while( *s && ( *s != '\n' ) && ( *s != ';' ) && ( x1 < maxx ) ) while( *s && ( *s != '\n' ) && ( *s != ';' ) && ( x1 < maxx ) )
x1 += Touch_DrawCharacter( x1, y1, *s++, size ); x1 += Touch_DrawCharacter( x1, y1, *s++, size );
y1 += cls.creditsFont.charHeight / 1024.f * size / SCR_H * SCR_W; y1 += cls.creditsFont.charHeight / 1024.f * size / Touch_AspectRatio();
if( y1 >= maxy ) if( y1 >= maxy )
break; break;
@@ -1357,11 +1430,12 @@ void Touch_Draw( void )
if( !touch.initialized || ( !touch_enable.value && !touch.clientonly )) if( !touch.initialized || ( !touch_enable.value && !touch.clientonly ))
return; return;
Touch_InitConfig();
if( cls.key_dest != key_game && !touch_in_menu.value ) if( cls.key_dest != key_game && !touch_in_menu.value )
return; return;
Touch_InitConfig();
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture ); ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
if( touch.state >= state_edit && touch_grid_enable.value ) if( touch.state >= state_edit && touch_grid_enable.value )
@@ -1948,6 +2022,8 @@ static int Touch_ControlsEvent( touchEventType type, int fingerID, float x, floa
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ) int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy )
{ {
y *= SCR_H/SCR_W/Touch_AspectRatio();
// Con_Printf("%f %f\n", TO_SCRN_X(x), TO_SCRN_Y(y));
// simulate menu mouse click // simulate menu mouse click
if( cls.key_dest != key_game && !touch_in_menu.value ) if( cls.key_dest != key_game && !touch_in_menu.value )
{ {

View File

@@ -172,6 +172,8 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
{ {
if( newstate == oldstate ) if( newstate == oldstate )
return; return;
if( m_ignore.value )
return;
// since SetCursorType controls cursor visibility // since SetCursorType controls cursor visibility
// execute it first, and then check mouse grab state // execute it first, and then check mouse grab state
@@ -212,6 +214,9 @@ void IN_CheckMouseState( qboolean active )
qboolean useRawInput = true; // always use SDL code qboolean useRawInput = true; // always use SDL code
#endif #endif
if( m_ignore.value )
return;
if( active && useRawInput && !host.mouse_visible && cls.state == ca_active ) if( active && useRawInput && !host.mouse_visible && cls.state == ca_active )
{ {
if( !s_bRawInput ) if( !s_bRawInput )

View File

@@ -75,6 +75,7 @@ void Touch_ResetDefaultButtons( void );
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ); int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
void Touch_KeyEvent( int key, int down ); void Touch_KeyEvent( int key, int down );
qboolean Touch_WantVisibleCursor( void ); qboolean Touch_WantVisibleCursor( void );
void Touch_NotifyResize( void );
// //
// in_joy.c // in_joy.c

View File

@@ -659,7 +659,7 @@ static void make_hull_windings( hull_t *hull, hull_model_t *model )
Con_Reportf( "%i hull polys\n", model->num_polys ); Con_Reportf( "%i hull polys\n", model->num_polys );
} }
void Mod_InitDebugHulls( void ) void Mod_InitDebugHulls( model_t *loadmodel )
{ {
int i; int i;

View File

@@ -16,6 +16,7 @@ CVAR_DEFINE_AUTO( gl_msaa_samples, "0", FCVAR_GLCONFIG, "samples number for mult
CVAR_DEFINE_AUTO( gl_clear, "0", FCVAR_ARCHIVE, "clearing screen after each frame" ); CVAR_DEFINE_AUTO( gl_clear, "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" ); CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" ); static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
void R_GetTextureParms( int *w, int *h, int texnum ) void R_GetTextureParms( int *w, int *h, int texnum )
{ {
@@ -98,16 +99,6 @@ static void *pfnMod_Extradata( int type, model_t *m )
return NULL; return NULL;
} }
static model_t *pfnMod_GetCurrentLoadingModel( void )
{
return loadmodel;
}
static void pfnMod_SetCurrentLoadingModel( model_t *m )
{
loadmodel = m;
}
static void pfnGetPredictedOrigin( vec3_t v ) static void pfnGetPredictedOrigin( vec3_t v )
{ {
VectorCopy( cl.simorg, v ); VectorCopy( cl.simorg, v );
@@ -282,8 +273,6 @@ static ref_api_t gEngfuncs =
Mod_ForName, Mod_ForName,
pfnMod_Extradata, pfnMod_Extradata,
CL_ModelHandle, CL_ModelHandle,
pfnMod_GetCurrentLoadingModel,
pfnMod_SetCurrentLoadingModel,
CL_GetRemapInfoForEntity, CL_GetRemapInfoForEntity,
CL_AllocRemapInfo, CL_AllocRemapInfo,
@@ -531,6 +520,7 @@ static qboolean R_LoadRenderer( const char *refopt )
return false; return false;
} }
Cvar_FullSet( "r_refdll_loaded", refopt, FCVAR_READ_ONLY );
Con_Reportf( "Renderer %s initialized\n", refdll ); Con_Reportf( "Renderer %s initialized\n", refdll );
return true; return true;
@@ -622,6 +612,7 @@ qboolean R_Init( void )
Cvar_RegisterVariable( &gl_clear ); Cvar_RegisterVariable( &gl_clear );
Cvar_RegisterVariable( &r_showtree ); Cvar_RegisterVariable( &r_showtree );
Cvar_RegisterVariable( &r_refdll ); Cvar_RegisterVariable( &r_refdll );
Cvar_RegisterVariable( &r_refdll_loaded );
// cvars that are expected to exist // cvars that are expected to exist
Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" ); Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );

View File

@@ -381,6 +381,7 @@ typedef void (*xcommand_t)( void );
qboolean FS_LoadProgs( void ); qboolean FS_LoadProgs( void );
void FS_Init( void ); void FS_Init( void );
void FS_Shutdown( void ); void FS_Shutdown( void );
void *FS_GetNativeObject( const char *obj );
// //
// cmd.c // cmd.c
@@ -747,8 +748,6 @@ void SV_ShutdownGame( void );
void SV_ExecLoadLevel( void ); void SV_ExecLoadLevel( void );
void SV_ExecLoadGame( void ); void SV_ExecLoadGame( void );
void SV_ExecChangeLevel( void ); void SV_ExecChangeLevel( void );
qboolean SV_InitGameProgs( void );
void SV_FreeGameProgs( void );
void CL_WriteMessageHistory( void ); void CL_WriteMessageHistory( void );
void CL_SendCmd( void ); void CL_SendCmd( void );
void CL_Disconnect( void ); void CL_Disconnect( void );

View File

@@ -1423,15 +1423,11 @@ save serverinfo variables into server.cfg (using for dedicated server too)
*/ */
void GAME_EXPORT Host_WriteServerConfig( const char *name ) void GAME_EXPORT Host_WriteServerConfig( const char *name )
{ {
qboolean already_loaded;
file_t *f; file_t *f;
string newconfigfile; string newconfigfile;
Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name ); Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name );
// TODO: remove this mechanism, make it safer for now
already_loaded = SV_InitGameProgs(); // collect user variables
// FIXME: move this out until menu parser is done // FIXME: move this out until menu parser is done
CSCR_LoadDefaultCVars( "settings.scr" ); CSCR_LoadDefaultCVars( "settings.scr" );
@@ -1448,10 +1444,6 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
Host_FinalizeConfig( f, name ); Host_FinalizeConfig( f, name );
} }
else Con_DPrintf( S_ERROR "Couldn't write %s.\n", name ); else Con_DPrintf( S_ERROR "Couldn't write %s.\n", name );
// don't unload library that wasn't loaded by us
if( !already_loaded )
SV_FreeGameProgs(); // release progs with all variables
} }
/* /*

View File

@@ -23,8 +23,17 @@ GNU General Public License for more details.
fs_api_t g_fsapi; fs_api_t g_fsapi;
fs_globals_t *FI; fs_globals_t *FI;
static pfnCreateInterface_t fs_pfnCreateInterface;
static HINSTANCE fs_hInstance; static HINSTANCE fs_hInstance;
void *FS_GetNativeObject( const char *obj )
{
if( fs_pfnCreateInterface )
return fs_pfnCreateInterface( obj, NULL );
return NULL;
}
static void FS_Rescan_f( void ) static void FS_Rescan_f( void )
{ {
FS_Rescan(); FS_Rescan();
@@ -53,7 +62,7 @@ static fs_interface_t fs_memfuncs =
_Mem_Realloc, _Mem_Realloc,
_Mem_Free, _Mem_Free,
Platform_GetNativeObject, Sys_GetNativeObject,
}; };
static void FS_UnloadProgs( void ) static void FS_UnloadProgs( void )
@@ -98,6 +107,13 @@ qboolean FS_LoadProgs( void )
return false; return false;
} }
if( !( fs_pfnCreateInterface = (pfnCreateInterface_t)COM_GetProcAddress( fs_hInstance, "CreateInterface" )))
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't find CreateInterface entry point in %s\n", name );
return false;
}
Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" ); Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
return true; return true;

View File

@@ -33,6 +33,7 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "base_cmd.h" #include "base_cmd.h"
#include "client.h" #include "client.h"
#include "server.h"
#include "netchan.h" #include "netchan.h"
#include "protocol.h" #include "protocol.h"
#include "mod_local.h" #include "mod_local.h"
@@ -127,6 +128,7 @@ void Sys_PrintUsage( void )
O("-noenginejoy ", "disable engine builtin joystick support") O("-noenginejoy ", "disable engine builtin joystick support")
O("-noenginemouse ", "disable engine builtin mouse support") O("-noenginemouse ", "disable engine builtin mouse support")
O("-nosound ", "disable sound output") O("-nosound ", "disable sound output")
O("-timedemo ", "run timedemo and exit")
#endif #endif
"\nPlatform-specific options:\n" "\nPlatform-specific options:\n"
@@ -1016,21 +1018,31 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
else else
{ {
#if TARGET_OS_IOS #if TARGET_OS_IOS
const char *IOS_GetDocsDir(); Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof( host.rootdir ));
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) ); #elif XASH_ANDROID && XASH_SDL
Q_strncpy( host.rootdir, SDL_AndroidGetExternalStoragePath(), sizeof( host.rootdir ));
#elif XASH_PSVITA #elif XASH_PSVITA
if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir ) ) ) if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir )))
{ {
Sys_Error( "couldn't find xash3d data directory" ); Sys_Error( "couldn't find xash3d data directory" );
host.rootdir[0] = 0; host.rootdir[0] = 0;
} }
#elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2 #elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2
char *szBasePath; char *szBasePath = SDL_GetBasePath();
if( szBasePath )
if( !( szBasePath = SDL_GetBasePath() ) ) {
Sys_Error( "couldn't determine current directory: %s", SDL_GetError() );
Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir )); Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir ));
SDL_free( szBasePath ); SDL_free( szBasePath );
}
else
{
#if XASH_POSIX || XASH_WIN32
if( !getcwd( host.rootdir, sizeof( host.rootdir )))
Sys_Error( "couldn't determine current directory: %s, getcwd: %s", SDL_GetError(), strerror( errno ));
#else
Sys_Error( "couldn't determine current directory: %s", SDL_GetError() );
#endif
}
#else #else
if( !getcwd( host.rootdir, sizeof( host.rootdir ))) if( !getcwd( host.rootdir, sizeof( host.rootdir )))
{ {
@@ -1149,6 +1161,7 @@ Host_Main
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func )
{ {
static double oldtime, newtime; static double oldtime, newtime;
string demoname;
host.starttime = Sys_DoubleTime(); host.starttime = Sys_DoubleTime();
@@ -1245,6 +1258,9 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline) Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline)
SCR_CheckStartupVids(); // must be last SCR_CheckStartupVids(); // must be last
if( Sys_GetParmFromCmdLine( "-timedemo", demoname ))
Cbuf_AddTextf( "timedemo %s\n", demoname );
oldtime = Sys_DoubleTime() - 0.1; oldtime = Sys_DoubleTime() - 0.1;
if( Host_IsDedicated( )) if( Host_IsDedicated( ))
@@ -1293,6 +1309,7 @@ void EXPORT Host_Shutdown( void )
#endif #endif
SV_Shutdown( "Server shutdown\n" ); SV_Shutdown( "Server shutdown\n" );
SV_UnloadProgs();
SV_ShutdownFilter(); SV_ShutdownFilter();
CL_Shutdown(); CL_Shutdown();

View File

@@ -142,6 +142,7 @@ void Image_CopyPalette32bit( void );
void Image_SetPixelFormat( void ); void Image_SetPixelFormat( void );
void Image_GetPaletteQ1( void ); void Image_GetPaletteQ1( void );
void Image_GetPaletteHL( void ); void Image_GetPaletteHL( void );
size_t Image_ComputeSize( int type, int width, int height, int depth );
// //
// formats load // formats load
@@ -156,6 +157,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
qboolean Image_LoadFNT( const char *name, const byte *buffer, fs_offset_t filesize ); qboolean Image_LoadFNT( const char *name, const byte *buffer, fs_offset_t filesize );
qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesize ); qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesize );
qboolean Image_LoadPAL( const char *name, const byte *buffer, fs_offset_t filesize ); qboolean Image_LoadPAL( const char *name, const byte *buffer, fs_offset_t filesize );
qboolean Image_LoadKTX2( const char *name, const byte *buffer, fs_offset_t filesize );
// //
// formats save // formats save

View File

@@ -104,6 +104,13 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
{ {
switch( headerExt->dxgiFormat ) switch( headerExt->dxgiFormat )
{ {
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
image.type = PF_BC4_UNSIGNED;
break;
case DXGI_FORMAT_BC4_SNORM:
image.type = PF_BC4_SIGNED;
break;
case DXGI_FORMAT_BC6H_SF16: case DXGI_FORMAT_BC6H_SF16:
image.type = PF_BC6H_SIGNED; image.type = PF_BC6H_SIGNED;
break; break;
@@ -112,9 +119,20 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
image.type = PF_BC6H_UNSIGNED; image.type = PF_BC6H_UNSIGNED;
break; break;
case DXGI_FORMAT_BC7_UNORM: case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
case DXGI_FORMAT_BC7_TYPELESS: case DXGI_FORMAT_BC7_TYPELESS:
image.type = PF_BC7; image.type = PF_BC7_UNORM;
break;
case DXGI_FORMAT_BC7_UNORM_SRGB:
image.type = PF_BC7_SRGB;
break;
case DXGI_FORMAT_BC5_TYPELESS:
image.type = PF_ATI2;
break;
case DXGI_FORMAT_BC5_UNORM:
image.type = PF_BC5_UNSIGNED;
break;
case DXGI_FORMAT_BC5_SNORM:
image.type = PF_BC5_SIGNED;
break; break;
default: default:
image.type = PF_UNKNOWN; image.type = PF_UNKNOWN;
@@ -143,6 +161,15 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
case TYPE_ATI2: case TYPE_ATI2:
image.type = PF_ATI2; image.type = PF_ATI2;
break; break;
case TYPE_BC5S:
image.type = PF_BC5_SIGNED;
break;
case TYPE_BC4S:
image.type = PF_BC4_SIGNED;
break;
case TYPE_BC4U:
image.type = PF_BC4_UNSIGNED;
break;
default: default:
image.type = PF_UNKNOWN; // assume error image.type = PF_UNKNOWN; // assume error
break; break;
@@ -188,27 +215,6 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
image.num_mips = hdr->dwMipMapCount; // get actual mip count image.num_mips = hdr->dwMipMapCount; // get actual mip count
} }
size_t Image_DXTGetLinearSize( int type, int width, int height, int depth )
{
switch( type )
{
case PF_DXT1: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 8 );
case PF_DXT3:
case PF_DXT5:
case PF_BC6H_SIGNED:
case PF_BC6H_UNSIGNED:
case PF_BC7:
case PF_ATI2: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 16 );
case PF_LUMINANCE: return (width * height * depth);
case PF_BGR_24:
case PF_RGB_24: return (width * height * depth * 3);
case PF_BGRA_32:
case PF_RGBA_32: return (width * height * depth * 4);
}
return 0;
}
size_t Image_DXTCalcMipmapSize( dds_t *hdr ) size_t Image_DXTCalcMipmapSize( dds_t *hdr )
{ {
size_t buffsize = 0; size_t buffsize = 0;
@@ -219,7 +225,7 @@ size_t Image_DXTCalcMipmapSize( dds_t *hdr )
{ {
width = Q_max( 1, ( hdr->dwWidth >> i )); width = Q_max( 1, ( hdr->dwWidth >> i ));
height = Q_max( 1, ( hdr->dwHeight >> i )); height = Q_max( 1, ( hdr->dwHeight >> i ));
buffsize += Image_DXTGetLinearSize( image.type, width, height, image.depth ); buffsize += Image_ComputeSize( image.type, width, height, image.depth );
} }
return buffsize; return buffsize;
@@ -255,7 +261,7 @@ uint Image_DXTCalcSize( const char *name, dds_t *hdr, size_t filesize )
if( filesize != buffsize ) // main check if( filesize != buffsize ) // main check
{ {
Con_DPrintf( S_WARN "Image_LoadDDS: (%s) probably corrupted (%i should be %lu)\n", name, buffsize, filesize ); Con_DPrintf( S_WARN "Image_LoadDDS: (%s) probably corrupted (%zu should be %lu)\n", name, buffsize, filesize );
if( buffsize > filesize ) if( buffsize > filesize )
return false; return false;
} }
@@ -268,7 +274,7 @@ void Image_DXTAdjustVolume( dds_t *hdr )
if( hdr->dwDepth <= 1 ) if( hdr->dwDepth <= 1 )
return; return;
hdr->dwLinearSize = Image_DXTGetLinearSize( image.type, hdr->dwWidth, hdr->dwHeight, hdr->dwDepth ); hdr->dwLinearSize = Image_ComputeSize( image.type, hdr->dwWidth, hdr->dwHeight, hdr->dwDepth );
hdr->dwFlags |= DDS_LINEARSIZE; hdr->dwFlags |= DDS_LINEARSIZE;
} }
@@ -323,7 +329,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
Image_DXTGetPixelFormat( &header, &header2 ); // and image type too :) Image_DXTGetPixelFormat( &header, &header2 ); // and image type too :)
Image_DXTAdjustVolume( &header ); Image_DXTAdjustVolume( &header );
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageDXT( image.type )) if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageCompressed( image.type ))
return false; // silently rejected return false; // silently rejected
if( image.type == PF_UNKNOWN ) if( image.type == PF_UNKNOWN )
@@ -356,8 +362,10 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
SetBits( image.flags, IMAGE_HAS_ALPHA ); SetBits( image.flags, IMAGE_HAS_ALPHA );
else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin )) else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin ))
SetBits( image.flags, IMAGE_HAS_ALPHA ); SetBits( image.flags, IMAGE_HAS_ALPHA );
else if ( image.type == PF_BC7 ) else if( image.type == PF_BC5_SIGNED || image.type == PF_BC5_UNSIGNED )
SetBits(image.flags, IMAGE_HAS_ALPHA); SetBits( image.flags, IMAGE_HAS_ALPHA );
else if( image.type == PF_BC7_UNORM || image.type == PF_BC7_SRGB )
SetBits( image.flags, IMAGE_HAS_ALPHA );
if( !FBitSet( header.dsPixelFormat.dwFlags, DDS_LUMINANCE )) if( !FBitSet( header.dsPixelFormat.dwFlags, DDS_LUMINANCE ))
SetBits( image.flags, IMAGE_HAS_COLOR ); SetBits( image.flags, IMAGE_HAS_COLOR );
break; break;

View File

@@ -32,6 +32,9 @@ GNU General Public License for more details.
#define TYPE_DX10 (('0'<<24)+('1'<<16)+('X'<<8)+'D') // little-endian "DX10" #define TYPE_DX10 (('0'<<24)+('1'<<16)+('X'<<8)+'D') // little-endian "DX10"
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1" #define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2" #define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
#define TYPE_BC5S (('S'<<24)+('5'<<16)+('C'<<8)+'B') // little-endian "BC5S"
#define TYPE_BC4S (('S'<<24)+('4'<<16)+('C'<<8)+'B') // little-endian "BC4S"
#define TYPE_BC4U (('U'<<24)+('4'<<16)+('C'<<8)+'B') // little-endian "BC4U"
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps #define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
#define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$" #define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
#define TYPE_o (('\0'<<24)+('\0'<<16)+('\0'<<8)+'o') // little-endian "o" #define TYPE_o (('\0'<<24)+('\0'<<16)+('\0'<<8)+'o') // little-endian "o"

View File

@@ -0,0 +1,204 @@
/*
img_ktx2.c - ktx2 format load
Copyright (C) 2023 Provod
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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.
*/
#include "imagelib.h"
#include "xash3d_mathlib.h"
#include "img_ktx2.h"
static void Image_KTX2Format( uint32_t ktx2_format )
{
switch( ktx2_format )
{
case KTX2_FORMAT_BC4_UNORM_BLOCK:
image.type = PF_BC4_UNSIGNED;
// 1 component for ref_gl
break;
case KTX2_FORMAT_BC4_SNORM_BLOCK:
image.type = PF_BC4_SIGNED;
// 1 component for ref_gl
break;
case KTX2_FORMAT_BC5_UNORM_BLOCK:
image.type = PF_BC5_UNSIGNED;
// 2 components for ref_gl
SetBits( image.flags, IMAGE_HAS_ALPHA );
break;
case KTX2_FORMAT_BC5_SNORM_BLOCK:
image.type = PF_BC5_SIGNED;
// 2 components for ref_gl
SetBits( image.flags, IMAGE_HAS_ALPHA );
break;
case KTX2_FORMAT_BC6H_UFLOAT_BLOCK:
image.type = PF_BC6H_UNSIGNED;
// 3 components for ref_gl
SetBits( image.flags, IMAGE_HAS_COLOR );
break;
case KTX2_FORMAT_BC6H_SFLOAT_BLOCK:
image.type = PF_BC6H_SIGNED;
// 3 components for ref_gl
SetBits( image.flags, IMAGE_HAS_COLOR );
break;
case KTX2_FORMAT_BC7_UNORM_BLOCK:
image.type = PF_BC7_UNORM;
// 4 components for ref_gl
SetBits( image.flags, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
break;
case KTX2_FORMAT_BC7_SRGB_BLOCK:
image.type = PF_BC7_SRGB;
// 4 components for ref_gl
SetBits( image.flags, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
break;
default:
image.type = PF_UNKNOWN;
break;
}
}
static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer, fs_offset_t filesize )
{
ktx2_index_t index;
size_t total_size = 0;
size_t max_offset = 0;
const byte *const levels_begin = buffer + KTX2_LEVELS_OFFSET;
// Sets image.type and image.flags
Image_KTX2Format( header->vkFormat );
if( image.type == PF_UNKNOWN )
{
Con_DPrintf( S_ERROR "%s: unsupported KTX2 format %d\n", __FUNCTION__, header->vkFormat );
return false;
}
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageCompressed( image.type ))
{
Con_DPrintf( S_WARN "%s: has compressed format, but support is not advertized\n", __FUNCTION__ );
return false;
}
if( header->pixelDepth > 1 )
{
Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth );
return false;
}
if( header->faceCount > 1 )
{
Con_DPrintf( S_ERROR "%s: unsupported KTX2 faceCount %d\n", __FUNCTION__, header->faceCount );
return false;
}
if( header->layerCount > 1 )
{
Con_DPrintf( S_ERROR "%s: unsupported KTX2 layerCount %d\n", __FUNCTION__, header->layerCount );
return false;
}
if( header->supercompressionScheme != 0 )
{
Con_DPrintf( S_ERROR "%s: unsupported KTX2 supercompressionScheme %d\n", __FUNCTION__, header->supercompressionScheme );
return false;
}
if( header->levelCount * sizeof( ktx2_level_t ) + KTX2_LEVELS_OFFSET > filesize )
{
Con_DPrintf( S_ERROR "%s: file abruptly ends\n", __FUNCTION__ );
return false;
}
memcpy( &index, buffer + KTX2_IDENTIFIER_SIZE + sizeof( ktx2_header_t ), sizeof( index ));
for( int mip = 0; mip < header->levelCount; ++mip )
{
const uint32_t width = Q_max( 1, ( header->pixelWidth >> mip ));
const uint32_t height = Q_max( 1, ( header->pixelHeight >> mip ));
const uint32_t mip_size = Image_ComputeSize( image.type, width, height, image.depth );
ktx2_level_t level;
memcpy( &level, levels_begin + mip * sizeof( level ), sizeof( level ));
if( mip_size != level.byteLength )
{
Con_DPrintf( S_ERROR "%s: mip=%d size mismatch read=%d, but computed=%d\n",
__FUNCTION__, mip, (int)level.byteLength, mip_size );
return false;
}
total_size += level.byteLength;
max_offset = Q_max( max_offset, level.byteLength + level.byteOffset );
}
if( max_offset > filesize )
return false;
image.size = total_size;
image.num_mips = header->levelCount;
image.rgba = Mem_Malloc( host.imagepool, image.size );
memcpy( image.rgba, buffer, image.size );
for( int mip = 0, cursor = 0; mip < header->levelCount; ++mip )
{
ktx2_level_t level;
memcpy( &level, levels_begin + mip * sizeof( level ), sizeof( level ));
memcpy( image.rgba + cursor, buffer + level.byteOffset, level.byteLength );
cursor += level.byteLength;
}
return true;
}
qboolean Image_LoadKTX2( const char *name, const byte *buffer, fs_offset_t filesize )
{
ktx2_header_t header;
if( filesize < KTX2_MINIMAL_HEADER_SIZE )
return false;
if( memcmp( buffer, KTX2_IDENTIFIER, KTX2_IDENTIFIER_SIZE ) != 0 )
{
Con_DPrintf( S_ERROR "%s: (%s) has invalid identifier\n", __FUNCTION__, name );
return false;
}
memcpy( &header, buffer + KTX2_IDENTIFIER_SIZE, sizeof( header ));
image.width = header.pixelWidth;
image.height = header.pixelHeight;
image.depth = Q_max( 1, header.pixelDepth );
image.num_mips = 1;
ClearBits( image.flags, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA | IMAGE_HAS_LUMA );
if( !Image_KTX2Parse( &header, buffer, filesize ))
{
if( !Image_CheckFlag( IL_KTX2_RAW ))
return false;
// If KTX2 to imagelib conversion failed, try passing the file as raw data.
// This is useful for ref_vk which can directly support hundreds of formats which we don't convert to pixformat_t here
Con_DPrintf( S_WARN "%s: (%s) could not be converted to supported imagelib format, passing as raw KTX2 data\n", __FUNCTION__, name );
// This is a catch-all for ref_vk, which can do this format directly and natively
image.type = PF_KTX2_RAW;
image.size = filesize;
//image.encode = TODO custom encode type?
image.rgba = Mem_Malloc( host.imagepool, image.size );
memcpy( image.rgba, buffer, image.size );
}
return true;
}

View File

@@ -0,0 +1,79 @@
/*
img_ktx2.h - ktx2 format reference
Copyright (C) 2023 Provod
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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.
*/
#ifndef IMG_KTX2_H
#define IMG_KTX2_H
#include <stdint.h>
#define KTX2_IDENTIFIER_SIZE 12
#define KTX2_IDENTIFIER "\xABKTX 20\xBB\r\n\x1A\n"
/*
static const char k_ktx2_identifier[KTX2_IDENTIFIER_SIZE] =
{
'\xAB', 'K', 'T', 'X', ' ', '2', '0', '\xBB', '\r', '\n', '\x1A', '\n'
};
*/
typedef struct
{
uint32_t vkFormat;
uint32_t typeSize;
uint32_t pixelWidth;
uint32_t pixelHeight;
uint32_t pixelDepth;
uint32_t layerCount;
uint32_t faceCount;
uint32_t levelCount;
uint32_t supercompressionScheme;
} ktx2_header_t;
typedef struct
{
uint32_t dfdByteOffset;
uint32_t dfdByteLength;
uint32_t kvdByteOffset;
uint32_t kvdByteLength;
uint64_t sgdByteOffset;
uint64_t sgdByteLength;
} ktx2_index_t;
typedef struct
{
uint64_t byteOffset;
uint64_t byteLength;
uint64_t uncompressedByteLength;
} ktx2_level_t;
#define KTX2_LEVELS_OFFSET ( KTX2_IDENTIFIER_SIZE + sizeof( ktx2_header_t ) + sizeof( ktx2_index_t ))
#define KTX2_MINIMAL_HEADER_SIZE ( KTX2_LEVELS_OFFSET + sizeof( ktx2_level_t ))
// These have the same values as enum VkFormat in vulkan_core.h
// There are hundreds of formats which can be contained in KTX2.
// Below are listed the ones which are supported here. This list can be extended.
typedef enum
{
KTX2_FORMAT_BC4_UNORM_BLOCK = 139,
KTX2_FORMAT_BC4_SNORM_BLOCK = 140,
KTX2_FORMAT_BC5_UNORM_BLOCK = 141,
KTX2_FORMAT_BC5_SNORM_BLOCK = 142,
KTX2_FORMAT_BC6H_UFLOAT_BLOCK = 143,
KTX2_FORMAT_BC6H_SFLOAT_BLOCK = 144,
KTX2_FORMAT_BC7_UNORM_BLOCK = 145,
KTX2_FORMAT_BC7_SRGB_BLOCK = 146,
} ktx2_format_t;
#endif // IMG_KTX2_H

View File

@@ -105,6 +105,7 @@ static const loadpixformat_t load_game[] =
{ "%s%s.%s", "lmp", Image_LoadLMP, IL_HINT_NO }, // hl menu images (cached.wad etc) { "%s%s.%s", "lmp", Image_LoadLMP, IL_HINT_NO }, // hl menu images (cached.wad etc)
{ "%s%s.%s", "fnt", Image_LoadFNT, IL_HINT_HL }, // hl console font (fonts.wad etc) { "%s%s.%s", "fnt", Image_LoadFNT, IL_HINT_HL }, // hl console font (fonts.wad etc)
{ "%s%s.%s", "pal", Image_LoadPAL, IL_HINT_NO }, // install studio\sprite palette { "%s%s.%s", "pal", Image_LoadPAL, IL_HINT_NO }, // install studio\sprite palette
{ "%s%s.%s", "ktx2", Image_LoadKTX2, IL_HINT_NO }, // ktx2 for world and studio models
{ NULL, NULL, NULL, IL_HINT_NO } { NULL, NULL, NULL, IL_HINT_NO }
}; };
@@ -283,8 +284,10 @@ int Image_ComparePalette( const byte *pal )
void Image_SetPalette( const byte *pal, uint *d_table ) void Image_SetPalette( const byte *pal, uint *d_table )
{ {
byte rgba[4]; byte rgba[4];
uint uirgba; // TODO: palette looks byte-swapped on big-endian
int i; int i;
// setup palette // setup palette
switch( image.d_rendermode ) switch( image.d_rendermode )
{ {
@@ -295,7 +298,8 @@ void Image_SetPalette( const byte *pal, uint *d_table )
rgba[1] = pal[i*3+1]; rgba[1] = pal[i*3+1];
rgba[2] = pal[i*3+2]; rgba[2] = pal[i*3+2];
rgba[3] = 0xFF; rgba[3] = 0xFF;
d_table[i] = *(uint *)rgba; memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba;
} }
break; break;
case LUMP_GRADIENT: case LUMP_GRADIENT:
@@ -305,7 +309,8 @@ void Image_SetPalette( const byte *pal, uint *d_table )
rgba[1] = pal[766]; rgba[1] = pal[766];
rgba[2] = pal[767]; rgba[2] = pal[767];
rgba[3] = i; rgba[3] = i;
d_table[i] = *(uint *)rgba; memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba;
} }
break; break;
case LUMP_MASKED: case LUMP_MASKED:
@@ -315,7 +320,8 @@ void Image_SetPalette( const byte *pal, uint *d_table )
rgba[1] = pal[i*3+1]; rgba[1] = pal[i*3+1];
rgba[2] = pal[i*3+2]; rgba[2] = pal[i*3+2];
rgba[3] = 0xFF; rgba[3] = 0xFF;
d_table[i] = *(uint *)rgba; memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba;
} }
d_table[255] = 0; d_table[255] = 0;
break; break;
@@ -326,7 +332,8 @@ void Image_SetPalette( const byte *pal, uint *d_table )
rgba[1] = pal[i*4+1]; rgba[1] = pal[i*4+1];
rgba[2] = pal[i*4+2]; rgba[2] = pal[i*4+2];
rgba[3] = pal[i*4+3]; rgba[3] = pal[i*4+3];
d_table[i] = *(uint *)rgba; memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba;
} }
break; break;
} }
@@ -1446,3 +1453,36 @@ qboolean Image_Process(rgbdata_t **pix, int width, int height, uint flags, float
return result; return result;
} }
// This codebase has too many copies of this function:
// - ref_gl has one
// - ref_vk has one
// - ref_soft has one
// - many more places probably have one too
// TODO figure out how to make it available for ref_*
size_t Image_ComputeSize( int type, int width, int height, int depth )
{
switch( type )
{
case PF_DXT1:
case PF_BC4_SIGNED:
case PF_BC4_UNSIGNED:
return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 8 );
case PF_DXT3:
case PF_DXT5:
case PF_ATI2:
case PF_BC5_UNSIGNED:
case PF_BC5_SIGNED:
case PF_BC6H_SIGNED:
case PF_BC6H_UNSIGNED:
case PF_BC7_UNORM:
case PF_BC7_SRGB: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 16 );
case PF_LUMINANCE: return ( width * height * depth );
case PF_BGR_24:
case PF_RGB_24: return ( width * height * depth * 3 );
case PF_BGRA_32:
case PF_RGBA_32: return ( width * height * depth * 4 );
}
return 0;
}

View File

@@ -23,15 +23,6 @@ GNU General Public License for more details.
#if XASH_EMSCRIPTEN #if XASH_EMSCRIPTEN
#include <emscripten.h> #include <emscripten.h>
#elif XASH_WIN32
extern "C"
{
// Enable NVIDIA High Performance Graphics while using Integrated Graphics.
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// Enable AMD High Performance Graphics while using Integrated Graphics.
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif #endif
#define E_GAME "XASH3D_GAME" // default env dir to start from #define E_GAME "XASH3D_GAME" // default env dir to start from
@@ -39,6 +30,10 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#define XASH_GAMEDIR "valve" #define XASH_GAMEDIR "valve"
#endif #endif
#if XASH_WIN32
#error "Single-binary or dedicated builds aren't supported for Windows!"
#endif
static char szGameDir[128]; // safe place to keep gamedir static char szGameDir[128]; // safe place to keep gamedir
static int szArgc; static int szArgc;
static char **szArgv; static char **szArgv;
@@ -47,7 +42,7 @@ static void Sys_ChangeGame( const char *progname )
{ {
// a1ba: may never be called within engine // a1ba: may never be called within engine
// if platform supports execv() function // if platform supports execv() function
Q_strncpy( szGameDir, progname, sizeof( szGameDir ) - 1 ); Q_strncpy( szGameDir, progname, sizeof( szGameDir ));
Host_Shutdown( ); Host_Shutdown( );
exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) ); exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) );
} }
@@ -88,7 +83,6 @@ _inline int Sys_Start( void )
return ret; return ret;
} }
#if !XASH_WIN32
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
#if XASH_PSVITA #if XASH_PSVITA
@@ -100,36 +94,4 @@ int main( int argc, char **argv )
#endif // XASH_PSVITA #endif // XASH_PSVITA
return Sys_Start(); return Sys_Start();
} }
#else #endif // SINGLE_BINARY
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int nShow)
{
LPWSTR* lpArgv;
int ret, i;
lpArgv = CommandLineToArgvW( GetCommandLineW(), &szArgc );
szArgv = ( char** )malloc( (szArgc + 1) * sizeof( char* ));
for( i = 0; i < szArgc; ++i )
{
size_t size = wcslen(lpArgv[i]) + 1;
// just in case, allocate some more memory
szArgv[i] = ( char * )malloc( size * sizeof( wchar_t ));
wcstombs( szArgv[i], lpArgv[i], size );
}
szArgv[szArgc] = 0;
LocalFree( lpArgv );
ret = Sys_Start();
for( ; i < szArgc; ++i )
free( szArgv[i] );
free( szArgv );
return ret;
}
#endif // XASH_WIN32
#endif

View File

@@ -419,5 +419,6 @@ void NET_InitMasters( void )
// keep main master always there // keep main master always there
NET_AddMaster( MASTERSERVER_ADR, false ); NET_AddMaster( MASTERSERVER_ADR, false );
NET_AddMaster( MASTERSERVER_ADR_TEST, false );
NET_LoadMasters( ); NET_LoadMasters( );
} }

File diff suppressed because it is too large Load Diff

View File

@@ -118,7 +118,6 @@ typedef struct world_static_s
#ifndef REF_DLL #ifndef REF_DLL
extern world_static_t world; extern world_static_t world;
extern poolhandle_t com_studiocache; extern poolhandle_t com_studiocache;
extern model_t *loadmodel;
extern convar_t mod_studiocache; extern convar_t mod_studiocache;
extern convar_t r_wadtextures; extern convar_t r_wadtextures;
extern convar_t r_showhull; extern convar_t r_showhull;
@@ -164,7 +163,7 @@ void Mod_PrintWorldStats_f( void );
// //
// mod_dbghulls.c // mod_dbghulls.c
// //
void Mod_InitDebugHulls( void ); void Mod_InitDebugHulls( model_t *mod );
void Mod_CreatePolygonsForHull( int hullnum ); void Mod_CreatePolygonsForHull( int hullnum );
void Mod_ReleaseHullPolygons( void ); void Mod_ReleaseHullPolygons( void );

View File

@@ -851,11 +851,11 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
char poolname[MAX_VA_STRING]; char poolname[MAX_VA_STRING];
studiohdr_t *phdr; studiohdr_t *phdr;
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", loadmodel->name ); Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name );
if( loaded ) *loaded = false; if( loaded ) *loaded = false;
loadmodel->mempool = Mem_AllocPool( poolname ); mod->mempool = Mem_AllocPool( poolname );
loadmodel->type = mod_studio; mod->type = mod_studio;
phdr = R_StudioLoadHeader( mod, buffer ); phdr = R_StudioLoadHeader( mod, buffer );
if( !phdr ) return; // bad model if( !phdr ) return; // bad model
@@ -886,9 +886,9 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
// give space for textures and skinrefs // give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t ); size1 = thdr->numtextures * sizeof( mstudiotexture_t );
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short ); size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
mod->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length + size1 + size2 ); mod->cache.data = Mem_Calloc( mod->mempool, phdr->length + size1 + size2 );
memcpy( loadmodel->cache.data, buffer, phdr->length ); // copy main mdl buffer memcpy( mod->cache.data, buffer, phdr->length ); // copy main mdl buffer
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
phdr->numskinfamilies = thdr->numskinfamilies; phdr->numskinfamilies = thdr->numskinfamilies;
phdr->numtextures = thdr->numtextures; phdr->numtextures = thdr->numtextures;
phdr->numskinref = thdr->numskinref; phdr->numskinref = thdr->numskinref;
@@ -905,52 +905,52 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
else else
{ {
// NOTE: don't modify source buffer because it's used for CRC computing // NOTE: don't modify source buffer because it's used for CRC computing
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length ); mod->cache.data = Mem_Calloc( mod->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length ); memcpy( mod->cache.data, buffer, phdr->length );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
#if !XASH_DEDICATED #if !XASH_DEDICATED
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr ); ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
#endif #endif
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base // NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex ); mod->cache.data = Mem_Realloc( mod->mempool, mod->cache.data, phdr->texturedataindex );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
phdr->length = phdr->texturedataindex; // update model size phdr->length = phdr->texturedataindex; // update model size
} }
} }
else else
{ {
// just copy model into memory // just copy model into memory
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length ); mod->cache.data = Mem_Calloc( mod->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length ); memcpy( mod->cache.data, buffer, phdr->length );
phdr = loadmodel->cache.data; phdr = mod->cache.data;
} }
// setup bounding box // setup bounding box
if( !VectorCompare( vec3_origin, phdr->bbmin )) if( !VectorCompare( vec3_origin, phdr->bbmin ))
{ {
// clipping bounding box // clipping bounding box
VectorCopy( phdr->bbmin, loadmodel->mins ); VectorCopy( phdr->bbmin, mod->mins );
VectorCopy( phdr->bbmax, loadmodel->maxs ); VectorCopy( phdr->bbmax, mod->maxs );
} }
else if( !VectorCompare( vec3_origin, phdr->min )) else if( !VectorCompare( vec3_origin, phdr->min ))
{ {
// movement bounding box // movement bounding box
VectorCopy( phdr->min, loadmodel->mins ); VectorCopy( phdr->min, mod->mins );
VectorCopy( phdr->max, loadmodel->maxs ); VectorCopy( phdr->max, mod->maxs );
} }
else else
{ {
// well compute bounds from vertices and round to nearest even values // well compute bounds from vertices and round to nearest even values
Mod_StudioComputeBounds( phdr, loadmodel->mins, loadmodel->maxs, true ); Mod_StudioComputeBounds( phdr, mod->mins, mod->maxs, true );
RoundUpHullSize( loadmodel->mins ); RoundUpHullSize( mod->mins );
RoundUpHullSize( loadmodel->maxs ); RoundUpHullSize( mod->maxs );
} }
loadmodel->numframes = Mod_StudioBodyVariations( loadmodel ); mod->numframes = Mod_StudioBodyVariations( mod );
loadmodel->radius = RadiusFromBounds( loadmodel->mins, loadmodel->maxs ); mod->radius = RadiusFromBounds( mod->mins, mod->maxs );
loadmodel->flags = phdr->flags; // copy header flags mod->flags = phdr->flags; // copy header flags
if( loaded ) *loaded = true; if( loaded ) *loaded = true;
} }

View File

@@ -31,7 +31,6 @@ poolhandle_t com_studiocache; // cache for submodels
CVAR_DEFINE( mod_studiocache, "r_studiocache", "1", FCVAR_ARCHIVE, "enables studio cache for speedup tracing hitboxes" ); CVAR_DEFINE( mod_studiocache, "r_studiocache", "1", FCVAR_ARCHIVE, "enables studio cache for speedup tracing hitboxes" );
CVAR_DEFINE_AUTO( r_wadtextures, "0", 0, "completely ignore textures in the bsp-file if enabled" ); CVAR_DEFINE_AUTO( r_wadtextures, "0", 0, "completely ignore textures in the bsp-file if enabled" );
CVAR_DEFINE_AUTO( r_showhull, "0", 0, "draw collision hulls 1-3" ); CVAR_DEFINE_AUTO( r_showhull, "0", 0, "draw collision hulls 1-3" );
model_t *loadmodel;
/* /*
=============================================================================== ===============================================================================
@@ -287,7 +286,6 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
Con_Reportf( "loading %s\n", mod->name ); Con_Reportf( "loading %s\n", mod->name );
mod->needload = NL_PRESENT; mod->needload = NL_PRESENT;
mod->type = mod_bad; mod->type = mod_bad;
loadmodel = mod;
// call the apropriate loader // call the apropriate loader
switch( *(uint *)buf ) switch( *(uint *)buf )

View File

@@ -274,8 +274,8 @@ static void NET_NetadrToSockadr( netadr_t *a, struct sockaddr_storage *s )
else if( a->type == NA_IP ) else if( a->type == NA_IP )
{ {
((struct sockaddr_in *)s)->sin_family = AF_INET; ((struct sockaddr_in *)s)->sin_family = AF_INET;
((struct sockaddr_in *)s)->sin_addr.s_addr = *(uint32_t *)&a->ip;
((struct sockaddr_in *)s)->sin_port = a->port; ((struct sockaddr_in *)s)->sin_port = a->port;
((struct sockaddr_in *)s)->sin_addr.s_addr = a->ip4;
} }
else if( a->type6 == NA_IP6 ) else if( a->type6 == NA_IP6 )
{ {
@@ -314,7 +314,7 @@ static void NET_SockadrToNetadr( const struct sockaddr_storage *s, netadr_t *a )
if( s->ss_family == AF_INET ) if( s->ss_family == AF_INET )
{ {
a->type = NA_IP; a->type = NA_IP;
*(int *)&a->ip = ((struct sockaddr_in *)s)->sin_addr.s_addr; a->ip4 = ((struct sockaddr_in *)s)->sin_addr.s_addr;
a->port = ((struct sockaddr_in *)s)->sin_port; a->port = ((struct sockaddr_in *)s)->sin_port;
} }
else if( s->ss_family == AF_INET6 ) else if( s->ss_family == AF_INET6 )
@@ -444,6 +444,7 @@ static void NET_InitializeCriticalSections( void )
void NET_ResolveThread( void ) void NET_ResolveThread( void )
{ {
struct sockaddr_storage addr; struct sockaddr_storage addr;
qboolean res;
RESOLVE_DBG( "[resolve thread] starting resolve for " ); RESOLVE_DBG( "[resolve thread] starting resolve for " );
RESOLVE_DBG( nsthread.hostname ); RESOLVE_DBG( nsthread.hostname );
@@ -453,13 +454,14 @@ void NET_ResolveThread( void )
RESOLVE_DBG( " with gethostbyname\n" ); RESOLVE_DBG( " with gethostbyname\n" );
#endif #endif
if( NET_GetHostByName( nsthread.hostname, nsthread.family, &addr )) if(( res = NET_GetHostByName( nsthread.hostname, nsthread.family, &addr )))
RESOLVE_DBG( "[resolve thread] success\n" ); RESOLVE_DBG( "[resolve thread] success\n" );
else else
RESOLVE_DBG( "[resolve thread] failed\n" ); RESOLVE_DBG( "[resolve thread] failed\n" );
mutex_lock( &nsthread.mutexres ); mutex_lock( &nsthread.mutexres );
nsthread.addr = addr; nsthread.addr = addr;
nsthread.busy = false; nsthread.busy = false;
nsthread.result = res ? NET_EAI_OK : NET_EAI_NONAME;
RESOLVE_DBG( "[resolve thread] returning result\n" ); RESOLVE_DBG( "[resolve thread] returning result\n" );
mutex_unlock( &nsthread.mutexres ); mutex_unlock( &nsthread.mutexres );
RESOLVE_DBG( "[resolve thread] exiting thread\n" ); RESOLVE_DBG( "[resolve thread] exiting thread\n" );
@@ -544,6 +546,7 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
memset( &nsthread.addr, 0, sizeof( nsthread.addr )); memset( &nsthread.addr, 0, sizeof( nsthread.addr ));
detach_thread( nsthread.thread ); detach_thread( nsthread.thread );
asyncfailed = false;
} }
else else
{ {

View File

@@ -70,6 +70,7 @@ GNU General Public License for more details.
#define NET_MAX_MESSAGE PAD_NUMBER(( NET_MAX_PAYLOAD + HEADER_BYTES ), 16 ) #define NET_MAX_MESSAGE PAD_NUMBER(( NET_MAX_PAYLOAD + HEADER_BYTES ), 16 )
#define MASTERSERVER_ADR "mentality.rip:27010" #define MASTERSERVER_ADR "mentality.rip:27010"
#define MASTERSERVER_ADR_TEST "mentality.rip:27011"
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" #define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0"
#define PORT_MASTER 27010 #define PORT_MASTER 27010

View File

@@ -149,7 +149,7 @@ void Sys_InitLog( void )
s_ld.logfileno = fileno( s_ld.logfile ); s_ld.logfileno = fileno( s_ld.logfile );
fprintf( s_ld.logfile, "=================================================================================\n" ); fprintf( s_ld.logfile, "=================================================================================\n" );
fprintf( s_ld.logfile, "\t%s (build %i) started at %s\n", s_ld.title, Q_buildnum(), Q_timestamp( TIME_FULL ) ); fprintf( s_ld.logfile, "\t%s (build %i commit %s (%s-%s)) started at %s\n", s_ld.title, Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch(), Q_timestamp( TIME_FULL ) );
fprintf( s_ld.logfile, "=================================================================================\n" ); fprintf( s_ld.logfile, "=================================================================================\n" );
} }
} }

View File

@@ -649,3 +649,31 @@ qboolean Sys_NewInstance( const char *gamedir )
return false; return false;
} }
/*
==================
Sys_GetNativeObject
Get platform-specific native object
==================
*/
void *Sys_GetNativeObject( const char *obj )
{
void *ptr;
if( !COM_CheckString( obj ))
return NULL;
ptr = FS_GetNativeObject( obj );
if( ptr )
return ptr;
// Backend should consider that obj is case-sensitive
#if XASH_ANDROID
ptr = Android_GetNativeObject( obj );
#endif // XASH_ANDROID
return ptr;
}

View File

@@ -70,6 +70,7 @@ void Sys_InitLog( void );
void Sys_CloseLog( void ); void Sys_CloseLog( void );
void Sys_Quit( void ) NORETURN; void Sys_Quit( void ) NORETURN;
qboolean Sys_NewInstance( const char *gamedir ); qboolean Sys_NewInstance( const char *gamedir );
void *Sys_GetNativeObject( const char *obj );
// //
// sys_con.c // sys_con.c

View File

@@ -37,6 +37,11 @@ void Platform_MessageBox( const char *title, const char *message, qboolean paren
qboolean Sys_DebuggerPresent( void ); // optional, see Sys_DebugBreak qboolean Sys_DebuggerPresent( void ); // optional, see Sys_DebugBreak
void Platform_SetStatus( const char *status ); void Platform_SetStatus( const char *status );
// legacy iOS port functions
#if TARGET_OS_IOS
const char *IOS_GetDocsDir( void );
#endif // TARGET_OS_IOS
#if XASH_WIN32 || XASH_LINUX #if XASH_WIN32 || XASH_LINUX
#define XASH_PLATFORM_HAVE_STATUS 1 #define XASH_PLATFORM_HAVE_STATUS 1
#else #else
@@ -134,17 +139,6 @@ static inline void Platform_Shutdown( void )
#endif #endif
} }
static inline void *Platform_GetNativeObject( const char *name )
{
void *ptr = NULL;
#if XASH_ANDROID
ptr = Android_GetNativeObject( name );
#endif
return ptr;
}
/* /*
============================================================================== ==============================================================================
@@ -153,7 +147,6 @@ static inline void *Platform_GetNativeObject( const char *name )
============================================================================== ==============================================================================
*/ */
void Platform_Vibrate( float life, char flags ); void Platform_Vibrate( float life, char flags );
void*Platform_GetNativeObject( const char *name );
/* /*
============================================================================== ==============================================================================

View File

@@ -128,7 +128,7 @@ static qboolean SDLash_IsInstanceIDAGameController( SDL_JoystickID joyId )
return true; return true;
return false; return false;
#else #else
if( SDL_GameControllerFromInstanceID( joyId ) ) if( SDL_GameControllerFromInstanceID( joyId ) != NULL )
return true; return true;
return false; return false;
#endif #endif
@@ -148,7 +148,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
#else #else
int keynum = key.keysym.sym; int keynum = key.keysym.sym;
#endif #endif
qboolean numLock = SDL_GetModState() & KMOD_NUM; qboolean numLock = FBitSet( SDL_GetModState(), KMOD_NUM );
#if XASH_ANDROID #if XASH_ANDROID
if( keynum == SDL_SCANCODE_VOLUMEUP || keynum == SDL_SCANCODE_VOLUMEDOWN ) if( keynum == SDL_SCANCODE_VOLUMEUP || keynum == SDL_SCANCODE_VOLUMEDOWN )
@@ -159,7 +159,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
if( SDL_IsTextInputActive() && down && cls.key_dest != key_game ) if( SDL_IsTextInputActive() && down && cls.key_dest != key_game )
{ {
if( SDL_GetModState() & KMOD_CTRL ) if( FBitSet( SDL_GetModState(), KMOD_CTRL ))
{ {
if( keynum >= SDL_SCANCODE_A && keynum <= SDL_SCANCODE_Z ) if( keynum >= SDL_SCANCODE_A && keynum <= SDL_SCANCODE_Z )
{ {
@@ -176,7 +176,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
if( isprint( keynum ) ) if( isprint( keynum ) )
{ {
if( SDL_GetModState() & KMOD_SHIFT ) if( FBitSet( SDL_GetModState(), KMOD_SHIFT ))
{ {
keynum = Key_ToUpper( keynum ); keynum = Key_ToUpper( keynum );
} }

View File

@@ -158,8 +158,8 @@ void *SW_LockBuffer( void )
void *pixels; void *pixels;
int stride; int stride;
if( SDL_LockTexture(sw.tex, NULL, &pixels, &stride ) ) if( SDL_LockTexture(sw.tex, NULL, &pixels, &stride ) < 0 )
Sys_Error("%s", SDL_GetError()); Sys_Error( "%s: %s", __func__, SDL_GetError( ));
return pixels; return pixels;
} }
@@ -272,7 +272,7 @@ static void R_InitVideoModes( void )
int j; int j;
SDL_DisplayMode mode; SDL_DisplayMode mode;
if( SDL_GetDisplayMode( displayIndex, i, &mode ) ) if( SDL_GetDisplayMode( displayIndex, i, &mode ) < 0 )
{ {
Msg( "SDL_GetDisplayMode: %s\n", SDL_GetError() ); Msg( "SDL_GetDisplayMode: %s\n", SDL_GetError() );
continue; continue;
@@ -419,12 +419,16 @@ static qboolean WIN_SetWindowIcon( HICON ico )
{ {
SDL_SysWMinfo wminfo; SDL_SysWMinfo wminfo;
if( SDL_GetWindowWMInfo( host.hWnd, &wminfo )) SDL_VERSION( &wminfo.version );
if( SDL_GetWindowWMInfo( host.hWnd, &wminfo ) == SDL_TRUE )
{ {
SendMessage( wminfo.info.win.window, WM_SETICON, ICON_SMALL, (LONG_PTR)ico ); SendMessage( wminfo.info.win.window, WM_SETICON, ICON_SMALL, (LONG_PTR)ico );
SendMessage( wminfo.info.win.window, WM_SETICON, ICON_BIG, (LONG_PTR)ico ); SendMessage( wminfo.info.win.window, WM_SETICON, ICON_BIG, (LONG_PTR)ico );
return true; return true;
} }
Con_Reportf( S_ERROR "%s: %s", __func__, SDL_GetError( ));
return false; return false;
} }
#endif #endif
@@ -438,6 +442,25 @@ GL_GetProcAddress
void *GL_GetProcAddress( const char *name ) void *GL_GetProcAddress( const char *name )
{ {
void *func = SDL_GL_GetProcAddress( name ); void *func = SDL_GL_GetProcAddress( name );
#if !SDL_VERSION_ATLEAST( 2, 0, 6 ) && XASH_POSIX
if( !func && Sys_CheckParm( "-egl" ))
{
/*
* SDL2 has broken SDL_GL_GetProcAddress until this commit if using egl:
* https://github.com/libsdl-org/SDL/commit/466ba57d42d244e80357e9ad3011c50af30ed225
* so call eglGetProcAddress directly
* */
static void *(*peglGetProcAddress)( const char * );
if( !peglGetProcAddress )
{
void *lib = dlopen( "libEGL.so", RTLD_NOW );
if( lib )
*(void**)&peglGetProcAddress = dlsym( lib, "eglGetProcAddress" );
}
if( peglGetProcAddress )
func = peglGetProcAddress( name );
}
#endif
#if XASH_PSVITA #if XASH_PSVITA
// try to find in main module // try to find in main module
@@ -473,8 +496,8 @@ void GL_UpdateSwapInterval( void )
{ {
ClearBits( gl_vsync.flags, FCVAR_CHANGED ); ClearBits( gl_vsync.flags, FCVAR_CHANGED );
if( SDL_GL_SetSwapInterval( gl_vsync.value ) ) if( SDL_GL_SetSwapInterval( gl_vsync.value ) < 0 )
Con_Reportf( S_ERROR "SDL_GL_SetSwapInterval: %s\n", SDL_GetError( ) ); Con_Reportf( S_ERROR "SDL_GL_SetSwapInterval: %s\n", SDL_GetError( ));
} }
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
} }
@@ -523,7 +546,7 @@ GL_UpdateContext
static qboolean GL_UpdateContext( void ) static qboolean GL_UpdateContext( void )
{ {
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( SDL_GL_MakeCurrent( host.hWnd, glw_state.context )) if( SDL_GL_MakeCurrent( host.hWnd, glw_state.context ) < 0 )
{ {
Con_Reportf( S_ERROR "GL_UpdateContext: %s\n", SDL_GetError()); Con_Reportf( S_ERROR "GL_UpdateContext: %s\n", SDL_GetError());
return GL_DeleteContext(); return GL_DeleteContext();
@@ -580,7 +603,7 @@ static qboolean VID_SetScreenResolution( int width, int height, window_mode_t wi
want.w = width; want.w = width;
want.h = height; want.h = height;
if( SDL_GetClosestDisplayMode( 0, &want, &got ) < 0 ) if( SDL_GetClosestDisplayMode( 0, &want, &got ) == NULL )
{ {
Con_Printf( S_ERROR "%s: SDL_GetClosestDisplayMode: %s", __func__, SDL_GetError( )); Con_Printf( S_ERROR "%s: SDL_GetClosestDisplayMode: %s", __func__, SDL_GetError( ));
return false; return false;
@@ -626,9 +649,9 @@ void VID_RestoreScreenResolution( void )
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
} }
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
static void VID_SetWindowIcon( SDL_Window *hWnd ) static void VID_SetWindowIcon( SDL_Window *hWnd )
{ {
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
rgbdata_t *icon = NULL; rgbdata_t *icon = NULL;
char iconpath[MAX_STRING]; char iconpath[MAX_STRING];
const char *localIcoPath; const char *localIcoPath;
@@ -666,8 +689,8 @@ static void VID_SetWindowIcon( SDL_Window *hWnd )
#if XASH_WIN32 // ICO support only for Win32 #if XASH_WIN32 // ICO support only for Win32
WIN_SetWindowIcon( LoadIcon( host.hInst, MAKEINTRESOURCE( 101 ))); WIN_SetWindowIcon( LoadIcon( host.hInst, MAKEINTRESOURCE( 101 )));
#endif #endif
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
} }
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
static qboolean VID_CreateWindowWithSafeGL( const char *wndname, int xpos, int ypos, int w, int h, uint32_t flags ) static qboolean VID_CreateWindowWithSafeGL( const char *wndname, int xpos, int ypos, int w, int h, uint32_t flags )
{ {
@@ -785,6 +808,7 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
else VID_RestoreScreenResolution(); else VID_RestoreScreenResolution();
#endif #endif
VID_SetWindowIcon( host.hWnd );
SDL_ShowWindow( host.hWnd ); SDL_ShowWindow( host.hWnd );
if( glw_state.software ) if( glw_state.software )
@@ -812,8 +836,13 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
{ {
if( !glw_state.initialized ) if( !glw_state.initialized )
{ {
if( !GL_CreateContext( )) while( !GL_CreateContext( ))
{
glw_state.safe++;
if(glw_state.safe > SAFE_DONTCARE)
return false; return false;
GL_SetupAttributes(); // re-choose attributes
}
VID_StartupGamma(); VID_StartupGamma();
} }
@@ -991,8 +1020,12 @@ qboolean R_Init_Video( const int type )
refState.desktopBitsPixel = 16; refState.desktopBitsPixel = 16;
#endif #endif
#ifdef SDL_HINT_QTWAYLAND_WINDOW_FLAGS
SDL_SetHint( SDL_HINT_QTWAYLAND_WINDOW_FLAGS, "OverridesSystemGestures" ); SDL_SetHint( SDL_HINT_QTWAYLAND_WINDOW_FLAGS, "OverridesSystemGestures" );
#endif
#ifdef SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION
SDL_SetHint( SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION, "landscape" ); SDL_SetHint( SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION, "landscape" );
#endif
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !XASH_WIN32 #if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !XASH_WIN32
SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" );
@@ -1018,7 +1051,7 @@ qboolean R_Init_Video( const int type )
// refdll can request some attributes // refdll can request some attributes
GL_SetupAttributes( ); GL_SetupAttributes( );
if( SDL_GL_LoadLibrary( EGL_LIB ) ) if( SDL_GL_LoadLibrary( EGL_LIB ) < 0 )
{ {
Con_Reportf( S_ERROR "Couldn't initialize OpenGL: %s\n", SDL_GetError()); Con_Reportf( S_ERROR "Couldn't initialize OpenGL: %s\n", SDL_GetError());
return false; return false;
@@ -1057,7 +1090,11 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_DisplayMode displayMode; SDL_DisplayMode displayMode;
SDL_GetCurrentDisplayMode( 0, &displayMode ); if( SDL_GetCurrentDisplayMode( 0, &displayMode ) < 0 )
{
Con_Printf( S_ERROR "SDL_GetCurrentDisplayMode: %s", SDL_GetError( ));
return rserr_invalid_mode;
}
// check our desktop attributes // check our desktop attributes
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
@@ -1086,8 +1123,11 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod
VID_RestoreScreenResolution(); VID_RestoreScreenResolution();
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( SDL_SetWindowFullscreen( host.hWnd, 0 )) if( SDL_SetWindowFullscreen( host.hWnd, 0 ) < 0 )
{
Con_Printf( S_ERROR "SDL_SetWindowFullscreen: %s", SDL_GetError( ));
return rserr_invalid_fullscreen; return rserr_invalid_fullscreen;
}
#if SDL_VERSION_ATLEAST( 2, 0, 5 ) #if SDL_VERSION_ATLEAST( 2, 0, 5 )
SDL_SetWindowResizable( host.hWnd, SDL_TRUE ); SDL_SetWindowResizable( host.hWnd, SDL_TRUE );
#endif #endif

View File

@@ -330,8 +330,6 @@ typedef struct ref_api_s
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC ); model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model ); void *(*Mod_Extradata)( int type, model_t *model );
struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle
struct model_s *(*Mod_GetCurrentLoadingModel)( void ); // loadmodel
void (*Mod_SetCurrentLoadingModel)( struct model_s* ); // loadmodel
// remap // remap
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e ); struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
@@ -506,7 +504,7 @@ typedef struct ref_interface_s
// bmodel // bmodel
void (*R_InitSkyClouds)( struct mip_s *mt, struct texture_s *tx, qboolean custom_palette ); void (*R_InitSkyClouds)( struct mip_s *mt, struct texture_s *tx, qboolean custom_palette );
void (*GL_SubdivideSurface)( msurface_t *fa ); void (*GL_SubdivideSurface)( model_t *mod, msurface_t *fa );
void (*CL_RunLightStyles)( void ); void (*CL_RunLightStyles)( void );
// sprites // sprites

View File

@@ -360,7 +360,6 @@ typedef struct
typedef struct typedef struct
{ {
qboolean initialized; // sv_init has completed qboolean initialized; // sv_init has completed
qboolean game_library_loaded; // is game library loaded in SV_InitGame
double timestart; // just for profiling double timestart; // just for profiling
int maxclients; // server max clients int maxclients; // server max clients

View File

@@ -121,8 +121,10 @@ void SV_ParseConsistencyResponse( sv_client_t *cl, sizebuf_t *msg )
{ {
value = MSG_ReadUBitLong( msg, 32 ); value = MSG_ReadUBitLong( msg, 32 );
LittleLongSW( value );
// will be compare only first 4 bytes // will be compare only first 4 bytes
if( value != *(int *)r->rgucMD5_hash ) if( memcmp( &value, r->rgucMD5_hash, 4 ))
badresindex = idx + 1; badresindex = idx + 1;
} }
else else

View File

@@ -3031,7 +3031,7 @@ void SV_SetStringArrayMode( qboolean dynamic )
#endif #endif
} }
#if XASH_64BIT && !XASH_WIN32 && !XASH_APPLE && !XASH_NSWITCH #if XASH_64BIT && !XASH_WIN32 && !XASH_APPLE && !XASH_NSWITCH && !XASH_ANDROID
#define USE_MMAP #define USE_MMAP
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
@@ -5130,7 +5130,6 @@ void SV_UnloadProgs( void )
Mod_ResetStudioAPI (); Mod_ResetStudioAPI ();
svs.game_library_loaded = false;
COM_FreeLibrary( svgame.hInstance ); COM_FreeLibrary( svgame.hInstance );
Mem_FreePool( &svgame.mempool ); Mem_FreePool( &svgame.mempool );
memset( &svgame, 0, sizeof( svgame )); memset( &svgame, 0, sizeof( svgame ));
@@ -5148,7 +5147,14 @@ qboolean SV_LoadProgs( const char *name )
static playermove_t gpMove; static playermove_t gpMove;
edict_t *e; edict_t *e;
if( svgame.hInstance ) SV_UnloadProgs(); if( svgame.hInstance )
{
#if XASH_WIN32
SV_UnloadProgs();
#else // XASH_WIN32
return true;
#endif // XASH_WIN32
}
// fill it in // fill it in
svgame.pmove = &gpMove; svgame.pmove = &gpMove;

View File

@@ -706,7 +706,7 @@ qboolean SV_InitGame( void )
{ {
string dllpath; string dllpath;
if( svs.game_library_loaded ) if( svgame.hInstance )
return true; return true;
// first initialize? // first initialize?
@@ -721,7 +721,6 @@ qboolean SV_InitGame( void )
} }
// client frames will be allocated in SV_ClientConnect // client frames will be allocated in SV_ClientConnect
svs.game_library_loaded = true;
return true; return true;
} }
@@ -1042,8 +1041,9 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba
// force normal player collisions for single player // force normal player collisions for single player
if( svs.maxclients == 1 ) Cvar_SetValue( "sv_clienttrace", 1 ); if( svs.maxclients == 1 ) Cvar_SetValue( "sv_clienttrace", 1 );
// make sure what server name doesn't contain path and extension // allow loading maps from subdirectories, strip extension anyway
COM_FileBase( mapname, sv.name, sizeof( sv.name )); Q_strncpy( sv.name, mapname, sizeof( sv.name ));
COM_StripExtension( sv.name );
// precache and static commands can be issued during map initialization // precache and static commands can be issued during map initialization
Host_SetServerState( ss_loading ); Host_SetServerState( ss_loading );
@@ -1115,28 +1115,6 @@ int SV_GetMaxClients( void )
return svs.maxclients; return svs.maxclients;
} }
qboolean SV_InitGameProgs( void )
{
string dllpath;
if( svgame.hInstance ) return true; // already loaded
COM_GetCommonLibraryPath( LIBRARY_SERVER, dllpath, sizeof( dllpath ));
// just try to initialize
SV_LoadProgs( dllpath );
return false;
}
void SV_FreeGameProgs( void )
{
if( svs.initialized ) return; // server is active
// unload progs (free cvars and commands)
SV_UnloadProgs();
}
/* /*
================ ================
SV_ExecLoadLevel SV_ExecLoadLevel

View File

@@ -48,7 +48,8 @@ CVAR_DEFINE_AUTO( sv_send_logos, "1", 0, "send custom decal logo to other player
CVAR_DEFINE_AUTO( sv_send_resources, "1", 0, "allow to download missed resources for players" ); CVAR_DEFINE_AUTO( sv_send_resources, "1", 0, "allow to download missed resources for players" );
CVAR_DEFINE_AUTO( sv_logbans, "0", 0, "print into the server log info about player bans" ); CVAR_DEFINE_AUTO( sv_logbans, "0", 0, "print into the server log info about player bans" );
CVAR_DEFINE_AUTO( sv_allow_upload, "1", FCVAR_SERVER, "allow uploading custom resources on a server" ); CVAR_DEFINE_AUTO( sv_allow_upload, "1", FCVAR_SERVER, "allow uploading custom resources on a server" );
CVAR_DEFINE_AUTO( sv_allow_download, "1", FCVAR_SERVER, "allow downloading custom resources to the client" ); CVAR_DEFINE( sv_allow_download, "sv_allowdownload", "1", FCVAR_SERVER, "allow downloading custom resources to the client" );
static CVAR_DEFINE_AUTO( sv_allow_dlfile, "1", 0, "compatibility cvar, does nothing" );
CVAR_DEFINE_AUTO( sv_uploadmax, "0.5", FCVAR_SERVER, "max size to upload custom resources (500 kB as default)" ); CVAR_DEFINE_AUTO( sv_uploadmax, "0.5", FCVAR_SERVER, "max size to upload custom resources (500 kB as default)" );
CVAR_DEFINE_AUTO( sv_downloadurl, "", FCVAR_PROTECTED, "location from which clients can download missing files" ); CVAR_DEFINE_AUTO( sv_downloadurl, "", FCVAR_PROTECTED, "location from which clients can download missing files" );
CVAR_DEFINE( sv_consistency, "mp_consistency", "1", FCVAR_SERVER, "enbale consistency check in multiplayer" ); CVAR_DEFINE( sv_consistency, "mp_consistency", "1", FCVAR_SERVER, "enbale consistency check in multiplayer" );
@@ -925,6 +926,7 @@ void SV_Init( void )
Cvar_RegisterVariable( &sv_unlagsamples ); Cvar_RegisterVariable( &sv_unlagsamples );
Cvar_RegisterVariable( &sv_allow_upload ); Cvar_RegisterVariable( &sv_allow_upload );
Cvar_RegisterVariable( &sv_allow_download ); Cvar_RegisterVariable( &sv_allow_download );
Cvar_RegisterVariable( &sv_allow_dlfile );
Cvar_RegisterVariable( &sv_send_logos ); Cvar_RegisterVariable( &sv_send_logos );
Cvar_RegisterVariable( &sv_send_resources ); Cvar_RegisterVariable( &sv_send_resources );
Cvar_RegisterVariable( &sv_uploadmax ); Cvar_RegisterVariable( &sv_uploadmax );
@@ -1089,7 +1091,9 @@ void SV_Shutdown( const char *finalmsg )
if( CL_IsPlaybackDemo( )) if( CL_IsPlaybackDemo( ))
CL_Drop(); CL_Drop();
SV_UnloadProgs (); #if XASH_WIN32
SV_UnloadProgs();
#endif // XASH_WIN32
return; return;
} }
@@ -1106,7 +1110,10 @@ void SV_Shutdown( const char *finalmsg )
NET_MasterShutdown(); NET_MasterShutdown();
NET_Config( false, false ); NET_Config( false, false );
SV_UnloadProgs (); SV_DeactivateServer();
#if XASH_WIN32
SV_UnloadProgs();
#endif // XASH_WIN32
CL_Drop(); CL_Drop();
// free current level // free current level

View File

@@ -80,8 +80,8 @@ static qboolean SV_CopyEdictToPhysEnt( physent_t *pe, edict_t *ed )
} }
else else
{ {
// otherwise copy the classname // otherwise copy the modelname
Q_strncpy( pe->name, STRING( ed->v.classname ), sizeof( pe->name )); Q_strncpy( pe->name, mod->name, sizeof( pe->name ));
} }
pe->model = pe->studiomodel = NULL; pe->model = pe->studiomodel = NULL;

View File

@@ -150,7 +150,10 @@ public:
void RemoveFile( const char *path, const char *id ) override void RemoveFile( const char *path, const char *id ) override
{ {
FS_Delete( path ); // FS_Delete is aware of slashes char dir[MAX_VA_STRING], fullpath[MAX_VA_STRING];
Q_snprintf( fullpath, sizeof( fullpath ), "%s/%s", IdToDir( dir, sizeof( dir ), id ), path );
FS_Delete( fullpath ); // FS_Delete is aware of slashes
} }
void CreateDirHierarchy( const char *path, const char *id ) override void CreateDirHierarchy( const char *path, const char *id ) override

View File

@@ -150,6 +150,4 @@ public:
virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */ virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */
}; };
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
#endif // VFILESYSTEM009_H #endif // VFILESYSTEM009_H

View File

@@ -770,13 +770,13 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
else if( !Q_stricmp( token, "secure" )) else if( !Q_stricmp( token, "secure" ))
{ {
pfile = COM_ParseFile( pfile, token, sizeof( token )); pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->secure = Q_atoi( token ); GameInfo->secure = Q_atoi( token ) ? true : false;
} }
// valid for both // valid for both
else if( !Q_stricmp( token, "nomodels" )) else if( !Q_stricmp( token, "nomodels" ))
{ {
pfile = COM_ParseFile( pfile, token, sizeof( token )); pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->nomodels = Q_atoi( token ); GameInfo->nomodels = Q_atoi( token ) ? true : false;
} }
else if( !Q_stricmp( token, isGameInfo ? "max_edicts" : "edicts" )) else if( !Q_stricmp( token, isGameInfo ? "max_edicts" : "edicts" ))
{ {
@@ -844,17 +844,17 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
else if( !Q_stricmp( token, "noskills" )) else if( !Q_stricmp( token, "noskills" ))
{ {
pfile = COM_ParseFile( pfile, token, sizeof( token )); pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->noskills = Q_atoi( token ); GameInfo->noskills = Q_atoi( token ) ? true : false;
} }
else if( !Q_stricmp( token, "render_picbutton_text" )) else if( !Q_stricmp( token, "render_picbutton_text" ))
{ {
pfile = COM_ParseFile( pfile, token, sizeof( token )); pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->render_picbutton_text = Q_atoi( token ); GameInfo->render_picbutton_text = Q_atoi( token ) ? true : false;
} }
else if( !Q_stricmp( token, "internal_vgui_support" )) else if( !Q_stricmp( token, "internal_vgui_support" ))
{ {
pfile = COM_ParseFile( pfile, token, sizeof( token )); pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->internal_vgui_support = Q_atoi( token ); GameInfo->internal_vgui_support = Q_atoi( token ) ? true : false;
} }
else if( !Q_stricmp( token, "quicksave_aged_count" )) else if( !Q_stricmp( token, "quicksave_aged_count" ))
{ {
@@ -1386,7 +1386,7 @@ static void _Sys_Error( const char *fmt, ... )
exit( 1 ); exit( 1 );
} }
static void *_Platform_GetNativeObject_stub( const char *object ) static void *Sys_GetNativeObject_stub( const char *object )
{ {
return NULL; return NULL;
} }
@@ -2841,7 +2841,7 @@ fs_interface_t g_engfuncs =
_Mem_Alloc, _Mem_Alloc,
_Mem_Realloc, _Mem_Realloc,
_Mem_Free, _Mem_Free,
_Platform_GetNativeObject_stub Sys_GetNativeObject_stub
}; };
static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs ) static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
@@ -2883,9 +2883,9 @@ static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
Con_Reportf( "filesystem_stdio: custom memory allocation functions found\n" ); Con_Reportf( "filesystem_stdio: custom memory allocation functions found\n" );
} }
if( engfuncs->_Platform_GetNativeObject ) if( engfuncs->_Sys_GetNativeObject )
{ {
g_engfuncs._Platform_GetNativeObject = engfuncs->_Platform_GetNativeObject; g_engfuncs._Sys_GetNativeObject = engfuncs->_Sys_GetNativeObject;
Con_Reportf( "filesystem_stdio: custom platform-specific functions found\n" ); Con_Reportf( "filesystem_stdio: custom platform-specific functions found\n" );
} }

View File

@@ -33,6 +33,7 @@ extern "C"
#define FS_API_VERSION 2 // not stable yet! #define FS_API_VERSION 2 // not stable yet!
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!! #define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
// search path flags // search path flags
enum enum
@@ -210,7 +211,7 @@ typedef struct fs_interface_t
void (*_Mem_Free)( void *data, const char *filename, int fileline ); void (*_Mem_Free)( void *data, const char *filename, int fileline );
// platform // platform
void *(*_Platform_GetNativeObject)( const char *object ); void *(*_Sys_GetNativeObject)( const char *object );
} fs_interface_t; } fs_interface_t;
typedef int (*FSAPI)( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *interface ); typedef int (*FSAPI)( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *interface );

View File

@@ -127,7 +127,7 @@ extern const fs_archive_t g_archives[];
#define Con_DPrintf (*g_engfuncs._Con_DPrintf) #define Con_DPrintf (*g_engfuncs._Con_DPrintf)
#define Con_Reportf (*g_engfuncs._Con_Reportf) #define Con_Reportf (*g_engfuncs._Con_Reportf)
#define Sys_Error (*g_engfuncs._Sys_Error) #define Sys_Error (*g_engfuncs._Sys_Error)
#define Platform_GetNativeObject (*g_engfuncs._Platform_GetNativeObject) #define Sys_GetNativeObject (*g_engfuncs._Sys_GetNativeObject)
// //
// filesystem.c // filesystem.c

View File

@@ -18,7 +18,6 @@ typedef void *HMODULE;
HMODULE g_hModule; HMODULE g_hModule;
FSAPI g_pfnGetFSAPI; FSAPI g_pfnGetFSAPI;
typedef void *(*pfnCreateInterface_t)( const char *, int * );
pfnCreateInterface_t g_pfnCreateInterface; pfnCreateInterface_t g_pfnCreateInterface;
fs_api_t g_fs; fs_api_t g_fs;
fs_globals_t *g_nullglobals; fs_globals_t *g_nullglobals;

View File

@@ -645,10 +645,10 @@ void COM_ExtractFilePath( const char *path, char *dest )
const char *src = path + Q_strlen( path ) - 1; const char *src = path + Q_strlen( path ) - 1;
// back up until a \ or the start // back up until a \ or the start
while( src != path && !(*(src - 1) == '\\' || *(src - 1) == '/' )) while( src > path && !(*(src - 1) == '\\' || *(src - 1) == '/' ))
src--; src--;
if( src != path ) if( src > path )
{ {
memcpy( dest, path, src - path ); memcpy( dest, path, src - path );
dest[src - path - 1] = 0; // cutoff backslash dest[src - path - 1] = 0; // cutoff backslash

40
public/tests/test_efp.c Normal file
View File

@@ -0,0 +1,40 @@
#include <stdlib.h>
#include "crtlib.h"
#include <stdio.h>
int Test_ExtractFilePath( void )
{
char dst[64];
const char *strings[] =
{
"dir/file", "dir",
"bark\\meow", "bark",
"nopath", "",
"knee/deep/in/paths", "knee/deep/in",
// yes, it removes the behavior/ even if it might be technically a directory
"keep/the/original/func/behavior/", "keep/the/original/func",
"backslashes\\are\\annoying\\af", "backslashes\\are\\annoying",
"", ""
};
size_t i;
for( i = 0; i < sizeof( strings ) / sizeof( strings[0] ); i += 2 )
{
COM_ExtractFilePath( strings[i], dst );
if( Q_strcmp( dst, strings[i+1] ))
{
printf( "%s %s %s\n", strings[i], strings[i+1], dst );
return (i >> 1) + 1;
}
}
return 0;
}
int main( void )
{
if( Test_ExtractFilePath( ))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}

View File

@@ -12,8 +12,7 @@ def options(opt):
return return
def configure(conf): def configure(conf):
# stub conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'notset')
return
def build(bld): def build(bld):
bld(name = 'sdk_includes', export_includes = '. ../common ../pm_shared ../engine') bld(name = 'sdk_includes', export_includes = '. ../common ../pm_shared ../engine')
@@ -28,6 +27,7 @@ def build(bld):
'strings': 'tests/test_strings.c', 'strings': 'tests/test_strings.c',
'build': 'tests/test_build.c', 'build': 'tests/test_build.c',
'filebase': 'tests/test_filebase.c', 'filebase': 'tests/test_filebase.c',
'efp': 'tests/test_efp.c',
} }
for i in tests: for i in tests:

View File

@@ -0,0 +1,70 @@
"#if VER <= 300\n"
"#define layout(x)\n"
"#endif\n"
"#if VER < 300\n"
"#define out attribute\n"
"#define in varying\n"
"#define texture texture2D\n"
"#endif\n"
"#if VER >= 130 || VER == 100\n"
"precision mediump float;\n"
"#endif\n"
"#if VER == 100\n"
"#define PREC mediump\n"
"#else\n"
"#define PREC\n"
"#endif\n"
"#if ATTR_TEXCOORD0\n"
"uniform sampler2D uTex0;\n"
"#endif\n"
"#if ATTR_TEXCOORD1\n"
"uniform sampler2D uTex1;\n"
"#endif\n"
"#if FEAT_ALPHA_TEST\n"
"uniform float uAlphaTest;\n"
"#endif\n"
"#if FEAT_FOG\n"
"uniform PREC vec4 uFog;\n"
"#endif\n"
"uniform PREC vec4 uColor;\n"
"#if ATTR_COLOR\n"
"in PREC vec4 vColor;\n"
"#endif\n"
"#if ATTR_TEXCOORD0\n"
"in PREC vec2 vTexCoord0;\n"
"#endif\n"
"#if ATTR_TEXCOORD1\n"
"in PREC vec2 vTexCoord1;\n"
"#endif\n"
"#if ATTR_NORMAL\n"
"in PREC vec2 vNormal;\n"
"#endif\n"
"#if VER >= 300\n"
"out vec4 oFragColor;\n"
"#else\n"
"#define oFragColor gl_FragColor\n"
"#endif\n"
"void main()\n"
"{\n"
"#if ATTR_COLOR\n"
"PREC vec4 c = vColor;\n"
"#else\n"
"PREC vec4 c = uColor;\n"
"#endif\n"
"#if ATTR_TEXCOORD0\n"
"c = c * texture(uTex0, vTexCoord0);\n"
"#endif\n"
"#if ATTR_TEXCOORD1\n"
"c = c * texture(uTex1, vTexCoord1);\n"
"#endif\n"
"#if FEAT_ALPHA_TEST\n"
"if(c.a <= uAlphaTest)\n"
"discard;\n"
"#endif\n"
"#if FEAT_FOG\n"
"float fogDist = gl_FragCoord.z / gl_FragCoord.w;\n"
"float fogRate = clamp(exp(-uFog.w * fogDist), 0.0, 1.0);\n"
"c.rgb = mix(uFog.rgb, c.rgb, fogRate);\n"
"#endif\n"
"oFragColor = c;\n"
"}\n"

1770
ref/gl/gl2_shim/gl2_shim.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
/*
vgl_shim.h - vitaGL custom immediate mode shim
Copyright (C) 2023 fgsfds
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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.
*/
#pragma once
// max verts in a single frame
#define GL2_MAX_VERTS 32768
int GL2_ShimInit( void );
void GL2_ShimInstall( void );
void GL2_ShimShutdown( void );
void GL2_ShimEndFrame( void );

View File

@@ -0,0 +1,53 @@
"#if VER <= 300\n"
"#define layout(x)\n"
"#endif\n"
"#if VER < 300\n"
"#define in attribute\n"
"#define out varying\n"
"#endif\n"
"\n"
"layout(location = LOC_ATTR_POSITION) in vec3 inPosition;\n"
"#if ATTR_COLOR\n"
"layout(location = LOC_ATTR_COLOR) in vec4 inColor;\n"
"#endif\n"
"#if ATTR_TEXCOORD0\n"
"layout(location = LOC_ATTR_TEXCOORD0) in vec2 inTexCoord0;\n"
"#endif\n"
"#if ATTR_TEXCOORD1\n"
"layout(location = LOC_ATTR_TEXCOORD1) in vec2 inTexCoord1;\n"
"#endif\n"
"\n"
"#if ATTR_NORMAL\n"
"in vec3 inNormal;\n"
"#endif\n"
"#if ATTR_COLOR\n"
"out vec4 vColor;\n"
"#endif\n"
"#if ATTR_TEXCOORD0\n"
"out vec2 vTexCoord0;\n"
"#endif\n"
"#if ATTR_TEXCOORD1\n"
"out vec2 vTexCoord1;\n"
"#endif\n"
"#if ATTR_NORMAL\n"
"out vec3 vNormal;\n"
"#endif\n"
"\n"
"uniform mat4 uMVP;\n"
"\n"
"void main()\n"
"{\n"
"gl_Position = uMVP * vec4(inPosition,1.0);\n"
"#if ATTR_COLOR\n"
"vColor = inColor;\n"
"#endif\n"
"#if ATTR_NORMAL\n"
"vNormal = inNormal;\n"
"#endif\n"
"#if ATTR_TEXCOORD0\n"
"vTexCoord0 = inTexCoord0;\n"
"#endif\n"
"#if ATTR_TEXCOORD1\n"
"vTexCoord1 = inTexCoord1;\n"
"#endif\n"
"}\n"

25
ref/gl/gl2_shim/wscript Normal file
View File

@@ -0,0 +1,25 @@
#! /usr/bin/env python
# encoding: utf-8
import os
def options(opt):
pass
def configure(conf):
conf.define('REF_DLL', 1)
def build(bld):
source = bld.path.ant_glob( [ '*.c' ] )
includes = [ '.' ]
libs = [ 'engine_includes', 'sdk_includes' ]
bld.env.LDFLAGS += ['-fPIC']
bld.env.CFLAGS += ['-fPIC']
bld.stlib(
source = source,
target = 'gl2_shim',
features = 'c',
includes = includes,
use = libs,
subsystem = bld.env.MSVC_SUBSYSTEM
)

View File

@@ -418,7 +418,6 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
static rgbdata_t skin; static rgbdata_t skin;
char name[MAX_QPATH]; char name[MAX_QPATH];
int i; int i;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
skin.width = width; skin.width = width;
skin.height = height; skin.height = height;
@@ -443,7 +442,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
} }
} }
COM_FileBase( loadmodel->name, name, sizeof( name )); COM_FileBase( mod->name, name, sizeof( name ));
// for alias models only player can have remap textures // for alias models only player can have remap textures
if( mod != NULL && !Q_stricmp( name, "player" )) if( mod != NULL && !Q_stricmp( name, "player" ))
@@ -476,12 +475,11 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
return gEngfuncs.FS_CopyImage( &skin ); return gEngfuncs.FS_CopyImage( &skin );
} }
void *Mod_LoadSingleSkin( daliasskintype_t *pskintype, int skinnum, int size ) void *Mod_LoadSingleSkin( model_t *loadmodel, daliasskintype_t *pskintype, int skinnum, int size )
{ {
string name, lumaname; string name, lumaname;
string checkname; string checkname;
rgbdata_t *pic; rgbdata_t *pic;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
Q_snprintf( name, sizeof( name ), "%s:frame%i", loadmodel->name, skinnum ); Q_snprintf( name, sizeof( name ), "%s:frame%i", loadmodel->name, skinnum );
Q_snprintf( lumaname, sizeof( lumaname ), "%s:luma%i", loadmodel->name, skinnum ); Q_snprintf( lumaname, sizeof( lumaname ), "%s:luma%i", loadmodel->name, skinnum );
@@ -508,14 +506,13 @@ void *Mod_LoadSingleSkin( daliasskintype_t *pskintype, int skinnum, int size )
return ((byte *)(pskintype + 1) + size); return ((byte *)(pskintype + 1) + size);
} }
void *Mod_LoadGroupSkin( daliasskintype_t *pskintype, int skinnum, int size ) void *Mod_LoadGroupSkin( model_t *loadmodel, daliasskintype_t *pskintype, int skinnum, int size )
{ {
daliasskininterval_t *pinskinintervals; daliasskininterval_t *pinskinintervals;
daliasskingroup_t *pinskingroup; daliasskingroup_t *pinskingroup;
string name, lumaname; string name, lumaname;
rgbdata_t *pic; rgbdata_t *pic;
int i, j; int i, j;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
// animating skin group. yuck. // animating skin group. yuck.
pskintype++; pskintype++;
@@ -555,7 +552,7 @@ void *Mod_LoadGroupSkin( daliasskintype_t *pskintype, int skinnum, int size )
Mod_LoadAllSkins Mod_LoadAllSkins
=============== ===============
*/ */
void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype ) void *Mod_LoadAllSkins( model_t *mod, int numskins, daliasskintype_t *pskintype )
{ {
int i, size; int i, size;
@@ -568,11 +565,11 @@ void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
{ {
if( pskintype->type == ALIAS_SKIN_SINGLE ) if( pskintype->type == ALIAS_SKIN_SINGLE )
{ {
pskintype = (daliasskintype_t *)Mod_LoadSingleSkin( pskintype, i, size ); pskintype = (daliasskintype_t *)Mod_LoadSingleSkin( mod, pskintype, i, size );
} }
else else
{ {
pskintype = (daliasskintype_t *)Mod_LoadGroupSkin( pskintype, i, size ); pskintype = (daliasskintype_t *)Mod_LoadGroupSkin( mod, pskintype, i, size );
} }
} }
@@ -680,7 +677,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
// load the skins // load the skins
pskintype = (daliasskintype_t *)&pinmodel[1]; pskintype = (daliasskintype_t *)&pinmodel[1];
pskintype = Mod_LoadAllSkins( m_pAliasHeader->numskins, pskintype ); pskintype = Mod_LoadAllSkins( mod, m_pAliasHeader->numskins, pskintype );
// load base s and t vertices // load base s and t vertices
pinstverts = (stvert_t *)pskintype; pinstverts = (stvert_t *)pskintype;
@@ -725,7 +722,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
GL_MakeAliasModelDisplayLists( mod ); GL_MakeAliasModelDisplayLists( mod );
// move the complete, relocatable alias model to the cache // move the complete, relocatable alias model to the cache
gEngfuncs.Mod_GetCurrentLoadingModel()->cache.data = m_pAliasHeader; mod->cache.data = m_pAliasHeader;
if( loaded ) *loaded = true; // done if( loaded ) *loaded = true; // done
} }

View File

@@ -27,6 +27,8 @@ GNU General Public License for more details.
#define XASH_GLES #define XASH_GLES
#define XASH_GL_STATIC #define XASH_GL_STATIC
#define REF_GL_KEEP_MANGLED_FUNCTIONS #define REF_GL_KEEP_MANGLED_FUNCTIONS
#elif defined XASH_GLES3COMPAT
#define XASH_GLES
#endif #endif
typedef uint GLenum; typedef uint GLenum;
@@ -811,6 +813,19 @@ typedef float GLmatrix[16];
#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 #define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
// GL Core additions
#define GL_NUM_EXTENSIONS 0x821D
#define GL_MAP_WRITE_BIT 0x0002
#define GL_MAP_COHERENT_BIT 0x0080
#define GL_MAP_PERSISTENT_BIT 0x0040
#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
#define GL_MAJOR_VERSION 0x821B
#define GL_MINOR_VERSION 0x821C
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
@@ -888,6 +903,7 @@ typedef float GLmatrix[16];
// helper opengl functions // helper opengl functions
APIENTRY_LINKAGE GLenum GL_FUNCTION( glGetError )(void); APIENTRY_LINKAGE GLenum GL_FUNCTION( glGetError )(void);
APIENTRY_LINKAGE const GLubyte * GL_FUNCTION( glGetString )(GLenum name); APIENTRY_LINKAGE const GLubyte * GL_FUNCTION( glGetString )(GLenum name);
APIENTRY_LINKAGE const GLubyte * GL_FUNCTION( glGetStringi )(GLenum name, GLint i);
// base gl functions // base gl functions
APIENTRY_LINKAGE void GL_FUNCTION( glAccum )(GLenum op, GLfloat value); APIENTRY_LINKAGE void GL_FUNCTION( glAccum )(GLenum op, GLfloat value);
@@ -1358,7 +1374,18 @@ APIENTRY_LINKAGE void GL_FUNCTION( glGenVertexArrays )( GLsizei n, const GLuint
APIENTRY_LINKAGE GLboolean GL_FUNCTION( glIsVertexArray )( GLuint array ); APIENTRY_LINKAGE GLboolean GL_FUNCTION( glIsVertexArray )( GLuint array );
APIENTRY_LINKAGE void GL_FUNCTION( glSwapInterval ) ( int interval ); APIENTRY_LINKAGE void GL_FUNCTION( glSwapInterval ) ( int interval );
#if !defined( XASH_GLES ) && !defined( XASH_GL4ES ) // arb shaders change in core
APIENTRY_LINKAGE void GL_FUNCTION( glDeleteProgram )(GLuint program);
APIENTRY_LINKAGE void GL_FUNCTION( glGetProgramiv )(GLuint program, GLenum e, GLuint *v);
APIENTRY_LINKAGE void GL_FUNCTION( glGetProgramInfoLog )(GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
// gl2shim deps
APIENTRY_LINKAGE void GL_FUNCTION( glBufferStorage )( GLenum target, GLsizei size, const GLvoid * data, GLbitfield flags);
APIENTRY_LINKAGE void GL_FUNCTION( glFlushMappedBufferRange )(GLenum target, GLsizei offset, GLsizei length);
APIENTRY_LINKAGE void *GL_FUNCTION( glMapBufferRange )(GLenum target, GLsizei offset, GLsizei length, GLbitfield access);
APIENTRY_LINKAGE void GL_FUNCTION( glDrawRangeElementsBaseVertex )( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLuint vertex );
#if !defined( XASH_GL_STATIC ) || (!defined( XASH_GLES ) && !defined( XASH_GL4ES ))
APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
#endif /* !XASH_GLES && !XASH_GL4ES */ #endif /* !XASH_GLES && !XASH_GL4ES */

View File

@@ -166,7 +166,7 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
} }
else if( FBitSet( tex->flags, TF_NOMIPMAP ) || tex->numMips <= 1 ) else if( FBitSet( tex->flags, TF_NOMIPMAP ) || tex->numMips <= 1 )
{ {
if( FBitSet( tex->flags, TF_NEAREST ) || ( IsLightMap( tex ) && gl_lightmap_nearest.value )) if( FBitSet( tex->flags, TF_NEAREST ) || ( IsLightMap( tex ) && gl_lightmap_nearest.value ) || ( tex->flags == TF_SKYSIDE && gl_texture_nearest.value ))
{ {
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
@@ -342,6 +342,8 @@ void R_SetTextureParameters( void )
// change all the existing mipmapped texture objects // change all the existing mipmapped texture objects
for( i = 0; i < gl_numTextures; i++ ) for( i = 0; i < gl_numTextures; i++ )
GL_UpdateTextureParams( i ); GL_UpdateTextureParams( i );
R_UpdateRippleTexParams();
} }
/* /*
@@ -388,7 +390,8 @@ static size_t GL_CalcImageSize( pixformat_t format, int width, int height, int d
case PF_DXT5: case PF_DXT5:
case PF_BC6H_SIGNED: case PF_BC6H_SIGNED:
case PF_BC6H_UNSIGNED: case PF_BC6H_UNSIGNED:
case PF_BC7: case PF_BC7_UNORM:
case PF_BC7_SRGB:
case PF_ATI2: case PF_ATI2:
size = (((width + 3) >> 2) * ((height + 3) >> 2) * 16) * depth; size = (((width + 3) >> 2) * ((height + 3) >> 2) * 16) * depth;
break; break;
@@ -694,7 +697,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
Assert( tex != NULL ); Assert( tex != NULL );
if( ImageDXT( format )) if( ImageCompressed( format ))
{ {
switch( format ) switch( format )
{ {
@@ -703,7 +706,8 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
case PF_DXT5: tex->format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break; case PF_DXT5: tex->format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
case PF_BC6H_SIGNED: tex->format = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; break; case PF_BC6H_SIGNED: tex->format = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; break;
case PF_BC6H_UNSIGNED: tex->format = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; break; case PF_BC6H_UNSIGNED: tex->format = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; break;
case PF_BC7: tex->format = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; break; case PF_BC7_SRGB:
case PF_BC7_UNORM: tex->format = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; break;
case PF_ATI2: case PF_ATI2:
if( glConfig.hardware_type == GLHW_RADEON ) if( glConfig.hardware_type == GLHW_RADEON )
tex->format = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; tex->format = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
@@ -1070,7 +1074,7 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
} }
else if( tex->target == GL_TEXTURE_2D_MULTISAMPLE ) else if( tex->target == GL_TEXTURE_2D_MULTISAMPLE )
{ {
#if !defined( XASH_GLES ) && !defined( XASH_GL4ES ) #if !defined( XASH_GL_STATIC ) || (!defined( XASH_GLES ) && !defined( XASH_GL4ES ))
samplesCount = (GLsizei)gEngfuncs.pfnGetCvarFloat("gl_msaa_samples"); samplesCount = (GLsizei)gEngfuncs.pfnGetCvarFloat("gl_msaa_samples");
switch (samplesCount) switch (samplesCount)
{ {
@@ -1083,9 +1087,9 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
samplesCount = 1; samplesCount = 1;
} }
pglTexImage2DMultisample( tex->target, samplesCount, tex->format, width, height, GL_TRUE ); pglTexImage2DMultisample( tex->target, samplesCount, tex->format, width, height, GL_TRUE );
#else /* !XASH_GLES && !XASH_GL4ES */ #else /* !XASH_GL_STATIC !XASH_GLES && !XASH_GL4ES */
gEngfuncs.Con_Printf( S_ERROR "GLES renderer don't support GL_TEXTURE_2D_MULTISAMPLE!\n" ); gEngfuncs.Con_Printf( S_ERROR "GLES renderer don't support GL_TEXTURE_2D_MULTISAMPLE!\n" );
#endif /* !XASH_GLES && !XASH_GL4ES */ #endif /* !XASH_GL_STATIC !XASH_GLES && !XASH_GL4ES */
} }
else // 2D or RECT else // 2D or RECT
{ {
@@ -1094,7 +1098,7 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
} }
} }
static void GL_TextureImageDXT( gl_texture_t *tex, GLint side, GLint level, GLint width, GLint height, GLint depth, size_t size, const void *data ) static void GL_TextureImageCompressed( gl_texture_t *tex, GLint side, GLint level, GLint width, GLint height, GLint depth, size_t size, const void *data )
{ {
GLuint cubeTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; GLuint cubeTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB;
qboolean subImage = FBitSet( tex->flags, TF_IMG_UPLOADED ); qboolean subImage = FBitSet( tex->flags, TF_IMG_UPLOADED );
@@ -1176,7 +1180,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
return false; return false;
} }
if( pic->type == PF_BC6H_SIGNED || pic->type == PF_BC6H_UNSIGNED || pic->type == PF_BC7 ) if( pic->type == PF_BC6H_SIGNED || pic->type == PF_BC6H_UNSIGNED || pic->type == PF_BC7_UNORM || pic->type == PF_BC7_SRGB )
{ {
if( !GL_Support( GL_ARB_TEXTURE_COMPRESSION_BPTC )) if( !GL_Support( GL_ARB_TEXTURE_COMPRESSION_BPTC ))
{ {
@@ -1217,7 +1221,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
if( buf != NULL && buf >= bufend ) if( buf != NULL && buf >= bufend )
gEngfuncs.Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name ); gEngfuncs.Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name );
if( ImageDXT( pic->type )) if( ImageCompressed( pic->type ))
{ {
for( j = 0; j < Q_max( 1, pic->numMips ); j++ ) for( j = 0; j < Q_max( 1, pic->numMips ); j++ )
{ {
@@ -1225,7 +1229,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
height = Q_max( 1, ( tex->height >> j )); height = Q_max( 1, ( tex->height >> j ));
texsize = GL_CalcTextureSize( tex->format, width, height, tex->depth ); texsize = GL_CalcTextureSize( tex->format, width, height, tex->depth );
size = GL_CalcImageSize( pic->type, width, height, tex->depth ); size = GL_CalcImageSize( pic->type, width, height, tex->depth );
GL_TextureImageDXT( tex, i, j, width, height, tex->depth, size, buf ); GL_TextureImageCompressed( tex, i, j, width, height, tex->depth, size, buf );
tex->size += texsize; tex->size += texsize;
buf += size; // move pointer buf += size; // move pointer
tex->numMips++; tex->numMips++;
@@ -1259,7 +1263,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap ); data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
else data = buf; else data = buf;
if( !ImageDXT( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA )) if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
data = GL_ApplyFilter( data, tex->width, tex->height ); data = GL_ApplyFilter( data, tex->width, tex->height );
// mips will be auto-generated if desired // mips will be auto-generated if desired
@@ -1307,7 +1311,7 @@ static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic )
tex->encode = pic->encode; // share encode method tex->encode = pic->encode; // share encode method
if( ImageDXT( pic->type )) if( ImageCompressed( pic->type ))
{ {
if( !pic->numMips ) if( !pic->numMips )
tex->flags |= TF_NOMIPMAP; // disable mipmapping by user request tex->flags |= TF_NOMIPMAP; // disable mipmapping by user request
@@ -1418,7 +1422,7 @@ static gl_texture_t *GL_AllocTexture( const char *name, texFlags_t flags )
// copy initial params // copy initial params
Q_strncpy( tex->name, name, sizeof( tex->name )); Q_strncpy( tex->name, name, sizeof( tex->name ));
if( FBitSet( flags, TF_SKYSIDE )) if( FBitSet( flags, TF_SKYSIDE ) && glConfig.context != CONTEXT_TYPE_GL_CORE )
tex->texnum = tr.skyboxbasenum++; tex->texnum = tr.skyboxbasenum++;
else else
{ {
@@ -1922,7 +1926,7 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
return; return;
} }
if( ImageDXT( image->original->type )) if( ImageCompressed( image->original->type ))
{ {
gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: can't process compressed texture %s\n", image->name ); gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: can't process compressed texture %s\n", image->name );
return; return;
@@ -2315,6 +2319,7 @@ void R_InitImages( void )
// validate cvars // validate cvars
R_SetTextureParameters(); R_SetTextureParameters();
GL_CreateInternalTextures(); GL_CreateInternalTextures();
R_InitRipples();
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" ); gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
} }

View File

@@ -40,6 +40,9 @@ int VGL_ShimInit( void );
void VGL_ShimShutdown( void ); void VGL_ShimShutdown( void );
void VGL_ShimEndFrame( void ); void VGL_ShimEndFrame( void );
#endif #endif
#if !defined(XASH_GL_STATIC)
#include "gl2_shim/gl2_shim.h"
#endif
#ifndef offsetof #ifndef offsetof
#ifdef __GNUC__ #ifdef __GNUC__
@@ -423,7 +426,7 @@ void R_MarkLeaves( void );
void R_DrawWorld( void ); void R_DrawWorld( void );
void R_DrawWaterSurfaces( void ); void R_DrawWaterSurfaces( void );
void R_DrawBrushModel( cl_entity_t *e ); void R_DrawBrushModel( cl_entity_t *e );
void GL_SubdivideSurface( msurface_t *fa ); void GL_SubdivideSurface( model_t *mod, msurface_t *fa );
void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa ); void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa );
void DrawGLPoly( glpoly_t *p, float xScale, float yScale ); void DrawGLPoly( glpoly_t *p, float xScale, float yScale );
texture_t *R_TextureAnimation( msurface_t *s ); texture_t *R_TextureAnimation( msurface_t *s );
@@ -486,6 +489,11 @@ void R_ClearSkyBox( void );
void R_DrawSkyBox( void ); void R_DrawSkyBox( void );
void R_DrawClouds( void ); void R_DrawClouds( void );
void EmitWaterPolys( msurface_t *warp, qboolean reverse ); void EmitWaterPolys( msurface_t *warp, qboolean reverse );
void R_InitRipples( void );
void R_ResetRipples( void );
void R_AnimateRipples( void );
void R_UpdateRippleTexParams( void );
void R_UploadRipples( texture_t *image );
// //
// gl_vgui.c // gl_vgui.c
@@ -561,7 +569,7 @@ void GL_CheckForErrors_( const char *filename, const int fileline );
const char *GL_ErrorString( int err ); const char *GL_ErrorString( int err );
qboolean GL_Support( int r_ext ); qboolean GL_Support( int r_ext );
int GL_MaxTextureUnits( void ); int GL_MaxTextureUnits( void );
qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext ); qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext, float minver );
void GL_SetExtension( int r_ext, int enable ); void GL_SetExtension( int r_ext, int enable );
// //
@@ -617,6 +625,11 @@ enum
GL_DRAW_RANGEELEMENTS_EXT, GL_DRAW_RANGEELEMENTS_EXT,
GL_TEXTURE_MULTISAMPLE, GL_TEXTURE_MULTISAMPLE,
GL_ARB_TEXTURE_COMPRESSION_BPTC, GL_ARB_TEXTURE_COMPRESSION_BPTC,
GL_SHADER_OBJECTS_EXT,
GL_ARB_VERTEX_ARRAY_OBJECT_EXT,
GL_BUFFER_STORAGE_EXT,
GL_MAP_BUFFER_RANGE_EXT,
GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT,
GL_EXTCOUNT, // must be last GL_EXTCOUNT, // must be last
}; };
@@ -662,6 +675,8 @@ typedef struct
int depth_bits; int depth_bits;
int stencil_bits; int stencil_bits;
int msaasamples; int msaasamples;
int version_major;
int version_minor;
gl_context_type_t context; gl_context_type_t context;
gles_wrapper_t wrapper; gles_wrapper_t wrapper;
@@ -738,7 +753,11 @@ extern convar_t r_lockfrustum;
extern convar_t r_traceglow; extern convar_t r_traceglow;
extern convar_t r_vbo; extern convar_t r_vbo;
extern convar_t r_vbo_dlightmode; extern convar_t r_vbo_dlightmode;
extern convar_t r_studio_sort_textures;
extern convar_t r_studio_drawelements;
extern convar_t r_ripple;
extern convar_t r_ripple_updatetime;
extern convar_t r_ripple_spawntime;
// //
// engine shared convars // engine shared convars

View File

@@ -26,10 +26,14 @@ CVAR_DEFINE_AUTO( r_novis, "0", 0, "ignore vis information (perfomance test)" );
CVAR_DEFINE_AUTO( r_nocull, "0", 0, "ignore frustrum culling (perfomance test)" ); CVAR_DEFINE_AUTO( r_nocull, "0", 0, "ignore frustrum culling (perfomance test)" );
CVAR_DEFINE_AUTO( r_lockpvs, "0", FCVAR_CHEAT, "lockpvs area at current point (pvs test)" ); CVAR_DEFINE_AUTO( r_lockpvs, "0", FCVAR_CHEAT, "lockpvs area at current point (pvs test)" );
CVAR_DEFINE_AUTO( r_lockfrustum, "0", FCVAR_CHEAT, "lock frustrum area at current point (cull test)" ); CVAR_DEFINE_AUTO( r_lockfrustum, "0", FCVAR_CHEAT, "lock frustrum area at current point (cull test)" );
CVAR_DEFINE_AUTO( r_traceglow, "1", FCVAR_GLCONFIG, "cull flares behind models" ); CVAR_DEFINE_AUTO( r_traceglow, "0", FCVAR_GLCONFIG, "cull flares behind models" );
CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" ); CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" ); CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" );
CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" ); CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" );
CVAR_DEFINE_AUTO( r_ripple, "0", FCVAR_GLCONFIG, "enable software-like water texture ripple simulation" );
CVAR_DEFINE_AUTO( r_ripple_updatetime, "0.05", FCVAR_GLCONFIG, "how fast ripple simulation is" );
CVAR_DEFINE_AUTO( r_ripple_spawntime, "0.1", FCVAR_GLCONFIG, "how fast new ripples spawn" );
DEFINE_ENGINE_SHARED_CVAR_LIST() DEFINE_ENGINE_SHARED_CVAR_LIST()
@@ -222,8 +226,10 @@ static dllfunc_t vbofuncs[] =
{ GL_CALL( glDeleteBuffersARB ) }, { GL_CALL( glDeleteBuffersARB ) },
{ GL_CALL( glGenBuffersARB ) }, { GL_CALL( glGenBuffersARB ) },
{ GL_CALL( glIsBufferARB ) }, { GL_CALL( glIsBufferARB ) },
#ifndef XASH_GLES
{ GL_CALL( glMapBufferARB ) }, { GL_CALL( glMapBufferARB ) },
{ GL_CALL( glUnmapBufferARB ) }, // , { GL_CALL( glUnmapBufferARB ) },
#endif
{ GL_CALL( glBufferDataARB ) }, { GL_CALL( glBufferDataARB ) },
{ GL_CALL( glBufferSubDataARB ) }, { GL_CALL( glBufferSubDataARB ) },
{ NULL, NULL } { NULL, NULL }
@@ -247,6 +253,192 @@ static dllfunc_t drawrangeelementsextfuncs[] =
{ NULL, NULL } { NULL, NULL }
}; };
// mangling in gl2shim???
// still need resolve some ext dynamicly, and mangling beginend wrappers will help only with LTO
// anyway this will not work with gl-wes/nanogl, we do not link to libGLESv2, so skip this now
#ifndef XASH_GL_STATIC
static dllfunc_t mapbufferrangefuncs[] =
{
{ GL_CALL( glMapBufferRange ) },
{ GL_CALL( glFlushMappedBufferRange ) },
#ifdef XASH_GLES
{ GL_CALL( glUnmapBufferARB ) },
#endif
{ NULL, NULL }
};
static dllfunc_t drawrangeelementsbasevertexfuncs[] =
{
{ GL_CALL( glDrawRangeElementsBaseVertex ) },
{ NULL, NULL }
};
static dllfunc_t bufferstoragefuncs[] =
{
{ GL_CALL( glBufferStorage ) },
{ NULL, NULL }
};
static dllfunc_t shaderobjectsfuncs[] =
{
{ GL_CALL( glDeleteObjectARB ) },
{ GL_CALL( glGetHandleARB ) },
{ GL_CALL( glDetachObjectARB ) },
{ GL_CALL( glCreateShaderObjectARB ) },
{ GL_CALL( glShaderSourceARB ) },
{ GL_CALL( glCompileShaderARB ) },
{ GL_CALL( glCreateProgramObjectARB ) },
{ GL_CALL( glAttachObjectARB ) },
{ GL_CALL( glLinkProgramARB ) },
{ GL_CALL( glUseProgramObjectARB ) },
{ GL_CALL( glValidateProgramARB ) },
{ GL_CALL( glUniform1fARB ) },
{ GL_CALL( glUniform2fARB ) },
{ GL_CALL( glUniform3fARB ) },
{ GL_CALL( glUniform4fARB ) },
{ GL_CALL( glUniform1iARB ) },
{ GL_CALL( glUniform2iARB ) },
{ GL_CALL( glUniform3iARB ) },
{ GL_CALL( glUniform4iARB ) },
{ GL_CALL( glUniform1fvARB ) },
{ GL_CALL( glUniform2fvARB ) },
{ GL_CALL( glUniform3fvARB ) },
{ GL_CALL( glUniform4fvARB ) },
{ GL_CALL( glUniform1ivARB ) },
{ GL_CALL( glUniform2ivARB ) },
{ GL_CALL( glUniform3ivARB ) },
{ GL_CALL( glUniform4ivARB ) },
{ GL_CALL( glUniformMatrix2fvARB ) },
{ GL_CALL( glUniformMatrix3fvARB ) },
{ GL_CALL( glUniformMatrix4fvARB ) },
{ GL_CALL( glGetObjectParameterfvARB ) },
{ GL_CALL( glGetObjectParameterivARB ) },
{ GL_CALL( glGetInfoLogARB ) },
{ GL_CALL( glGetAttachedObjectsARB ) },
{ GL_CALL( glGetUniformLocationARB ) },
{ GL_CALL( glGetActiveUniformARB ) },
{ GL_CALL( glGetUniformfvARB ) },
{ GL_CALL( glGetUniformivARB ) },
{ GL_CALL( glGetShaderSourceARB ) },
{ GL_CALL( glVertexAttribPointerARB ) },
{ GL_CALL( glEnableVertexAttribArrayARB ) },
{ GL_CALL( glDisableVertexAttribArrayARB ) },
{ GL_CALL( glBindAttribLocationARB ) },
{ GL_CALL( glGetActiveAttribARB ) },
{ GL_CALL( glGetAttribLocationARB ) },
{ GL_CALL( glVertexAttrib2fARB ) },
{ GL_CALL( glVertexAttrib2fvARB ) },
// { GL_CALL( glVertexAttrib3fv ) },
// { GL_CALL( glVertexAttrib4f ) },
// { GL_CALL( glVertexAttrib4fv ) },
// { GL_CALL( glVertexAttrib4ubv ) },
{ NULL, NULL }
};
/*
==================
Even if *ARB functions may work in GL driver in Core context,
renderdoc completely ignores this calls, so we cannot workaround this
by removing ARB suffix after failed function resolve
I desided not to remove ARB suffix from function declarations because
it historicaly related to ARB_shader_object extension, not GL2+ functions
and all shader code from XashXT/ancient xash3d uses it too
Commented out lines left there intentionally to prevent usage on core/gles
==================
*/
static dllfunc_t shaderobjectsfuncs_gles[] =
{
{ "glDeleteShader" , (void **)&pglDeleteObjectARB },
//{ "glGetHandleARB" , (void **)&pglGetHandleARB },
{ "glDetachShader" , (void **)&pglDetachObjectARB },
{ "glCreateShader" , (void **)&pglCreateShaderObjectARB },
{ "glShaderSource" , (void **)&pglShaderSourceARB },
{ "glCompileShader" , (void **)&pglCompileShaderARB },
{ "glCreateProgram" , (void **)&pglCreateProgramObjectARB },
{ "glAttachShader" , (void **)&pglAttachObjectARB },
{ "glLinkProgram" , (void **)&pglLinkProgramARB },
{ "glUseProgram" , (void **)&pglUseProgramObjectARB },
{ "glValidateProgram" , (void **)&pglValidateProgramARB },
{ "glUniform1f" , (void **)&pglUniform1fARB },
{ "glUniform2f" , (void **)&pglUniform2fARB },
{ "glUniform3f" , (void **)&pglUniform3fARB },
{ "glUniform4f" , (void **)&pglUniform4fARB },
{ "glUniform1i" , (void **)&pglUniform1iARB },
{ "glUniform2i" , (void **)&pglUniform2iARB },
{ "glUniform3i" , (void **)&pglUniform3iARB },
{ "glUniform4i" , (void **)&pglUniform4iARB },
{ "glUniform1f" , (void **)&pglUniform1fvARB },
{ "glUniform2fv" , (void **)&pglUniform2fvARB },
{ "glUniform3fv" , (void **)&pglUniform3fvARB },
{ "glUniform4fv" , (void **)&pglUniform4fvARB },
{ "glUniform1iv" , (void **)&pglUniform1ivARB },
{ "glUniform2iv" , (void **)&pglUniform2ivARB },
{ "glUniform3iv" , (void **)&pglUniform3ivARB },
{ "glUniform4iv" , (void **)&pglUniform4ivARB },
{ "glUniformMatrix2fv" , (void **)&pglUniformMatrix2fvARB },
{ "glUniformMatrix3fv" , (void **)&pglUniformMatrix3fvARB },
{ "glUniformMatrix4fv" , (void **)&pglUniformMatrix4fvARB },
// { "glGetShaderfv" , (void **)&pglGetObjectParameterfvARB }, // missing in ES2?
{ "glGetShaderiv" , (void **)&pglGetObjectParameterivARB },
{ "glGetShaderInfoLog" , (void **)&pglGetInfoLogARB },
// { "glGetAttachedObjects" , (void **)&pglGetAttachedObjectsARB }, // missing in ES2?
{ "glGetUniformLocation" , (void **)&pglGetUniformLocationARB },
{ "glGetActiveUniform" , (void **)&pglGetActiveUniformARB },
{ "glGetUniformfv" , (void **)&pglGetUniformfvARB },
{ "glGetUniformiv" , (void **)&pglGetUniformivARB },
{ "glGetShaderSource" , (void **)&pglGetShaderSourceARB },
{ "glVertexAttribPointer" , (void **)&pglVertexAttribPointerARB },
{ "glEnableVertexAttribArray" , (void **)&pglEnableVertexAttribArrayARB },
{ "glDisableVertexAttribArray" , (void **)&pglDisableVertexAttribArrayARB },
{ "glBindAttribLocation" , (void **)&pglBindAttribLocationARB },
{ "glGetActiveAttrib" , (void **)&pglGetActiveAttribARB },
{ "glGetAttribLocation" , (void **)&pglGetAttribLocationARB },
{ "glVertexAttrib2f" , (void **)&pglVertexAttrib2fARB },
{ "glVertexAttrib2fv" , (void **)&pglVertexAttrib2fvARB },
{ "glVertexAttrib3fv" , (void **)&pglVertexAttrib3fvARB },
// Core/GLES only
{ GL_CALL( glGetProgramiv ) },
{ GL_CALL( glDeleteProgram ) },
{ GL_CALL( glGetProgramInfoLog ) },
//{ "glVertexAttrib4f" , (void **)&pglVertexAttrib4fARB },
//{ "glVertexAttrib4fv" , (void **)&pglVertexAttrib4fvARB },
//{ "glVertexAttrib4ubv" , (void **)&pglVertexAttrib4ubvARB },
{ NULL, NULL }
};
static dllfunc_t vaofuncs[] =
{
{ GL_CALL( glBindVertexArray ) },
{ GL_CALL( glDeleteVertexArrays ) },
{ GL_CALL( glGenVertexArrays ) },
{ GL_CALL( glIsVertexArray ) },
{ NULL, NULL }
};
static dllfunc_t multitexturefuncs_es[] =
{
{ GL_CALL( glActiveTexture ) },
{ GL_CALL( glActiveTextureARB ) },
{ GL_CALL( glClientActiveTexture ) },
{ GL_CALL( glClientActiveTextureARB ) },
{ NULL , NULL }
};
static dllfunc_t multitexturefuncs_es2[] =
{
{ GL_CALL( glActiveTexture ) },
{ GL_CALL( glActiveTextureARB ) },
{ NULL , NULL }
};
#endif
/* /*
======================== ========================
DebugCallback DebugCallback
@@ -319,12 +511,13 @@ int GL_MaxTextureUnits( void )
GL_CheckExtension GL_CheckExtension
================= =================
*/ */
qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext ) qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext, float minver )
{ {
const dllfunc_t *func; const dllfunc_t *func;
cvar_t *parm = NULL; cvar_t *parm = NULL;
const char *extensions_string; const char *extensions_string;
char desc[MAX_VA_STRING]; char desc[MAX_VA_STRING];
float glver = (float)glConfig.version_major + glConfig.version_minor / 10.0f;
gEngfuncs.Con_Reportf( "GL_CheckExtension: %s ", name ); gEngfuncs.Con_Reportf( "GL_CheckExtension: %s ", name );
GL_SetExtension( r_ext, true ); GL_SetExtension( r_ext, true );
@@ -345,7 +538,7 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
extensions_string = glConfig.extensions_string; extensions_string = glConfig.extensions_string;
if(( name[2] == '_' || name[3] == '_' ) && !Q_strstr( extensions_string, name )) if(( name[2] == '_' || name[3] == '_' ) && !Q_strstr( extensions_string, name ) && ( glver < minver || !minver || !glver ) )
{ {
GL_SetExtension( r_ext, false ); // update render info GL_SetExtension( r_ext, false ); // update render info
gEngfuncs.Con_Reportf( "- ^1failed\n" ); gEngfuncs.Con_Reportf( "- ^1failed\n" );
@@ -360,12 +553,56 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
for( func = funcs; func && func->name; func++ ) for( func = funcs; func && func->name; func++ )
{ {
// functions are cleared before all the extensions are evaluated // functions are cleared before all the extensions are evaluated
if((*func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL ) if(( *func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL )
{
string name;
char *end;
size_t i = 0;
#ifdef XASH_GLES
const char *suffixes[] = { "", "EXT", "OES" };
#else
const char *suffixes[] = { "", "EXT" };
#endif
// HACK: fix ARB names
Q_strncpy( name, func->name, sizeof( name ));
if(( end = Q_strstr( name, "ARB" )))
{
*end = '\0';
}
else // I need Q_strstrnul
{
end = name + Q_strlen( name );
i++; // skip empty suffix
}
for( ; i < sizeof( suffixes ) / sizeof( suffixes[0] ); i++ )
{
void *f;
Q_strncat( name, suffixes[i], sizeof( name ));
if(( f = gEngfuncs.GL_GetProcAddress( name )))
{
// GL_GetProcAddress prints errors about missing functions, so tell user that we found it with different name
gEngfuncs.Con_Printf( S_NOTE "found %s\n", name );
*func->func = f;
break;
}
else
{
*end = '\0'; // cut suffix, try next
}
}
// not found...
if( i == sizeof( suffixes ) / sizeof( suffixes[0] ))
{ {
// one or more functions are invalid, extension will be disabled
GL_SetExtension( r_ext, false ); GL_SetExtension( r_ext, false );
} }
} }
}
#endif #endif
if( GL_Support( r_ext )) if( GL_Support( r_ext ))
@@ -545,7 +782,11 @@ void GL_InitExtensionsGLES( void )
#elif defined( XASH_WES ) #elif defined( XASH_WES )
glConfig.context = CONTEXT_TYPE_GLES_2_X; glConfig.context = CONTEXT_TYPE_GLES_2_X;
glConfig.wrapper = GLES_WRAPPER_WES; glConfig.wrapper = GLES_WRAPPER_WES;
#elif defined( XASH_GLES3COMPAT )
glConfig.context = CONTEXT_TYPE_GLES_2_X;
glConfig.wrapper = GLES_WRAPPER_NONE;
#else #else
#error "unknown gles wrapper" #error "unknown gles wrapper"
#endif #endif
@@ -556,12 +797,22 @@ void GL_InitExtensionsGLES( void )
switch( extid ) switch( extid )
{ {
case GL_ARB_VERTEX_BUFFER_OBJECT_EXT: case GL_ARB_VERTEX_BUFFER_OBJECT_EXT:
GL_SetExtension( extid, true ); GL_CheckExtension( "vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", extid, 1.0 );
break; break;
case GL_ARB_MULTITEXTURE: case GL_ARB_MULTITEXTURE:
if( !GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 ) && glConfig.wrapper == GLES_WRAPPER_NONE )
{
#ifndef XASH_GL_STATIC
if( !GL_CheckExtension( "multitexture_es1", multitexturefuncs_es, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 )
&& !GL_CheckExtension( "multitexture_es2", multitexturefuncs_es2, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 2.0 ))
break;
#endif
}
GL_SetExtension( extid, true ); // required to be supported by wrapper GL_SetExtension( extid, true ); // required to be supported by wrapper
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units ); pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
if( glConfig.max_texture_units <= 1 )
pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_texture_units );
if( glConfig.max_texture_units <= 1 ) if( glConfig.max_texture_units <= 1 )
{ {
GL_SetExtension( extid, false ); GL_SetExtension( extid, false );
@@ -571,24 +822,50 @@ void GL_InitExtensionsGLES( void )
glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units; glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units;
break; break;
case GL_TEXTURE_CUBEMAP_EXT: case GL_TEXTURE_CUBEMAP_EXT:
if( GL_CheckExtension( "GL_OES_texture_cube_map", NULL, "gl_texture_cubemap", extid )) if( GL_CheckExtension( "GL_OES_texture_cube_map", NULL, "gl_texture_cubemap", extid, 0 ))
pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size ); pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size );
break; break;
case GL_ANISOTROPY_EXT: case GL_ANISOTROPY_EXT:
glConfig.max_texture_anisotropy = 0.0f; glConfig.max_texture_anisotropy = 0.0f;
if( GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_ext_anisotropic_filter", extid )) if( GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_ext_anisotropic_filter", extid, 0 ))
pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy ); pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy );
break; break;
case GL_TEXTURE_LOD_BIAS: case GL_TEXTURE_LOD_BIAS:
if( GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_texture_mipmap_biasing", extid )) if( GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_texture_mipmap_biasing", extid, 0 ))
pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lod_bias ); pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lod_bias );
break; break;
case GL_ARB_TEXTURE_NPOT_EXT: case GL_ARB_TEXTURE_NPOT_EXT:
GL_CheckExtension( "GL_OES_texture_npot", NULL, "gl_texture_npot", extid ); GL_CheckExtension( "GL_OES_texture_npot", NULL, "gl_texture_npot", extid, 0 );
break; break;
#ifndef XASH_GL_STATIC
case GL_SHADER_OBJECTS_EXT:
GL_CheckExtension( "ES2 Shaders", shaderobjectsfuncs_gles, "gl_shaderobjects", extid, 2.0 );
break;
case GL_ARB_VERTEX_ARRAY_OBJECT_EXT:
if( !GL_CheckExtension( "GL_OES_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 ))
GL_CheckExtension( "GL_EXT_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 );
break;
case GL_DRAW_RANGEELEMENTS_EXT:
if( !GL_CheckExtension( "GL_EXT_draw_range_elements", drawrangeelementsfuncs, "gl_drawrangeelements", extid, 3.0 ))
GL_CheckExtension( "GL_OES_draw_range_elements", drawrangeelementsfuncs, "gl_drawrangeelements", extid, 3.0 );
break;
case GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT:
if( !GL_CheckExtension( "GL_OES_draw_elements_base_vertex", drawrangeelementsbasevertexfuncs, "gl_drawrangeelementsbasevertex", GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT, 0 ))
GL_CheckExtension( "GL_EXT_draw_elements_base_vertex", drawrangeelementsbasevertexfuncs, "gl_drawrangeelementsbasevertex", GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT, 3.2 );
break;
case GL_MAP_BUFFER_RANGE_EXT:
GL_CheckExtension( "GL_EXT_map_buffer_range", mapbufferrangefuncs, "gl_map_buffer_range", GL_MAP_BUFFER_RANGE_EXT , 3.0);
break;
case GL_BUFFER_STORAGE_EXT:
GL_CheckExtension( "GL_EXT_buffer_storage", bufferstoragefuncs, "gl_buffer_storage", GL_BUFFER_STORAGE_EXT, 0);
break;
#endif
case GL_DEBUG_OUTPUT: case GL_DEBUG_OUTPUT:
if( glw_state.extended ) if( glw_state.extended )
GL_CheckExtension( "GL_KHR_debug", NULL, NULL, extid ); GL_CheckExtension( "GL_KHR_debug", debugoutputfuncs, "gl_debug_output", extid, 0 );
else
GL_SetExtension( extid, false );
break; break;
// case GL_TEXTURE_COMPRESSION_EXT: NOPE // case GL_TEXTURE_COMPRESSION_EXT: NOPE
// case GL_SHADER_GLSL100_EXT: NOPE // case GL_SHADER_GLSL100_EXT: NOPE
@@ -607,12 +884,15 @@ void GL_InitExtensionsGLES( void )
GL_SetExtension( extid, false ); GL_SetExtension( extid, false );
} }
} }
#ifndef XASH_GL_STATIC
GL2_ShimInit();
#endif
} }
#else #else
void GL_InitExtensionsBigGL( void ) void GL_InitExtensionsBigGL( void )
{ {
// intialize wrapper type // intialize wrapper type
glConfig.context = CONTEXT_TYPE_GL; glConfig.context = gEngfuncs.Sys_CheckParm( "-glcore" )? CONTEXT_TYPE_GL_CORE : CONTEXT_TYPE_GL;
glConfig.wrapper = GLES_WRAPPER_NONE; glConfig.wrapper = GLES_WRAPPER_NONE;
if( Q_stristr( glConfig.renderer_string, "geforce" )) if( Q_stristr( glConfig.renderer_string, "geforce" ))
@@ -643,7 +923,7 @@ void GL_InitExtensionsBigGL( void )
// multitexture // multitexture
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1; glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;
if( GL_CheckExtension( "GL_ARB_multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE )) if( GL_CheckExtension( "GL_ARB_multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.3f ))
{ {
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units ); pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
} }
@@ -652,7 +932,7 @@ void GL_InitExtensionsBigGL( void )
GL_SetExtension( GL_ARB_MULTITEXTURE, false ); GL_SetExtension( GL_ARB_MULTITEXTURE, false );
// 3d texture support // 3d texture support
if( GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", GL_TEXTURE_3D_EXT )) if( GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", GL_TEXTURE_3D_EXT, 2.0f ))
{ {
pglGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max_3d_texture_size ); pglGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max_3d_texture_size );
@@ -664,25 +944,25 @@ void GL_InitExtensionsBigGL( void )
} }
// 2d texture array support // 2d texture array support
if( GL_CheckExtension( "GL_EXT_texture_array", texture3dextfuncs, "gl_texture_2d_array", GL_TEXTURE_ARRAY_EXT )) if( GL_CheckExtension( "GL_EXT_texture_array", texture3dextfuncs, "gl_texture_2d_array", GL_TEXTURE_ARRAY_EXT, 0 ))
pglGetIntegerv( GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &glConfig.max_2d_texture_layers ); pglGetIntegerv( GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &glConfig.max_2d_texture_layers );
// cubemaps support // cubemaps support
if( GL_CheckExtension( "GL_ARB_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURE_CUBEMAP_EXT )) if( GL_CheckExtension( "GL_ARB_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURE_CUBEMAP_EXT, 0 ))
{ {
pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size ); pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size );
// check for seamless cubemaps too // check for seamless cubemaps too
GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, "gl_texture_cubemap_seamless", GL_ARB_SEAMLESS_CUBEMAP ); GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, "gl_texture_cubemap_seamless", GL_ARB_SEAMLESS_CUBEMAP, 0 );
} }
GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT ); GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT, 0 );
GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, "gl_texture_dxt_compression", GL_TEXTURE_COMPRESSION_EXT ); GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, "gl_texture_dxt_compression", GL_TEXTURE_COMPRESSION_EXT, 0 );
if( !GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT )) if( !GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT, 2.0 )) // present in ES2
GL_CheckExtension( "GL_SGIS_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT ); GL_CheckExtension( "GL_SGIS_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT, 0 );
glConfig.max_texture_anisotropy = 0.0f; glConfig.max_texture_anisotropy = 0.0f;
if( GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_texture_anisotropic_filter", GL_ANISOTROPY_EXT )) if( GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_texture_anisotropic_filter", GL_ANISOTROPY_EXT, 0 ))
pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy ); pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy );
#if XASH_WIN32 // Win32 only drivers? #if XASH_WIN32 // Win32 only drivers?
@@ -690,20 +970,30 @@ void GL_InitExtensionsBigGL( void )
if( glConfig.hardware_type != GLHW_INTEL ) if( glConfig.hardware_type != GLHW_INTEL )
#endif #endif
{ {
if( GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_texture_mipmap_biasing", GL_TEXTURE_LOD_BIAS )) if( GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_texture_mipmap_biasing", GL_TEXTURE_LOD_BIAS, 1.4 ))
pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lod_bias ); pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lod_bias );
} }
GL_CheckExtension( "GL_ARB_texture_border_clamp", NULL, NULL, GL_CLAMP_TEXBORDER_EXT ); GL_CheckExtension( "GL_ARB_texture_border_clamp", NULL, NULL, GL_CLAMP_TEXBORDER_EXT, 2.0 ); // present in ES2
GL_CheckExtension( "GL_ARB_depth_texture", NULL, NULL, GL_DEPTH_TEXTURE ); GL_CheckExtension( "GL_ARB_depth_texture", NULL, NULL, GL_DEPTH_TEXTURE, 1.4 ); // missing in gles, check GL_OES_depth_texture
GL_CheckExtension( "GL_ARB_texture_float", NULL, "gl_texture_float", GL_ARB_TEXTURE_FLOAT_EXT ); GL_CheckExtension( "GL_ARB_texture_float", NULL, "gl_texture_float", GL_ARB_TEXTURE_FLOAT_EXT, 0 );
GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_texture_depth_float", GL_ARB_DEPTH_FLOAT_EXT ); GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_texture_depth_float", GL_ARB_DEPTH_FLOAT_EXT, 0 );
GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4 ); // don't confuse users GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4, 0 ); // don't confuse users
GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT ); GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT, 2.0 );
GL_CheckExtension( "GL_ARB_texture_multisample", multisampletexfuncs, "gl_texture_multisample", GL_TEXTURE_MULTISAMPLE ); GL_CheckExtension( "GL_ARB_texture_multisample", multisampletexfuncs, "gl_texture_multisample", GL_TEXTURE_MULTISAMPLE, 0 );
GL_CheckExtension( "GL_ARB_texture_compression_bptc", NULL, "gl_texture_bptc_compression", GL_ARB_TEXTURE_COMPRESSION_BPTC ); GL_CheckExtension( "GL_ARB_texture_compression_bptc", NULL, "gl_texture_bptc_compression", GL_ARB_TEXTURE_COMPRESSION_BPTC, 0 );
if( GL_CheckExtension( "GL_ARB_shading_language_100", NULL, NULL, GL_SHADER_GLSL100_EXT )) #ifndef XASH_GL_STATIC
if( glConfig.context == CONTEXT_TYPE_GL_CORE )
GL_CheckExtension( "shader_objects", shaderobjectsfuncs_gles, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT, 2.0 );
else
GL_CheckExtension( "GL_ARB_shader_objects", shaderobjectsfuncs, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT, 2.0 );
GL_CheckExtension( "GL_ARB_vertex_array_object", vaofuncs, "gl_vertex_array_object", GL_ARB_VERTEX_ARRAY_OBJECT_EXT, 3.0 );
GL_CheckExtension( "GL_ARB_buffer_storage", bufferstoragefuncs, "gl_buffer_storage", GL_BUFFER_STORAGE_EXT, 4.4);
GL_CheckExtension( "GL_ARB_map_buffer_range", mapbufferrangefuncs, "gl_map_buffer_range", GL_MAP_BUFFER_RANGE_EXT , 3.0);
GL_CheckExtension( "GL_ARB_draw_elements_base_vertex", drawrangeelementsbasevertexfuncs, "gl_drawrangeelementsbasevertex", GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT, 3.2 );
#endif
if( GL_CheckExtension( "GL_ARB_shading_language_100", NULL, NULL, GL_SHADER_GLSL100_EXT, 2.0 ))
{ {
pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords ); pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords );
pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_teximage_units ); pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_teximage_units );
@@ -724,12 +1014,12 @@ void GL_InitExtensionsBigGL( void )
} }
// rectangle textures support // rectangle textures support
GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT ); GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT, 0 );
if( !GL_CheckExtension( "glDrawRangeElements", drawrangeelementsfuncs, "gl_drawrangeelements", GL_DRAW_RANGEELEMENTS_EXT ) ) if( !GL_CheckExtension( "glDrawRangeElements", drawrangeelementsfuncs, "gl_drawrangeelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ) )
{ {
if( GL_CheckExtension( "glDrawRangeElementsEXT", drawrangeelementsextfuncs, if( GL_CheckExtension( "glDrawRangeElementsEXT", drawrangeelementsextfuncs,
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT ) ) "gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ))
{ {
#ifndef XASH_GL_STATIC #ifndef XASH_GL_STATIC
pglDrawRangeElements = pglDrawRangeElementsEXT; pglDrawRangeElements = pglDrawRangeElementsEXT;
@@ -739,7 +1029,7 @@ void GL_InitExtensionsBigGL( void )
// this won't work without extended context // this won't work without extended context
if( glw_state.extended ) if( glw_state.extended )
GL_CheckExtension( "GL_ARB_debug_output", debugoutputfuncs, "gl_debug_output", GL_DEBUG_OUTPUT ); GL_CheckExtension( "GL_ARB_debug_output", debugoutputfuncs, "gl_debug_output", GL_DEBUG_OUTPUT, 0 );
#if XASH_PSVITA #if XASH_PSVITA
// not all GL1.1 functions are implemented in vitaGL, but there's enough // not all GL1.1 functions are implemented in vitaGL, but there's enough
@@ -747,23 +1037,77 @@ void GL_InitExtensionsBigGL( void )
// init our immediate mode override // init our immediate mode override
VGL_ShimInit(); VGL_ShimInit();
#endif #endif
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
if( gEngfuncs.Sys_CheckParm( "-gl2shim" ))
GL2_ShimInit();
#endif
} }
#endif #endif
void GL_InitExtensions( void ) void GL_InitExtensions( void )
{ {
char value[MAX_VA_STRING]; char value[MAX_VA_STRING];
GLint major = 0, minor = 0;
GL_OnContextCreated(); GL_OnContextCreated();
// initialize gl extensions // initialize gl extensions
GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, GL_OPENGL_110 ); GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, GL_OPENGL_110, 1.0 );
// get our various GL strings // get our various GL strings
glConfig.vendor_string = (const char *)pglGetString( GL_VENDOR ); glConfig.vendor_string = (const char *)pglGetString( GL_VENDOR );
glConfig.renderer_string = (const char *)pglGetString( GL_RENDERER ); glConfig.renderer_string = (const char *)pglGetString( GL_RENDERER );
glConfig.version_string = (const char *)pglGetString( GL_VERSION ); glConfig.version_string = (const char *)pglGetString( GL_VERSION );
glConfig.extensions_string = (const char *)pglGetString( GL_EXTENSIONS ); glConfig.extensions_string = (const char *)pglGetString( GL_EXTENSIONS );
pglGetIntegerv( GL_MAJOR_VERSION, &major );
pglGetIntegerv( GL_MINOR_VERSION, &minor );
if( !major && glConfig.version_string )
{
const char *str = glConfig.version_string;
float ver;
while( *str && ( *str < '0' || *str > '9' )) str++;
ver = Q_atof(str);
if( ver )
{
glConfig.version_major = ver;
glConfig.version_minor = (int)(ver * 10) % 10;
}
}
else
{
glConfig.version_major = major;
glConfig.version_minor = minor;
}
#ifndef XASH_GL_STATIC
if( !glConfig.extensions_string )
{
int n = 0;
pglGetStringi = gEngfuncs.GL_GetProcAddress( "glGetStringi" );
pglGetIntegerv( GL_NUM_EXTENSIONS, &n );
if( n && pglGetStringi )
{
int i, len = 1;
char *str;
for( i = 0; i < n; i++ )
len += Q_strlen((const char *)pglGetStringi( GL_EXTENSIONS, i )) + 1;
str = (char*)Mem_Calloc( r_temppool, len );
glConfig.extensions_string = str;
for( i = 0; i < n; i++ )
{
int l = Q_strncpy( str, pglGetStringi( GL_EXTENSIONS, i ), len );
str += l;
*str++ = ' ';
len -= l + 1;
}
}
}
#endif
gEngfuncs.Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string ); gEngfuncs.Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string );
#ifdef XASH_GLES #ifdef XASH_GLES
@@ -785,6 +1129,7 @@ void GL_InitExtensions( void )
// force everything to happen in the main thread instead of in a separate driver thread // force everything to happen in the main thread instead of in a separate driver thread
pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB ); pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB );
} }
// enable all the low priority messages // enable all the low priority messages
@@ -843,6 +1188,11 @@ void GL_InitCommands( void )
gEngfuncs.Cvar_RegisterVariable( &r_lockpvs ); gEngfuncs.Cvar_RegisterVariable( &r_lockpvs );
gEngfuncs.Cvar_RegisterVariable( &r_lockfrustum ); gEngfuncs.Cvar_RegisterVariable( &r_lockfrustum );
gEngfuncs.Cvar_RegisterVariable( &r_traceglow ); gEngfuncs.Cvar_RegisterVariable( &r_traceglow );
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
gEngfuncs.Cvar_RegisterVariable( &r_ripple );
gEngfuncs.Cvar_RegisterVariable( &r_ripple_updatetime );
gEngfuncs.Cvar_RegisterVariable( &r_ripple_spawntime );
gEngfuncs.Cvar_RegisterVariable( &gl_extensions ); gEngfuncs.Cvar_RegisterVariable( &gl_extensions );
gEngfuncs.Cvar_RegisterVariable( &gl_texture_nearest ); gEngfuncs.Cvar_RegisterVariable( &gl_texture_nearest );
@@ -927,6 +1277,8 @@ qboolean R_Init( void )
GL_SetDefaultState(); GL_SetDefaultState();
r_temppool = Mem_AllocPool( "Render Zone" );
// create the window and set up the context // create the window and set up the context
if( !gEngfuncs.R_Init_Video( REF_GL )) // request GL context if( !gEngfuncs.R_Init_Video( REF_GL )) // request GL context
{ {
@@ -934,11 +1286,10 @@ qboolean R_Init( void )
gEngfuncs.R_Free_Video(); gEngfuncs.R_Free_Video();
// Why? Host_Error again??? // Why? Host_Error again???
// gEngfuncs.Host_Error( "Can't initialize video subsystem\nProbably driver was not installed" ); // gEngfuncs.Host_Error( "Can't initialize video subsystem\nProbably driver was not installed" );
Mem_FreePool( &r_temppool );
return false; return false;
} }
r_temppool = Mem_AllocPool( "Render Zone" );
GL_SetDefaults(); GL_SetDefaults();
R_CheckVBO(); R_CheckVBO();
R_InitImages(); R_InitImages();
@@ -963,6 +1314,9 @@ void R_Shutdown( void )
GL_RemoveCommands(); GL_RemoveCommands();
R_ShutdownImages(); R_ShutdownImages();
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
GL2_ShimShutdown();
#endif
Mem_FreePool( &r_temppool ); Mem_FreePool( &r_temppool );
@@ -1031,7 +1385,7 @@ void GL_SetupAttributes( int safegl )
#ifdef XASH_NANOGL #ifdef XASH_NANOGL
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 1 ); gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 1 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 1 ); gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 1 );
#elif defined( XASH_WES ) || defined( XASH_REGAL ) #else
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 2 ); gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 2 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 0 ); gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 0 );
#endif #endif
@@ -1046,14 +1400,22 @@ void GL_SetupAttributes( int safegl )
SetBits( context_flags, FCONTEXT_CORE_PROFILE ); SetBits( context_flags, FCONTEXT_CORE_PROFILE );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_CORE ); gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_CORE );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 3 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 3 );
} }
else else
{ {
if( !safegl )
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_COMPATIBILITY ); gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_COMPATIBILITY );
else
{
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 1 );
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 1 );
}
} }
#endif // XASH_GLES #endif // XASH_GLES
if( gEngfuncs.Sys_CheckParm( "-gldebug" ) ) if( gEngfuncs.Sys_CheckParm( "-gldebug" ))
{ {
gEngfuncs.Con_Reportf( "Creating an extended GL context for debug...\n" ); gEngfuncs.Con_Reportf( "Creating an extended GL context for debug...\n" );
SetBits( context_flags, FCONTEXT_DEBUG_ARB ); SetBits( context_flags, FCONTEXT_DEBUG_ARB );
@@ -1182,6 +1544,8 @@ void GL_OnContextCreated( void )
glState.stencilEnabled = glConfig.stencil_bits ? true : false; glState.stencilEnabled = glConfig.stencil_bits ? true : false;
gEngfuncs.GL_GetAttribute( REF_GL_MULTISAMPLESAMPLES, &glConfig.msaasamples ); gEngfuncs.GL_GetAttribute( REF_GL_MULTISAMPLESAMPLES, &glConfig.msaasamples );
gEngfuncs.GL_GetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, &glConfig.version_major );
gEngfuncs.GL_GetAttribute( REF_GL_CONTEXT_MINOR_VERSION, &glConfig.version_minor );
#ifdef XASH_WES #ifdef XASH_WES
wes_init( "" ); wes_init( "" );

View File

@@ -20,6 +20,7 @@ GNU General Public License for more details.
#include "particledef.h" #include "particledef.h"
#include "entity_types.h" #include "entity_types.h"
#define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA ) #define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA )
float gldepthmin, gldepthmax; float gldepthmin, gldepthmax;
@@ -968,6 +969,8 @@ void R_RenderScene( void )
R_MarkLeaves(); R_MarkLeaves();
R_DrawFog (); R_DrawFog ();
if( RI.drawWorld )
R_AnimateRipples();
R_CheckGLFog(); R_CheckGLFog();
R_DrawWorld(); R_DrawWorld();
@@ -1126,6 +1129,9 @@ void R_EndFrame( void )
{ {
#if XASH_PSVITA #if XASH_PSVITA
VGL_ShimEndFrame(); VGL_ShimEndFrame();
#endif
#if !defined( XASH_GL_STATIC )
GL2_ShimEndFrame();
#endif #endif
// flush any remaining 2D bits // flush any remaining 2D bits
R_Set2DMode( false ); R_Set2DMode( false );

View File

@@ -85,7 +85,7 @@ static void R_ParseDetailTextures( const char *filename )
if( Q_stricmp( tex->name, texname )) if( Q_stricmp( tex->name, texname ))
continue; continue;
tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR ); tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR|TF_NOFLIP_TGA );
// texture is loaded // texture is loaded
if( tex->dt_texturenum ) if( tex->dt_texturenum )
@@ -150,6 +150,7 @@ void R_NewMap( void )
GL_BuildLightmaps (); GL_BuildLightmaps ();
R_GenerateVBO(); R_GenerateVBO();
R_ResetRipples();
if( gEngfuncs.drawFuncs->R_NewMap != NULL ) if( gEngfuncs.drawFuncs->R_NewMap != NULL )
gEngfuncs.drawFuncs->R_NewMap(); gEngfuncs.drawFuncs->R_NewMap();

View File

@@ -78,7 +78,7 @@ static void BoundPoly( int numverts, float *verts, vec3_t mins, vec3_t maxs )
} }
} }
static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts ) static void SubdividePolygon_r( model_t *loadmodel, msurface_t *warpface, int numverts, float *verts )
{ {
vec3_t front[SUBDIVIDE_SIZE], back[SUBDIVIDE_SIZE]; vec3_t front[SUBDIVIDE_SIZE], back[SUBDIVIDE_SIZE];
mextrasurf_t *warpinfo = warpface->info; mextrasurf_t *warpinfo = warpface->info;
@@ -88,7 +88,6 @@ static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts
float sample_size; float sample_size;
vec3_t mins, maxs; vec3_t mins, maxs;
glpoly_t *poly; glpoly_t *poly;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
if( numverts > ( SUBDIVIDE_SIZE - 4 )) if( numverts > ( SUBDIVIDE_SIZE - 4 ))
gEngfuncs.Host_Error( "Mod_SubdividePolygon: too many vertexes on face ( %i )\n", numverts ); gEngfuncs.Host_Error( "Mod_SubdividePolygon: too many vertexes on face ( %i )\n", numverts );
@@ -143,8 +142,8 @@ static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts
} }
} }
SubdividePolygon_r( warpface, f, front[0] ); SubdividePolygon_r( loadmodel, warpface, f, front[0] );
SubdividePolygon_r( warpface, b, back[0] ); SubdividePolygon_r( loadmodel, warpface, b, back[0] );
return; return;
} }
@@ -205,7 +204,7 @@ void GL_SetupFogColorForSurfaces( void )
vec3_t fogColor; vec3_t fogColor;
float factor, div; float factor, div;
if( !glState.isFogEnabled) if( !glState.isFogEnabled )
return; return;
if( RI.currententity && RI.currententity->curstate.rendermode == kRenderTransTexture ) if( RI.currententity && RI.currententity->curstate.rendermode == kRenderTransTexture )
@@ -238,13 +237,12 @@ boundaries so that turbulent and sky warps
can be done reasonably. can be done reasonably.
================ ================
*/ */
void GL_SubdivideSurface( msurface_t *fa ) void GL_SubdivideSurface( model_t *loadmodel, msurface_t *fa )
{ {
vec3_t verts[SUBDIVIDE_SIZE]; vec3_t verts[SUBDIVIDE_SIZE];
int numverts; int numverts;
int i, lindex; int i, lindex;
float *vec; float *vec;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
// convert edges back to a normal polygon // convert edges back to a normal polygon
numverts = 0; numverts = 0;
@@ -261,7 +259,7 @@ void GL_SubdivideSurface( msurface_t *fa )
SetBits( fa->flags, SURF_DRAWTURB_QUADS ); // predict state SetBits( fa->flags, SURF_DRAWTURB_QUADS ); // predict state
// do subdivide // do subdivide
SubdividePolygon_r( fa, numverts, verts[0] ); SubdividePolygon_r( loadmodel, fa, numverts, verts[0] );
} }
/* /*
@@ -877,7 +875,7 @@ void DrawGLPolyChain( glpoly_t *p, float soffset, float toffset )
} }
} }
_inline qboolean R_HasLightmap( void ) static qboolean R_HasLightmap( void )
{ {
if( r_fullbright->value || !WORLDMODEL->lightdata ) if( r_fullbright->value || !WORLDMODEL->lightdata )
return false; return false;
@@ -1137,14 +1135,15 @@ void R_RenderBrushPoly( msurface_t *fa, int cull_type )
t = R_TextureAnimation( fa ); t = R_TextureAnimation( fa );
GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
if( FBitSet( fa->flags, SURF_DRAWTURB )) if( FBitSet( fa->flags, SURF_DRAWTURB ))
{ {
R_UploadRipples( t );
// warp texture, no lightmaps // warp texture, no lightmaps
EmitWaterPolys( fa, (cull_type == CULL_BACKSIDE)); EmitWaterPolys( fa, (cull_type == CULL_BACKSIDE));
return; return;
} }
else GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
if( t->fb_texturenum ) if( t->fb_texturenum )
{ {
@@ -1413,7 +1412,7 @@ void R_DrawWaterSurfaces( void )
continue; continue;
// set modulate mode explicitly // set modulate mode explicitly
GL_Bind( XASH_TEXTURE0, t->gl_texturenum ); R_UploadRipples( t );
for( ; s; s = s->texturechain ) for( ; s; s = s->texturechain )
EmitWaterPolys( s, false ); EmitWaterPolys( s, false );
@@ -1792,11 +1791,7 @@ void R_GenerateVBO( void )
R_ClearVBO(); R_ClearVBO();
// we do not want to write vbo code that does not use multitexture // we do not want to write vbo code that does not use multitexture
#if ALLOW_VBO if( !GL_Support( GL_ARB_VERTEX_BUFFER_OBJECT_EXT ) || !GL_Support( GL_ARB_MULTITEXTURE ) || glConfig.max_texture_units < 2 || !gEngfuncs.Sys_CheckParm("-gl-allow-vbo-dontuse") )
if( !GL_Support( GL_ARB_VERTEX_BUFFER_OBJECT_EXT ) || !GL_Support( GL_ARB_MULTITEXTURE ) || glConfig.max_texture_units < 2 )
#else
if( 1 )
#endif
{ {
gEngfuncs.Cvar_FullSet( "gl_vbo", "0", FCVAR_READ_ONLY ); gEngfuncs.Cvar_FullSet( "gl_vbo", "0", FCVAR_READ_ONLY );
return; return;

View File

@@ -121,9 +121,9 @@ typedef struct
} studio_draw_state_t; } studio_draw_state_t;
// studio-related cvars // studio-related cvars
static CVAR_DEFINE_AUTO( r_studio_sort_textures, "0", FCVAR_GLCONFIG, "change draw order for additive meshes" ); CVAR_DEFINE_AUTO( r_studio_sort_textures, "0", FCVAR_GLCONFIG, "change draw order for additive meshes" );
CVAR_DEFINE_AUTO( r_studio_drawelements, "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" );
static cvar_t *cl_righthand = NULL; static cvar_t *cl_righthand = NULL;
static CVAR_DEFINE_AUTO( r_studio_drawelements, "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" );
static r_studio_interface_t *pStudioDraw; static r_studio_interface_t *pStudioDraw;
static studio_draw_state_t g_studio; // global studio state static studio_draw_state_t g_studio; // global studio state
@@ -146,8 +146,6 @@ R_StudioInit
*/ */
void R_StudioInit( void ) void R_StudioInit( void )
{ {
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
#if XASH_PSVITA #if XASH_PSVITA
// don't do the same array-building work twice since that's what our FFP shim does anyway // don't do the same array-building work twice since that's what our FFP shim does anyway
@@ -1728,7 +1726,7 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
out[2] = Q_min( (int)( finalLight[2] ), 255 ); out[2] = Q_min( (int)( finalLight[2] ), 255 );
} }
static void R_StudioSetColorArray(short *ptricmds, vec3_t *pstudionorms, byte *color ) static void R_StudioSetColorArray( short *ptricmds, vec3_t *pstudionorms, byte *color )
{ {
float *lv = (float *)g_studio.lightvalues[ptricmds[1]]; float *lv = (float *)g_studio.lightvalues[ptricmds[1]];
@@ -1898,9 +1896,8 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t ) static void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t )
{ {
float *lv;
int i; int i;
while(( i = *( ptricmds++ ))) while(( i = *( ptricmds++ )))
@@ -1931,9 +1928,8 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms ) static void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms )
{ {
float *lv;
int i; int i;
while(( i = *( ptricmds++ ))) while(( i = *( ptricmds++ )))
@@ -1963,7 +1959,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale ) static void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale )
{ {
float *lv, *av; float *lv, *av;
int i, idx; int i, idx;
@@ -2008,7 +2004,7 @@ _inline void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, floa
} }
_inline int R_StudioBuildIndices( qboolean tri_strip, int vertexState ) static int R_StudioBuildIndices( qboolean tri_strip, int vertexState )
{ {
// build in indices // build in indices
if( vertexState++ < 3 ) if( vertexState++ < 3 )
@@ -2051,7 +2047,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioBuildArrayNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t ) static void R_StudioBuildArrayNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t )
{ {
float *lv; float *lv;
int i; int i;
@@ -2094,7 +2090,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioBuildArrayFloatMesh( short *ptricmds, vec3_t *pstudionorms ) static void R_StudioBuildArrayFloatMesh( short *ptricmds, vec3_t *pstudionorms )
{ {
float *lv; float *lv;
int i; int i;
@@ -2137,7 +2133,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioBuildArrayChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale ) static void R_StudioBuildArrayChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale )
{ {
float *lv, *av; float *lv, *av;
int i, idx; int i, idx;
@@ -2194,7 +2190,7 @@ _inline void R_StudioBuildArrayChromeMesh( short *ptricmds, vec3_t *pstudionorms
} }
} }
_inline void R_StudioDrawArrays( uint startverts, uint startelems ) static void R_StudioDrawArrays( uint startverts, uint startelems )
{ {
pglEnableClientState( GL_VERTEX_ARRAY ); pglEnableClientState( GL_VERTEX_ARRAY );
pglVertexPointer( 3, GL_FLOAT, 12, g_studio.arrayverts ); pglVertexPointer( 3, GL_FLOAT, 12, g_studio.arrayverts );

View File

@@ -62,6 +62,29 @@ static float r_turbsin[] =
#include "warpsin.h" #include "warpsin.h"
}; };
#define RIPPLES_CACHEWIDTH_BITS 7
#define RIPPLES_CACHEWIDTH ( 1 << RIPPLES_CACHEWIDTH_BITS )
#define RIPPLES_CACHEWIDTH_MASK (( RIPPLES_CACHEWIDTH ) - 1 )
#define RIPPLES_TEXSIZE ( RIPPLES_CACHEWIDTH * RIPPLES_CACHEWIDTH )
#define RIPPLES_TEXSIZE_MASK ( RIPPLES_TEXSIZE - 1 )
STATIC_ASSERT( RIPPLES_TEXSIZE == 0x4000, "fix the algorithm to work with custom resolution" );
static struct
{
double time;
double oldtime;
short *curbuf, *oldbuf;
short buf[2][RIPPLES_TEXSIZE];
qboolean update;
uint32_t texture[RIPPLES_TEXSIZE];
int gl_texturenum;
int rippletexturenum;
float texturescale; // not all textures are 128x128, scale the texcoords down
} g_ripple;
static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] ) static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] )
{ {
const char *skybox_ext[3] = { "dds", "tga", "bmp" }; const char *skybox_ext[3] = { "dds", "tga", "bmp" };
@@ -761,11 +784,8 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
float s, t, os, ot; float s, t, os, ot;
glpoly_t *p; glpoly_t *p;
int i; int i;
#ifndef XASH_GLES
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS ); const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS ) && glConfig.context == CONTEXT_TYPE_GL;
#else
const qboolean useQuads = false; // TODO: figure out why
#endif
if( !warp->polys ) return; if( !warp->polys ) return;
@@ -802,10 +822,18 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
os = v[3]; os = v[3];
ot = v[4]; ot = v[4];
if( !r_ripple.value )
{
s = os + r_turbsin[(int)((ot * 0.125f + gpGlobals->time) * TURBSCALE) & 255]; s = os + r_turbsin[(int)((ot * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
s *= ( 1.0f / SUBDIVIDE_SIZE );
t = ot + r_turbsin[(int)((os * 0.125f + gpGlobals->time) * TURBSCALE) & 255]; t = ot + r_turbsin[(int)((os * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
}
else
{
s = os / g_ripple.texturescale;
t = ot / g_ripple.texturescale;
}
s *= ( 1.0f / SUBDIVIDE_SIZE );
t *= ( 1.0f / SUBDIVIDE_SIZE ); t *= ( 1.0f / SUBDIVIDE_SIZE );
pglTexCoord2f( s, t ); pglTexCoord2f( s, t );
@@ -825,3 +853,193 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
GL_SetupFogColorForSurfaces(); GL_SetupFogColorForSurfaces();
} }
/*
============================================================
HALF-LIFE SOFTWARE WATER
============================================================
*/
void R_ResetRipples( void )
{
g_ripple.curbuf = g_ripple.buf[0];
g_ripple.oldbuf = g_ripple.buf[1];
g_ripple.time = g_ripple.oldtime = gpGlobals->time - 0.1;
memset( g_ripple.buf, 0, sizeof( g_ripple.buf ));
}
void R_InitRipples( void )
{
rgbdata_t pic = { 0 };
pic.width = pic.height = RIPPLES_CACHEWIDTH;
pic.depth = 1;
pic.flags = IMAGE_HAS_COLOR;
pic.buffer = (byte *)g_ripple.texture;
pic.type = PF_RGBA_32;
pic.size = sizeof( g_ripple.texture );
pic.numMips = 1;
memset( pic.buffer, 0, pic.size );
g_ripple.rippletexturenum = GL_LoadTextureInternal( "*rippletex", &pic, TF_NOMIPMAP );
}
static void R_SwapBufs( void )
{
short *tempbufp = g_ripple.curbuf;
g_ripple.curbuf = g_ripple.oldbuf;
g_ripple.oldbuf = tempbufp;
}
static void R_SpawnNewRipple( int x, int y, short val )
{
#define PIXEL( x, y ) ((( x ) & RIPPLES_CACHEWIDTH_MASK ) + ((( y ) & RIPPLES_CACHEWIDTH_MASK) << 7 ))
g_ripple.oldbuf[PIXEL( x, y )] += val;
val >>= 2;
g_ripple.oldbuf[PIXEL( x + 1, y )] += val;
g_ripple.oldbuf[PIXEL( x - 1, y )] += val;
g_ripple.oldbuf[PIXEL( x, y + 1 )] += val;
g_ripple.oldbuf[PIXEL( x, y - 1 )] += val;
#undef PIXEL
}
static void R_RunRipplesAnimation( const short *oldbuf, short *pbuf )
{
size_t i = 0;
const int w = RIPPLES_CACHEWIDTH;
const int m = RIPPLES_TEXSIZE_MASK;
for( i = w; i < m + w; i++, pbuf++ )
{
*pbuf = (
( (int)oldbuf[( i - ( w * 2 )) & m]
+ (int)oldbuf[( i - ( w + 1 )) & m]
+ (int)oldbuf[( i - ( w - 1 )) & m]
+ (int)oldbuf[( i ) & m]) >> 1 ) - (int)*pbuf;
*pbuf -= ( *pbuf >> 6 );
}
}
static int MostSignificantBit( unsigned int v )
{
#if __GNUC__
return 31 - __builtin_clz( v );
#else
int i;
for( i = 0, v >>= 1; v; v >>= 1, i++ );
return i;
#endif
}
void R_AnimateRipples( void )
{
double frametime = gpGlobals->time - g_ripple.time;
g_ripple.update = r_ripple.value && frametime >= r_ripple_updatetime.value;
if( !g_ripple.update )
return;
g_ripple.time = gpGlobals->time;
R_SwapBufs();
if( g_ripple.time - g_ripple.oldtime > r_ripple_spawntime.value )
{
int x, y, val;
g_ripple.oldtime = g_ripple.time;
x = rand() & 0x7fff;
y = rand() & 0x7fff;
val = rand() & 0x3ff;
R_SpawnNewRipple( x, y, val );
}
R_RunRipplesAnimation( g_ripple.oldbuf, g_ripple.curbuf );
}
void R_UpdateRippleTexParams( void )
{
gl_texture_t *tex = R_GetTexture( g_ripple.rippletexturenum );
GL_Bind( XASH_TEXTURE0, g_ripple.rippletexturenum );
if( gl_texture_nearest.value )
{
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
}
else
{
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
}
void R_UploadRipples( texture_t *image )
{
gl_texture_t *glt;
uint32_t *pixels;
int wbits, wmask, wshft;
// discard unuseful textures
if( !r_ripple.value || image->width > RIPPLES_CACHEWIDTH || image->width != image->height )
{
GL_Bind( XASH_TEXTURE0, image->gl_texturenum );
return;
}
glt = R_GetTexture( image->gl_texturenum );
if( !glt || !glt->original || !glt->original->buffer || !FBitSet( glt->flags, TF_EXPAND_SOURCE ))
{
GL_Bind( XASH_TEXTURE0, image->gl_texturenum );
return;
}
GL_Bind( XASH_TEXTURE0, g_ripple.rippletexturenum );
// no updates this frame
if( !g_ripple.update && image->gl_texturenum == g_ripple.gl_texturenum )
return;
g_ripple.gl_texturenum = image->gl_texturenum;
if( r_ripple.value == 1.0f )
{
g_ripple.texturescale = Q_max( 1.0f, image->width / 64.0f );
}
else
{
g_ripple.texturescale = 1.0f;
}
pixels = (uint32_t *)glt->original->buffer;
wbits = MostSignificantBit( image->width );
wshft = 7 - wbits;
wmask = image->width - 1;
for( int y = 0; y < image->height; y++ )
{
int ry = y << ( 7 + wshft );
for( int x = 0; x < image->width; x++ )
{
int rx = x << wshft;
int val = g_ripple.curbuf[ry + rx] >> 4;
int py = (y - val) & wmask;
int px = (x + val) & wmask;
int p = ( py << wbits ) + px;
g_ripple.texture[(y << wbits) + x] = pixels[p];
}
}
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, image->width, image->width, 0,
GL_RGBA, GL_UNSIGNED_BYTE, g_ripple.texture );
}

View File

@@ -39,7 +39,7 @@ def build(bld):
else: else:
libs += [ 'public', 'M' ] libs += [ 'public', 'M' ]
source = bld.path.ant_glob(['*.c']) source = bld.path.ant_glob(['*.c', 'gl2_shim/*.c'])
includes = '.' includes = '.'
targets = { targets = {
@@ -63,6 +63,11 @@ def build(bld):
'libs': ['DL', 'gl4es', 'LOG'], 'libs': ['DL', 'gl4es', 'LOG'],
'defines': ['XASH_GL_STATIC', 'XASH_GL4ES'], 'defines': ['XASH_GL_STATIC', 'XASH_GL4ES'],
}, },
'ref_gles3compat': {
'enable': bld.env.GLES3COMPAT,
'libs': ['DL', 'gl4es', 'LOG'],
'defines': ['XASH_GLES3COMPAT'],
},
} }
for k,v in targets.items(): for k,v in targets.items():

View File

@@ -329,7 +329,7 @@ void R_InitSkyClouds(mip_t *mt, texture_t *tx, qboolean custom_palette)
} }
void GAME_EXPORT GL_SubdivideSurface(msurface_t *fa) void GAME_EXPORT GL_SubdivideSurface( model_t *mod, msurface_t *fa )
{ {
} }

View File

@@ -557,7 +557,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap ); data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
else data = buf; else data = buf;
//if( !ImageDXT( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA )) //if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
// data = GL_ApplyFilter( data, tex->width, tex->height ); // data = GL_ApplyFilter( data, tex->width, tex->height );
// mips will be auto-generated if desired // mips will be auto-generated if desired
@@ -663,7 +663,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
if( buf != NULL && buf >= bufend ) if( buf != NULL && buf >= bufend )
gEngfuncs.Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name ); gEngfuncs.Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name );
if( ImageDXT( pic->type )) if( ImageCompressed( pic->type ))
{ {
for( j = 0; j < Q_max( 1, pic->numMips ); j++ ) for( j = 0; j < Q_max( 1, pic->numMips ); j++ )
{ {
@@ -671,7 +671,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
height = Q_max( 1, ( tex->height >> j )); height = Q_max( 1, ( tex->height >> j ));
texsize = GL_CalcTextureSize( tex->format, width, height, tex->depth ); texsize = GL_CalcTextureSize( tex->format, width, height, tex->depth );
size = GL_CalcImageSize( pic->type, width, height, tex->depth ); size = GL_CalcImageSize( pic->type, width, height, tex->depth );
GL_TextureImageDXT( tex, i, j, width, height, tex->depth, size, buf ); GL_TextureImageCompressed( tex, i, j, width, height, tex->depth, size, buf );
tex->size += texsize; tex->size += texsize;
buf += size; // move pointer buf += size; // move pointer
tex->numMips++; tex->numMips++;
@@ -705,7 +705,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap ); data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
else data = buf; else data = buf;
if( !ImageDXT( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA )) if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
data = GL_ApplyFilter( data, tex->width, tex->height ); data = GL_ApplyFilter( data, tex->width, tex->height );
// mips will be auto-generated if desired // mips will be auto-generated if desired
@@ -753,7 +753,7 @@ static void GL_ProcessImage( image_t *tex, rgbdata_t *pic )
if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR; if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR;
if( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA; if( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA;
if( ImageDXT( pic->type )) if( ImageCompressed( pic->type ))
{ {
if( !pic->numMips ) if( !pic->numMips )
tex->flags |= TF_NOMIPMAP; // disable mipmapping by user request tex->flags |= TF_NOMIPMAP; // disable mipmapping by user request
@@ -1178,7 +1178,7 @@ void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int b
return; return;
} }
if( ImageDXT( image->original->type )) if( ImageCompressed( image->original->type ))
{ {
gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: can't process compressed texture %s\n", image->name ); gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: can't process compressed texture %s\n", image->name );
return; return;

View File

@@ -1096,6 +1096,7 @@ extern convar_t sw_surfcacheoverride;
extern convar_t sw_texfilt; extern convar_t sw_texfilt;
extern convar_t r_traceglow; extern convar_t r_traceglow;
extern convar_t sw_noalphabrushes; extern convar_t sw_noalphabrushes;
extern convar_t r_studio_sort_textures;
extern struct qfrustum_s { extern struct qfrustum_s {
mplane_t screenedge[4]; mplane_t screenedge[4];

View File

@@ -67,7 +67,7 @@ CVAR_DEFINE_AUTO( sw_surfcacheoverride, "0", 0, "");
static CVAR_DEFINE_AUTO( sw_waterwarp, "1", FCVAR_GLCONFIG, "nothing"); static CVAR_DEFINE_AUTO( sw_waterwarp, "1", FCVAR_GLCONFIG, "nothing");
static CVAR_DEFINE_AUTO( sw_notransbrushes, "0", FCVAR_GLCONFIG, "do not apply transparency to water/glasses (faster)"); static CVAR_DEFINE_AUTO( sw_notransbrushes, "0", FCVAR_GLCONFIG, "do not apply transparency to water/glasses (faster)");
CVAR_DEFINE_AUTO( sw_noalphabrushes, "0", FCVAR_GLCONFIG, "do not draw brush holes (faster)"); CVAR_DEFINE_AUTO( sw_noalphabrushes, "0", FCVAR_GLCONFIG, "do not draw brush holes (faster)");
CVAR_DEFINE_AUTO( r_traceglow, "1", FCVAR_GLCONFIG, "cull flares behind models" ); CVAR_DEFINE_AUTO( r_traceglow, "0", FCVAR_GLCONFIG, "cull flares behind models" );
CVAR_DEFINE_AUTO( sw_texfilt, "0", FCVAR_GLCONFIG, "texture dither"); CVAR_DEFINE_AUTO( sw_texfilt, "0", FCVAR_GLCONFIG, "texture dither");
static CVAR_DEFINE_AUTO( r_novis, "0", 0, "" ); static CVAR_DEFINE_AUTO( r_novis, "0", 0, "" );
@@ -1918,6 +1918,7 @@ qboolean GAME_EXPORT R_Init( void )
gEngfuncs.Cvar_RegisterVariable( &sw_texfilt ); gEngfuncs.Cvar_RegisterVariable( &sw_texfilt );
#endif #endif
gEngfuncs.Cvar_RegisterVariable( &r_novis ); gEngfuncs.Cvar_RegisterVariable( &r_novis );
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
r_temppool = Mem_AllocPool( "ref_soft zone" ); r_temppool = Mem_AllocPool( "ref_soft zone" );

View File

@@ -117,7 +117,7 @@ typedef struct
} studio_draw_state_t; } studio_draw_state_t;
// studio-related cvars // studio-related cvars
static CVAR_DEFINE_AUTO( r_studio_sort_textures, "0", FCVAR_GLCONFIG, "change draw order for additive meshes" ); CVAR_DEFINE_AUTO( r_studio_sort_textures, "0", FCVAR_GLCONFIG, "change draw order for additive meshes" );
static cvar_t *cl_righthand = NULL; static cvar_t *cl_righthand = NULL;
static r_studio_interface_t *pStudioDraw; static r_studio_interface_t *pStudioDraw;
@@ -141,8 +141,6 @@ R_StudioInit
*/ */
void R_StudioInit( void ) void R_StudioInit( void )
{ {
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
Matrix3x4_LoadIdentity( g_studio.rotationmatrix ); Matrix3x4_LoadIdentity( g_studio.rotationmatrix );
// g-cont. cvar disabled by Valve // g-cont. cvar disabled by Valve
@@ -1893,7 +1891,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t ) static void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t )
{ {
float *lv; float *lv;
int i; int i;
@@ -1926,7 +1924,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms ) static void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms )
{ {
float *lv; float *lv;
int i; int i;
@@ -1958,7 +1956,7 @@ R_StudioDrawNormalMesh
generic path generic path
=============== ===============
*/ */
_inline void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale ) static void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale )
{ {
float *lv, *av; float *lv, *av;
int i, idx; int i, idx;

View File

@@ -41,21 +41,17 @@ static void SequenceNameFix( void )
{ {
int i, j, counter; int i, j, counter;
qboolean hasduplicates = false; qboolean hasduplicates = false;
mstudioseqdesc_t *seqdesc, *seqdesc1; mstudioseqdesc_t *seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ), *seqdesc1;
for( i = 0; i < model_hdr->numseq; i++ ) for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
{ {
seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ) + i;
counter = 1; counter = 1;
for( j = 0; j < model_hdr->numseq; j++ ) seqdesc1 = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
{
seqdesc1 = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ) + j;
for( j = 0; j < model_hdr->numseq; ++j, ++seqdesc1 )
if( j != i && !Q_strncmp( seqdesc1->label, seqdesc->label, sizeof( seqdesc1->label ) ) ) if( j != i && !Q_strncmp( seqdesc1->label, seqdesc->label, sizeof( seqdesc1->label ) ) )
Q_snprintf( seqdesc1->label, sizeof( seqdesc1->label ), "%s_%i", seqdesc1->label, ++counter ); Q_snprintf( seqdesc1->label, sizeof( seqdesc1->label ), "%s_%i", seqdesc1->label, ++counter );
}
if( counter > 1 ) if( counter > 1 )
{ {
@@ -79,15 +75,11 @@ BoneNameFix
static void BoneNameFix( void ) static void BoneNameFix( void )
{ {
int i, counter = 0; int i, counter = 0;
mstudiobone_t *bone; mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
for( i = 0; i < model_hdr->numbones; i++ )
{
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + i;
for( i = 0; i < model_hdr->numbones; ++i, ++bone )
if( bone->name[0] == '\0' ) if( bone->name[0] == '\0' )
Q_snprintf( bone->name, sizeof( bone->name ), "MDLDEC_Bone%i", ++counter ); Q_snprintf( bone->name, sizeof( bone->name ), "MDLDEC_Bone%i", ++counter );
}
if( counter ) if( counter )
printf( "WARNING: Gived name to %i unnamed bone(s).\n", counter ); printf( "WARNING: Gived name to %i unnamed bone(s).\n", counter );
@@ -266,6 +258,8 @@ static void ShowHelp( const char *app_name )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
int ret = 0;
puts( "\nHalf-Life Studio Model Decompiler " APP_VERSION ); puts( "\nHalf-Life Studio Model Decompiler " APP_VERSION );
puts( "Copyright Flying With Gauss 2020 (c) " ); puts( "Copyright Flying With Gauss 2020 (c) " );
puts( "--------------------------------------------------" ); puts( "--------------------------------------------------" );
@@ -273,6 +267,7 @@ int main( int argc, char *argv[] )
if( argc == 1 ) if( argc == 1 )
{ {
ShowHelp( argv[0] ); ShowHelp( argv[0] );
ret = 2;
goto end; goto end;
} }
else if( argc == 3 ) else if( argc == 3 )
@@ -280,6 +275,7 @@ int main( int argc, char *argv[] )
if( Q_strlen( argv[2] ) > MAX_SYSPATH - 2 ) if( Q_strlen( argv[2] ) > MAX_SYSPATH - 2 )
{ {
fputs( "ERROR: Destination path is too long.\n", stderr ); fputs( "ERROR: Destination path is too long.\n", stderr );
ret = 1;
goto end; goto end;
} }
@@ -287,7 +283,10 @@ int main( int argc, char *argv[] )
} }
if( !LoadActivityList( argv[0] ) || !LoadMDL( argv[1] ) ) if( !LoadActivityList( argv[0] ) || !LoadMDL( argv[1] ) )
{
ret = 1;
goto end; goto end;
}
WriteQCScript(); WriteQCScript();
WriteSMD(); WriteSMD();
@@ -298,6 +297,6 @@ int main( int argc, char *argv[] )
end: end:
puts( "--------------------------------------------------" ); puts( "--------------------------------------------------" );
return 0; return ret;
} }

View File

@@ -15,6 +15,7 @@ GNU General Public License for more details.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "xash3d_mathlib.h"
#include "eiface.h" #include "eiface.h"
#include "studio.h" #include "studio.h"
#include "crtlib.h" #include "crtlib.h"
@@ -197,6 +198,7 @@ static void WriteTextureRenderMode( FILE *fp )
{ {
int i; int i;
mstudiotexture_t *texture; mstudiotexture_t *texture;
long pos = ftell( fp );
for( i = 0; i < texture_hdr->numtextures; i++ ) for( i = 0; i < texture_hdr->numtextures; i++ )
{ {
@@ -234,6 +236,9 @@ static void WriteTextureRenderMode( FILE *fp )
if( texture->flags & STUDIO_NF_TWOSIDE ) if( texture->flags & STUDIO_NF_TWOSIDE )
fprintf( fp, "$texrendermode \"%s\" \"twoside\" \n", texture->name ); fprintf( fp, "$texrendermode \"%s\" \"twoside\" \n", texture->name );
} }
if( ftell( fp ) != pos )
fputs( "\n", fp );
} }
/* /*
@@ -244,42 +249,41 @@ WriteSkinFamilyInfo
static void WriteSkinFamilyInfo( FILE *fp ) static void WriteSkinFamilyInfo( FILE *fp )
{ {
int i, j, k; int i, j, k;
short *skinref, index; short *skinref, *index;
mstudiotexture_t *texture; mstudiotexture_t *texture;
if( texture_hdr->numskinfamilies < 2 ) if( texture_hdr->numskinfamilies < 2 )
return; return;
fprintf( fp, "\n// %i skin families\n", texture_hdr->numskinfamilies ); fprintf( fp, "// %i skin families\n", texture_hdr->numskinfamilies );
fputs( "$texturegroup skinfamilies \n{\n", fp ); fputs( "$texturegroup \"skinfamilies\"\n{\n", fp );
skinref = (short *)( (byte *)texture_hdr + texture_hdr->skinindex ); skinref = (short *)( (byte *)texture_hdr + texture_hdr->skinindex );
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
for( i = 0; i < texture_hdr->numskinfamilies; ++i ) for( i = 0; i < texture_hdr->numskinfamilies; ++i )
{ {
fputs( "{", fp ); fputs( "\t{\n", fp );
for( j = 0; j < texture_hdr->numskinref; ++j ) index = skinref + i * texture_hdr->numskinref;
for( j = 0; j < texture_hdr->numskinref; ++j, ++index )
{ {
index = *( skinref + i * texture_hdr->numskinref + j );
for( k = 0; k < texture_hdr->numskinfamilies; ++k ) for( k = 0; k < texture_hdr->numskinfamilies; ++k )
{ {
if( index == *( skinref + k * texture_hdr->numskinref + j ) ) if( *index == *( skinref + k * texture_hdr->numskinref + j ) )
continue; continue;
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ) + index; fprintf( fp, "\t\t\"%s\"\n", texture[*index].name );
fprintf( fp, " \"%s\" ", texture->name );
break; break;
} }
} }
fputs( "}\n", fp ); fputs( "\t}\n", fp );
} }
fputs( "}\n", fp ); fputs( "}\n\n", fp );
} }
/* /*
@@ -296,15 +300,15 @@ static void WriteAttachmentInfo( FILE *fp )
if( !model_hdr->numattachments ) if( !model_hdr->numattachments )
return; return;
fprintf( fp, "\n// %i attachment(s)\n", model_hdr->numattachments ); attachment = (mstudioattachment_t *)( (byte *)model_hdr + model_hdr->attachmentindex );
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
for( i = 0; i < model_hdr->numattachments; ++i ) fprintf( fp, "// %i attachment%s\n", model_hdr->numattachments, model_hdr->numattachments > 1 ? "s" : "" );
{
attachment = (mstudioattachment_t *)( (byte *)model_hdr + model_hdr->attachmentindex ) + i;
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + attachment->bone;
fprintf( fp, "$attachment %i \"%s\" %f %f %f\n", i, bone->name, attachment->org[0], attachment->org[1], attachment->org[2] ); for( i = 0; i < model_hdr->numattachments; ++i, ++attachment )
} fprintf( fp, "$attachment %i \"%s\" %f %f %f\n", i, bone[attachment->bone].name, attachment->org[0], attachment->org[1], attachment->org[2] );
fputs( "\n", fp );
} }
/* /*
@@ -315,23 +319,21 @@ WriteBodyGroupInfo
static void WriteBodyGroupInfo( FILE *fp ) static void WriteBodyGroupInfo( FILE *fp )
{ {
int i, j; int i, j;
mstudiobodyparts_t *bodypart; mstudiobodyparts_t *bodypart = (mstudiobodyparts_t *) ( (byte *)model_hdr + model_hdr->bodypartindex );
mstudiomodel_t *model; mstudiomodel_t *model;
char modelname[64]; char modelname[64];
fputs( "\n// reference mesh(es)\n", fp ); fprintf( fp, "// %i reference mesh%s\n", model_hdr->numbodyparts, model_hdr->numbodyparts > 1 ? "es" : "" );
for( i = 0; i < model_hdr->numbodyparts; ++i ) for( i = 0; i < model_hdr->numbodyparts; ++i, ++bodypart )
{
bodypart = (mstudiobodyparts_t *) ( (byte *)model_hdr + model_hdr->bodypartindex ) + i;
if( bodypart->nummodels == 1 )
{ {
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex ); model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex );
if( bodypart->nummodels == 1 )
{
COM_FileBase( model->name, modelname, sizeof( modelname )); COM_FileBase( model->name, modelname, sizeof( modelname ));
fprintf( fp, "$body \"%s\" \"%s\"\n\n", bodypart->name, modelname ); fprintf( fp, "$body \"%s\" \"%s\"\n", bodypart->name, modelname );
continue; continue;
} }
@@ -339,23 +341,23 @@ static void WriteBodyGroupInfo( FILE *fp )
fputs( "{\n", fp ); fputs( "{\n", fp );
for( j = 0; j < bodypart->nummodels; ++j ) for( j = 0; j < bodypart->nummodels; ++j, ++model )
{ {
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex ) + j;
if( !Q_strncmp( model->name, "blank", 5 ) ) if( !Q_strncmp( model->name, "blank", 5 ) )
{ {
fputs( "blank\n", fp ); fputs( "\tblank\n", fp );
continue; continue;
} }
COM_FileBase( model->name, modelname, sizeof( modelname )); COM_FileBase( model->name, modelname, sizeof( modelname ));
fprintf( fp, "studio \"%s\"\n", modelname ); fprintf( fp, "\tstudio \"%s\"\n", modelname );
} }
fputs( "}\n\n" , fp ); fputs( "}\n", fp );
} }
fputs( "\n", fp );
} }
/* /*
@@ -373,19 +375,28 @@ static void WriteControllerInfo( FILE *fp )
if( !model_hdr->numbonecontrollers ) if( !model_hdr->numbonecontrollers )
return; return;
fprintf( fp, "\n// %i bone controller(s)\n", model_hdr->numbonecontrollers ); bonecontroller = (mstudiobonecontroller_t *)( (byte *)model_hdr + model_hdr->bonecontrollerindex );
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
for( i = 0; i < model_hdr->numbonecontrollers; ++i ) fprintf( fp, "// %i bone controller%s\n", model_hdr->numbonecontrollers, model_hdr->numbonecontrollers > 1 ? "s" : "" );
for( i = 0; i < model_hdr->numbonecontrollers; ++i, ++bonecontroller )
{ {
bonecontroller = (mstudiobonecontroller_t *)( (byte *)model_hdr + model_hdr->bonecontrollerindex ) + i;
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + bonecontroller->bone;
GetMotionTypeString( bonecontroller->type & ~STUDIO_RLOOP, motion_types, sizeof( motion_types ), false ); GetMotionTypeString( bonecontroller->type & ~STUDIO_RLOOP, motion_types, sizeof( motion_types ), false );
fprintf( fp, "$controller %i \"%s\" %s %f %f\n", fputs( "$controller ", fp );
bonecontroller->index, bone->name, motion_types,
if( bonecontroller->index == 4 )
fputs( "Mouth", fp );
else
fprintf( fp, "%i", bonecontroller->index );
fprintf( fp, " \"%s\" %s %f %f\n",
bone[bonecontroller->bone].name, motion_types,
bonecontroller->start, bonecontroller->end ); bonecontroller->start, bonecontroller->end );
} }
fputs( "\n", fp );
} }
/* /*
@@ -402,18 +413,41 @@ static void WriteHitBoxInfo( FILE *fp )
if( !model_hdr->numhitboxes ) if( !model_hdr->numhitboxes )
return; return;
fprintf( fp, "\n// %i hit box(es)\n", model_hdr->numhitboxes ); hitbox = (mstudiobbox_t *)( (byte *)model_hdr + model_hdr->hitboxindex );
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
for( i = 0; i < model_hdr->numhitboxes; i++ ) fprintf( fp, "// %i hit box%s\n", model_hdr->numhitboxes, model_hdr->numhitboxes > 1 ? "es" : "" );
{
hitbox = (mstudiobbox_t *)( (byte *)model_hdr + model_hdr->hitboxindex ) + i;
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + hitbox->bone;
for( i = 0; i < model_hdr->numhitboxes; ++i, ++hitbox )
fprintf( fp, "$hbox %i \"%s\" %f %f %f %f %f %f\n", fprintf( fp, "$hbox %i \"%s\" %f %f %f %f %f %f\n",
hitbox->group, bone->name, hitbox->group, bone[hitbox->bone].name,
hitbox->bbmin[0], hitbox->bbmin[1], hitbox->bbmin[2], hitbox->bbmin[0], hitbox->bbmin[1], hitbox->bbmin[2],
hitbox->bbmax[0], hitbox->bbmax[1], hitbox->bbmax[2] ); hitbox->bbmax[0], hitbox->bbmax[1], hitbox->bbmax[2] );
fputs( "\n", fp );
}
/*
============
CalcSequenceGroupSize
============
*/
static int CalcSequenceGroupSize( void )
{
int i, maxsize = 0, groupsize = DEFAULT_SEQGROUPSIZE;
for( i = 1; i < model_hdr->numseqgroups; i++ )
maxsize = Q_max( anim_hdr[i]->length, maxsize );
if( maxsize > 0 )
{
groupsize = maxsize / 1024;
if( maxsize % 1024 )
groupsize++;
} }
return groupsize;
} }
/* /*
@@ -430,132 +464,95 @@ static void WriteSequenceInfo( FILE *fp )
mstudioseqdesc_t *seqdesc; mstudioseqdesc_t *seqdesc;
if( model_hdr->numseqgroups > 1 ) if( model_hdr->numseqgroups > 1 )
fputs( "\n$sequencegroupsize 64\n", fp ); fprintf( fp, "$sequencegroupsize %d\n\n", CalcSequenceGroupSize( ) );
if( model_hdr->numseq > 0 ) if( model_hdr->numseq > 0 )
fprintf( fp, "\n// %i animation sequence(s)\n", model_hdr->numseq ); fprintf( fp, "// %i animation sequence%s\n", model_hdr->numseq, model_hdr->numseq > 1 ? "s" : "" );
else return;
for( i = 0; i < model_hdr->numseq; ++i ) seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
{ {
seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ) + i; fprintf( fp, "$sequence \"%s\" {\n", seqdesc->label );
fprintf( fp, "$sequence \"%s\" ", seqdesc->label );
if( seqdesc->numblends > 1 ) if( seqdesc->numblends > 1 )
{ {
if( seqdesc->numblends > 2 )
{
fputs( "{\n", fp );
for( j = 0; j < seqdesc->numblends; j++ ) for( j = 0; j < seqdesc->numblends; j++ )
{ fprintf( fp, "\t\"%s_blend%02i\"\n", seqdesc->label, j + 1 );
fputs( " ", fp );
fprintf( fp, "\"%s_blend%i\" ", seqdesc->label, j + 1 );
fputs( "\n", fp );
}
fputs( " ", fp );
} }
else else
{ {
fprintf( fp, "\"%s_blend1\" ", seqdesc->label ); fprintf( fp, "\t\"%s\"\n", seqdesc->label );
fprintf( fp, "\"%s_blend2\" ", seqdesc->label );
} }
GetMotionTypeString( seqdesc->blendtype[0], motion_types, sizeof( motion_types ), false );
fprintf( fp, "blend %s %.0f %.0f",
motion_types, seqdesc->blendstart[0], seqdesc->blendend[0] );
}
else
{
fprintf( fp, "\"%s\"", seqdesc->label );
}
if( seqdesc->motiontype )
{
GetMotionTypeString( seqdesc->motiontype, motion_types, sizeof( motion_types ), true );
fprintf( fp, "%s", motion_types );
}
fprintf( fp, " fps %.0f ", seqdesc->fps );
if( seqdesc->flags == 1 )
fputs( "loop ", fp );
if( seqdesc->activity ) if( seqdesc->activity )
{ {
activity = FindActivityName( seqdesc->activity ); activity = FindActivityName( seqdesc->activity );
if( activity ) if( activity )
{ {
fprintf( fp, "%s %i ", activity, seqdesc->actweight ); fprintf( fp, "\t%s %i\n", activity, seqdesc->actweight );
} }
else else
{ {
printf( "WARNING: Sequence %s has a custom activity flag (ACT_%i %i).\n", printf( "WARNING: Sequence %s has a custom activity flag (ACT_%i %i).\n",
seqdesc->label, seqdesc->activity, seqdesc->actweight ); seqdesc->label, seqdesc->activity, seqdesc->actweight );
fprintf( fp, "ACT_%i %i ", seqdesc->activity, seqdesc->actweight ); fprintf( fp, "\tACT_%i %i\n", seqdesc->activity, seqdesc->actweight );
} }
} }
if( seqdesc->numblends > 1 )
{
GetMotionTypeString( seqdesc->blendtype[0], motion_types, sizeof( motion_types ), false );
fprintf( fp, "\tblend %s %.0f %.0f\n",
motion_types, seqdesc->blendstart[0], seqdesc->blendend[0] );
if( !seqdesc->blendtype[0] )
printf( "WARNING: Something wrong with blending type for sequence: %s\n", seqdesc->label );
}
event = (mstudioevent_t *)( (byte *)model_hdr + seqdesc->eventindex );
for( j = 0; j < seqdesc->numevents; ++j, ++event )
{
fprintf( fp, "\t{ event %i %i", event->event, event->frame );
if( event->options[0] != '\0' )
fprintf( fp, " \"%s\"", event->options );
fputs( " }\n", fp );
}
fprintf( fp, "\tfps %.0f\n", seqdesc->fps );
if( seqdesc->flags == 1 )
fputs( "\tloop\n", fp );
if( seqdesc->motiontype )
{
GetMotionTypeString( seqdesc->motiontype, motion_types, sizeof( motion_types ), true );
fprintf( fp, "\t%s\n", motion_types );
}
if( seqdesc->entrynode && seqdesc->exitnode ) if( seqdesc->entrynode && seqdesc->exitnode )
{ {
if( seqdesc->entrynode == seqdesc->exitnode ) if( seqdesc->entrynode == seqdesc->exitnode )
fprintf( fp, "node %i ", seqdesc->entrynode ); fprintf( fp, "\tnode %i\n", seqdesc->entrynode );
else if( seqdesc->nodeflags ) else if( seqdesc->nodeflags )
fprintf( fp, "rtransition %i %i ", seqdesc->entrynode, seqdesc->exitnode ); fprintf( fp, "\trtransition %i %i\n", seqdesc->entrynode, seqdesc->exitnode );
else else
fprintf( fp, "transition %i %i ", seqdesc->entrynode, seqdesc->exitnode ); fprintf( fp, "\ttransition %i %i\n", seqdesc->entrynode, seqdesc->exitnode );
} }
if( seqdesc->numevents > 2 ) fputs( "}\n", fp );
{
fputs( "{\n ", fp );
for( j = 0; j < seqdesc->numevents; j++ )
{
if( seqdesc->numblends <= 2 )
fputs( " ", fp );
else
fputs( " ", fp );
event = (mstudioevent_t *)( (byte *)model_hdr + seqdesc->eventindex ) + j;
fprintf( fp, "{ event %i %i", event->event, event->frame );
if( event->options[0] != '\0' )
fprintf( fp, " \"%s\"", event->options );
fputs( " }\n ", fp );
}
fputs( "}", fp );
}
else
{
for( j = 0; j < seqdesc->numevents; j++ )
{
event = (mstudioevent_t *)( (byte *)model_hdr + seqdesc->eventindex ) + j;
fprintf( fp, "{ event %i %i", event->event, event->frame );
if( event->options[0] != '\0')
fprintf( fp, " \"%s\"", event->options );
fputs( " } ", fp );
}
} }
fputs( "\n", fp ); fputs( "\n", fp );
if( seqdesc->numblends > 2 )
fputs( "}\n", fp );
}
} }
/* /*
@@ -601,41 +598,38 @@ void WriteQCScript( void )
fprintf( fp, "$modelname \"%s.mdl\"\n", modelfile ); fprintf( fp, "$modelname \"%s.mdl\"\n", modelfile );
fputs( "$cd \".\\\"\n", fp ); fputs( "$cd \".\"\n", fp );
fputs( "$cdtexture \".\\\"\n", fp ); fputs( "$cdtexture \".\"\n", fp );
fputs( "$scale 1.0\n", fp );
fputs( "$cliptotextures\n", fp ); fputs( "$cliptotextures\n", fp );
fputs( "\n", fp ); fputs( "$scale 1.0\n", fp );
if( !model_hdr->numtextures )
fputs( "$externaltextures\n", fp );
if( model_hdr->flags != 0 )
{
fprintf( fp, "$flags %i\n", model_hdr->flags );
printf( "WARNING: This model uses the $flags keyword set to %i\n", model_hdr->flags );
}
fputs( "\n", fp );
fprintf( fp, "$bbox %f %f %f", model_hdr->min[0], model_hdr->min[1], model_hdr->min[2] );
fprintf( fp, " %f %f %f\n", model_hdr->max[0], model_hdr->max[1], model_hdr->max[2] );
fprintf( fp, "$cbox %f %f %f", model_hdr->bbmin[0], model_hdr->bbmin[1], model_hdr->bbmin[2] );
fprintf( fp, " %f %f %f\n", model_hdr->bbmax[0], model_hdr->bbmax[1], model_hdr->bbmax[2] );
fprintf( fp, "$eyeposition %f %f %f\n", model_hdr->eyeposition[0], model_hdr->eyeposition[1], model_hdr->eyeposition[2] );
fputs( "\n", fp ); fputs( "\n", fp );
WriteBodyGroupInfo( fp ); WriteBodyGroupInfo( fp );
WriteTextureRenderMode( fp );
fprintf( fp, "$flags %u\n\n", model_hdr->flags &~( STUDIO_HAS_BONEINFO | STUDIO_HAS_BONEWEIGHTS ) );
fprintf( fp, "$eyeposition %f %f %f\n\n", model_hdr->eyeposition[0], model_hdr->eyeposition[1], model_hdr->eyeposition[2] );
if( !model_hdr->numtextures )
fputs( "$externaltextures\n\n", fp );
WriteSkinFamilyInfo( fp ); WriteSkinFamilyInfo( fp );
WriteTextureRenderMode( fp );
if( model_hdr->flags & ( STUDIO_HAS_BONEINFO | STUDIO_HAS_BONEWEIGHTS ) )
fputs( "$boneweights\n\n", fp );
WriteAttachmentInfo( fp ); WriteAttachmentInfo( fp );
WriteControllerInfo( fp );
fprintf( fp, "$bbox %f %f %f", model_hdr->min[0], model_hdr->min[1], model_hdr->min[2] );
fprintf( fp, " %f %f %f\n\n", model_hdr->max[0], model_hdr->max[1], model_hdr->max[2] );
fprintf( fp, "$cbox %f %f %f", model_hdr->bbmin[0], model_hdr->bbmin[1], model_hdr->bbmin[2] );
fprintf( fp, " %f %f %f\n\n", model_hdr->bbmax[0], model_hdr->bbmax[1], model_hdr->bbmax[2] );
WriteHitBoxInfo( fp ); WriteHitBoxInfo( fp );
WriteControllerInfo( fp );
WriteSequenceInfo( fp ); WriteSequenceInfo( fp );
fputs( "\n// End of QC script.\n", fp ); fputs( "// End of QC script.\n", fp );
fclose( fp ); fclose( fp );
printf( "QC Script: %s\n", filename ); printf( "QC Script: %s\n", filename );

View File

@@ -16,6 +16,7 @@ GNU General Public License for more details.
#ifndef QC_H #ifndef QC_H
#define QC_H #define QC_H
#define DEFAULT_SEQGROUPSIZE 64
#define ACTIVITIES_FILE "activities.txt" #define ACTIVITIES_FILE "activities.txt"
qboolean LoadActivityList( const char *appname ); qboolean LoadActivityList( const char *appname );

View File

@@ -25,17 +25,18 @@ GNU General Public License for more details.
#include "smd.h" #include "smd.h"
static matrix3x4 *bonetransform; static matrix3x4 *bonetransform;
static matrix3x4 *worldtransform;
/* /*
============ ============
CreateBoneTransformMatrices CreateBoneTransformMatrices
============ ============
*/ */
static qboolean CreateBoneTransformMatrices( void ) static qboolean CreateBoneTransformMatrices( matrix3x4 **matrix )
{ {
bonetransform = calloc( model_hdr->numbones, sizeof( matrix3x4 ) ); *matrix = calloc( model_hdr->numbones, sizeof( matrix3x4 ) );
if( !bonetransform ) if( !*matrix )
{ {
fputs( "ERROR: Couldn't allocate memory for bone transformation matrices!\n", stderr ); fputs( "ERROR: Couldn't allocate memory for bone transformation matrices!\n", stderr );
return false; return false;
@@ -52,14 +53,12 @@ FillBoneTransformMatrices
static void FillBoneTransformMatrices( void ) static void FillBoneTransformMatrices( void )
{ {
int i; int i;
mstudiobone_t *bone; mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
matrix3x4 bonematrix; matrix3x4 bonematrix;
vec4_t q; vec4_t q;
for( i = 0; i < model_hdr->numbones; i++ ) for( i = 0; i < model_hdr->numbones; ++i, ++bone )
{ {
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + i;
AngleQuaternion( &bone->value[3], q, true ); AngleQuaternion( &bone->value[3], q, true );
Matrix3x4_FromOriginQuat( bonematrix, q, bone->value ); Matrix3x4_FromOriginQuat( bonematrix, q, bone->value );
@@ -73,14 +72,28 @@ static void FillBoneTransformMatrices( void )
} }
} }
/*
============
FillWorldTransformMatrices
============
*/
static void FillWorldTransformMatrices( void )
{
int i;
mstudioboneinfo_t *boneinfo = (mstudioboneinfo_t *)( (byte *)model_hdr + model_hdr->boneindex + model_hdr->numbones * sizeof( mstudiobone_t ) );
for( i = 0; i < model_hdr->numbones; ++i, ++boneinfo )
Matrix3x4_ConcatTransforms( worldtransform[i], bonetransform[i], boneinfo->poseToBone );
}
/* /*
============ ============
RemoveBoneTransformMatrices RemoveBoneTransformMatrices
============ ============
*/ */
static void RemoveBoneTransformMatrices( void ) static void RemoveBoneTransformMatrices( matrix3x4 **matrix )
{ {
free( bonetransform ); free( *matrix );
} }
/* /*
@@ -171,16 +184,12 @@ WriteNodes
static void WriteNodes( FILE *fp ) static void WriteNodes( FILE *fp )
{ {
int i; int i;
mstudiobone_t *bone; mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
fputs( "nodes\n", fp ); fputs( "nodes\n", fp );
for( i = 0; i < model_hdr->numbones; i++ ) for( i = 0; i < model_hdr->numbones; ++i, ++bone )
{
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + i;
fprintf( fp, "%3i \"%s\" %i\n", i, bone->name, bone->parent ); fprintf( fp, "%3i \"%s\" %i\n", i, bone->name, bone->parent );
}
fputs( "end\n", fp ); fputs( "end\n", fp );
} }
@@ -193,15 +202,13 @@ WriteSkeleton
static void WriteSkeleton( FILE *fp ) static void WriteSkeleton( FILE *fp )
{ {
int i, j; int i, j;
mstudiobone_t *bone; mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
fputs( "skeleton\n", fp ); fputs( "skeleton\n", fp );
fputs( "time 0\n", fp ); fputs( "time 0\n", fp );
for( i = 0; i < model_hdr->numbones; i++ ) for( i = 0; i < model_hdr->numbones; ++i, ++bone )
{ {
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + i;
fprintf( fp, "%3i", i ); fprintf( fp, "%3i", i );
for( j = 0; j < 6; j++ ) for( j = 0; j < 6; j++ )
@@ -220,32 +227,24 @@ WriteTriangleInfo
*/ */
static void WriteTriangleInfo( FILE *fp, mstudiomodel_t *model, mstudiotexture_t *texture, mstudiotrivert_t **triverts, qboolean isevenstrip ) static void WriteTriangleInfo( FILE *fp, mstudiomodel_t *model, mstudiotexture_t *texture, mstudiotrivert_t **triverts, qboolean isevenstrip )
{ {
int i, indices[3]; int i, j, k, l, index;
int vert_index; int vert_index;
int norm_index; int norm_index;
int bone_index; int bone_index;
int valid_bones;
float s, t, u, v; float s, t, u, v;
byte *vertbone; byte *vertbone;
vec3_t *studioverts; vec3_t *studioverts;
vec3_t *studionorms; vec3_t *studionorms;
vec3_t vert, norm; vec3_t vert, norm;
float weights[MAXSTUDIOBONEWEIGHTS], oldweight, totalweight;
if( isevenstrip ) matrix3x4 bonematrix[MAXSTUDIOBONEWEIGHTS], skinmatrix, *pskinmatrix;
{ mstudioboneweight_t *studioboneweights;
indices[0] = 1;
indices[1] = 2;
indices[2] = 0;
}
else
{
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
}
vertbone = ( (byte *)model_hdr + model->vertinfoindex ); vertbone = ( (byte *)model_hdr + model->vertinfoindex );
studioverts = (vec3_t *)( (byte *)model_hdr + model->vertindex ); studioverts = (vec3_t *)( (byte *)model_hdr + model->vertindex );
studionorms = (vec3_t *)( (byte *)model_hdr + model->normindex ); studionorms = (vec3_t *)( (byte *)model_hdr + model->normindex );
studioboneweights = (mstudioboneweight_t *)( (byte *)model_hdr + model->blendvertinfoindex );
s = 1.0f / texture->width; s = 1.0f / texture->width;
t = 1.0f / texture->height; t = 1.0f / texture->height;
@@ -254,30 +253,76 @@ static void WriteTriangleInfo( FILE *fp, mstudiomodel_t *model, mstudiotexture_t
for( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
vert_index = triverts[indices[i]]->vertindex; index = isevenstrip ? ( i + 1 ) % 3 : i;
norm_index = triverts[indices[i]]->normindex; vert_index = triverts[index]->vertindex;
norm_index = triverts[index]->normindex;
bone_index = vertbone[vert_index]; bone_index = vertbone[vert_index];
Matrix3x4_VectorTransform( bonetransform[bone_index], studioverts[vert_index], vert ); if( model_hdr->flags & STUDIO_HAS_BONEWEIGHTS )
Matrix3x4_VectorRotate( bonetransform[bone_index], studionorms[norm_index], norm ); {
valid_bones = 0, totalweight = 0;
memset( skinmatrix, 0, sizeof( matrix3x4 ) );
for( j = 0; j < MAXSTUDIOBONEWEIGHTS; ++j )
if( studioboneweights[vert_index].bone[j] != -1 )
valid_bones++;
for( j = 0; j < valid_bones; ++j )
{
Matrix3x4_Copy( bonematrix[j], worldtransform[studioboneweights[vert_index].bone[j]] );
weights[j] = studioboneweights[vert_index].weight[j] / 255.0f;
totalweight += weights[j];
}
oldweight = weights[0];
if( totalweight < 1.0f )
weights[0] += 1.0f - totalweight;
for( j = 0; j < valid_bones; ++j )
for( k = 0; k < 3; ++k )
for( l = 0; l < 4; ++l )
skinmatrix[k][l] += bonematrix[j][k][l] * weights[j];
pskinmatrix = &skinmatrix;
}
else
pskinmatrix = &bonetransform[bone_index];
Matrix3x4_VectorTransform( *pskinmatrix, studioverts[vert_index], vert );
Matrix3x4_VectorRotate( *pskinmatrix, studionorms[norm_index], norm );
VectorNormalize( norm ); VectorNormalize( norm );
if( texture->flags & STUDIO_NF_UV_COORDS ) if( texture->flags & STUDIO_NF_UV_COORDS )
{ {
u = HalfToFloat( triverts[indices[i]]->s ); u = HalfToFloat( triverts[index]->s );
v = -HalfToFloat( triverts[indices[i]]->t ); v = -HalfToFloat( triverts[index]->t );
} }
else else
{ {
u = ( triverts[indices[i]]->s + 1.0f ) * s; u = ( triverts[index]->s + 1.0f ) * s;
v = 1.0f - triverts[indices[i]]->t * t; v = 1.0f - triverts[index]->t * t;
} }
fprintf( fp, "%3i %f %f %f %f %f %f %f %f\n", fprintf( fp, "%3i %f %f %f %f %f %f %f %f",
bone_index, bone_index,
vert[0], vert[1], vert[2], vert[0], vert[1], vert[2],
norm[0], norm[1], norm[2], norm[0], norm[1], norm[2],
u, v ); u, v );
if( model_hdr->flags & STUDIO_HAS_BONEWEIGHTS )
{
fprintf( fp, " %d", valid_bones );
weights[0] = oldweight;
for( j = 0; j < valid_bones; ++j )
fprintf( fp, " %d %f",
studioboneweights[vert_index].bone[j],
weights[j] );
}
fputs( "\n", fp );
} }
} }
@@ -289,16 +334,15 @@ WriteTriangles
static void WriteTriangles( FILE *fp, mstudiomodel_t *model ) static void WriteTriangles( FILE *fp, mstudiomodel_t *model )
{ {
int i, j, k; int i, j, k;
mstudiomesh_t *mesh; mstudiomesh_t *mesh = (mstudiomesh_t *)( (byte *)model_hdr + model->meshindex );
mstudiotexture_t *texture; mstudiotexture_t *texture;
mstudiotrivert_t *triverts[3]; mstudiotrivert_t *triverts[3];
short *tricmds; short *tricmds;
fputs( "triangles\n", fp ); fputs( "triangles\n", fp );
for( i = 0; i < model->nummesh; i++ ) for( i = 0; i < model->nummesh; ++i, ++mesh )
{ {
mesh = (mstudiomesh_t *)( (byte *)model_hdr + model->meshindex ) + i;
tricmds = (short *)( (byte *)model_hdr + mesh->triindex ); tricmds = (short *)( (byte *)model_hdr + mesh->triindex );
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ) + mesh->skinref; texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ) + mesh->skinref;
@@ -383,21 +427,21 @@ WriteFrameInfo
static void WriteFrameInfo( FILE *fp, mstudioanim_t *anim, mstudioseqdesc_t *seqdesc, int frame ) static void WriteFrameInfo( FILE *fp, mstudioanim_t *anim, mstudioseqdesc_t *seqdesc, int frame )
{ {
int i, j; int i, j;
float scale;
vec_t motion[6]; // x, y, z, xr, yr, zr vec_t motion[6]; // x, y, z, xr, yr, zr
mstudiobone_t *bone; mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
fprintf( fp, "time %i\n", frame ); fprintf( fp, "time %i\n", frame );
for( i = 0; i < model_hdr->numbones; i++, anim++ ) for( i = 0; i < model_hdr->numbones; ++i, ++anim, ++bone )
{ {
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + i;
CalcBonePosition( anim, bone, motion, frame ); CalcBonePosition( anim, bone, motion, frame );
if( bone->parent == -1 ) if( bone->parent == -1 )
{ {
for( j = 0; j < 3; j++ ) scale = frame / (float)( seqdesc->numframes - 1 );
motion[j] += frame * 1.0f / seqdesc->numframes * seqdesc->linearmovement[j];
VectorMA( motion, scale, seqdesc->linearmovement, motion );
ProperBoneRotationZ( motion, 270.0f ); ProperBoneRotationZ( motion, 270.0f );
} }
@@ -449,19 +493,27 @@ static void WriteReferences( void )
char name[64]; char name[64];
char filename[MAX_SYSPATH]; char filename[MAX_SYSPATH];
if( !CreateBoneTransformMatrices() ) if( !CreateBoneTransformMatrices( &bonetransform ) )
return; return;
FillBoneTransformMatrices(); FillBoneTransformMatrices();
for( i = 0; i < model_hdr->numbodyparts; i++ ) if( model_hdr->flags & STUDIO_HAS_BONEINFO )
{ {
bodypart = (mstudiobodyparts_t *)( (byte *)model_hdr + model_hdr->bodypartindex ) + i; if( !CreateBoneTransformMatrices( &worldtransform ) )
return;
for( j = 0; j < bodypart->nummodels; j++ ) FillWorldTransformMatrices();
}
bodypart = (mstudiobodyparts_t *)( (byte *)model_hdr + model_hdr->bodypartindex );
for( i = 0; i < model_hdr->numbodyparts; ++i, ++bodypart )
{ {
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex ) + j; model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex );
for( j = 0; j < bodypart->nummodels; ++j, ++model )
{
if( !Q_strncmp( model->name, "blank", 5 ) ) if( !Q_strncmp( model->name, "blank", 5 ) )
continue; continue;
@@ -472,8 +524,7 @@ static void WriteReferences( void )
if( len == -1 ) if( len == -1 )
{ {
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", name ); fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", name );
RemoveBoneTransformMatrices(); goto _fail;
return;
} }
fp = fopen( filename, "w" ); fp = fopen( filename, "w" );
@@ -481,8 +532,7 @@ static void WriteReferences( void )
if( !fp ) if( !fp )
{ {
fprintf( stderr, "ERROR: Can't write %s\n", filename ); fprintf( stderr, "ERROR: Can't write %s\n", filename );
RemoveBoneTransformMatrices(); goto _fail;
return;
} }
fputs( "version 1\n", fp ); fputs( "version 1\n", fp );
@@ -497,7 +547,11 @@ static void WriteReferences( void )
} }
} }
RemoveBoneTransformMatrices(); _fail:
RemoveBoneTransformMatrices( &bonetransform );
if( model_hdr->flags & STUDIO_HAS_BONEINFO )
RemoveBoneTransformMatrices( &worldtransform );
} }
/* /*
@@ -511,18 +565,16 @@ static void WriteSequences( void )
int len; int len;
FILE *fp; FILE *fp;
char filename[MAX_SYSPATH]; char filename[MAX_SYSPATH];
mstudioseqdesc_t *seqdesc; mstudioseqdesc_t *seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
for( i = 0; i < model_hdr->numseq; i++ ) for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
{ {
seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ) + i;
for( j = 0; j < seqdesc->numblends; j++ ) for( j = 0; j < seqdesc->numblends; j++ )
{ {
if( seqdesc->numblends == 1 ) if( seqdesc->numblends == 1 )
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.smd", destdir, seqdesc->label ); len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.smd", destdir, seqdesc->label );
else else
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s_blend%i.smd", destdir, seqdesc->label, j + 1 ); len = Q_snprintf( filename, MAX_SYSPATH, "%s%s_blend%02i.smd", destdir, seqdesc->label, j + 1 );
if( len == -1 ) if( len == -1 )
{ {

View File

@@ -33,7 +33,7 @@ static void WriteBMP( mstudiotexture_t *texture )
int i, len; int i, len;
FILE *fp; FILE *fp;
const byte *p; const byte *p;
byte *palette, *pic, *buf; byte *palette, *pic;
char filename[MAX_SYSPATH], texturename[64]; char filename[MAX_SYSPATH], texturename[64];
rgba_t rgba_palette[256]; rgba_t rgba_palette[256];
bmp_t bmp_hdr = {0,}; bmp_t bmp_hdr = {0,};
@@ -87,23 +87,17 @@ static void WriteBMP( mstudiotexture_t *texture )
fwrite( rgba_palette, sizeof( rgba_palette ), 1, fp ); fwrite( rgba_palette, sizeof( rgba_palette ), 1, fp );
buf = malloc( texture_size );
p = pic; p = pic;
p += ( bmp_hdr.height - 1 ) * bmp_hdr.width; p += ( bmp_hdr.height - 1 ) * bmp_hdr.width;
for( i = 0; i < bmp_hdr.height; i++ ) for( i = 0; i < bmp_hdr.height; i++ )
{ {
memcpy( buf + bmp_hdr.width * i, p, bmp_hdr.width ); fwrite( p, bmp_hdr.width, 1, fp );
p -= bmp_hdr.width; p -= bmp_hdr.width;
} }
fwrite( buf, texture_size, 1, fp );
fclose( fp ); fclose( fp );
free( buf );
printf( "Texture: %s\n", filename ); printf( "Texture: %s\n", filename );
} }
@@ -115,13 +109,9 @@ WriteTextures
void WriteTextures( void ) void WriteTextures( void )
{ {
int i; int i;
mstudiotexture_t *texture; mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
for( i = 0; i < texture_hdr->numtextures; i++ )
{
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ) + i;
for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
WriteBMP( texture ); WriteBMP( texture );
}
} }

12
waf vendored

File diff suppressed because one or more lines are too long

View File

@@ -90,6 +90,7 @@ SUBDIRS = [
# enabled on PSVita only # enabled on PSVita only
Subproject('ref/gl/vgl_shim', lambda x: x.env.DEST_OS == 'psvita'), Subproject('ref/gl/vgl_shim', lambda x: x.env.DEST_OS == 'psvita'),
] ]
REFDLLS = [ REFDLLS = [
@@ -98,6 +99,7 @@ REFDLLS = [
RefDll('gles1', False, 'NANOGL'), RefDll('gles1', False, 'NANOGL'),
RefDll('gles2', False, 'GLWES'), RefDll('gles2', False, 'GLWES'),
RefDll('gl4es', False), RefDll('gl4es', False),
RefDll('gles3compat', False),
] ]
def options(opt): def options(opt):
@@ -165,7 +167,7 @@ def configure(conf):
conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64'] conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64']
# Load compilers early # Load compilers early
conf.load('xshlib xcompile compiler_c compiler_cxx') conf.load('xshlib xcompile compiler_c compiler_cxx cmake gccdeps msvcdeps')
if conf.options.NSWITCH: if conf.options.NSWITCH:
conf.load('nswitch') conf.load('nswitch')
@@ -294,6 +296,7 @@ def configure(conf):
# '-Werror=format=2', # '-Werror=format=2',
'-Werror=implicit-fallthrough=2', '-Werror=implicit-fallthrough=2',
'-Werror=logical-op', '-Werror=logical-op',
'-Werror=nonnull',
'-Werror=packed', '-Werror=packed',
'-Werror=packed-not-aligned', '-Werror=packed-not-aligned',
'-Werror=parentheses', '-Werror=parentheses',
@@ -468,12 +471,11 @@ int main(int argc, char **argv) { strchrnul(argv[1], 'x'); return 0; }'''
if conf.check_cfg(package='opus', uselib_store='opus', args='opus >= 1.4 --cflags --libs', mandatory=False): if conf.check_cfg(package='opus', uselib_store='opus', args='opus >= 1.4 --cflags --libs', mandatory=False):
# now try to link with export that only exists with CUSTOM_MODES defined # now try to link with export that only exists with CUSTOM_MODES defined
frag='''#include <opus_custom.h> frag='''#include <opus_custom.h>
int main(void) { return !opus_custom_encoder_init(0, 0, 0); }''' int main(void) { return !opus_custom_encoder_init((OpusCustomEncoder *)1, (const OpusCustomMode *)1, 1); }'''
if conf.check_cc(msg='Checking if opus supports custom modes', defines='CUSTOM_MODES=1', use='opus', fragment=frag, mandatory=False): if conf.check_cc(msg='Checking if opus supports custom modes', defines='CUSTOM_MODES=1', use='opus', fragment=frag, mandatory=False):
conf.env.HAVE_SYSTEM_OPUS = True conf.env.HAVE_SYSTEM_OPUS = True
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'notset')
conf.define('XASH_LOW_MEMORY', conf.options.LOW_MEMORY) conf.define('XASH_LOW_MEMORY', conf.options.LOW_MEMORY)
for i in SUBDIRS: for i in SUBDIRS: