20 Sep 2016

This commit is contained in:
g-cont 2016-09-20 00:00:00 +03:00 committed by Alibek Omarov
parent 1c8fe772e3
commit e949102115
21 changed files with 4200 additions and 808 deletions

View File

@ -216,7 +216,8 @@ typedef struct
{
float vecs[2][4]; // texmatrix [s/t][xyz offset]
int miptex;
int flags;
short flags;
short groupid;
} dtexinfo_t;
typedef word dmarkface_t; // leaf marksurfaces indexes

View File

@ -89,7 +89,8 @@ typedef struct
// s or t = dot( 3Dpoint, vecs[i] ) + vecs[i][3]
float mipadjust; // mipmap limits for very small surfaces
texture_t *texture;
int flags; // sky or slime, no lightmap or 256 subdivision
short flags; // sky or slime, no lightmap or 256 subdivision
short groupid;
} mtexinfo_t;
// 73 bytes per VBO vertex

View File

@ -44,7 +44,7 @@ GNU General Public License for more details.
#define PARM_TEX_TARGET 8
#define PARM_TEX_TEXNUM 9
#define PARM_TEX_FLAGS 10
#define PARM_TEX_TYPE 11
#define PARM_TEX_DEPTH 11 // 3D texture depth or 2D array num layers
#define PARM_TEX_CACHEFRAME 12 // compare with worldmodel->needload
#define PARM_TEX_GLFORMAT 13 // get a texture GL-format
#define PARM_TEX_ENCODE 14 // custom encoding for DXT image
@ -78,25 +78,6 @@ enum
SKYBOX_DOWN,
};
typedef enum
{
TEX_INVALID = 0, // free slot
TEX_SYSTEM, // generated by engine
TEX_NOMIP, // hud pics, menu etc
TEX_BRUSH, // a map texture
TEX_SPRITE, // sprite frames
TEX_STUDIO, // studio skins
TEX_LIGHTMAP, // lightmap textures
TEX_DECAL, // decals
TEX_VGUI, // vgui fonts or images
TEX_CUBEMAP, // cubemap textures (sky)
TEX_DETAIL, // detail textures
TEX_REMAP, // local copy of remap texture
TEX_SCREENCOPY, // keep screen copy e.g. for mirror
TEX_CUSTOM, // user created texture
TEX_DEPTHMAP // shadowmap texture
} texType_t;
typedef enum
{
TF_NEAREST = (1<<0), // disable texfilter
@ -120,14 +101,13 @@ typedef enum
TF_TEXTURE_1D = (1<<18), // this is GL_TEXTURE_1D
TF_BORDER = (1<<19), // zero clamp for projected textures
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
TF_STATIC = (1<<21), // a marker for purge mechanism (not used by engine)
TF_STATIC = (1<<21), // obsolete (not used)
TF_TEXTURE_RECTANGLE= (1<<22), // this is GL_TEXTURE_RECTANGLE
TF_ALPHA_BORDER = (1<<23), // clamp to (0,0,0,255) (probably no difference)
TF_ALPHACONTRAST = (1<<25), // special texture flags for internal usage
TF_FLOAT = (1<<26), // float textures
TF_TEXTURE_2D_ARRAY = (1<<24), // this is 2D texture array (multi-layers)
TF_IMG_UPLOADED = (1<<25), // this is set for first time when called glTexImage, otherwise it will be call glTexSubImage
TF_ARB_FLOAT = (1<<26), // float textures
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
TF_FLOATDATA = (1<<28), // incoming dataType has type GL_FLOAT
} texFlags_t;
typedef struct beam_s BEAM;
@ -185,7 +165,7 @@ typedef struct render_api_s
const byte* (*GL_TextureData)( unsigned int texnum ); // may be NULL
int (*GL_LoadTexture)( const char *name, const byte *buf, size_t size, int flags );
int (*GL_CreateTexture)( const char *name, int width, int height, const void *buffer, int flags );
void (*GL_SetTextureType)( unsigned int texnum, unsigned int type );
int (*GL_LoadTextureArray)( const char **names, int flags );
void (*GL_TextureCacheFrame)( unsigned int texnum );
void (*GL_FreeTexture)( unsigned int texnum );

View File

@ -127,7 +127,6 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor );
ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR, NULL ); // do copy
GL_SetTextureType( ptexture->index, TEX_REMAP );
// restore original palette
Q_memcpy( pal, paletteBackup, 768 );

View File

