Skip to content

Commit

Permalink
Merge branch '0.20-renderdll'
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Mar 22, 2019
2 parents 6a6f341 + 743c5ca commit 1483b21
Show file tree
Hide file tree
Showing 109 changed files with 8,199 additions and 7,875 deletions.
1 change: 1 addition & 0 deletions common/backends.h
Expand Up @@ -18,6 +18,7 @@ GNU General Public License for more details.
#define BACKENDS_H

// video backends (XASH_VIDEO)
#define VIDEO_DONTCARE -1 // a special mode for ref_dll
#define VIDEO_NULL 0
#define VIDEO_SDL 1
#define VIDEO_ANDROID 2
Expand Down
109 changes: 109 additions & 0 deletions common/com_image.h
@@ -0,0 +1,109 @@
#pragma once
/*
========================================================================
internal image format
typically expanded to rgba buffer
NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 == PF_RGB_888
========================================================================
*/
#define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24)
#define ImageDXT( type ) (type == PF_DXT1 || type == PF_DXT3 || type == PF_DXT5 || type == PF_ATI2)

typedef enum
{
PF_UNKNOWN = 0,
PF_INDEXED_24, // inflated palette (768 bytes)
PF_INDEXED_32, // deflated palette (1024 bytes)
PF_RGBA_32, // normal rgba buffer
PF_BGRA_32, // big endian RGBA (MacOS)
PF_RGB_24, // uncompressed dds or another 24-bit image
PF_BGR_24, // big-endian RGB (MacOS)
PF_DXT1, // s3tc DXT1 format
PF_DXT3, // s3tc DXT3 format
PF_DXT5, // s3tc DXT5 format
PF_ATI2, // latc ATI2N format
PF_TOTALCOUNT, // must be last
} pixformat_t;

typedef struct bpc_desc_s
{
int format; // pixelformat
char name[16]; // used for debug
uint glFormat; // RGBA format
int bpp; // channels (e.g. rgb = 3, rgba = 4)
} bpc_desc_t;

// imagelib global settings
typedef enum
{
IL_USE_LERPING = BIT(0), // lerping images during resample
IL_KEEP_8BIT = BIT(1), // don't expand paletted images
IL_ALLOW_OVERWRITE = BIT(2), // allow to overwrite stored images
IL_DONTFLIP_TGA = BIT(3), // Steam background completely ignore tga attribute 0x20 (stupid lammers!)
IL_DDS_HARDWARE = BIT(4), // DXT compression is support
IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals
IL_OVERVIEW = BIT(6), // overview required some unque operations
} ilFlags_t;

// goes into rgbdata_t->encode
#define DXT_ENCODE_DEFAULT 0 // don't use custom encoders
#define DXT_ENCODE_COLOR_YCoCg 0x1A01 // make sure that value dosn't collide with anything
#define DXT_ENCODE_ALPHA_1BIT 0x1A02 // normal 1-bit alpha
#define DXT_ENCODE_ALPHA_8BIT 0x1A03 // normal 8-bit alpha
#define DXT_ENCODE_ALPHA_SDF 0x1A04 // signed distance field
#define DXT_ENCODE_NORMAL_AG_ORTHO 0x1A05 // orthographic projection
#define DXT_ENCODE_NORMAL_AG_STEREO 0x1A06 // stereographic projection
#define DXT_ENCODE_NORMAL_AG_PARABOLOID 0x1A07 // paraboloid projection
#define DXT_ENCODE_NORMAL_AG_QUARTIC 0x1A08 // newton method
#define DXT_ENCODE_NORMAL_AG_AZIMUTHAL 0x1A09 // Lambert Azimuthal Equal-Area

// rgbdata output flags
typedef enum
{
// rgbdata->flags
IMAGE_CUBEMAP = BIT(0), // it's 6-sides cubemap buffer
IMAGE_HAS_ALPHA = BIT(1), // image contain alpha-channel
IMAGE_HAS_COLOR = BIT(2), // image contain RGB-channel
IMAGE_COLORINDEX = BIT(3), // all colors in palette is gradients of last color (decals)
IMAGE_HAS_LUMA = BIT(4), // image has luma pixels (q1-style maps)
IMAGE_SKYBOX = BIT(5), // only used by FS_SaveImage - for write right suffixes
IMAGE_QUAKESKY = BIT(6), // it's a quake sky double layered clouds (so keep it as 8 bit)
IMAGE_DDS_FORMAT = BIT(7), // a hint for GL loader
IMAGE_MULTILAYER = BIT(8), // to differentiate from 3D texture
IMAGE_ONEBIT_ALPHA = BIT(9), // binary alpha
IMAGE_QUAKEPAL = BIT(10), // image has quake1 palette

// Image_Process manipulation flags
IMAGE_FLIP_X = BIT(16), // flip the image by width
IMAGE_FLIP_Y = BIT(17), // flip the image by height
IMAGE_ROT_90 = BIT(18), // flip from upper left corner to down right corner
IMAGE_ROT180 = IMAGE_FLIP_X|IMAGE_FLIP_Y,
IMAGE_ROT270 = IMAGE_FLIP_X|IMAGE_FLIP_Y|IMAGE_ROT_90,
IMAGE_EMBOSS = BIT(19), // apply emboss mapping
IMAGE_RESAMPLE = BIT(20), // resample image to specified dims
// reserved
// reserved
IMAGE_FORCE_RGBA = BIT(23), // force image to RGBA buffer
IMAGE_MAKE_LUMA = BIT(24), // create luma texture from indexed
IMAGE_QUANTIZE = BIT(25), // make indexed image from 24 or 32- bit image
IMAGE_LIGHTGAMMA = BIT(26), // apply gamma for image
IMAGE_REMAP = BIT(27), // interpret width and height as top and bottom color
} imgFlags_t;

