08 Dec 2013
This commit is contained in:
parent
ddf4f3d27a
commit
5d1310364a
|
@ -27,7 +27,7 @@ GNU General Public License for more details.
|
|||
// move misc functions at end of the interface
|
||||
// added new export for clearing studio decals
|
||||
|
||||
#define CL_RENDER_INTERFACE_VERSION 30
|
||||
#define CL_RENDER_INTERFACE_VERSION 31
|
||||
#define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals
|
||||
|
||||
#define SURF_INFO( surf, mod ) ((mextrasurf_t *)mod->cache.data + (surf - mod->surfaces))
|
||||
|
@ -197,13 +197,18 @@ typedef struct render_api_s
|
|||
int (*AVI_IsActive)( void *Avi );
|
||||
|
||||
// glState related calls (must use this instead of normal gl-calls to prevent de-synchornize local states between engine and the client)
|
||||
void (*GL_Bind)( unsigned int tmu, unsigned int texnum );
|
||||
void (*GL_SelectTexture)( unsigned int texture );
|
||||
void (*GL_Bind)( int tmu, unsigned int texnum );
|
||||
void (*GL_SelectTexture)( int tmu );
|
||||
void (*GL_LoadTextureMatrix)( const float *glmatrix );
|
||||
void (*GL_TexMatrixIdentity)( void );
|
||||
void (*GL_CleanUpTextureUnits)( int last ); // pass 0 for clear all the texture units
|
||||
void (*GL_TexGen)( unsigned int coord, unsigned int mode );
|
||||
void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
|
||||
void (*GL_TexCoordArrayMode)( unsigned int texmode );
|
||||
void (*GL_Reserved0)( void ); // for potential interface expansion without broken compatibility
|
||||
void (*GL_Reserved1)( void );
|
||||
void (*GL_Reserved2)( void );
|
||||
void (*GL_Reserved3)( void );
|
||||
|
||||
// Misc renderer functions
|
||||
void (*GL_DrawParticles)( const float *vieworg, const float *fwd, const float *rt, const float *up, unsigned int clipFlags );
|
||||
|
@ -218,13 +223,12 @@ typedef struct render_api_s
|
|||
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
|
||||
wadlist_t *(*COM_GetWadsList)( void ); // returns a wadlist for the given map
|
||||
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 30
|
||||
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
// find in files
|
||||
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
|
||||
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 31
|
||||
} render_api_t;
|
||||
|
||||
// render callbacks
|
||||
|
|
|
@ -156,33 +156,33 @@ void GL_LoadIdentityTexMatrix( void )
|
|||
GL_SelectTexture
|
||||
=================
|
||||
*/
|
||||
void GL_SelectTexture( GLenum texture )
|
||||
void GL_SelectTexture( GLint tmu )
|
||||
{
|
||||
if( !GL_Support( GL_ARB_MULTITEXTURE ))
|
||||
return;
|
||||
|
||||
// don't allow negative texture units
|
||||
if((GLint)texture < 0 ) texture = 0;
|
||||
if( tmu < 0 ) return;
|
||||
|
||||
if( texture >= GL_MaxTextureUnits( ))
|
||||
if( tmu >= GL_MaxTextureUnits( ))
|
||||
{
|
||||
MsgDev( D_ERROR, "GL_SelectTexture: bad tmu state %i\n", texture );
|
||||
MsgDev( D_ERROR, "GL_SelectTexture: bad tmu state %i\n", tmu );
|
||||
return;
|
||||
}
|
||||
|
||||
if( glState.activeTMU == texture )
|
||||
if( glState.activeTMU == tmu )
|
||||
return;
|
||||
|
||||
glState.activeTMU = texture;
|
||||
glState.activeTMU = tmu;
|
||||
|
||||
if( pglActiveTextureARB )
|
||||
{
|
||||
pglActiveTextureARB( texture + GL_TEXTURE0_ARB );
|
||||
pglClientActiveTextureARB( texture + GL_TEXTURE0_ARB );
|
||||
pglActiveTextureARB( tmu + GL_TEXTURE0_ARB );
|
||||
pglClientActiveTextureARB( tmu + GL_TEXTURE0_ARB );
|
||||
}
|
||||
else if( pglSelectTextureSGIS )
|
||||
{
|
||||
pglSelectTextureSGIS( texture + GL_TEXTURE0_SGIS );
|
||||
pglSelectTextureSGIS( tmu + GL_TEXTURE0_SGIS );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,7 @@ void GL_CleanUpTextureUnits( int last )
|
|||
glState.currentTextures[i] = -1; // unbind texture
|
||||
}
|
||||
|
||||
GL_SetTexCoordArrayMode( GL_NONE );
|
||||
GL_LoadIdentityTexMatrix();
|
||||
GL_DisableAllTexGens();
|
||||
GL_SelectTexture( i - 1 );
|
||||
|
@ -297,7 +298,7 @@ void GL_TexGen( GLenum coord, GLenum mode )
|
|||
|
||||
if( mode )
|
||||
{
|
||||
if(!( glState.genSTEnabled[tmu] & bit ))
|
||||
if( !( glState.genSTEnabled[tmu] & bit ))
|
||||
{
|
||||
pglEnable( gen );
|
||||
glState.genSTEnabled[tmu] |= bit;
|
||||
|
@ -314,6 +315,34 @@ void GL_TexGen( GLenum coord, GLenum mode )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_SetTexCoordArrayMode
|
||||
=================
|
||||
*/
|
||||
void GL_SetTexCoordArrayMode( GLenum mode )
|
||||
{
|
||||
int tmu = glState.activeTMU;
|
||||
int bit, cmode = glState.texCoordArrayMode[tmu];
|
||||
|
||||
if( mode == GL_TEXTURE_COORD_ARRAY )
|
||||
bit = 1;
|
||||
else if( mode == GL_TEXTURE_CUBE_MAP_ARB )
|
||||
bit = 2;
|
||||
else bit = 0;
|
||||
|
||||
if( cmode != bit )
|
||||
{
|
||||
if( cmode == 1 ) pglDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
else if( cmode == 2 ) pglDisable( GL_TEXTURE_CUBE_MAP_ARB );
|
||||
|
||||
if( bit == 1 ) pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
else if( bit == 2 ) pglEnable( GL_TEXTURE_CUBE_MAP_ARB );
|
||||
|
||||
glState.texCoordArrayMode[tmu] = bit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_Cull
|
||||
|
|
|
@ -226,7 +226,7 @@ void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height,
|
|||
Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", rows );
|
||||
|
||||
tex = R_GetTexture( texture );
|
||||
GL_Bind( GL_TEXTURE0, texture );
|
||||
GL_Bind( GL_KEEP_UNIT, texture );
|
||||
tex->width = cols;
|
||||
tex->height = rows;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ const char *GL_Target( GLenum target )
|
|||
GL_Bind
|
||||
=================
|
||||
*/
|
||||
void GL_Bind( GLenum tmu, GLenum texnum )
|
||||
void GL_Bind( GLint tmu, GLenum texnum )
|
||||
{
|
||||
gltexture_t *texture;
|
||||
|
||||
|
@ -75,7 +75,9 @@ void GL_Bind( GLenum tmu, GLenum texnum )
|
|||
if( texnum <= 0 ) texnum = tr.defaultTexture;
|
||||
ASSERT( texnum > 0 && texnum < MAX_TEXTURES );
|
||||
|
||||
if( tmu != GL_KEEP_UNIT )
|
||||
GL_SelectTexture( tmu );
|
||||
else tmu = glState.activeTMU;
|
||||
|
||||
texture = &r_textures[texnum];
|
||||
|
||||
|
@ -90,8 +92,8 @@ void GL_Bind( GLenum tmu, GLenum texnum )
|
|||
if( glState.currentTextures[tmu] == texture->texnum )
|
||||
return;
|
||||
|
||||
glState.currentTextures[tmu] = texture->texnum;
|
||||
pglBindTexture( texture->target, texture->texnum );
|
||||
glState.currentTextures[tmu] = texture->texnum;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -253,13 +253,14 @@ extern struct particle_s *cl_free_trails;
|
|||
void GL_BackendStartFrame( void );
|
||||
void GL_BackendEndFrame( void );
|
||||
void GL_CleanUpTextureUnits( int last );
|
||||
void GL_Bind( GLenum tmu, GLenum texnum );
|
||||
void GL_Bind( GLint tmu, GLenum texnum );
|
||||
void GL_MultiTexCoord2f( GLenum texture, GLfloat s, GLfloat t );
|
||||
void GL_SetTexCoordArrayMode( GLenum mode );
|
||||
void GL_LoadTexMatrix( const matrix4x4 m );
|
||||
void GL_LoadTexMatrixExt( const float *glmatrix );
|
||||
void GL_LoadMatrix( const matrix4x4 source );
|
||||
void GL_TexGen( GLenum coord, GLenum mode );
|
||||
void GL_SelectTexture( GLenum texture );
|
||||
void GL_SelectTexture( GLint texture );
|
||||
void GL_LoadIdentityTexMatrix( void );
|
||||
void GL_DisableAllTexGens( void );
|
||||
void GL_SetRenderMode( int mode );
|
||||
|
@ -525,6 +526,7 @@ enum
|
|||
|
||||
enum
|
||||
{
|
||||
GL_KEEP_UNIT = -1,
|
||||
GL_TEXTURE0 = 0,
|
||||
GL_TEXTURE1,
|
||||
GL_TEXTURE2,
|
||||
|
@ -577,6 +579,7 @@ typedef struct
|
|||
GLuint currentTextureTargets[MAX_TEXTURE_UNITS];
|
||||
GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS];
|
||||
GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R
|
||||
GLint texCoordArrayMode[MAX_TEXTURE_UNITS]; // 0 - disabled, 1 - enabled, 2 - cubemap
|
||||
|
||||
int faceCull;
|
||||
int frontFace;
|
||||
|
|
|
@ -1671,6 +1671,11 @@ static render_api_t gRenderAPI =
|
|||
GL_CleanUpTextureUnits,
|
||||
GL_TexGen,
|
||||
GL_TextureTarget,
|
||||
GL_SetTexCoordArrayMode,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
CL_DrawParticlesExternal,
|
||||
R_EnvShot,
|
||||
COM_CompareFileTime,
|
||||
|
|
|
@ -629,6 +629,7 @@ static void GL_SetDefaultTexState( void )
|
|||
int i;
|
||||
|
||||
Q_memset( glState.currentTextures, -1, MAX_TEXTURE_UNITS * sizeof( *glState.currentTextures ));
|
||||
Q_memset( glState.texCoordArrayMode, 0, MAX_TEXTURE_UNITS * sizeof( *glState.texCoordArrayMode ));
|
||||
Q_memset( glState.genSTEnabled, 0, MAX_TEXTURE_UNITS * sizeof( *glState.genSTEnabled ));
|
||||
|
||||
for( i = 0; i < MAX_TEXTURE_UNITS; i++ )
|
||||
|
|
Reference in New Issue