@ -235,6 +235,29 @@ typedef float GLmatrix[16];
#define GL_PROXY_TEXTURE_2D 0x8064
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_RG 0x8227
#define GL_RG_INTEGER 0x8228
#define GL_R8 0x8229
#define GL_R16 0x822A
#define GL_RG8 0x822B
#define GL_RG16 0x822C
#define GL_R16F 0x822D
#define GL_R32F 0x822E
#define GL_RG16F 0x822F
#define GL_RG32F 0x8230
#define GL_R8I 0x8231
#define GL_R8UI 0x8232
#define GL_R16I 0x8233
#define GL_R16UI 0x8234
#define GL_R32I 0x8235
#define GL_R32UI 0x8236
#define GL_RG8I 0x8237
#define GL_RG8UI 0x8238
#define GL_RG16I 0x8239
#define GL_RG16UI 0x823A
#define GL_RG32I 0x823B
#define GL_RG32UI 0x823C
// texture coord name
#define GL_S 0x2000
#define GL_T 0x2001
@ -614,6 +637,15 @@ typedef float GLmatrix[16];
#define GL_DOT3_RGB_ARB 0x86AE
#define GL_DOT3_RGBA_ARB 0x86AF
#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19
#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B
#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C
#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D
#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E
#define GL_MULTISAMPLE_ARB 0x809D
#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F

File diff suppressed because it is too large Load Diff

3248
engine/client/gl_image.old Normal file

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,7 @@ typedef struct gltexture_s
word srcHeight;
word width; // upload width\height
word height;
word depth; // texture depth or count of layers for 2D_ARRAY
byte numMips; // mipmap count
uint cacheframe; // worldmodel->load_sequence
@ -79,7 +80,6 @@ typedef struct gltexture_s
rgbdata_t *original; // keep original image
// debug info
byte texType; // used for gl_showtextures
size_t size; // upload size for debug targets
// detail textures stuff
@ -162,7 +162,6 @@ typedef struct
int whiteTexture;
int grayTexture;
int blackTexture;
int acontTexture;
int defaultTexture; // use for bad textures
int particleTexture; // particle texture
int particleTexture2; // unsmoothed particle texture
@ -303,8 +302,8 @@ void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height,
//
void R_SetTextureParameters( void );
gltexture_t *R_GetTexture( GLenum texnum );
void GL_SetTextureType( GLenum texnum, GLenum type );
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter );
int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter );
int GL_LoadTextureInternal( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update );
byte *GL_ResampleTexture( const byte *source, int in_w, int in_h, int out_w, int out_h, qboolean isNormalMap );
int GL_CreateTexture( const char *name, int width, int height, const void *buffer, texFlags_t flags );
@ -508,6 +507,8 @@ enum
GL_SGIS_MIPMAPS_EXT,
GL_DRAW_RANGEELEMENTS_EXT,
GL_LOCKARRAYS_EXT,
GL_TEXTURE_2D_RECT_EXT,
GL_TEXTURE_ARRAY_EXT,
GL_TEXTURE_3D_EXT,
GL_CLAMPTOEDGE_EXT,
GL_BLEND_MINMAX_EXT,
@ -556,6 +557,7 @@ typedef struct
int max_teximage_units;
GLint max_2d_texture_size;
GLint max_2d_rectangle_size;
GLint max_2d_texture_layers;
GLint max_3d_texture_size;
GLint max_cubemap_size;
GLint texRectangle;

View File

@ -160,7 +160,6 @@ int R_AllocateMirrorTexture( void )
r_screen.flags = IMAGE_HAS_COLOR;
r_screen.buffer = NULL; // create empty texture for now
tr.mirrorTextures[i] = GL_LoadTextureInternal( txName, &r_screen, TF_IMAGE, false );
GL_SetTextureType( tr.mirrorTextures[i], TEX_SCREENCOPY );
texture = tr.mirrorTextures[i];
}

View File

