mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
Compare commits
76 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6634e0487c | ||
|
|
7d61b5317c | ||
|
|
201258dc9e | ||
|
|
0330569537 | ||
|
|
a1ab84a2ca | ||
|
|
2d79f3ef7a | ||
|
|
99a7e9ad87 | ||
|
|
02b8037f33 | ||
|
|
fc55a685e3 | ||
|
|
b76a75d6b4 | ||
|
|
a251600c8a | ||
|
|
c551aefd77 | ||
|
|
f343f0da41 | ||
|
|
6d318a4102 | ||
|
|
a2b992d865 | ||
|
|
ddf3f2ffdb | ||
|
|
2454e87509 | ||
|
|
0dc44249a2 | ||
|
|
150cbfa4de | ||
|
|
c0b068d81b | ||
|
|
fbc312b6cf | ||
|
|
342e0d3e2e | ||
|
|
202b228691 | ||
|
|
c9c1286803 | ||
|
|
eab98b0eda | ||
|
|
35be80fc21 | ||
|
|
6041bb0a43 | ||
|
|
c7dd9d6437 | ||
|
|
d378878c91 | ||
|
|
4a2f8cafcd | ||
|
|
d254bac16b | ||
|
|
e23b632ce5 | ||
|
|
2f321b1471 | ||
|
|
0265e88d8f | ||
|
|
4114d2f24d | ||
|
|
8124035763 | ||
|
|
96127c6eb0 | ||
|
|
cf65a39b83 | ||
|
|
0341f96b70 | ||
|
|
c95d91cfe3 | ||
|
|
cbd10c6279 | ||
|
|
5df9e57743 | ||
|
|
c178022fb5 | ||
|
|
724c29d711 | ||
|
|
74a2dbeb91 | ||
|
|
5d20d24ebc | ||
|
|
0e2fc277c8 | ||
|
|
1505740b73 | ||
|
|
6bad07b39d | ||
|
|
f85437dfc5 | ||
|
|
c765261db6 | ||
|
|
73087ead2d | ||
|
|
8c88e82709 | ||
|
|
40dd6e0234 | ||
|
|
eb23b226cc | ||
|
|
676526a518 | ||
|
|
7e0bd86b65 | ||
|
|
97489635af | ||
|
|
a9ea3976a7 | ||
|
|
5501ca927a | ||
|
|
a19fb82d66 | ||
|
|
9d032e953f | ||
|
|
38587151a9 | ||
|
|
02d5bab04b | ||
|
|
d8f3e53b1f | ||
|
|
877ed8a92a | ||
|
|
487a652aa8 | ||
|
|
64c5d141af | ||
|
|
16db8a8008 | ||
|
|
b6b14da102 | ||
|
|
a575605c75 | ||
|
|
a205a3e878 | ||
|
|
26ef3e274c | ||
|
|
33be1b7591 | ||
|
|
de19d78571 | ||
|
|
287381d5ca |
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: d6a54bbf0c...adb3e413ec
@@ -133,22 +133,8 @@ Available in mod archive on ModDB - https://www.moddb.com/mods/overturn
|
||||
## Oz Deathmatch
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
Download page on official site - http://www.thothie.com/ww/
|
||||
|
||||
## XashXT
|
||||
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
|
||||
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
|
||||
|
||||
## 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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
## 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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
@@ -341,16 +357,22 @@ Branch **half-screwed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portab
|
||||
Port to Linux - https://github.com/fmoraw/NS
|
||||
|
||||
## 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
|
||||
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
|
||||
|
||||
## The Wastes
|
||||
Version 1.5: Port to Linux - https://git.mentality.rip/a1batross/halflife-thewastes-sdk
|
||||
|
||||
## Threewave CTF
|
||||
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
|
||||
Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x
|
||||
|
||||
|
||||
@@ -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 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
|
||||
{
|
||||
@@ -25,9 +38,15 @@ typedef enum
|
||||
PF_DXT3, // s3tc DXT3/BC2 format
|
||||
PF_DXT5, // s3tc DXT5/BC3 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_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
|
||||
} pixformat_t;
|
||||
|
||||
@@ -50,6 +69,7 @@ typedef enum
|
||||
IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals
|
||||
IL_OVERVIEW = BIT(6), // overview required some unque operations
|
||||
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;
|
||||
|
||||
// goes into rgbdata_t->encode
|
||||
|
||||
@@ -86,16 +86,19 @@ typedef uint64_t longtime_t;
|
||||
#endif
|
||||
#define _format(x) __attribute__((format(printf, x, x+1)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NONNULL __attribute__((nonnull))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EXPORT __declspec( dllexport )
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#else
|
||||
#define EXPORT
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#endif
|
||||
|
||||
#if ( __GNUC__ >= 3 )
|
||||
|
||||
@@ -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 )
|
||||
return; // IPX no longer support
|
||||
|
||||
if( request == NETAPI_REQUEST_SERVERLIST )
|
||||
return; // no support for server list requests
|
||||
|
||||
// find a free request
|
||||
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->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
|
||||
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req );
|
||||
}
|
||||
// local servers request
|
||||
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
|
||||
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 );
|
||||
}
|
||||
|
||||
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 ));
|
||||
break;
|
||||
}
|
||||
@@ -3456,8 +3433,6 @@ void GAME_EXPORT NetAPI_CancelAllRequests( void )
|
||||
}
|
||||
|
||||
memset( clgame.net_requests, 0, sizeof( clgame.net_requests ));
|
||||
clgame.request_type = NET_REQUEST_CANCEL;
|
||||
clgame.master_request = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -92,7 +92,7 @@ client_t cl;
|
||||
client_static_t cls;
|
||||
clgame_static_t clgame;
|
||||
|
||||
void CL_InternetServers_f( void );
|
||||
static void CL_SendMasterServerScanRequest( void );
|
||||
|
||||
//======================================================================
|
||||
int GAME_EXPORT CL_Active( void )
|
||||
@@ -1081,7 +1081,7 @@ void CL_CheckForResend( void )
|
||||
qboolean bandwidthTest;
|
||||
|
||||
if( cls.internetservers_wait )
|
||||
CL_InternetServers_f();
|
||||
CL_SendMasterServerScanRequest();
|
||||
|
||||
// if the local server is running and we aren't then connect
|
||||
if( cls.state == ca_disconnected && SV_Active( ))
|
||||
@@ -1574,10 +1574,10 @@ void CL_LocalServers_f( void )
|
||||
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;
|
||||
char *info;
|
||||
char *info, temp[32];
|
||||
|
||||
if( unlikely( size < sizeof( MS_SCAN_REQUEST )))
|
||||
return 0;
|
||||
@@ -1587,7 +1587,9 @@ size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat )
|
||||
info = buf + sizeof( MS_SCAN_REQUEST ) - 1;
|
||||
remaining = size - sizeof( MS_SCAN_REQUEST );
|
||||
|
||||
info[0] = 0;
|
||||
Q_strncpy( info, filter, remaining );
|
||||
|
||||
*key = COM_RandomLong( 0, 0x7FFFFFFF );
|
||||
|
||||
#ifndef XASH_ALL_SERVERS
|
||||
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, "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 );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
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
|
||||
@@ -1605,26 +1622,24 @@ CL_InternetServers_f
|
||||
*/
|
||||
void CL_InternetServers_f( void )
|
||||
{
|
||||
char fullquery[512];
|
||||
size_t len;
|
||||
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" );
|
||||
|
||||
NET_Config( true, true ); // allow remote
|
||||
|
||||
cls.internetservers_wait = NET_SendToMasters( NS_CLIENT, len, fullquery );
|
||||
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;
|
||||
}
|
||||
CL_SendMasterServerScanRequest();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2152,6 +2167,25 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
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
|
||||
while( MSG_GetNumBitsLeft( msg ) > 8 )
|
||||
{
|
||||
@@ -2161,58 +2195,10 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
|
||||
// list is ends here
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION );
|
||||
}
|
||||
NET_Config( true, false ); // allow remote
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION );
|
||||
}
|
||||
|
||||
if( cls.internetservers_pending )
|
||||
@@ -2341,7 +2327,7 @@ void CL_ReadPackets( void )
|
||||
// decide the simulation time
|
||||
cl.oldtime = cl.time;
|
||||
|
||||
if( cls.demoplayback != DEMO_XASH3D && !cl.paused )
|
||||
if( !cl.paused )
|
||||
cl.time += host.frametime;
|
||||
|
||||
// demo time
|
||||
|
||||
@@ -265,8 +265,18 @@ void CL_LegacyParseResourceList( sizebuf_t *msg )
|
||||
}
|
||||
|
||||
if( CL_IsPlaybackDemo() )
|
||||
{
|
||||
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();
|
||||
|
||||
@@ -423,13 +423,6 @@ typedef struct
|
||||
float applied_angle;
|
||||
} 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
|
||||
{
|
||||
net_response_t resp;
|
||||
@@ -491,9 +484,7 @@ typedef struct
|
||||
client_textmessage_t *titles; // title messages, not network messages
|
||||
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 *master_request; // queued master request
|
||||
|
||||
efrag_t *free_efrags; // linked efrags
|
||||
cl_entity_t viewent; // viewmodel
|
||||
@@ -627,7 +618,10 @@ typedef struct
|
||||
file_t *demofile;
|
||||
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_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
|
||||
qboolean legacymode; // one-way 48 protocol compatibility
|
||||
@@ -765,7 +759,6 @@ int CL_IsDevOverviewMode( void );
|
||||
void CL_PingServers_f( void );
|
||||
void CL_SignonReply( void );
|
||||
void CL_ClearState( void );
|
||||
size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat );
|
||||
|
||||
//
|
||||
// cl_demo.c
|
||||
|
||||
@@ -142,6 +142,7 @@ void Image_CopyPalette32bit( void );
|
||||
void Image_SetPixelFormat( void );
|
||||
void Image_GetPaletteQ1( void );
|
||||
void Image_GetPaletteHL( void );
|
||||
size_t Image_ComputeSize( int type, int width, int height, int depth );
|
||||
|
||||
//
|
||||
// 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_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_LoadKTX2( const char *name, const byte *buffer, fs_offset_t filesize );
|
||||
|
||||
//
|
||||
// formats save
|
||||
|
||||
@@ -104,6 +104,13 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
{
|
||||
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:
|
||||
image.type = PF_BC6H_SIGNED;
|
||||
break;
|
||||
@@ -112,9 +119,20 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
image.type = PF_BC6H_UNSIGNED;
|
||||
break;
|
||||
case DXGI_FORMAT_BC7_UNORM:
|
||||
case DXGI_FORMAT_BC7_UNORM_SRGB:
|
||||
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;
|
||||
default:
|
||||
image.type = PF_UNKNOWN;
|
||||
@@ -122,7 +140,7 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
switch( hdr->dsPixelFormat.dwFourCC )
|
||||
{
|
||||
case TYPE_DXT1:
|
||||
@@ -143,6 +161,15 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
case TYPE_ATI2:
|
||||
image.type = PF_ATI2;
|
||||
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:
|
||||
image.type = PF_UNKNOWN; // assume error
|
||||
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
|
||||
}
|
||||
|
||||
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 buffsize = 0;
|
||||
@@ -219,7 +225,7 @@ size_t Image_DXTCalcMipmapSize( dds_t *hdr )
|
||||
{
|
||||
width = Q_max( 1, ( hdr->dwWidth >> 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;
|
||||
@@ -255,7 +261,7 @@ uint Image_DXTCalcSize( const char *name, dds_t *hdr, size_t filesize )
|
||||
|
||||
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 )
|
||||
return false;
|
||||
}
|
||||
@@ -268,7 +274,7 @@ void Image_DXTAdjustVolume( dds_t *hdr )
|
||||
if( hdr->dwDepth <= 1 )
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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_DXTAdjustVolume( &header );
|
||||
|
||||
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageDXT( image.type ))
|
||||
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageCompressed( image.type ))
|
||||
return false; // silently rejected
|
||||
|
||||
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 );
|
||||
else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin ))
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
else if ( image.type == PF_BC7 )
|
||||
SetBits(image.flags, IMAGE_HAS_ALPHA);
|
||||
else if( image.type == PF_BC5_SIGNED || image.type == PF_BC5_UNSIGNED )
|
||||
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 ))
|
||||
SetBits( image.flags, IMAGE_HAS_COLOR );
|
||||
break;
|
||||
|
||||
@@ -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_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_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_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
|
||||
#define TYPE_o (('\0'<<24)+('\0'<<16)+('\0'<<8)+'o') // little-endian "o"
|
||||
@@ -202,7 +205,7 @@ typedef enum
|
||||
DXGI_FORMAT_FORCE_UINT = 0xffffffff
|
||||
} dxgi_format_t;
|
||||
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
|
||||
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
|
||||
|
||||
204
engine/common/imagelib/img_ktx2.c
Normal file
204
engine/common/imagelib/img_ktx2.c
Normal 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;
|
||||
}
|
||||
79
engine/common/imagelib/img_ktx2.h
Normal file
79
engine/common/imagelib/img_ktx2.h
Normal 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
|
||||
@@ -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", "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", "ktx2", Image_LoadKTX2, IL_HINT_NO }, // ktx2 for world and studio models
|
||||
{ NULL, NULL, NULL, IL_HINT_NO }
|
||||
};
|
||||
|
||||
@@ -1446,3 +1447,36 @@ qboolean Image_Process(rgbdata_t **pix, int width, int height, uint flags, float
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ void Sys_InitLog( void )
|
||||
s_ld.logfileno = fileno( s_ld.logfile );
|
||||
|
||||
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" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -812,8 +812,13 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
|
||||
{
|
||||
if( !glw_state.initialized )
|
||||
{
|
||||
if( !GL_CreateContext( ))
|
||||
return false;
|
||||
while( !GL_CreateContext( ))
|
||||
{
|
||||
glw_state.safe++;
|
||||
if(glw_state.safe > SAFE_DONTCARE)
|
||||
return false;
|
||||
GL_SetupAttributes(); // re-choose attributes
|
||||
}
|
||||
|
||||
VID_StartupGamma();
|
||||
}
|
||||
|
||||
70
ref/gl/gl2_shim/fragment.glsl.inc
Normal file
70
ref/gl/gl2_shim/fragment.glsl.inc
Normal 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
1770
ref/gl/gl2_shim/gl2_shim.c
Normal file
File diff suppressed because it is too large
Load Diff
24
ref/gl/gl2_shim/gl2_shim.h
Normal file
24
ref/gl/gl2_shim/gl2_shim.h
Normal 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 );
|
||||
53
ref/gl/gl2_shim/vertex.glsl.inc
Normal file
53
ref/gl/gl2_shim/vertex.glsl.inc
Normal 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
25
ref/gl/gl2_shim/wscript
Normal 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
|
||||
)
|
||||
@@ -27,6 +27,8 @@ GNU General Public License for more details.
|
||||
#define XASH_GLES
|
||||
#define XASH_GL_STATIC
|
||||
#define REF_GL_KEEP_MANGLED_FUNCTIONS
|
||||
#elif defined XASH_GLES3COMPAT
|
||||
#define XASH_GLES
|
||||
#endif
|
||||
|
||||
typedef uint GLenum;
|
||||
@@ -811,6 +813,19 @@ typedef float GLmatrix[16];
|
||||
#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
|
||||
#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_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
@@ -888,6 +903,7 @@ typedef float GLmatrix[16];
|
||||
// helper opengl functions
|
||||
APIENTRY_LINKAGE GLenum GL_FUNCTION( glGetError )(void);
|
||||
APIENTRY_LINKAGE const GLubyte * GL_FUNCTION( glGetString )(GLenum name);
|
||||
APIENTRY_LINKAGE const GLubyte * GL_FUNCTION( glGetStringi )(GLenum name, GLint i);
|
||||
|
||||
// base gl functions
|
||||
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 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);
|
||||
#endif /* !XASH_GLES && !XASH_GL4ES */
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
|
||||
}
|
||||
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_MAG_FILTER, GL_NEAREST );
|
||||
@@ -388,7 +388,8 @@ static size_t GL_CalcImageSize( pixformat_t format, int width, int height, int d
|
||||
case PF_DXT5:
|
||||
case PF_BC6H_SIGNED:
|
||||
case PF_BC6H_UNSIGNED:
|
||||
case PF_BC7:
|
||||
case PF_BC7_UNORM:
|
||||
case PF_BC7_SRGB:
|
||||
case PF_ATI2:
|
||||
size = (((width + 3) >> 2) * ((height + 3) >> 2) * 16) * depth;
|
||||
break;
|
||||
@@ -694,7 +695,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
|
||||
|
||||
Assert( tex != NULL );
|
||||
|
||||
if( ImageDXT( format ))
|
||||
if( ImageCompressed( format ))
|
||||
{
|
||||
switch( format )
|
||||
{
|
||||
@@ -703,7 +704,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_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_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:
|
||||
if( glConfig.hardware_type == GLHW_RADEON )
|
||||
tex->format = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
|
||||
@@ -1070,7 +1072,7 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
|
||||
}
|
||||
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");
|
||||
switch (samplesCount)
|
||||
{
|
||||
@@ -1083,9 +1085,9 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
|
||||
samplesCount = 1;
|
||||
}
|
||||
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" );
|
||||
#endif /* !XASH_GLES && !XASH_GL4ES */
|
||||
#endif /* !XASH_GL_STATIC !XASH_GLES && !XASH_GL4ES */
|
||||
}
|
||||
else // 2D or RECT
|
||||
{
|
||||
@@ -1094,7 +1096,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;
|
||||
qboolean subImage = FBitSet( tex->flags, TF_IMG_UPLOADED );
|
||||
@@ -1176,7 +1178,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
|
||||
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 ))
|
||||
{
|
||||
@@ -1217,7 +1219,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
|
||||
if( buf != NULL && buf >= bufend )
|
||||
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++ )
|
||||
{
|
||||
@@ -1225,7 +1227,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
|
||||
height = Q_max( 1, ( tex->height >> j ));
|
||||
texsize = GL_CalcTextureSize( tex->format, 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;
|
||||
buf += size; // move pointer
|
||||
tex->numMips++;
|
||||
@@ -1259,7 +1261,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 );
|
||||
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 );
|
||||
|
||||
// mips will be auto-generated if desired
|
||||
@@ -1307,7 +1309,7 @@ static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic )
|
||||
|
||||
tex->encode = pic->encode; // share encode method
|
||||
|
||||
if( ImageDXT( pic->type ))
|
||||
if( ImageCompressed( pic->type ))
|
||||
{
|
||||
if( !pic->numMips )
|
||||
tex->flags |= TF_NOMIPMAP; // disable mipmapping by user request
|
||||
@@ -1418,7 +1420,7 @@ static gl_texture_t *GL_AllocTexture( const char *name, texFlags_t flags )
|
||||
// copy initial params
|
||||
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++;
|
||||
else
|
||||
{
|
||||
@@ -1922,7 +1924,7 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
|
||||
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 );
|
||||
return;
|
||||
|
||||
@@ -40,6 +40,9 @@ int VGL_ShimInit( void );
|
||||
void VGL_ShimShutdown( void );
|
||||
void VGL_ShimEndFrame( void );
|
||||
#endif
|
||||
#if !defined(XASH_GL_STATIC)
|
||||
#include "gl2_shim/gl2_shim.h"
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#ifdef __GNUC__
|
||||
@@ -561,7 +564,7 @@ void GL_CheckForErrors_( const char *filename, const int fileline );
|
||||
const char *GL_ErrorString( int err );
|
||||
qboolean GL_Support( int r_ext );
|
||||
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 );
|
||||
|
||||
//
|
||||
@@ -617,6 +620,11 @@ enum
|
||||
GL_DRAW_RANGEELEMENTS_EXT,
|
||||
GL_TEXTURE_MULTISAMPLE,
|
||||
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
|
||||
};
|
||||
|
||||
@@ -662,6 +670,8 @@ typedef struct
|
||||
int depth_bits;
|
||||
int stencil_bits;
|
||||
int msaasamples;
|
||||
int version_major;
|
||||
int version_minor;
|
||||
|
||||
gl_context_type_t context;
|
||||
gles_wrapper_t wrapper;
|
||||
@@ -738,7 +748,8 @@ extern convar_t r_lockfrustum;
|
||||
extern convar_t r_traceglow;
|
||||
extern convar_t r_vbo;
|
||||
extern convar_t r_vbo_dlightmode;
|
||||
|
||||
extern convar_t r_studio_sort_textures;
|
||||
extern convar_t r_studio_drawelements;
|
||||
|
||||
//
|
||||
// engine shared convars
|
||||
|
||||
@@ -222,8 +222,10 @@ static dllfunc_t vbofuncs[] =
|
||||
{ GL_CALL( glDeleteBuffersARB ) },
|
||||
{ GL_CALL( glGenBuffersARB ) },
|
||||
{ GL_CALL( glIsBufferARB ) },
|
||||
#ifndef XASH_GLES
|
||||
{ GL_CALL( glMapBufferARB ) },
|
||||
{ GL_CALL( glUnmapBufferARB ) }, // ,
|
||||
{ GL_CALL( glUnmapBufferARB ) },
|
||||
#endif
|
||||
{ GL_CALL( glBufferDataARB ) },
|
||||
{ GL_CALL( glBufferSubDataARB ) },
|
||||
{ NULL, NULL }
|
||||
@@ -247,6 +249,192 @@ static dllfunc_t drawrangeelementsextfuncs[] =
|
||||
{ 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
|
||||
@@ -319,12 +507,13 @@ int GL_MaxTextureUnits( void )
|
||||
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;
|
||||
cvar_t *parm = NULL;
|
||||
const char *extensions_string;
|
||||
char desc[MAX_VA_STRING];
|
||||
float glver = (float)glConfig.version_major + glConfig.version_minor / 10.0f;
|
||||
|
||||
gEngfuncs.Con_Reportf( "GL_CheckExtension: %s ", name );
|
||||
GL_SetExtension( r_ext, true );
|
||||
@@ -345,7 +534,7 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
|
||||
|
||||
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
|
||||
gEngfuncs.Con_Reportf( "- ^1failed\n" );
|
||||
@@ -362,8 +551,22 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
|
||||
// functions are cleared before all the extensions are evaluated
|
||||
if((*func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL )
|
||||
{
|
||||
// one or more functions are invalid, extension will be disabled
|
||||
GL_SetExtension( r_ext, false );
|
||||
// HACK: fix ARB names
|
||||
char *str = Q_strstr( func->name, "ARB" );
|
||||
if(str)
|
||||
{
|
||||
string name;
|
||||
|
||||
Q_strncpy( name, func->name, MAX_STRING );
|
||||
name[str - func->name] = '\0';
|
||||
*func->func = gEngfuncs.GL_GetProcAddress( name );
|
||||
|
||||
if( !*func->func )
|
||||
GL_SetExtension( r_ext, false );
|
||||
}
|
||||
else
|
||||
// one or more functions are invalid, extension will be disabled
|
||||
GL_SetExtension( r_ext, false );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -545,7 +748,11 @@ void GL_InitExtensionsGLES( void )
|
||||
#elif defined( XASH_WES )
|
||||
glConfig.context = CONTEXT_TYPE_GLES_2_X;
|
||||
glConfig.wrapper = GLES_WRAPPER_WES;
|
||||
#elif defined( XASH_GLES3COMPAT )
|
||||
glConfig.context = CONTEXT_TYPE_GLES_2_X;
|
||||
glConfig.wrapper = GLES_WRAPPER_NONE;
|
||||
#else
|
||||
|
||||
#error "unknown gles wrapper"
|
||||
#endif
|
||||
|
||||
@@ -556,12 +763,22 @@ void GL_InitExtensionsGLES( void )
|
||||
switch( extid )
|
||||
{
|
||||
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;
|
||||
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
|
||||
|
||||
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 )
|
||||
{
|
||||
GL_SetExtension( extid, false );
|
||||
@@ -571,24 +788,48 @@ void GL_InitExtensionsGLES( void )
|
||||
glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units;
|
||||
break;
|
||||
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 );
|
||||
break;
|
||||
case GL_ANISOTROPY_EXT:
|
||||
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 );
|
||||
break;
|
||||
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 );
|
||||
break;
|
||||
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;
|
||||
#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:
|
||||
if( glw_state.extended )
|
||||
GL_CheckExtension( "GL_KHR_debug", NULL, NULL, extid );
|
||||
GL_CheckExtension( "GL_KHR_debug", NULL, NULL, extid, 0 );
|
||||
break;
|
||||
// case GL_TEXTURE_COMPRESSION_EXT: NOPE
|
||||
// case GL_SHADER_GLSL100_EXT: NOPE
|
||||
@@ -607,12 +848,15 @@ void GL_InitExtensionsGLES( void )
|
||||
GL_SetExtension( extid, false );
|
||||
}
|
||||
}
|
||||
#ifndef XASH_GL_STATIC
|
||||
GL2_ShimInit();
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void GL_InitExtensionsBigGL( void )
|
||||
{
|
||||
// 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;
|
||||
|
||||
if( Q_stristr( glConfig.renderer_string, "geforce" ))
|
||||
@@ -643,7 +887,7 @@ void GL_InitExtensionsBigGL( void )
|
||||
|
||||
// multitexture
|
||||
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 );
|
||||
}
|
||||
@@ -652,7 +896,7 @@ void GL_InitExtensionsBigGL( void )
|
||||
GL_SetExtension( GL_ARB_MULTITEXTURE, false );
|
||||
|
||||
// 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 );
|
||||
|
||||
@@ -664,25 +908,25 @@ void GL_InitExtensionsBigGL( void )
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
||||
// 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 );
|
||||
|
||||
// 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_compression", texturecompressionfuncs, "gl_texture_dxt_compression", GL_TEXTURE_COMPRESSION_EXT );
|
||||
if( !GL_CheckExtension( "GL_EXT_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 );
|
||||
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, 0 );
|
||||
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, 0 );
|
||||
|
||||
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 );
|
||||
|
||||
#if XASH_WIN32 // Win32 only drivers?
|
||||
@@ -690,20 +934,30 @@ void GL_InitExtensionsBigGL( void )
|
||||
if( glConfig.hardware_type != GLHW_INTEL )
|
||||
#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 );
|
||||
}
|
||||
|
||||
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_texture_float", NULL, "gl_texture_float", GL_ARB_TEXTURE_FLOAT_EXT );
|
||||
GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_texture_depth_float", GL_ARB_DEPTH_FLOAT_EXT );
|
||||
GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4 ); // 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_texture_multisample", multisampletexfuncs, "gl_texture_multisample", GL_TEXTURE_MULTISAMPLE );
|
||||
GL_CheckExtension( "GL_ARB_texture_compression_bptc", NULL, "gl_texture_bptc_compression", GL_ARB_TEXTURE_COMPRESSION_BPTC );
|
||||
if( GL_CheckExtension( "GL_ARB_shading_language_100", NULL, NULL, GL_SHADER_GLSL100_EXT ))
|
||||
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, 0 );
|
||||
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, 0 ); // don't confuse users
|
||||
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, 0 );
|
||||
GL_CheckExtension( "GL_ARB_texture_compression_bptc", NULL, "gl_texture_bptc_compression", GL_ARB_TEXTURE_COMPRESSION_BPTC, 0 );
|
||||
#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_IMAGE_UNITS_ARB, &glConfig.max_teximage_units );
|
||||
@@ -724,12 +978,12 @@ void GL_InitExtensionsBigGL( void )
|
||||
}
|
||||
|
||||
// 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,
|
||||
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT ) )
|
||||
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ))
|
||||
{
|
||||
#ifndef XASH_GL_STATIC
|
||||
pglDrawRangeElements = pglDrawRangeElementsEXT;
|
||||
@@ -739,7 +993,7 @@ void GL_InitExtensionsBigGL( void )
|
||||
|
||||
// this won't work without extended context
|
||||
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
|
||||
// not all GL1.1 functions are implemented in vitaGL, but there's enough
|
||||
@@ -747,23 +1001,77 @@ void GL_InitExtensionsBigGL( void )
|
||||
// init our immediate mode override
|
||||
VGL_ShimInit();
|
||||
#endif
|
||||
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
|
||||
if( gEngfuncs.Sys_CheckParm( "-gl2shim" ))
|
||||
GL2_ShimInit();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void GL_InitExtensions( void )
|
||||
{
|
||||
char value[MAX_VA_STRING];
|
||||
GLint major = 0, minor = 0;
|
||||
|
||||
GL_OnContextCreated();
|
||||
|
||||
// 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
|
||||
glConfig.vendor_string = (const char *)pglGetString( GL_VENDOR );
|
||||
glConfig.renderer_string = (const char *)pglGetString( GL_RENDERER );
|
||||
glConfig.version_string = (const char *)pglGetString( GL_VERSION );
|
||||
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 );
|
||||
|
||||
#ifdef XASH_GLES
|
||||
@@ -843,6 +1151,8 @@ void GL_InitCommands( void )
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_lockpvs );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_lockfrustum );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_traceglow );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
|
||||
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_extensions );
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_texture_nearest );
|
||||
@@ -927,6 +1237,8 @@ qboolean R_Init( void )
|
||||
|
||||
GL_SetDefaultState();
|
||||
|
||||
r_temppool = Mem_AllocPool( "Render Zone" );
|
||||
|
||||
// create the window and set up the context
|
||||
if( !gEngfuncs.R_Init_Video( REF_GL )) // request GL context
|
||||
{
|
||||
@@ -934,11 +1246,10 @@ qboolean R_Init( void )
|
||||
gEngfuncs.R_Free_Video();
|
||||
// Why? Host_Error again???
|
||||
// gEngfuncs.Host_Error( "Can't initialize video subsystem\nProbably driver was not installed" );
|
||||
Mem_FreePool( &r_temppool );
|
||||
return false;
|
||||
}
|
||||
|
||||
r_temppool = Mem_AllocPool( "Render Zone" );
|
||||
|
||||
GL_SetDefaults();
|
||||
R_CheckVBO();
|
||||
R_InitImages();
|
||||
@@ -963,6 +1274,9 @@ void R_Shutdown( void )
|
||||
|
||||
GL_RemoveCommands();
|
||||
R_ShutdownImages();
|
||||
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
|
||||
GL2_ShimShutdown();
|
||||
#endif
|
||||
|
||||
Mem_FreePool( &r_temppool );
|
||||
|
||||
@@ -1046,14 +1360,22 @@ void GL_SetupAttributes( int safegl )
|
||||
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_MAJOR_VERSION, 3 );
|
||||
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_COMPATIBILITY );
|
||||
if( !safegl )
|
||||
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
|
||||
|
||||
if( gEngfuncs.Sys_CheckParm( "-gldebug" ) )
|
||||
if( gEngfuncs.Sys_CheckParm( "-gldebug" ))
|
||||
{
|
||||
gEngfuncs.Con_Reportf( "Creating an extended GL context for debug...\n" );
|
||||
SetBits( context_flags, FCONTEXT_DEBUG_ARB );
|
||||
@@ -1182,6 +1504,8 @@ void GL_OnContextCreated( void )
|
||||
glState.stencilEnabled = glConfig.stencil_bits ? true : false;
|
||||
|
||||
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
|
||||
wes_init( "" );
|
||||
|
||||
@@ -20,6 +20,7 @@ GNU General Public License for more details.
|
||||
#include "particledef.h"
|
||||
#include "entity_types.h"
|
||||
|
||||
|
||||
#define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA )
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
@@ -1126,6 +1127,9 @@ void R_EndFrame( void )
|
||||
{
|
||||
#if XASH_PSVITA
|
||||
VGL_ShimEndFrame();
|
||||
#endif
|
||||
#if !defined( XASH_GL_STATIC )
|
||||
GL2_ShimEndFrame();
|
||||
#endif
|
||||
// flush any remaining 2D bits
|
||||
R_Set2DMode( false );
|
||||
|
||||
@@ -1792,11 +1792,7 @@ void R_GenerateVBO( void )
|
||||
R_ClearVBO();
|
||||
|
||||
// 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 )
|
||||
#else
|
||||
if( 1 )
|
||||
#endif
|
||||
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") )
|
||||
{
|
||||
gEngfuncs.Cvar_FullSet( "gl_vbo", "0", FCVAR_READ_ONLY );
|
||||
return;
|
||||
|
||||
@@ -121,9 +121,9 @@ typedef struct
|
||||
} studio_draw_state_t;
|
||||
|
||||
// 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_DEFINE_AUTO( r_studio_drawelements, "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" );
|
||||
|
||||
static r_studio_interface_t *pStudioDraw;
|
||||
static studio_draw_state_t g_studio; // global studio state
|
||||
@@ -146,8 +146,6 @@ R_StudioInit
|
||||
*/
|
||||
void R_StudioInit( void )
|
||||
{
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
|
||||
|
||||
#if XASH_PSVITA
|
||||
// don't do the same array-building work twice since that's what our FFP shim does anyway
|
||||
|
||||
@@ -761,11 +761,8 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
|
||||
float s, t, os, ot;
|
||||
glpoly_t *p;
|
||||
int i;
|
||||
#ifndef XASH_GLES
|
||||
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS );
|
||||
#else
|
||||
const qboolean useQuads = false; // TODO: figure out why
|
||||
#endif
|
||||
|
||||
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS ) && glConfig.context == CONTEXT_TYPE_GL;
|
||||
|
||||
if( !warp->polys ) return;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ def build(bld):
|
||||
else:
|
||||
libs += [ 'public', 'M' ]
|
||||
|
||||
source = bld.path.ant_glob(['*.c'])
|
||||
source = bld.path.ant_glob(['*.c', 'gl2_shim/*.c'])
|
||||
includes = '.'
|
||||
|
||||
targets = {
|
||||
@@ -63,6 +63,11 @@ def build(bld):
|
||||
'libs': ['DL', 'gl4es', 'LOG'],
|
||||
'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():
|
||||
|
||||
@@ -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 );
|
||||
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 );
|
||||
|
||||
// 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 )
|
||||
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++ )
|
||||
{
|
||||
@@ -671,7 +671,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
||||
height = Q_max( 1, ( tex->height >> j ));
|
||||
texsize = GL_CalcTextureSize( tex->format, 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;
|
||||
buf += size; // move pointer
|
||||
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 );
|
||||
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 );
|
||||
|
||||
// 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( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA;
|
||||
|
||||
if( ImageDXT( pic->type ))
|
||||
if( ImageCompressed( pic->type ))
|
||||
{
|
||||
if( !pic->numMips )
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
return;
|
||||
|
||||
@@ -1096,6 +1096,7 @@ extern convar_t sw_surfcacheoverride;
|
||||
extern convar_t sw_texfilt;
|
||||
extern convar_t r_traceglow;
|
||||
extern convar_t sw_noalphabrushes;
|
||||
extern convar_t r_studio_sort_textures;
|
||||
|
||||
extern struct qfrustum_s {
|
||||
mplane_t screenedge[4];
|
||||
|
||||
@@ -1918,6 +1918,7 @@ qboolean GAME_EXPORT R_Init( void )
|
||||
gEngfuncs.Cvar_RegisterVariable( &sw_texfilt );
|
||||
#endif
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_novis );
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
|
||||
|
||||
r_temppool = Mem_AllocPool( "ref_soft zone" );
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ typedef struct
|
||||
} studio_draw_state_t;
|
||||
|
||||
// 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 r_studio_interface_t *pStudioDraw;
|
||||
@@ -141,8 +141,6 @@ R_StudioInit
|
||||
*/
|
||||
void R_StudioInit( void )
|
||||
{
|
||||
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
|
||||
|
||||
Matrix3x4_LoadIdentity( g_studio.rotationmatrix );
|
||||
|
||||
// g-cont. cvar disabled by Valve
|
||||
|
||||
@@ -41,21 +41,17 @@ static void SequenceNameFix( void )
|
||||
{
|
||||
int i, j, counter;
|
||||
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;
|
||||
|
||||
for( j = 0; j < model_hdr->numseq; j++ )
|
||||
{
|
||||
seqdesc1 = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ) + j;
|
||||
seqdesc1 = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
|
||||
|
||||
for( j = 0; j < model_hdr->numseq; ++j, ++seqdesc1 )
|
||||
if( j != i && !Q_strncmp( seqdesc1->label, seqdesc->label, sizeof( seqdesc1->label ) ) )
|
||||
Q_snprintf( seqdesc1->label, sizeof( seqdesc1->label ), "%s_%i", seqdesc1->label, ++counter );
|
||||
}
|
||||
|
||||
if( counter > 1 )
|
||||
{
|
||||
@@ -79,15 +75,11 @@ BoneNameFix
|
||||
static void BoneNameFix( void )
|
||||
{
|
||||
int i, counter = 0;
|
||||
mstudiobone_t *bone;
|
||||
|
||||
for( i = 0; i < model_hdr->numbones; i++ )
|
||||
{
|
||||
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + i;
|
||||
mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
|
||||
|
||||
for( i = 0; i < model_hdr->numbones; ++i, ++bone )
|
||||
if( bone->name[0] == '\0' )
|
||||
Q_snprintf( bone->name, sizeof( bone->name ), "MDLDEC_Bone%i", ++counter );
|
||||
}
|
||||
|
||||
if( 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 ret = 0;
|
||||
|
||||
puts( "\nHalf-Life Studio Model Decompiler " APP_VERSION );
|
||||
puts( "Copyright Flying With Gauss 2020 (c) " );
|
||||
puts( "--------------------------------------------------" );
|
||||
@@ -273,6 +267,7 @@ int main( int argc, char *argv[] )
|
||||
if( argc == 1 )
|
||||
{
|
||||
ShowHelp( argv[0] );
|
||||
ret = 2;
|
||||
goto end;
|
||||
}
|
||||
else if( argc == 3 )
|
||||
@@ -280,6 +275,7 @@ int main( int argc, char *argv[] )
|
||||
if( Q_strlen( argv[2] ) > MAX_SYSPATH - 2 )
|
||||
{
|
||||
fputs( "ERROR: Destination path is too long.\n", stderr );
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -287,7 +283,10 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
if( !LoadActivityList( argv[0] ) || !LoadMDL( argv[1] ) )
|
||||
{
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
WriteQCScript();
|
||||
WriteSMD();
|
||||
@@ -298,6 +297,6 @@ int main( int argc, char *argv[] )
|
||||
end:
|
||||
puts( "--------------------------------------------------" );
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ GNU General Public License for more details.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "eiface.h"
|
||||
#include "studio.h"
|
||||
#include "crtlib.h"
|
||||
@@ -197,6 +198,7 @@ static void WriteTextureRenderMode( FILE *fp )
|
||||
{
|
||||
int i;
|
||||
mstudiotexture_t *texture;
|
||||
long pos = ftell( fp );
|
||||
|
||||
for( i = 0; i < texture_hdr->numtextures; i++ )
|
||||
{
|
||||
@@ -234,6 +236,9 @@ static void WriteTextureRenderMode( FILE *fp )
|
||||
if( texture->flags & STUDIO_NF_TWOSIDE )
|
||||
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 )
|
||||
{
|
||||
int i, j, k;
|
||||
short *skinref, index;
|
||||
short *skinref, *index;
|
||||
mstudiotexture_t *texture;
|
||||
|
||||
if( texture_hdr->numskinfamilies < 2 )
|
||||
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 );
|
||||
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
|
||||
|
||||
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 )
|
||||
{
|
||||
if( index == *( skinref + k * texture_hdr->numskinref + j ) )
|
||||
if( *index == *( skinref + k * texture_hdr->numskinref + j ) )
|
||||
continue;
|
||||
|
||||
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ) + index;
|
||||
|
||||
fprintf( fp, " \"%s\" ", texture->name );
|
||||
fprintf( fp, "\t\t\"%s\"\n", texture[*index].name );
|
||||
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 )
|
||||
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 )
|
||||
{
|
||||
attachment = (mstudioattachment_t *)( (byte *)model_hdr + model_hdr->attachmentindex ) + i;
|
||||
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + attachment->bone;
|
||||
fprintf( fp, "// %i attachment%s\n", model_hdr->numattachments, model_hdr->numattachments > 1 ? "s" : "" );
|
||||
|
||||
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 )
|
||||
{
|
||||
int i, j;
|
||||
mstudiobodyparts_t *bodypart;
|
||||
mstudiobodyparts_t *bodypart = (mstudiobodyparts_t *) ( (byte *)model_hdr + model_hdr->bodypartindex );
|
||||
mstudiomodel_t *model;
|
||||
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;
|
||||
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex );
|
||||
|
||||
if( bodypart->nummodels == 1 )
|
||||
{
|
||||
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -339,23 +341,23 @@ static void WriteBodyGroupInfo( FILE *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 ) )
|
||||
{
|
||||
fputs( "blank\n", fp );
|
||||
fputs( "\tblank\n", fp );
|
||||
continue;
|
||||
}
|
||||
|
||||
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 )
|
||||
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 );
|
||||
|
||||
fprintf( fp, "$controller %i \"%s\" %s %f %f\n",
|
||||
bonecontroller->index, bone->name, motion_types,
|
||||
fputs( "$controller ", fp );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
fputs( "\n", fp );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -402,18 +413,41 @@ static void WriteHitBoxInfo( FILE *fp )
|
||||
if( !model_hdr->numhitboxes )
|
||||
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++ )
|
||||
{
|
||||
hitbox = (mstudiobbox_t *)( (byte *)model_hdr + model_hdr->hitboxindex ) + i;
|
||||
bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex ) + hitbox->bone;
|
||||
fprintf( fp, "// %i hit box%s\n", model_hdr->numhitboxes, model_hdr->numhitboxes > 1 ? "es" : "" );
|
||||
|
||||
for( i = 0; i < model_hdr->numhitboxes; ++i, ++hitbox )
|
||||
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->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;
|
||||
|
||||
if( model_hdr->numseqgroups > 1 )
|
||||
fputs( "\n$sequencegroupsize 64\n", fp );
|
||||
fprintf( fp, "$sequencegroupsize %d\n\n", CalcSequenceGroupSize( ) );
|
||||
|
||||
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\" ", seqdesc->label );
|
||||
fprintf( fp, "$sequence \"%s\" {\n", seqdesc->label );
|
||||
|
||||
if( seqdesc->numblends > 1 )
|
||||
{
|
||||
if( seqdesc->numblends > 2 )
|
||||
{
|
||||
fputs( "{\n", fp );
|
||||
|
||||
for( j = 0; j < seqdesc->numblends; j++ )
|
||||
{
|
||||
fputs( " ", fp );
|
||||
|
||||
fprintf( fp, "\"%s_blend%i\" ", seqdesc->label, j + 1 );
|
||||
|
||||
fputs( "\n", fp );
|
||||
}
|
||||
|
||||
fputs( " ", fp );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( fp, "\"%s_blend1\" ", 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] );
|
||||
for( j = 0; j < seqdesc->numblends; j++ )
|
||||
fprintf( fp, "\t\"%s_blend%02i\"\n", seqdesc->label, j + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( fp, "\"%s\"", seqdesc->label );
|
||||
fprintf( fp, "\t\"%s\"\n", 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 )
|
||||
{
|
||||
activity = FindActivityName( seqdesc->activity );
|
||||
|
||||
if( activity )
|
||||
{
|
||||
fprintf( fp, "%s %i ", activity, seqdesc->actweight );
|
||||
fprintf( fp, "\t%s %i\n", activity, seqdesc->actweight );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "WARNING: Sequence %s has a custom activity flag (ACT_%i %i).\n",
|
||||
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 )
|
||||
fprintf( fp, "node %i ", seqdesc->entrynode );
|
||||
fprintf( fp, "\tnode %i\n", seqdesc->entrynode );
|
||||
else if( seqdesc->nodeflags )
|
||||
fprintf( fp, "rtransition %i %i ", seqdesc->entrynode, seqdesc->exitnode );
|
||||
fprintf( fp, "\trtransition %i %i\n", seqdesc->entrynode, seqdesc->exitnode );
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
if( seqdesc->numblends > 2 )
|
||||
fputs( "}\n", fp );
|
||||
fputs( "}\n", fp );
|
||||
}
|
||||
|
||||
fputs( "\n", fp );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -601,41 +598,38 @@ void WriteQCScript( void )
|
||||
|
||||
fprintf( fp, "$modelname \"%s.mdl\"\n", modelfile );
|
||||
|
||||
fputs( "$cd \".\\\"\n", fp );
|
||||
fputs( "$cdtexture \".\\\"\n", fp );
|
||||
fputs( "$scale 1.0\n", fp );
|
||||
fputs( "$cd \".\"\n", fp );
|
||||
fputs( "$cdtexture \".\"\n", fp );
|
||||
fputs( "$cliptotextures\n", fp );
|
||||
fputs( "\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( "$scale 1.0\n", fp );
|
||||
fputs( "\n", 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 );
|
||||
WriteTextureRenderMode( fp );
|
||||
|
||||
if( model_hdr->flags & ( STUDIO_HAS_BONEINFO | STUDIO_HAS_BONEWEIGHTS ) )
|
||||
fputs( "$boneweights\n\n", 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 );
|
||||
WriteControllerInfo( fp );
|
||||
WriteSequenceInfo( fp );
|
||||
|
||||
fputs( "\n// End of QC script.\n", fp );
|
||||
fputs( "// End of QC script.\n", fp );
|
||||
fclose( fp );
|
||||
|
||||
printf( "QC Script: %s\n", filename );
|
||||
|
||||
@@ -16,6 +16,7 @@ GNU General Public License for more details.
|
||||
#ifndef QC_H
|
||||
#define QC_H
|
||||
|
||||
#define DEFAULT_SEQGROUPSIZE 64
|
||||
#define ACTIVITIES_FILE "activities.txt"
|
||||
|
||||
qboolean LoadActivityList( const char *appname );
|
||||
|
||||
@@ -25,17 +25,18 @@ GNU General Public License for more details.
|
||||
#include "smd.h"
|
||||
|
||||
static matrix3x4 *bonetransform;
|
||||
static matrix3x4 *worldtransform;
|
||||
|
||||
/*
|
||||
============
|
||||
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 );
|
||||
return false;
|
||||
@@ -52,14 +53,12 @@ FillBoneTransformMatrices
|
||||
static void FillBoneTransformMatrices( void )
|
||||
{
|
||||
int i;
|
||||
mstudiobone_t *bone;
|
||||
mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
|
||||
matrix3x4 bonematrix;
|
||||
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 );
|
||||
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
|
||||
============
|
||||
*/
|
||||
static void RemoveBoneTransformMatrices( void )
|
||||
static void RemoveBoneTransformMatrices( matrix3x4 **matrix )
|
||||
{
|
||||
free( bonetransform );
|
||||
free( *matrix );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -171,16 +184,12 @@ WriteNodes
|
||||
static void WriteNodes( FILE *fp )
|
||||
{
|
||||
int i;
|
||||
mstudiobone_t *bone;
|
||||
mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
|
||||
|
||||
fputs( "nodes\n", fp );
|
||||
|
||||
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 )
|
||||
fprintf( fp, "%3i \"%s\" %i\n", i, bone->name, bone->parent );
|
||||
}
|
||||
|
||||
fputs( "end\n", fp );
|
||||
}
|
||||
@@ -193,15 +202,13 @@ WriteSkeleton
|
||||
static void WriteSkeleton( FILE *fp )
|
||||
{
|
||||
int i, j;
|
||||
mstudiobone_t *bone;
|
||||
mstudiobone_t *bone = (mstudiobone_t *)( (byte *)model_hdr + model_hdr->boneindex );
|
||||
|
||||
fputs( "skeleton\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 );
|
||||
|
||||
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 )
|
||||
{
|
||||
int i, indices[3];
|
||||
int vert_index;
|
||||
int norm_index;
|
||||
int bone_index;
|
||||
float s, t, u, v;
|
||||
byte *vertbone;
|
||||
vec3_t *studioverts;
|
||||
vec3_t *studionorms;
|
||||
vec3_t vert, norm;
|
||||
|
||||
if( isevenstrip )
|
||||
{
|
||||
indices[0] = 1;
|
||||
indices[1] = 2;
|
||||
indices[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
indices[0] = 0;
|
||||
indices[1] = 1;
|
||||
indices[2] = 2;
|
||||
}
|
||||
int i, j, k, l, index;
|
||||
int vert_index;
|
||||
int norm_index;
|
||||
int bone_index;
|
||||
int valid_bones;
|
||||
float s, t, u, v;
|
||||
byte *vertbone;
|
||||
vec3_t *studioverts;
|
||||
vec3_t *studionorms;
|
||||
vec3_t vert, norm;
|
||||
float weights[MAXSTUDIOBONEWEIGHTS], oldweight, totalweight;
|
||||
matrix3x4 bonematrix[MAXSTUDIOBONEWEIGHTS], skinmatrix, *pskinmatrix;
|
||||
mstudioboneweight_t *studioboneweights;
|
||||
|
||||
vertbone = ( (byte *)model_hdr + model->vertinfoindex );
|
||||
studioverts = (vec3_t *)( (byte *)model_hdr + model->vertindex );
|
||||
studionorms = (vec3_t *)( (byte *)model_hdr + model->normindex );
|
||||
studioboneweights = (mstudioboneweight_t *)( (byte *)model_hdr + model->blendvertinfoindex );
|
||||
|
||||
s = 1.0f / texture->width;
|
||||
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++ )
|
||||
{
|
||||
vert_index = triverts[indices[i]]->vertindex;
|
||||
norm_index = triverts[indices[i]]->normindex;
|
||||
index = isevenstrip ? ( i + 1 ) % 3 : i;
|
||||
vert_index = triverts[index]->vertindex;
|
||||
norm_index = triverts[index]->normindex;
|
||||
bone_index = vertbone[vert_index];
|
||||
|
||||
Matrix3x4_VectorTransform( bonetransform[bone_index], studioverts[vert_index], vert );
|
||||
Matrix3x4_VectorRotate( bonetransform[bone_index], studionorms[norm_index], norm );
|
||||
if( model_hdr->flags & STUDIO_HAS_BONEWEIGHTS )
|
||||
{
|
||||
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 );
|
||||
|
||||
if( texture->flags & STUDIO_NF_UV_COORDS )
|
||||
{
|
||||
u = HalfToFloat( triverts[indices[i]]->s );
|
||||
v = -HalfToFloat( triverts[indices[i]]->t );
|
||||
u = HalfToFloat( triverts[index]->s );
|
||||
v = -HalfToFloat( triverts[index]->t );
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ( triverts[indices[i]]->s + 1.0f ) * s;
|
||||
v = 1.0f - triverts[indices[i]]->t * t;
|
||||
u = ( triverts[index]->s + 1.0f ) * s;
|
||||
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,
|
||||
vert[0], vert[1], vert[2],
|
||||
norm[0], norm[1], norm[2],
|
||||
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 )
|
||||
{
|
||||
int i, j, k;
|
||||
mstudiomesh_t *mesh;
|
||||
mstudiomesh_t *mesh = (mstudiomesh_t *)( (byte *)model_hdr + model->meshindex );
|
||||
mstudiotexture_t *texture;
|
||||
mstudiotrivert_t *triverts[3];
|
||||
short *tricmds;
|
||||
|
||||
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 );
|
||||
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 )
|
||||
{
|
||||
int i, j;
|
||||
float scale;
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
if( bone->parent == -1 )
|
||||
{
|
||||
for( j = 0; j < 3; j++ )
|
||||
motion[j] += frame * 1.0f / seqdesc->numframes * seqdesc->linearmovement[j];
|
||||
scale = frame / (float)( seqdesc->numframes - 1 );
|
||||
|
||||
VectorMA( motion, scale, seqdesc->linearmovement, motion );
|
||||
|
||||
ProperBoneRotationZ( motion, 270.0f );
|
||||
}
|
||||
@@ -449,19 +493,27 @@ static void WriteReferences( void )
|
||||
char name[64];
|
||||
char filename[MAX_SYSPATH];
|
||||
|
||||
if( !CreateBoneTransformMatrices() )
|
||||
if( !CreateBoneTransformMatrices( &bonetransform ) )
|
||||
return;
|
||||
|
||||
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 );
|
||||
|
||||
for( j = 0; j < bodypart->nummodels; ++j, ++model )
|
||||
{
|
||||
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex ) + j;
|
||||
|
||||
if( !Q_strncmp( model->name, "blank", 5 ) )
|
||||
continue;
|
||||
|
||||
@@ -472,8 +524,7 @@ static void WriteReferences( void )
|
||||
if( len == -1 )
|
||||
{
|
||||
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", name );
|
||||
RemoveBoneTransformMatrices();
|
||||
return;
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
fp = fopen( filename, "w" );
|
||||
@@ -481,8 +532,7 @@ static void WriteReferences( void )
|
||||
if( !fp )
|
||||
{
|
||||
fprintf( stderr, "ERROR: Can't write %s\n", filename );
|
||||
RemoveBoneTransformMatrices();
|
||||
return;
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
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;
|
||||
FILE *fp;
|
||||
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++ )
|
||||
{
|
||||
if( seqdesc->numblends == 1 )
|
||||
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.smd", destdir, seqdesc->label );
|
||||
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 )
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ static void WriteBMP( mstudiotexture_t *texture )
|
||||
int i, len;
|
||||
FILE *fp;
|
||||
const byte *p;
|
||||
byte *palette, *pic, *buf;
|
||||
byte *palette, *pic;
|
||||
char filename[MAX_SYSPATH], texturename[64];
|
||||
rgba_t rgba_palette[256];
|
||||
bmp_t bmp_hdr = {0,};
|
||||
@@ -87,23 +87,17 @@ static void WriteBMP( mstudiotexture_t *texture )
|
||||
|
||||
fwrite( rgba_palette, sizeof( rgba_palette ), 1, fp );
|
||||
|
||||
buf = malloc( texture_size );
|
||||
|
||||
p = pic;
|
||||
p += ( bmp_hdr.height - 1 ) * bmp_hdr.width;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
fwrite( buf, texture_size, 1, fp );
|
||||
|
||||
fclose( fp );
|
||||
|
||||
free( buf );
|
||||
|
||||
printf( "Texture: %s\n", filename );
|
||||
}
|
||||
|
||||
@@ -115,13 +109,9 @@ WriteTextures
|
||||
void WriteTextures( void )
|
||||
{
|
||||
int i;
|
||||
mstudiotexture_t *texture;
|
||||
|
||||
for( i = 0; i < texture_hdr->numtextures; i++ )
|
||||
{
|
||||
texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ) + i;
|
||||
mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
|
||||
|
||||
for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
|
||||
WriteBMP( texture );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
3
wscript
3
wscript
@@ -90,6 +90,7 @@ SUBDIRS = [
|
||||
|
||||
# enabled on PSVita only
|
||||
Subproject('ref/gl/vgl_shim', lambda x: x.env.DEST_OS == 'psvita'),
|
||||
|
||||
]
|
||||
|
||||
REFDLLS = [
|
||||
@@ -98,6 +99,7 @@ REFDLLS = [
|
||||
RefDll('gles1', False, 'NANOGL'),
|
||||
RefDll('gles2', False, 'GLWES'),
|
||||
RefDll('gl4es', False),
|
||||
RefDll('gles3compat', False),
|
||||
]
|
||||
|
||||
def options(opt):
|
||||
@@ -294,6 +296,7 @@ def configure(conf):
|
||||
# '-Werror=format=2',
|
||||
'-Werror=implicit-fallthrough=2',
|
||||
'-Werror=logical-op',
|
||||
'-Werror=nonnull',
|
||||
'-Werror=packed',
|
||||
'-Werror=packed-not-aligned',
|
||||
'-Werror=parentheses',
|
||||
|
||||
Reference in New Issue
Block a user