typedef struct rgbdata_s
{
word width; // image width
word height; // image height
word depth; // image depth
uint type; // compression type
uint flags; // misc image flags
word encode; // DXT may have custom encoder, that will be decoded in GLSL-side
byte numMips; // mipmap count
byte *palette; // palette if present
byte *buffer; // image buffer
rgba_t fogParams; // some water textures in hl1 has info about fog color and alpha
size_t size; // for bounds checking
} rgbdata_t;

34 changes: 33 additions & 1 deletion common/com_model.h
Expand Up @@ -495,4 +495,36 @@ typedef struct
maliasframedesc_t frames[1]; // variable sized
} aliashdr_t;

#endif//COM_MODEL_H


// remapping info
#define SUIT_HUE_START 192
#define SUIT_HUE_END 223
#define PLATE_HUE_START 160
#define PLATE_HUE_END 191

#define SHIRT_HUE_START 16
#define SHIRT_HUE_END 32
#define PANTS_HUE_START 96
#define PANTS_HUE_END 112


// 1/32 epsilon to keep floating point happy
#define DIST_EPSILON (1.0f / 32.0f)
#define FRAC_EPSILON (1.0f / 1024.0f)
#define BACKFACE_EPSILON 0.01f
#define MAX_BOX_LEAFS 256
#define ANIM_CYCLE 2
#define MOD_FRAMES 20



#define MAX_DEMOS 32
#define MAX_MOVIES 8
#define MAX_CDTRACKS 32
#define MAX_CLIENT_SPRITES 256 // SpriteTextures
#define MAX_EFRAGS 8192 // Arcane Dimensions required
#define MAX_REQUESTS 64


#endif//COM_MODEL_H
10 changes: 9 additions & 1 deletion common/defaults.h
Expand Up @@ -95,7 +95,11 @@ SETUP BACKENDS DEFINITIONS
// fallback to NULL
//
#ifndef XASH_VIDEO
#define XASH_VIDEO VIDEO_NULL
#ifdef REF_DLL
#define XASH_VIDEO VIDEO_DONTCARE
#else
#define XASH_VIDEO VIDEO_NULL
#endif
#endif

#ifndef XASH_SOUND
Expand Down Expand Up @@ -150,6 +154,10 @@ Default build-depended cvar and constant values
#define DEFAULT_FULLSCREEN 1
#endif

#ifndef DEFAULT_RENDERER
#define DEFAULT_RENDERER "ref_gl"
#endif

#if TARGET_OS_IPHONE
#define DEFAULT_CON_MAXFRAC "0.5"
#else
Expand Down
10 changes: 10 additions & 0 deletions common/port.h
Expand Up @@ -54,6 +54,8 @@ GNU General Public License for more details.
#define OPEN_COMMAND "xdg-open"
#endif

#define OS_LIB_PREFIX "lib"

#if defined(__ANDROID__)
#if defined(LOAD_HARDFP)
#define POSTFIX "_hardfp"
Expand All @@ -78,6 +80,7 @@ GNU General Public License for more details.
#define __stdcall

#define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#define O_BINARY 0 // O_BINARY is Windows extension
#define O_TEXT 0 // O_TEXT is Windows extension

Expand Down Expand Up @@ -113,6 +116,9 @@ GNU General Public License for more details.
#else // WIN32
#ifdef __MINGW32__
#define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#else
#define FORCEINLINE __forceinline
#endif

#define strcasecmp _stricmp
Expand Down Expand Up @@ -156,4 +162,8 @@ GNU General Public License for more details.
#define USHRT_MAX 65535
#endif

#ifdef XASH_SDL
#include <SDL.h>
#endif

#endif // PORT_H
1 change: 1 addition & 0 deletions common/r_efx.h
Expand Up @@ -85,6 +85,7 @@ color24 gTracerColors[] =
#define FTENT_SCALE 0x00100000 // An experiment