@ -1412,6 +1412,9 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_TEX_MIPCOUNT:
glt = R_GetTexture( arg );
return glt->numMips;
case PARM_TEX_DEPTH:
glt = R_GetTexture( arg );
return glt->depth;
case PARM_TEX_SKYBOX:
ASSERT( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];
@ -1458,9 +1461,6 @@ static int GL_RenderGetParm( int parm, int arg )
return glt->cacheframe;
case PARM_MAP_HAS_DELUXE:
return (world.deluxedata != NULL);
case PARM_TEX_TYPE:
glt = R_GetTexture( arg );
return glt->texType;
case PARM_CACHEFRAME:
return world.load_sequence;
case PARM_MAX_IMAGE_UNITS:
@ -1609,6 +1609,11 @@ static int GL_LoadTextureNoFilter( const char *name, const byte *buf, size_t siz
return GL_LoadTexture( name, buf, size, flags, NULL );
}
static int GL_LoadTextureArrayNoFilter( const char **names, int flags )
{
return GL_LoadTextureArray( names, flags, NULL );
}
static const ref_overview_t *GL_GetOverviewParms( void )
{
return &clgame.overView;
@ -1667,7 +1672,7 @@ static render_api_t gRenderAPI =
GL_TextureData,
GL_LoadTextureNoFilter,
GL_CreateTexture,
GL_SetTextureType,
GL_LoadTextureArrayNoFilter,
GL_TextureUpdateCache,
GL_FreeTexture,
DrawSingleDecal,

View File

@ -291,7 +291,6 @@ void R_ParseDetailTextures( const char *filename )
{
gltexture_t *glt;
GL_SetTextureType( tex->dt_texturenum, TEX_DETAIL );
glt = R_GetTexture( tex->gl_texturenum );
glt->xscale = xScale;
glt->yscale = yScale;

View File

@ -637,7 +637,6 @@ static void LM_UploadBlock( qboolean dynamic )
r_lightmap.flags = ( world.version == Q1BSP_VERSION ) ? 0 : IMAGE_HAS_COLOR;
r_lightmap.buffer = gl_lms.lightmap_buffer;
tr.lightmapTextures[i] = GL_LoadTextureInternal( lmName, &r_lightmap, TF_FONT, false );
GL_SetTextureType( tr.lightmapTextures[i], TEX_LIGHTMAP );
if( ++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS )
Host_Error( "AllocBlock: full\n" );

View File

@ -104,8 +104,6 @@ static dframetype_t *R_SpriteLoadFrame( model_t *mod, void *pin, mspriteframe_t
pspriteframe->gl_texturenum = gl_texturenum;
*ppframe = pspriteframe;
GL_SetTextureType( pspriteframe->gl_texturenum, TEX_SPRITE );
return (dframetype_t *)((byte *)(pinframe + 1) + pinframe->width * pinframe->height );
}
@ -384,8 +382,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
pspriteframe->down = ( h >> 1 ) - h;
pspriteframe->right = w + -( w >> 1 );
pspriteframe->gl_texturenum = GL_LoadTextureInternal( texname, &temp, TF_IMAGE, false );
GL_SetTextureType( pspriteframe->gl_texturenum, TEX_NOMIP );
xl += w;
if( xl >= pix->width )
{

View File

@ -3482,7 +3482,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
{
// duplicate texnum for easy acess
if( tx ) tx->gl_texturenum = ptexture->index;
GL_SetTextureType( ptexture->index, TEX_STUDIO );
}
}

View File

@ -1602,6 +1602,8 @@ void R_RenderInfo_f( void )
Msg( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: %.1f\n", glConfig.max_texture_anisotropy );
if( glConfig.texRectangle )
Msg( "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: %i\n", glConfig.max_2d_rectangle_size );
if( GL_Support( GL_TEXTURE_ARRAY_EXT ))
Msg( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: %i\n", glConfig.max_2d_texture_layers );
if( GL_Support( GL_SHADER_GLSL100_EXT ))
{
Msg( "GL_MAX_TEXTURE_COORDS_ARB: %i\n", glConfig.max_texture_coords );
@ -1775,6 +1777,12 @@ void GL_InitExtensions( void )
}
}
// 2d texture array support
GL_CheckExtension( "GL_EXT_texture_array", texture3dextfuncs, "gl_texture_2d_array", GL_TEXTURE_ARRAY_EXT );
if( GL_Support( GL_TEXTURE_ARRAY_EXT ))
pglGetIntegerv( GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &glConfig.max_2d_texture_layers );
GL_CheckExtension( "GL_SGIS_generate_mipmap", NULL, "gl_sgis_generate_mipmaps", GL_SGIS_MIPMAPS_EXT );
// hardware cubemaps
@ -1846,6 +1854,9 @@ void GL_InitExtensions( void )
// occlusion queries
GL_CheckExtension( "GL_ARB_occlusion_query", occlusionfunc, "gl_occlusion_queries", GL_OCCLUSION_QUERIES_EXT );
// rectangle textures support
GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT );
if( GL_Support( GL_SHADER_GLSL100_EXT ))
{
pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords );

View File

@ -462,7 +462,6 @@ void R_SetupSky( const char *skyboxname )
{
Q_snprintf( sidename, sizeof( sidename ), "%s%s", loadname, r_skyBoxSuffix[i] );
tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY, NULL );
GL_SetTextureType( tr.skyboxTextures[i], TEX_CUBEMAP );
if( !tr.skyboxTextures[i] ) break;
}
@ -475,7 +474,6 @@ void R_SetupSky( const char *skyboxname )
{
Q_snprintf( sidename, sizeof( sidename ), "%s_%s", loadname, r_skyBoxSuffix[i] );
tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY, NULL );
GL_SetTextureType( tr.skyboxTextures[i], TEX_CUBEMAP );
if( !tr.skyboxTextures[i] ) break;
}
if( i == 6 ) return; // loaded
@ -757,9 +755,6 @@ void R_InitSky( mip_t *mt, texture_t *tx )
// load it in
tr.alphaskyTexture = GL_LoadTextureInternal( "alpha_sky", &r_temp, TF_UNCOMPRESSED|TF_NOMIPMAP, false );
GL_SetTextureType( tr.solidskyTexture, TEX_BRUSH );
GL_SetTextureType( tr.alphaskyTexture, TEX_BRUSH );
// clean up
FS_FreeImage( r_sky );
Mem_Free( trans );