typedef struct tempent_s TEMPENTITY;
struct pmtrace_s;
typedef struct tempent_s
{
int flags;
Expand Down
5 changes: 3 additions & 2 deletions common/render_api.h
Expand Up @@ -235,7 +235,8 @@ typedef struct render_api_s
float (*pfnTime)( void ); // Sys_DoubleTime
void (*Cvar_Set)( const char *name, const char *value );
void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents)
void (*SetRandomSeed)( long lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random
// a1ba: changed long to int
void (*SetRandomSeed)( int lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 37
} render_api_t;

Expand All @@ -254,7 +255,7 @@ typedef struct render_interface_s
// clear decals by engine request (e.g. for demo recording or vid_restart)
void (*R_ClearStudioDecals)( void );
// grab r_speeds message
qboolean (*R_SpeedsMessage)( char *out, size_t size );
qboolean (*R_SpeedsMessage)( char *out, size_t size );
// alloc or destroy model custom data
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
// alloc or destroy entity custom data
Expand Down
117 changes: 117 additions & 0 deletions common/xash3d_types.h
@@ -1,6 +1,13 @@
// basic typedefs
#ifndef XASH_TYPES_H
#define XASH_TYPES_H

#ifdef _WIN32
#include <wchar.h> // off_t
#endif // _WIN32

#include <sys/types.h> // off_t

typedef unsigned char byte;
typedef int sound_t;
typedef float vec_t;
Expand Down Expand Up @@ -30,4 +37,114 @@ typedef Uint64 integer64;
typedef unsigned long long integer64;
#endif
typedef integer64 longtime_t;

#define MAX_STRING 256 // generic string
#define MAX_INFO_STRING 256 // infostrings are transmitted across network
#define MAX_SERVERINFO_STRING 512 // server handles too many settings. expand to 1024?
#define MAX_LOCALINFO_STRING 32768 // localinfo used on server and not sended to the clients
#define MAX_SYSPATH 1024 // system filepath
#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Con_Printf or Con_DPrintf
#define MAX_TOKEN 2048 // parse token length
#define MAX_MODS 512 // environment games that engine can keep visible
#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions

#define BIT( n ) ( 1 << ( n ))
#define GAMMA ( 2.2 ) // Valve Software gamma
#define INVGAMMA ( 1.0 / 2.2 ) // back to 1.0
#define TEXGAMMA ( 0.9 ) // compensate dim textures
#define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))

#ifndef __cplusplus
#ifdef NULL
#undef NULL
#endif

#define NULL ((void *)0)
#endif

// color strings
#define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' )
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )

#if defined(__GNUC__)
#ifdef __i386__
#define EXPORT __attribute__ ((visibility ("default"),force_align_arg_pointer))
#define GAME_EXPORT __attribute((force_align_arg_pointer))
#else
#define EXPORT __attribute__ ((visibility ("default")))
#define GAME_EXPORT
#endif
#elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#else
#define EXPORT
#define GAME_EXPORT
#endif


#ifdef XASH_BIG_ENDIAN
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))
#define LittleLongSW(x) (x = LittleLong(x) )
#define LittleShort(x) ((short)( (((short)(x) >> 8) & 255) + (((short)(x) & 255) << 8)))
#define LittleShortSW(x) (x = LittleShort(x) )
_inline float LittleFloat( float f )
{
union
{
float f;
unsigned char b[4];
} dat1, dat2;

dat1.f = f;
dat2.b[0] = dat1.b[3];
dat2.b[1] = dat1.b[2];
dat2.b[2] = dat1.b[1];
dat2.b[3] = dat1.b[0];

return dat2.f;
}
#else
#define LittleLong(x) (x)
#define LittleLongSW(x)
#define LittleShort(x) (x)
#define LittleShortSW(x)
#define LittleFloat(x) (x)
#endif


typedef unsigned int dword;
typedef unsigned int uint;
typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file
typedef struct wfile_s wfile_t; // wad file
typedef struct stream_s stream_t; // sound stream for background music playing
typedef off_t fs_offset_t;

typedef struct dllfunc_s
{
const char *name;
void **func;
} dllfunc_t;

typedef struct dll_info_s
{
const char *name; // name of library
const dllfunc_t *fcts; // list of dll exports
qboolean crash; // crash if dll not found
void *link; // hinstance of loading library
} dll_info_t;

typedef void (*setpair_t)( const char *key, const char *value, void *buffer, void *numpairs );

// config strings are a general means of communication from
// the server to all connected clients.
// each config string can be at most CS_SIZE characters.
#define MAX_QPATH 64 // max length of a game pathname
#define MAX_OSPATH 260 // max length of a filesystem pathname
#define CS_SIZE 64 // size of one config string
#define CS_TIME 16 // size of time string

#endif // XASH_TYPES_H
1 change: 0 additions & 1 deletion engine/client/avi/avi_win.c
Expand Up @@ -16,7 +16,6 @@ GNU General Public License for more details.
#ifdef _WIN32
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include <vfw.h> // video for windows

// msvfw32.dll exports
Expand Down

0 comments on commit 1483b21

Please sign in to comment.