View File

@ -98,7 +98,6 @@ void VGUI_UploadTexture( int id, const char *buffer, int width, int height )
r_image.buffer = (byte *)buffer;
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE, false );
GL_SetTextureType( g_textures[id], TEX_VGUI );
g_iBoundTexture = id;
}
@ -131,7 +130,6 @@ void VGUI_CreateTexture( int id, int width, int height )
r_image.buffer = NULL;
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE|TF_NEAREST, false );
GL_SetTextureType( g_textures[id], TEX_VGUI );
g_iBoundTexture = id;
}

View File

@ -426,6 +426,7 @@ 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)
typedef enum
@ -485,6 +486,7 @@ typedef enum
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_Process manipulation flags
IMAGE_FLIP_X = BIT(16), // flip the image by width

View File

@ -57,6 +57,10 @@ GNU General Public License for more details.
#define STUDIO_TO_RAD (M_PI / 32768.0)
#define nanmask (255<<23)
#define INV127F ( 1.0f / 127.0f )
#define INV255F ( 1.0f / 255.0f )
#define MAKE_SIGNED( x ) ((( x ) * INV127F ) - 1.0f )
#define Q_rint(x) ((x) < 0 ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)

View File

@ -744,7 +744,6 @@ static void Mod_LoadTextures( const dlump_t *l )
if( load_external )
{
tr.solidskyTexture = GL_LoadTexture( texname, NULL, 0, TF_UNCOMPRESSED|TF_NOMIPMAP, NULL );
GL_SetTextureType( tr.solidskyTexture, TEX_BRUSH );
load_external = false;
}
@ -766,7 +765,6 @@ static void Mod_LoadTextures( const dlump_t *l )
if( load_external )
{
tr.alphaskyTexture = GL_LoadTexture( texname, NULL, 0, TF_UNCOMPRESSED|TF_NOMIPMAP, NULL );
GL_SetTextureType( tr.alphaskyTexture, TEX_BRUSH );
load_external = false;
}
}
@ -918,13 +916,6 @@ static void Mod_LoadTextures( const dlump_t *l )
}
}
}
if( tx->gl_texturenum != tr.defaultTexture )
{
// apply texture type (just for debug)
GL_SetTextureType( tx->gl_texturenum, TEX_BRUSH );
GL_SetTextureType( tx->fb_texturenum, TEX_BRUSH );
}
}
// sequence the animations
@ -1113,6 +1104,7 @@ static void Mod_LoadTexInfo( const dlump_t *l )
out->texture = loadmodel->textures[miptex];
out->flags = in->flags;
out->groupid = in->groupid;
}
}

View File

@ -61,9 +61,16 @@ TargetDir=\Xash3D\src_main\temp\engine\!release
InputPath=\Xash3D\src_main\temp\engine\!release\xash.dll
SOURCE="$(InputPath)"
"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll"
BuildCmds= \
copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll" \
copy $(TargetDir)\xash.dll "D:\Paranoia2\xash.dll" \
"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"D:\Paranoia2\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "engine - Win32 Debug"
@ -98,9 +105,16 @@ TargetDir=\Xash3D\src_main\temp\engine\!debug
InputPath=\Xash3D\src_main\temp\engine\!debug\xash.dll
SOURCE="$(InputPath)"
"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll"
BuildCmds= \
copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll" \
copy $(TargetDir)\xash.dll "D:\Paranoia2\xash.dll" \
"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"D:\Paranoia2\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ENDIF