|
|
@ -35,32 +35,19 @@ Limitations: |
|
|
|
#ifndef XASH_GL_STATIC |
|
|
|
#ifndef XASH_GL_STATIC |
|
|
|
#include "gl2_shim.h" |
|
|
|
#include "gl2_shim.h" |
|
|
|
#include <malloc.h> |
|
|
|
#include <malloc.h> |
|
|
|
//#include "xash3d_mathlib.h"
|
|
|
|
|
|
|
|
#define MAX_SHADERLEN 4096 |
|
|
|
#define MAX_SHADERLEN 4096 |
|
|
|
// increase this when adding more attributes
|
|
|
|
// increase this when adding more attributes
|
|
|
|
#define MAX_PROGS 32 |
|
|
|
#define MAX_PROGS 32 |
|
|
|
// must be LESS GL2_MAX_VERTS
|
|
|
|
// must be LESS GL2_MAX_VERTS
|
|
|
|
#define MAX_BEGINEND_VERTS 8192 |
|
|
|
#define MAX_BEGINEND_VERTS 8192 |
|
|
|
|
|
|
|
|
|
|
|
void (APIENTRY*_pglWaitSync)( void * sync, |
|
|
|
|
|
|
|
GLbitfield flags, |
|
|
|
|
|
|
|
uint64_t timeout); |
|
|
|
|
|
|
|
GLuint (APIENTRY*_pglClientWaitSync)( void * sync, |
|
|
|
|
|
|
|
GLbitfield flags, |
|
|
|
|
|
|
|
uint64_t timeout); |
|
|
|
|
|
|
|
void *(APIENTRY*_pglFenceSync)( GLenum condition, |
|
|
|
|
|
|
|
GLbitfield flags); |
|
|
|
|
|
|
|
void (APIENTRY*_pglDeleteSync)( void * sync ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern ref_api_t gEngfuncs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum gl2wrap_attrib_e |
|
|
|
enum gl2wrap_attrib_e |
|
|
|
{ |
|
|
|
{ |
|
|
|
GL2_ATTR_POS = 0, // 1
|
|
|
|
GL2_ATTR_POS = 0, // 1
|
|
|
|
GL2_ATTR_COLOR = 1, // 2
|
|
|
|
GL2_ATTR_COLOR, // 2
|
|
|
|
GL2_ATTR_TEXCOORD0 = 2, // 4
|
|
|
|
GL2_ATTR_TEXCOORD0, // 4
|
|
|
|
GL2_ATTR_TEXCOORD1 = 3, // 8
|
|
|
|
GL2_ATTR_TEXCOORD1, // 8
|
|
|
|
GL2_ATTR_MAX |
|
|
|
GL2_ATTR_MAX |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -69,7 +56,7 @@ enum gl2wrap_flag_e |
|
|
|
{ |
|
|
|
{ |
|
|
|
GL2_FLAG_ALPHA_TEST = GL2_ATTR_MAX, // 16
|
|
|
|
GL2_FLAG_ALPHA_TEST = GL2_ATTR_MAX, // 16
|
|
|
|
GL2_FLAG_FOG, // 32
|
|
|
|
GL2_FLAG_FOG, // 32
|
|
|
|
GL2_FLAG_NORMAL, |
|
|
|
GL2_FLAG_NORMAL, // 64
|
|
|
|
GL2_FLAG_MAX |
|
|
|
GL2_FLAG_MAX |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -157,8 +144,6 @@ static struct |
|
|
|
} gl2wrap_quad; |
|
|
|
} gl2wrap_quad; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const int gl2wrap_attr_size[GL2_ATTR_MAX] = { 3, 4, 2, 2 }; |
|
|
|
static const int gl2wrap_attr_size[GL2_ATTR_MAX] = { 3, 4, 2, 2 }; |
|
|
|
|
|
|
|
|
|
|
|
static const char *gl2wrap_flag_name[GL2_FLAG_MAX] = |
|
|
|
static const char *gl2wrap_flag_name[GL2_FLAG_MAX] = |
|
|
@ -180,7 +165,7 @@ static const char *gl2wrap_attr_name[GL2_ATTR_MAX] = |
|
|
|
"inTexCoord1", |
|
|
|
"inTexCoord1", |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#define MB(x,y) (x?GL_MAP_##y##_BIT:0) |
|
|
|
#define MB( x, y ) (( x ) ? GL_MAP_##y##_BIT : 0 ) |
|
|
|
|
|
|
|
|
|
|
|
static void (APIENTRY *rpglEnable)( GLenum e ); |
|
|
|
static void (APIENTRY *rpglEnable)( GLenum e ); |
|
|
|
static void (APIENTRY *rpglDisable)( GLenum e ); |
|
|
|
static void (APIENTRY *rpglDisable)( GLenum e ); |
|
|
@ -192,8 +177,8 @@ static void (APIENTRY*rpglBindBufferARB)( GLenum buf, GLuint obj); |
|
|
|
static void GL2_FreeArrays( void ); |
|
|
|
static void GL2_FreeArrays( void ); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef QUAD_BATCH |
|
|
|
#ifdef QUAD_BATCH |
|
|
|
void GL2_FlushPrims( void ); |
|
|
|
static void GL2_FlushPrims( void ); |
|
|
|
static void APIENTRY (*rpglBindTexture)( GLenum tex, GLuint obj); |
|
|
|
static void (APIENTRY *rpglBindTexture)( GLenum tex, GLuint obj ); |
|
|
|
static void APIENTRY GL2_BindTexture( GLenum tex, GLuint obj ) |
|
|
|
static void APIENTRY GL2_BindTexture( GLenum tex, GLuint obj ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( gl2wrap_quad.texture != obj ) |
|
|
|
if( gl2wrap_quad.texture != obj ) |
|
|
@ -250,15 +235,16 @@ static GLuint GL2_GenerateShader( gl2wrap_prog_t *prog, GLenum type ) |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < GL2_FLAG_MAX; ++i ) |
|
|
|
for( i = 0; i < GL2_FLAG_MAX; ++i ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_snprintf( tmp, sizeof( tmp ), "#define %s %d\n", gl2wrap_flag_name[i], prog->flags & ( 1 << i ) ); |
|
|
|
Q_snprintf( tmp, sizeof( tmp ), "#define %s %d\n", gl2wrap_flag_name[i], FBitSet( prog->flags, BIT( i ))); |
|
|
|
Q_strncat( shader, tmp, MAX_SHADERLEN ); |
|
|
|
Q_strncat( shader, tmp, MAX_SHADERLEN ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( version >= 310 ) |
|
|
|
if( version >= 310 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
loc = 0; |
|
|
|
loc = 0; |
|
|
|
for( i = 0; i < GL2_ATTR_MAX; ++i ) |
|
|
|
for( i = 0; i < GL2_ATTR_MAX; ++i ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( prog->flags & ( 1 << i ) ) |
|
|
|
if( FBitSet( prog->flags, BIT( i ))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_snprintf( tmp, sizeof( tmp ), "#define LOC_%s %d\n", gl2wrap_flag_name[i], loc++ ); |
|
|
|
Q_snprintf( tmp, sizeof( tmp ), "#define LOC_%s %d\n", gl2wrap_flag_name[i], loc++ ); |
|
|
|
Q_strncat( shader, tmp, MAX_SHADERLEN ); |
|
|
|
Q_strncat( shader, tmp, MAX_SHADERLEN ); |
|
|
@ -316,13 +302,13 @@ static gl2wrap_prog_t *GL2_GetProg( const GLuint flags ) |
|
|
|
|
|
|
|
|
|
|
|
if( i == MAX_PROGS ) |
|
|
|
if( i == MAX_PROGS ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gEngfuncs.Host_Error( "GL2_GetProg(): Ran out of program slots for 0x%04x\n", flags ); |
|
|
|
gEngfuncs.Host_Error( "GL2_GetProg: Ran out of program slots for 0x%04x\n", flags ); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// new prog; generate shaders
|
|
|
|
// new prog; generate shaders
|
|
|
|
|
|
|
|
|
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_GetProg(): Generating progs for 0x%04x\n", flags ); |
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_GetProg: Generating progs for 0x%04x\n", flags ); |
|
|
|
prog = &gl2wrap.progs[i]; |
|
|
|
prog = &gl2wrap.progs[i]; |
|
|
|
prog->flags = flags; |
|
|
|
prog->flags = flags; |
|
|
|
|
|
|
|
|
|
|
@ -341,7 +327,7 @@ static gl2wrap_prog_t *GL2_GetProg( const GLuint flags ) |
|
|
|
loc = 0; |
|
|
|
loc = 0; |
|
|
|
for( i = 0; i < GL2_ATTR_MAX; ++i ) |
|
|
|
for( i = 0; i < GL2_ATTR_MAX; ++i ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( flags & ( 1 << i ) ) |
|
|
|
if( FBitSet( flags, BIT( i ))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
prog->attridx[i] = loc; |
|
|
|
prog->attridx[i] = loc; |
|
|
|
if( gl2wrap_config.version <= 300 ) |
|
|
|
if( gl2wrap_config.version <= 300 ) |
|
|
@ -369,7 +355,7 @@ static gl2wrap_prog_t *GL2_GetProg( const GLuint flags ) |
|
|
|
pglGetObjectParameterivARB( glprog, GL_OBJECT_LINK_STATUS_ARB, &status ); |
|
|
|
pglGetObjectParameterivARB( glprog, GL_OBJECT_LINK_STATUS_ARB, &status ); |
|
|
|
if( status == GL_FALSE ) |
|
|
|
if( status == GL_FALSE ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gEngfuncs.Con_Reportf( S_ERROR "GL2_GetProg(): Failed linking progs for 0x%04x!\n%s\n", prog->flags, GL_PrintInfoLog(glprog, true) ); |
|
|
|
gEngfuncs.Con_Reportf( S_ERROR "GL2_GetProg: Failed linking progs for 0x%04x!\n%s\n", prog->flags, GL_PrintInfoLog( glprog, true )); |
|
|
|
prog->flags = 0; |
|
|
|
prog->flags = 0; |
|
|
|
if( pglDeleteProgram ) |
|
|
|
if( pglDeleteProgram ) |
|
|
|
pglDeleteProgram( glprog ); |
|
|
|
pglDeleteProgram( glprog ); |
|
|
@ -378,7 +364,6 @@ static gl2wrap_prog_t *GL2_GetProg( const GLuint flags ) |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prog->ucolor = pglGetUniformLocationARB( glprog, "uColor" ); |
|
|
|
prog->ucolor = pglGetUniformLocationARB( glprog, "uColor" ); |
|
|
|
prog->ualpha = pglGetUniformLocationARB( glprog, "uAlphaTest" ); |
|
|
|
prog->ualpha = pglGetUniformLocationARB( glprog, "uAlphaTest" ); |
|
|
|
prog->utex0 = pglGetUniformLocationARB( glprog, "uTex0" ); |
|
|
|
prog->utex0 = pglGetUniformLocationARB( glprog, "uTex0" ); |
|
|
@ -412,18 +397,19 @@ static gl2wrap_prog_t *GL2_GetProg( const GLuint flags ) |
|
|
|
pglBindVertexArray( 0 ); |
|
|
|
pglBindVertexArray( 0 ); |
|
|
|
|
|
|
|
|
|
|
|
// these never change
|
|
|
|
// these never change
|
|
|
|
if ( prog->flags & ( 1U << GL2_ATTR_TEXCOORD0 ) && prog->utex0 >= 0 ) |
|
|
|
if( FBitSet( prog->flags, BIT( GL2_ATTR_TEXCOORD0 )) && prog->utex0 >= 0 ) |
|
|
|
pglUniform1iARB( prog->utex0, 0 ); |
|
|
|
pglUniform1iARB( prog->utex0, 0 ); |
|
|
|
if ( prog->flags & ( 1U << GL2_ATTR_TEXCOORD1 ) && prog->utex1 >= 0 ) |
|
|
|
if( FBitSet( prog->flags, BIT( GL2_ATTR_TEXCOORD1 )) && prog->utex1 >= 0 ) |
|
|
|
pglUniform1iARB( prog->utex1, 1 ); |
|
|
|
pglUniform1iARB( prog->utex1, 1 ); |
|
|
|
if( gl2wrap.cur_prog ) |
|
|
|
if( gl2wrap.cur_prog ) |
|
|
|
pglUseProgramObjectARB( gl2wrap.cur_prog->glprog ); |
|
|
|
pglUseProgramObjectARB( gl2wrap.cur_prog->glprog ); |
|
|
|
prog->glprog = glprog; |
|
|
|
prog->glprog = glprog; |
|
|
|
|
|
|
|
|
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_GetProg(): Generated progs for 0x%04x\n", flags ); |
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_GetProg: Generated progs for 0x%04x\n", flags ); |
|
|
|
|
|
|
|
|
|
|
|
return prog; |
|
|
|
return prog; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void GL2_UpdateMVP( gl2wrap_prog_t *prog ); |
|
|
|
static void GL2_UpdateMVP( gl2wrap_prog_t *prog ); |
|
|
|
static gl2wrap_prog_t *GL2_SetProg( const GLuint flags ) |
|
|
|
static gl2wrap_prog_t *GL2_SetProg( const GLuint flags ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -512,18 +498,20 @@ static void GL2_InitIncrementalBuffer( int i, GLuint size ) |
|
|
|
qboolean GL2_InitProgs( void ) |
|
|
|
qboolean GL2_InitProgs( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static const GLuint precache_progs[] = { |
|
|
|
static const GLuint precache_progs[] = { |
|
|
|
0x0001, // out = ucolor
|
|
|
|
BIT( GL2_ATTR_POS ), // out = ucolor
|
|
|
|
0x0005, // out = tex0 * ucolor
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_ATTR_TEXCOORD0 ), // out = tex0 * ucolor
|
|
|
|
0x0007, // out = tex0 * vcolor
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_ATTR_TEXCOORD0 ) | BIT( GL2_ATTR_COLOR ), // out = tex0 * vcolor
|
|
|
|
0x0015, // out = tex0 * ucolor + FEAT_ALPHA_TEST
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_ATTR_TEXCOORD0 ) | BIT( GL2_FLAG_ALPHA_TEST ), // out = tex0 * ucolor + FEAT_ALPHA_TEST
|
|
|
|
0x0021, // out = ucolor + FEAT_FOG
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_FLAG_FOG ), // out = ucolor + FEAT_FOG
|
|
|
|
0x0025, // out = tex0 * ucolor + FEAT_FOG
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_ATTR_TEXCOORD0 ) | BIT( GL2_FLAG_FOG ), // out = tex0 * ucolor + FEAT_FOG
|
|
|
|
0x0027, // out = tex0 * vcolor + FEAT_FOG
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_ATTR_TEXCOORD0 ) | BIT( GL2_ATTR_COLOR ) | BIT( GL2_FLAG_FOG ), // out = tex0 * vcolor + FEAT_FOG
|
|
|
|
0x0035, // out = tex0 * ucolor + FEAT_ALPHA_TEST + FEAT_FOG
|
|
|
|
BIT( GL2_ATTR_POS ) | BIT( GL2_ATTR_TEXCOORD0 ) | BIT( GL2_FLAG_ALPHA_TEST ) | BIT( GL2_FLAG_FOG ), // out = tex0 * ucolor + FEAT_ALPHA_TEST + FEAT_FOG
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
const size_t precache_progs_count = sizeof( precache_progs ) / sizeof( precache_progs[0] ); |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_InitProgs(): Pre-generating %u progs, version %d...\n", (uint)(sizeof( precache_progs ) / sizeof( *precache_progs )), gl2wrap_config.version ); |
|
|
|
|
|
|
|
for ( i = 0; i < (int)( sizeof( precache_progs ) / sizeof( *precache_progs ) ); ++i ) |
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_InitProgs: Pre-generating %u progs, version %d...\n", (uint)( precache_progs_count ), gl2wrap_config.version ); |
|
|
|
|
|
|
|
for( i = 0; i < (int)( precache_progs_count ); ++i ) |
|
|
|
if( !GL2_GetProg( precache_progs[i] )) |
|
|
|
if( !GL2_GetProg( precache_progs[i] )) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -535,20 +523,21 @@ int GL2_ShimInit( void ) |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
GLuint total; |
|
|
|
GLuint total; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_init ) |
|
|
|
if( gl2wrap_init ) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
if( !pglBindBufferARB ) |
|
|
|
if( !pglBindBufferARB ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gEngfuncs.Con_Printf( S_ERROR "GL2_ShimInit(): missing VBO, disabling\n"); |
|
|
|
gEngfuncs.Con_Printf( S_ERROR "GL2_ShimInit: missing VBO, disabling\n" ); |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( !pglCompileShaderARB ) |
|
|
|
if( !pglCompileShaderARB ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gEngfuncs.Con_Printf( S_ERROR "GL2_ShimInit(): missing shaders, disabling\n"); |
|
|
|
gEngfuncs.Con_Printf( S_ERROR "GL2_ShimInit: missing shaders, disabling\n" ); |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gl2wrap_config.vao_mandatory = gEngfuncs.Sys_CheckParm( "-vao" ) || glConfig.context == CONTEXT_TYPE_GL_CORE; |
|
|
|
gl2wrap_config.vao_mandatory = gEngfuncs.Sys_CheckParm( "-vao" ) || glConfig.context == CONTEXT_TYPE_GL_CORE; |
|
|
|
gl2wrap_config.incremental = true; |
|
|
|
gl2wrap_config.incremental = true; |
|
|
|
gl2wrap_config.async = true; |
|
|
|
gl2wrap_config.async = true; |
|
|
@ -557,17 +546,20 @@ int GL2_ShimInit( void ) |
|
|
|
gl2wrap_config.coherent = true; |
|
|
|
gl2wrap_config.coherent = true; |
|
|
|
gl2wrap_config.supports_mapbuffer = true; |
|
|
|
gl2wrap_config.supports_mapbuffer = true; |
|
|
|
gl2wrap_config.cycle_buffers = 4096; |
|
|
|
gl2wrap_config.cycle_buffers = 4096; |
|
|
|
|
|
|
|
|
|
|
|
if( !pglBufferStorage ) |
|
|
|
if( !pglBufferStorage ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap_config.buf_storage = false; |
|
|
|
gl2wrap_config.buf_storage = false; |
|
|
|
gEngfuncs.Con_Printf( S_NOTE "GL2_ShimInit(): missing BufferStorage\n"); |
|
|
|
gEngfuncs.Con_Printf( S_NOTE "GL2_ShimInit: missing BufferStorage\n" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( !pglMapBufferRange ) |
|
|
|
if( !pglMapBufferRange ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap_config.incremental = false, gl2wrap_config.supports_mapbuffer = false; |
|
|
|
gl2wrap_config.incremental = false; |
|
|
|
gEngfuncs.Con_Printf( S_NOTE "GL2_ShimInit(): missing MapBufferRange, disabling incremental rendering\n"); |
|
|
|
gl2wrap_config.supports_mapbuffer = false; |
|
|
|
|
|
|
|
gEngfuncs.Con_Printf( S_NOTE "GL2_ShimInit: missing MapBufferRange, disabling incremental rendering\n" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( gEngfuncs.Sys_CheckParm( "-nocoherent" )) |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-nocoherent" )) |
|
|
|
gl2wrap_config.coherent = false; |
|
|
|
gl2wrap_config.coherent = false; |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-nobufstor" )) |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-nobufstor" )) |
|
|
@ -579,13 +571,13 @@ int GL2_ShimInit( void ) |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-nomapbuffer" )) |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-nomapbuffer" )) |
|
|
|
gl2wrap_config.supports_mapbuffer = false; |
|
|
|
gl2wrap_config.supports_mapbuffer = false; |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-noincremental" )) |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-noincremental" )) |
|
|
|
gl2wrap_config.incremental = false, gl2wrap_config.buf_storage = false; |
|
|
|
gl2wrap_config.incremental = gl2wrap_config.buf_storage = false; |
|
|
|
|
|
|
|
|
|
|
|
gl2wrap_config.version = 310; |
|
|
|
gl2wrap_config.version = 310; |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-minshaders" )) |
|
|
|
if( gEngfuncs.Sys_CheckParm( "-minshaders" )) |
|
|
|
gl2wrap_config.version = 100; |
|
|
|
gl2wrap_config.version = 100; |
|
|
|
if( gl2wrap_config.buf_storage ) |
|
|
|
if( gl2wrap_config.buf_storage ) |
|
|
|
gl2wrap_config.incremental = true, gl2wrap_config.vao_mandatory = true; |
|
|
|
gl2wrap_config.incremental = gl2wrap_config.vao_mandatory = true; |
|
|
|
if( !pglBindVertexArray || !gl2wrap_config.vao_mandatory ) |
|
|
|
if( !pglBindVertexArray || !gl2wrap_config.vao_mandatory ) |
|
|
|
gl2wrap_config.incremental = gl2wrap_config.buf_storage = gl2wrap_config.vao_mandatory = false; |
|
|
|
gl2wrap_config.incremental = gl2wrap_config.buf_storage = gl2wrap_config.vao_mandatory = false; |
|
|
|
if( gl2wrap_config.incremental && !gl2wrap_config.buf_storage ) |
|
|
|
if( gl2wrap_config.incremental && !gl2wrap_config.buf_storage ) |
|
|
@ -594,7 +586,7 @@ int GL2_ShimInit( void ) |
|
|
|
gl2wrap_config.cycle_buffers = 4; |
|
|
|
gl2wrap_config.cycle_buffers = 4; |
|
|
|
if( !gl2wrap_config.vao_mandatory ) |
|
|
|
if( !gl2wrap_config.vao_mandatory ) |
|
|
|
gl2wrap_config.cycle_buffers = 1; |
|
|
|
gl2wrap_config.cycle_buffers = 1; |
|
|
|
gEngfuncs.Con_Printf( S_NOTE "GL2_ShimInit(): config: %s%s%s%s%s%s%sCYCLE=%d VER=%d\n", |
|
|
|
gEngfuncs.Con_Printf( S_NOTE "GL2_ShimInit: config: %s%s%s%s%s%s%sCYCLE=%d VER=%d\n", |
|
|
|
gl2wrap_config.buf_storage ? "BUF_STOR " : "", |
|
|
|
gl2wrap_config.buf_storage ? "BUF_STOR " : "", |
|
|
|
gl2wrap_config.buf_storage&&gl2wrap_config.coherent ? "COHERENT " : "", |
|
|
|
gl2wrap_config.buf_storage&&gl2wrap_config.coherent ? "COHERENT " : "", |
|
|
|
gl2wrap_config.async ? "ASYNC " : "", |
|
|
|
gl2wrap_config.async ? "ASYNC " : "", |
|
|
@ -623,9 +615,11 @@ int GL2_ShimInit( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap.attrbuf[i] = Mem_Calloc( r_temppool, size ); |
|
|
|
gl2wrap.attrbuf[i] = Mem_Calloc( r_temppool, size ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_config.incremental ) |
|
|
|
if( gl2wrap_config.incremental ) |
|
|
|
|
|
|
|
{ |
|
|
|
GL2_InitIncrementalBuffer( i, size ); |
|
|
|
GL2_InitIncrementalBuffer( i, size ); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( !gl2wrap_config.incremental && gl2wrap_config.vao_mandatory ) |
|
|
|
if( !gl2wrap_config.incremental && gl2wrap_config.vao_mandatory ) |
|
|
@ -649,7 +643,7 @@ int GL2_ShimInit( void ) |
|
|
|
pglBindVertexArray( 0 ); |
|
|
|
pglBindVertexArray( 0 ); |
|
|
|
rpglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
rpglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
|
|
|
|
|
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_ShimInit(): %u bytes allocated for vertex buffer\n", total ); |
|
|
|
gEngfuncs.Con_DPrintf( S_NOTE "GL2_ShimInit: %u bytes allocated for vertex buffer\n", total ); |
|
|
|
|
|
|
|
|
|
|
|
if( !GL2_InitProgs( )) |
|
|
|
if( !GL2_InitProgs( )) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -661,7 +655,7 @@ int GL2_ShimInit( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap_config.version = 100; |
|
|
|
gl2wrap_config.version = 100; |
|
|
|
if( !GL2_InitProgs( )) |
|
|
|
if( !GL2_InitProgs( )) |
|
|
|
gEngfuncs.Host_Error("Failed to compile shaders!\n"); |
|
|
|
gEngfuncs.Host_Error( "GL2_ShimInit: Failed to compile shaders!\n" ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -686,7 +680,6 @@ void GL2_ShimShutdown( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( gl2wrap.progs[i].flags ) |
|
|
|
if( gl2wrap.progs[i].flags ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int j; |
|
|
|
|
|
|
|
pglDeleteProgram( gl2wrap.progs[i].glprog ); |
|
|
|
pglDeleteProgram( gl2wrap.progs[i].glprog ); |
|
|
|
if( gl2wrap.progs[i].vao_begin ) |
|
|
|
if( gl2wrap.progs[i].vao_begin ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -781,10 +774,7 @@ static void APIENTRY GL2_Begin( GLenum prim ) |
|
|
|
GLuint flags2 = gl2wrap.cur_flags; |
|
|
|
GLuint flags2 = gl2wrap.cur_flags; |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_quad.flags != flags || prim != GL_QUADS ) |
|
|
|
if( gl2wrap_quad.flags != flags || prim != GL_QUADS ) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GL2_FlushPrims(); |
|
|
|
GL2_FlushPrims(); |
|
|
|
} |
|
|
|
|
|
|
|
else if( gl2wrap_quad.flags == flags && prim == GL_QUADS ) |
|
|
|
else if( gl2wrap_quad.flags == flags && prim == GL_QUADS ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -793,9 +783,8 @@ static void APIENTRY GL2_Begin( GLenum prim ) |
|
|
|
gl2wrap.prim = prim; |
|
|
|
gl2wrap.prim = prim; |
|
|
|
gl2wrap.begin = gl2wrap.end; |
|
|
|
gl2wrap.begin = gl2wrap.end; |
|
|
|
// pos always enabled
|
|
|
|
// pos always enabled
|
|
|
|
gl2wrap.cur_flags |= 1 << GL2_ATTR_POS; |
|
|
|
SetBits( gl2wrap.cur_flags, BIT( GL2_ATTR_POS )); |
|
|
|
} |
|
|
|
} |
|
|
|
void (APIENTRY*_pglMemoryBarrier)(GLbitfield barriers); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
============================== |
|
|
|
============================== |
|
|
@ -842,21 +831,22 @@ static void GL2_UpdateIncrementalBuffer( gl2wrap_prog_t *prog, int count ) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GL2_FlushPrims( void ) |
|
|
|
static void GL2_FlushPrims( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
int startindex = 0; |
|
|
|
int startindex = 0; |
|
|
|
GLuint flags = gl2wrap.cur_flags; |
|
|
|
GLuint flags = gl2wrap.cur_flags; |
|
|
|
GLint count = gl2wrap.end - gl2wrap.begin; |
|
|
|
GLint count = gl2wrap.end - gl2wrap.begin; |
|
|
|
gl2wrap_prog_t *prog; |
|
|
|
gl2wrap_prog_t *prog; |
|
|
|
|
|
|
|
|
|
|
|
if( !gl2wrap.prim || !count ) |
|
|
|
if( !gl2wrap.prim || !count ) |
|
|
|
goto leave_label; // end without begin
|
|
|
|
goto leave_label; // end without begin
|
|
|
|
|
|
|
|
|
|
|
|
// enable alpha test and fog if needed
|
|
|
|
// enable alpha test and fog if needed
|
|
|
|
if( gl2wrap_state.alpha_test ) |
|
|
|
if( gl2wrap_state.alpha_test ) |
|
|
|
flags |= 1 << GL2_FLAG_ALPHA_TEST; |
|
|
|
SetBits( flags, BIT( GL2_FLAG_ALPHA_TEST )); |
|
|
|
if( gl2wrap_state.fog ) |
|
|
|
if( gl2wrap_state.fog ) |
|
|
|
flags |= 1 << GL2_FLAG_FOG; |
|
|
|
SetBits( flags, BIT( GL2_FLAG_FOG )); |
|
|
|
|
|
|
|
|
|
|
|
// disable all vertex attrib pointers
|
|
|
|
// disable all vertex attrib pointers
|
|
|
|
if( !gl2wrap_config.vao_mandatory ) |
|
|
|
if( !gl2wrap_config.vao_mandatory ) |
|
|
@ -868,11 +858,10 @@ void GL2_FlushPrims( void ) |
|
|
|
prog = GL2_SetProg( flags ); |
|
|
|
prog = GL2_SetProg( flags ); |
|
|
|
if( !prog ) |
|
|
|
if( !prog ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gEngfuncs.Host_Error( "GL2_End(): Could not find program for flags 0x%04x!\n", flags ); |
|
|
|
gEngfuncs.Host_Error( "GL2_End: Could not find program for flags 0x%04x!\n", flags ); |
|
|
|
goto leave_label; |
|
|
|
goto leave_label; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_config.incremental ) |
|
|
|
if( gl2wrap_config.incremental ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GL2_UpdateIncrementalBuffer( prog, count ); |
|
|
|
GL2_UpdateIncrementalBuffer( prog, count ); |
|
|
@ -894,7 +883,6 @@ void GL2_FlushPrims( void ) |
|
|
|
pglBindBufferARB( GL_ARRAY_BUFFER_ARB, gl2wrap.attrbufobj[i][gl2wrap.attrbufcycle] ); |
|
|
|
pglBindBufferARB( GL_ARRAY_BUFFER_ARB, gl2wrap.attrbufobj[i][gl2wrap.attrbufcycle] ); |
|
|
|
if( gl2wrap_config.supports_mapbuffer ) |
|
|
|
if( gl2wrap_config.supports_mapbuffer ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_attr_size[i] * 4 * count > MAX_BEGINEND_VERTS ) |
|
|
|
if( gl2wrap_attr_size[i] * 4 * count > MAX_BEGINEND_VERTS ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pglBufferDataARB( GL_ARRAY_BUFFER_ARB, gl2wrap_attr_size[i] * 4 * count, gl2wrap.attrbuf[i] + gl2wrap_attr_size[i] * gl2wrap.begin, GL_STREAM_DRAW_ARB ); |
|
|
|
pglBufferDataARB( GL_ARRAY_BUFFER_ARB, gl2wrap_attr_size[i] * 4 * count, gl2wrap.attrbuf[i] + gl2wrap_attr_size[i] * gl2wrap.begin, GL_STREAM_DRAW_ARB ); |
|
|
@ -932,26 +920,32 @@ void GL2_FlushPrims( void ) |
|
|
|
else if( pglDrawRangeElementsBaseVertex ) |
|
|
|
else if( pglDrawRangeElementsBaseVertex ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Opengl deprecated QUADS, but made some workarounds availiable |
|
|
|
* OpenGL deprecated QUADS, but made some workarounds availiable |
|
|
|
* idea: bound static index array that will repeat 0 1 2 0 2 3 4 5 6 4 6 7... |
|
|
|
* idea: bound static index array that will repeat 0 1 2 0 2 3 4 5 6 4 6 7... |
|
|
|
* sequence and draw source arrays. But our array may have different offset |
|
|
|
* sequence and draw source arrays. But our array may have different offset |
|
|
|
* When DrawRangeElementsBaseVertex unavailiable, we need build 4 different index arrays (as sequence have period 4) |
|
|
|
* When DrawRangeElementsBaseVertex unavailiable, we need build 4 different index arrays (as sequence have period 4) |
|
|
|
* or just put 0-4 offset when it's availiable |
|
|
|
* or just put 0-4 offset when it's availiable |
|
|
|
* */ |
|
|
|
* */ |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, gl2wrap.triquads_ibo[0] ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, gl2wrap.triquads_ibo[0] ); |
|
|
|
pglDrawRangeElementsBaseVertex( GL_TRIANGLES, startindex, startindex + count, Q_min(count / 4 * 6,TRIQUADS_SIZE * 6 - startindex), GL_UNSIGNED_SHORT, (void*)(size_t)(startindex / 4 * 6 * 2), startindex % 4 ); |
|
|
|
pglDrawRangeElementsBaseVertex( GL_TRIANGLES, startindex, startindex + count, |
|
|
|
|
|
|
|
Q_min( count / 4 * 6, TRIQUADS_SIZE * 6 - startindex ), GL_UNSIGNED_SHORT, |
|
|
|
|
|
|
|
(void *)(size_t)( startindex / 4 * 6 * 2 ), startindex % 4 ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( rpglDrawRangeElements ) |
|
|
|
else if( rpglDrawRangeElements ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, gl2wrap.triquads_ibo[startindex % 4] ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, gl2wrap.triquads_ibo[startindex % 4] ); |
|
|
|
rpglDrawRangeElements( GL_TRIANGLES, startindex, startindex + count, Q_min(count / 4 * 6,TRIQUADS_SIZE * 6 - startindex), GL_UNSIGNED_SHORT, (void*)(size_t)(startindex / 4 * 6 * 2) ); |
|
|
|
rpglDrawRangeElements( GL_TRIANGLES, startindex, startindex + count, |
|
|
|
|
|
|
|
Q_min( count / 4 * 6, TRIQUADS_SIZE * 6 - startindex ), GL_UNSIGNED_SHORT, |
|
|
|
|
|
|
|
(void *)(size_t)( startindex / 4 * 6 * 2 )); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, gl2wrap.triquads_ibo[startindex % 4] ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, gl2wrap.triquads_ibo[startindex % 4] ); |
|
|
|
rpglDrawElements( GL_TRIANGLES, Q_min(count / 4 * 6,TRIQUADS_SIZE * 6 - startindex), GL_UNSIGNED_SHORT, (void*)(size_t)(startindex / 4 * 6 * 2) ); |
|
|
|
rpglDrawElements( GL_TRIANGLES, |
|
|
|
|
|
|
|
Q_min( count / 4 * 6, TRIQUADS_SIZE * 6 - startindex ), GL_UNSIGNED_SHORT, |
|
|
|
|
|
|
|
(void *)(size_t)( startindex / 4 * 6 * 2 )); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
pglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -985,9 +979,9 @@ static void APIENTRY GL2_End( void ) |
|
|
|
GLuint flags = gl2wrap.cur_flags; |
|
|
|
GLuint flags = gl2wrap.cur_flags; |
|
|
|
// enable alpha test and fog if needed
|
|
|
|
// enable alpha test and fog if needed
|
|
|
|
/*if( alpha_test_state )
|
|
|
|
/*if( alpha_test_state )
|
|
|
|
flags |= 1 << GL2_FLAG_ALPHA_TEST; |
|
|
|
SetBits( flags, BIT( GL2_FLAG_ALPHA_TEST )); |
|
|
|
if( fogging ) |
|
|
|
if( fogging ) |
|
|
|
flags |= 1 << GL2_FLAG_FOG;*/ |
|
|
|
SetBits( flags, BIT( GL2_FLAG_FOG ));*/ |
|
|
|
gl2wrap_quad.flags = flags; |
|
|
|
gl2wrap_quad.flags = flags; |
|
|
|
gl2wrap_quad.active = 1; |
|
|
|
gl2wrap_quad.active = 1; |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1026,6 +1020,7 @@ static void APIENTRY GL2_TexImage2D( GLenum target, GLint level, GLint internalf |
|
|
|
if( data != pixels ) |
|
|
|
if( data != pixels ) |
|
|
|
free( data ); |
|
|
|
free( data ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void (APIENTRY *rpglTexParameteri)( GLenum target, GLenum pname, GLint param ); |
|
|
|
static void (APIENTRY *rpglTexParameteri)( GLenum target, GLenum pname, GLint param ); |
|
|
|
static void APIENTRY GL2_TexParameteri( GLenum target, GLenum pname, GLint param ) |
|
|
|
static void APIENTRY GL2_TexParameteri( GLenum target, GLenum pname, GLint param ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1037,7 +1032,7 @@ static void APIENTRY GL2_TexParameteri( GLenum target, GLenum pname, GLint param |
|
|
|
pname == GL_TEXTURE_WRAP_T ) && |
|
|
|
pname == GL_TEXTURE_WRAP_T ) && |
|
|
|
param == GL_CLAMP ) |
|
|
|
param == GL_CLAMP ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
param = 0x812F; |
|
|
|
param = GL_CLAMP_TO_EDGE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rpglTexParameteri( target, pname, param ); |
|
|
|
rpglTexParameteri( target, pname, param ); |
|
|
@ -1052,9 +1047,6 @@ static GLboolean APIENTRY GL2_IsEnabled(GLenum e) |
|
|
|
return rpglIsEnabled( e ); |
|
|
|
return rpglIsEnabled( e ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) |
|
|
|
static void APIENTRY GL2_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLfloat *p = gl2wrap.attrbuf[GL2_ATTR_POS] + gl2wrap.end * 3; |
|
|
|
GLfloat *p = gl2wrap.attrbuf[GL2_ATTR_POS] + gl2wrap.end * 3; |
|
|
@ -1062,20 +1054,21 @@ static void APIENTRY GL2_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) |
|
|
|
*p++ = y; |
|
|
|
*p++ = y; |
|
|
|
*p++ = z; |
|
|
|
*p++ = z; |
|
|
|
|
|
|
|
|
|
|
|
if(gl2wrap.cur_flags & 1 << GL2_ATTR_COLOR) |
|
|
|
if( FBitSet( gl2wrap.cur_flags, BIT( GL2_ATTR_COLOR ))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLfloat *p = gl2wrap.attrbuf[GL2_ATTR_COLOR] + gl2wrap.end * 4; |
|
|
|
GLfloat *p = gl2wrap.attrbuf[GL2_ATTR_COLOR] + gl2wrap.end * 4; |
|
|
|
gl2wrap.cur_flags |= 1 << GL2_ATTR_COLOR; |
|
|
|
SetBits( gl2wrap.cur_flags, BIT( GL2_ATTR_COLOR )); |
|
|
|
*p++ = gl2wrap.color[0]; |
|
|
|
*p++ = gl2wrap.color[0]; |
|
|
|
*p++ = gl2wrap.color[1]; |
|
|
|
*p++ = gl2wrap.color[1]; |
|
|
|
*p++ = gl2wrap.color[2]; |
|
|
|
*p++ = gl2wrap.color[2]; |
|
|
|
*p++ = gl2wrap.color[3]; |
|
|
|
*p++ = gl2wrap.color[3]; |
|
|
|
} |
|
|
|
} |
|
|
|
++gl2wrap.end; |
|
|
|
++gl2wrap.end; |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap.end - gl2wrap.begin >= MAX_BEGINEND_VERTS ) |
|
|
|
if( gl2wrap.end - gl2wrap.begin >= MAX_BEGINEND_VERTS ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLenum prim = gl2wrap.prim; |
|
|
|
GLenum prim = gl2wrap.prim; |
|
|
|
gEngfuncs.Con_DPrintf( S_ERROR "GL2_Vertex3f(): Vertex buffer overflow!\n" ); |
|
|
|
gEngfuncs.Con_DPrintf( S_ERROR "GL2_Vertex3f: Vertex buffer overflow!\n" ); |
|
|
|
GL2_FlushPrims(); |
|
|
|
GL2_FlushPrims(); |
|
|
|
GL2_Begin( prim ); |
|
|
|
GL2_Begin( prim ); |
|
|
|
} |
|
|
|
} |
|
|
@ -1112,7 +1105,7 @@ static void APIENTRY GL2_Color4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) |
|
|
|
if( gl2wrap.prim ) |
|
|
|
if( gl2wrap.prim ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// HACK: enable color attribute if we're using color inside a Begin-End pair
|
|
|
|
// HACK: enable color attribute if we're using color inside a Begin-End pair
|
|
|
|
gl2wrap.cur_flags |= 1 << GL2_ATTR_COLOR; |
|
|
|
SetBits( gl2wrap.cur_flags, BIT( GL2_ATTR_COLOR )); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1135,7 +1128,7 @@ static void APIENTRY GL2_TexCoord2f( GLfloat u, GLfloat v ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// by spec glTexCoord always updates texunit 0
|
|
|
|
// by spec glTexCoord always updates texunit 0
|
|
|
|
GLfloat *p = gl2wrap.attrbuf[GL2_ATTR_TEXCOORD0] + gl2wrap.end * 2; |
|
|
|
GLfloat *p = gl2wrap.attrbuf[GL2_ATTR_TEXCOORD0] + gl2wrap.end * 2; |
|
|
|
gl2wrap.cur_flags |= 1 << GL2_ATTR_TEXCOORD0; |
|
|
|
SetBits( gl2wrap.cur_flags, BIT( GL2_ATTR_TEXCOORD0 )); |
|
|
|
*p++ = u; |
|
|
|
*p++ = u; |
|
|
|
*p++ = v; |
|
|
|
*p++ = v; |
|
|
|
} |
|
|
|
} |
|
|
@ -1143,16 +1136,17 @@ static void APIENTRY GL2_TexCoord2f( GLfloat u, GLfloat v ) |
|
|
|
static void APIENTRY GL2_MultiTexCoord2f( GLenum tex, GLfloat u, GLfloat v ) |
|
|
|
static void APIENTRY GL2_MultiTexCoord2f( GLenum tex, GLfloat u, GLfloat v ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLfloat *p; |
|
|
|
GLfloat *p; |
|
|
|
|
|
|
|
|
|
|
|
// assume there can only be two
|
|
|
|
// assume there can only be two
|
|
|
|
if( tex == GL_TEXTURE0_ARB ) |
|
|
|
if( tex == GL_TEXTURE0_ARB ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
p = gl2wrap.attrbuf[GL2_ATTR_TEXCOORD0] + gl2wrap.end * 2; |
|
|
|
p = gl2wrap.attrbuf[GL2_ATTR_TEXCOORD0] + gl2wrap.end * 2; |
|
|
|
gl2wrap.cur_flags |= 1 << GL2_ATTR_TEXCOORD0; |
|
|
|
SetBits( gl2wrap.cur_flags, BIT( GL2_ATTR_TEXCOORD0 )); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
p = gl2wrap.attrbuf[GL2_ATTR_TEXCOORD1] + gl2wrap.end * 2; |
|
|
|
p = gl2wrap.attrbuf[GL2_ATTR_TEXCOORD1] + gl2wrap.end * 2; |
|
|
|
gl2wrap.cur_flags |= 1 << GL2_ATTR_TEXCOORD1; |
|
|
|
SetBits( gl2wrap.cur_flags, BIT( GL2_ATTR_TEXCOORD1 )); |
|
|
|
} |
|
|
|
} |
|
|
|
*p++ = u; |
|
|
|
*p++ = u; |
|
|
|
*p++ = v; |
|
|
|
*p++ = v; |
|
|
@ -1197,27 +1191,24 @@ static qboolean GL2_CatchEnable( GLenum e, qboolean enable ) |
|
|
|
gl2wrap_state.fog = enable; |
|
|
|
gl2wrap_state.fog = enable; |
|
|
|
else if( e == GL_ALPHA_TEST ) |
|
|
|
else if( e == GL_ALPHA_TEST ) |
|
|
|
gl2wrap_state.alpha_test = enable; |
|
|
|
gl2wrap_state.alpha_test = enable; |
|
|
|
else return false; |
|
|
|
else |
|
|
|
|
|
|
|
return false; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_Enable( GLenum e ) |
|
|
|
static void APIENTRY GL2_Enable( GLenum e ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( GL2_SkipEnable(e) ) |
|
|
|
if( !GL2_SkipEnable( e ) && !GL2_CatchEnable( e, true )) |
|
|
|
{} |
|
|
|
|
|
|
|
else if(!GL2_CatchEnable(e, true)) |
|
|
|
|
|
|
|
rpglEnable( e ); |
|
|
|
rpglEnable( e ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_Disable( GLenum e ) |
|
|
|
static void APIENTRY GL2_Disable( GLenum e ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( GL2_SkipEnable(e) ) |
|
|
|
if( !GL2_SkipEnable( e ) && !GL2_CatchEnable( e, false )) |
|
|
|
{} |
|
|
|
|
|
|
|
else if(!GL2_CatchEnable(e, false)) |
|
|
|
|
|
|
|
rpglDisable( e ); |
|
|
|
rpglDisable( e ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
=========================== |
|
|
|
=========================== |
|
|
|
|
|
|
|
|
|
|
@ -1258,7 +1249,6 @@ static void APIENTRY GL2_LoadIdentity( void ) |
|
|
|
gl2wrap_matrix.update = 0xFFFFFFFFFFFFFFFF; |
|
|
|
gl2wrap_matrix.update = 0xFFFFFFFFFFFFFFFF; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_Ortho( double l, double r, double b, double t, double n, double f ) |
|
|
|
static void APIENTRY GL2_Ortho( double l, double r, double b, double t, double n, double f ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLfloat m0 = 2 / ( r - l ); |
|
|
|
GLfloat m0 = 2 / ( r - l ); |
|
|
@ -1311,9 +1301,9 @@ static void GL2_Mul4x4(const GLfloat *in0, const GLfloat *in1, GLfloat *out) |
|
|
|
static void GL2_UpdateMVP( gl2wrap_prog_t *prog ) |
|
|
|
static void GL2_UpdateMVP( gl2wrap_prog_t *prog ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// use bitset to determine if need update matrix for this prog
|
|
|
|
// use bitset to determine if need update matrix for this prog
|
|
|
|
if( gl2wrap_matrix.update & ( 1U << prog->flags ) ) |
|
|
|
if( FBitSet( gl2wrap_matrix.update, BIT( prog->flags ))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap_matrix.update &= ~( 1U << prog->flags ); |
|
|
|
ClearBits( gl2wrap_matrix.update, BIT( prog->flags )); |
|
|
|
GL2_Mul4x4( gl2wrap_matrix.mv, gl2wrap_matrix.pr, gl2wrap_matrix.mvp ); |
|
|
|
GL2_Mul4x4( gl2wrap_matrix.mv, gl2wrap_matrix.pr, gl2wrap_matrix.mvp ); |
|
|
|
pglUniformMatrix4fvARB( prog->uMVP, 1, false, (void *)gl2wrap_matrix.mvp ); |
|
|
|
pglUniformMatrix4fvARB( prog->uMVP, 1, false, (void *)gl2wrap_matrix.mvp ); |
|
|
|
} |
|
|
|
} |
|
|
@ -1324,16 +1314,17 @@ static void APIENTRY GL2_LoadMatrixf( const GLfloat *m ) |
|
|
|
memcpy( gl2wrap_matrix.current, m, 16 * sizeof( float )); |
|
|
|
memcpy( gl2wrap_matrix.current, m, 16 * sizeof( float )); |
|
|
|
gl2wrap_matrix.update = 0xFFFFFFFFFFFFFFFF; |
|
|
|
gl2wrap_matrix.update = 0xFFFFFFFFFFFFFFFF; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef XASH_GLES |
|
|
|
#ifdef XASH_GLES |
|
|
|
static void ( APIENTRY *_pglDepthRangef)( GLfloat zFar, GLfloat zNear ); |
|
|
|
static void ( APIENTRY *_pglDepthRangef)( GLfloat zFar, GLfloat zNear ); |
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_DepthRange( GLdouble zFar, GLdouble zNear ) |
|
|
|
static void APIENTRY GL2_DepthRange( GLdouble zFar, GLdouble zNear ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_pglDepthRangef( zFar, zNear ); |
|
|
|
_pglDepthRangef( zFar, zNear ); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
====================== |
|
|
|
===================== |
|
|
|
|
|
|
|
|
|
|
|
Array drawing |
|
|
|
Array drawing |
|
|
|
|
|
|
|
|
|
|
@ -1359,7 +1350,6 @@ static struct |
|
|
|
GLuint vao_dynamic; |
|
|
|
GLuint vao_dynamic; |
|
|
|
} gl2wrap_arrays; |
|
|
|
} gl2wrap_arrays; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void GL2_SetPointer( int idx, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) |
|
|
|
static void GL2_SetPointer( int idx, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap_arrays.ptr[idx].size = size; |
|
|
|
gl2wrap_arrays.ptr[idx].size = size; |
|
|
@ -1368,9 +1358,9 @@ static void GL2_SetPointer( int idx, GLint size, GLenum type, GLsizei stride, co |
|
|
|
gl2wrap_arrays.ptr[idx].userptr = pointer; |
|
|
|
gl2wrap_arrays.ptr[idx].userptr = pointer; |
|
|
|
gl2wrap_arrays.ptr[idx].vbo = gl2wrap_state.vbo; |
|
|
|
gl2wrap_arrays.ptr[idx].vbo = gl2wrap_state.vbo; |
|
|
|
// if( vbo )
|
|
|
|
// if( vbo )
|
|
|
|
// gl2wrap_arrays.vbo_flags |= 1 << idx;
|
|
|
|
// SetBits( gl2wrap_arrays.vbo_flags, BIT( idx );
|
|
|
|
// else
|
|
|
|
// else
|
|
|
|
// gl2wrap_arrays.vbo_flags &= ~(1 << idx);
|
|
|
|
// ClearBits( gl2wrap_arrays.vbo_flags, BIT( idx );
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) |
|
|
|
static void APIENTRY GL2_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) |
|
|
@ -1390,7 +1380,8 @@ static void APIENTRY GL2_TexCoordPointer( GLint size, GLenum type, GLsizei strid |
|
|
|
|
|
|
|
|
|
|
|
static unsigned int GL2_GetArrIdx( GLenum array ) |
|
|
|
static unsigned int GL2_GetArrIdx( GLenum array ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (array) { |
|
|
|
switch( array ) |
|
|
|
|
|
|
|
{ |
|
|
|
case GL_VERTEX_ARRAY: |
|
|
|
case GL_VERTEX_ARRAY: |
|
|
|
return GL2_ATTR_POS; |
|
|
|
return GL2_ATTR_POS; |
|
|
|
case GL_COLOR_ARRAY: |
|
|
|
case GL_COLOR_ARRAY: |
|
|
@ -1398,21 +1389,20 @@ static unsigned int GL2_GetArrIdx( GLenum array ) |
|
|
|
case GL_TEXTURE_COORD_ARRAY: |
|
|
|
case GL_TEXTURE_COORD_ARRAY: |
|
|
|
ASSERT( gl2wrap_state.tmu < 2 ); |
|
|
|
ASSERT( gl2wrap_state.tmu < 2 ); |
|
|
|
return GL2_ATTR_TEXCOORD0 + gl2wrap_state.tmu; |
|
|
|
return GL2_ATTR_TEXCOORD0 + gl2wrap_state.tmu; |
|
|
|
default: |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_EnableClientState( GLenum array ) |
|
|
|
static void APIENTRY GL2_EnableClientState( GLenum array ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int idx = GL2_GetArrIdx(array); |
|
|
|
unsigned int idx = GL2_GetArrIdx( array ); |
|
|
|
gl2wrap_arrays.flags |= 1 << idx; |
|
|
|
SetBits( gl2wrap_arrays.flags, BIT( idx )); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY GL2_DisableClientState( GLenum array ) |
|
|
|
static void APIENTRY GL2_DisableClientState( GLenum array ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned int idx = GL2_GetArrIdx( array ); |
|
|
|
unsigned int idx = GL2_GetArrIdx( array ); |
|
|
|
gl2wrap_arrays.flags &= ~(1 << idx); |
|
|
|
ClearBits( gl2wrap_arrays.flags, BIT( idx )); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1446,7 +1436,6 @@ just memcopy it into and flush when overflowed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static void GL2_UpdatePersistentArrayBuffer( gl2wrap_prog_t *prog, int size, int offset, GLuint start, GLuint end, int stride, int attr ) |
|
|
|
static void GL2_UpdatePersistentArrayBuffer( gl2wrap_prog_t *prog, int size, int offset, GLuint start, GLuint end, int stride, int attr ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_arrays.stream_counter + size > GL2_MAX_VERTS * 64 ) |
|
|
|
if( gl2wrap_arrays.stream_counter + size > GL2_MAX_VERTS * 64 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLuint flags = GL_MAP_WRITE_BIT | MB( !gl2wrap_config.coherent, FLUSH_EXPLICIT ) | |
|
|
|
GLuint flags = GL_MAP_WRITE_BIT | MB( !gl2wrap_config.coherent, FLUSH_EXPLICIT ) | |
|
|
@ -1479,8 +1468,14 @@ static void GL2_UpdateIncrementalArrayBuffer( gl2wrap_prog_t *prog, int size, in |
|
|
|
qboolean inv = false; |
|
|
|
qboolean inv = false; |
|
|
|
GLuint flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | MB( inv,INVALIDATE_BUFFER ) | |
|
|
|
GLuint flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | MB( inv,INVALIDATE_BUFFER ) | |
|
|
|
MB( gl2wrap_config.async, UNSYNCHRONIZED ) | MB( gl2wrap_config.force_flush, FLUSH_EXPLICIT ); |
|
|
|
MB( gl2wrap_config.async, UNSYNCHRONIZED ) | MB( gl2wrap_config.force_flush, FLUSH_EXPLICIT ); |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_arrays.stream_counter + size > GL2_MAX_VERTS * 64 ) |
|
|
|
if( gl2wrap_arrays.stream_counter + size > GL2_MAX_VERTS * 64 ) |
|
|
|
size = end * stride, offset = 0, gl2wrap_arrays.stream_counter = 0, inv = true; |
|
|
|
{ |
|
|
|
|
|
|
|
size = end * stride; |
|
|
|
|
|
|
|
offset = 0; |
|
|
|
|
|
|
|
gl2wrap_arrays.stream_counter = 0; |
|
|
|
|
|
|
|
inv = true; |
|
|
|
|
|
|
|
} |
|
|
|
mem = pglMapBufferRange( GL_ARRAY_BUFFER_ARB, gl2wrap_arrays.stream_counter, size, flags ); |
|
|
|
mem = pglMapBufferRange( GL_ARRAY_BUFFER_ARB, gl2wrap_arrays.stream_counter, size, flags ); |
|
|
|
memcpy( mem, ((char *)gl2wrap_arrays.ptr[attr].userptr ) + offset, size ); |
|
|
|
memcpy( mem, ((char *)gl2wrap_arrays.ptr[attr].userptr ) + offset, size ); |
|
|
|
if( gl2wrap_config.force_flush ) |
|
|
|
if( gl2wrap_config.force_flush ) |
|
|
@ -1499,8 +1494,8 @@ Prepare BufferStorage |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static void GL2_AllocArrayPersistenStorage( void ) |
|
|
|
static void GL2_AllocArrayPersistenStorage( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLuint flags = GL_MAP_WRITE_BIT | MB(!gl2wrap_config.coherent,FLUSH_EXPLICIT) |
|
|
|
GLuint flags = GL_MAP_WRITE_BIT | MB( !gl2wrap_config.coherent, FLUSH_EXPLICIT ) | |
|
|
|
| GL_MAP_PERSISTENT_BIT | MB(gl2wrap_config.coherent, COHERENT); |
|
|
|
GL_MAP_PERSISTENT_BIT | MB( gl2wrap_config.coherent, COHERENT ); |
|
|
|
pglGenBuffersARB( 1, &gl2wrap_arrays.stream_buffer ); |
|
|
|
pglGenBuffersARB( 1, &gl2wrap_arrays.stream_buffer ); |
|
|
|
rpglBindBufferARB( GL_ARRAY_BUFFER_ARB, gl2wrap_arrays.stream_buffer ); |
|
|
|
rpglBindBufferARB( GL_ARRAY_BUFFER_ARB, gl2wrap_arrays.stream_buffer ); |
|
|
|
pglBufferStorage( GL_ARRAY_BUFFER_ARB, GL2_MAX_VERTS * 64, NULL, GL_MAP_WRITE_BIT | MB( gl2wrap_config.coherent, COHERENT ) | GL_MAP_PERSISTENT_BIT ); |
|
|
|
pglBufferStorage( GL_ARRAY_BUFFER_ARB, GL2_MAX_VERTS * 64, NULL, GL_MAP_WRITE_BIT | MB( gl2wrap_config.coherent, COHERENT ) | GL_MAP_PERSISTENT_BIT ); |
|
|
@ -1547,16 +1542,18 @@ static void GL2_SetupArrays( GLuint start, GLuint end ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gl2wrap_prog_t *prog; |
|
|
|
gl2wrap_prog_t *prog; |
|
|
|
unsigned int flags = gl2wrap_arrays.flags; |
|
|
|
unsigned int flags = gl2wrap_arrays.flags; |
|
|
|
|
|
|
|
|
|
|
|
if( !flags ) |
|
|
|
if( !flags ) |
|
|
|
return; // Legacy pointers not used
|
|
|
|
return; // Legacy pointers not used
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QUAD_BATCH |
|
|
|
#ifdef QUAD_BATCH |
|
|
|
GL2_FlushPrims(); |
|
|
|
GL2_FlushPrims(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if( gl2wrap_state.alpha_test ) |
|
|
|
if( gl2wrap_state.alpha_test ) |
|
|
|
flags |= 1 << GL2_FLAG_ALPHA_TEST; |
|
|
|
SetBits( flags, BIT( GL2_FLAG_ALPHA_TEST )); |
|
|
|
if( gl2wrap_state.fog ) |
|
|
|
if( gl2wrap_state.fog ) |
|
|
|
flags |= 1 << GL2_FLAG_FOG; |
|
|
|
SetBits( flags, BIT( GL2_FLAG_FOG )); |
|
|
|
prog = GL2_SetProg( flags );// | GL2_ATTR_TEXCOORD0 );
|
|
|
|
prog = GL2_SetProg( flags );// | GL2_ATTR_TEXCOORD0 );
|
|
|
|
if( !prog ) |
|
|
|
if( !prog ) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1572,7 +1569,7 @@ static void GL2_SetupArrays( GLuint start, GLuint end ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( prog->attridx[i] < 0 ) |
|
|
|
if( prog->attridx[i] < 0 ) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if( flags & (1 << i) ) // attribute is enabled
|
|
|
|
if( FBitSet( flags, BIT( i ))) // attribute is enabled
|
|
|
|
{ |
|
|
|
{ |
|
|
|
pglEnableVertexAttribArrayARB( prog->attridx[i] ); |
|
|
|
pglEnableVertexAttribArrayARB( prog->attridx[i] ); |
|
|
|
// sometimes usage of client pointers may be faster, sometimes not
|
|
|
|
// sometimes usage of client pointers may be faster, sometimes not
|
|
|
@ -1580,9 +1577,8 @@ static void GL2_SetupArrays( GLuint start, GLuint end ) |
|
|
|
if( gl2wrap_config.vao_mandatory && !gl2wrap_arrays.ptr[i].vbo ) |
|
|
|
if( gl2wrap_config.vao_mandatory && !gl2wrap_arrays.ptr[i].vbo ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// detect stride by type
|
|
|
|
// detect stride by type
|
|
|
|
int stride = gl2wrap_arrays.ptr[i].stride; |
|
|
|
int stride = gl2wrap_arrays.ptr[i].stride, size, offset; |
|
|
|
int size; |
|
|
|
|
|
|
|
int offset; |
|
|
|
|
|
|
|
if( stride == 0 ) |
|
|
|
if( stride == 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( gl2wrap_arrays.ptr[i].type == GL_UNSIGNED_BYTE ) |
|
|
|
if( gl2wrap_arrays.ptr[i].type == GL_UNSIGNED_BYTE ) |
|
|
@ -1682,8 +1678,6 @@ static void APIENTRY GL2_ClientActiveTextureARB( GLenum tex ) |
|
|
|
//pglActiveTextureARB( tex );
|
|
|
|
//pglActiveTextureARB( tex );
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GL2_OVERRIDE_PTR( name ) \ |
|
|
|
#define GL2_OVERRIDE_PTR( name ) \ |
|
|
|
{ \ |
|
|
|
{ \ |
|
|
|
pgl ## name = GL2_ ## name; \ |
|
|
|
pgl ## name = GL2_ ## name; \ |
|
|
@ -1695,8 +1689,10 @@ static void APIENTRY GL2_ClientActiveTextureARB( GLenum tex ) |
|
|
|
pgl ## name = GL2_ ## name; \ |
|
|
|
pgl ## name = GL2_ ## name; \ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void APIENTRY stub( void ) |
|
|
|
static void APIENTRY stub( void ){} |
|
|
|
{ |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define GL2_STUB( name ) \ |
|
|
|
#define GL2_STUB( name ) \ |
|
|
|
{ \ |
|
|
|
{ \ |
|
|
@ -1757,16 +1753,6 @@ void GL2_ShimInstall( void ) |
|
|
|
GL2_OVERRIDE_PTR( VertexPointer ) |
|
|
|
GL2_OVERRIDE_PTR( VertexPointer ) |
|
|
|
GL2_OVERRIDE_PTR( ColorPointer ) |
|
|
|
GL2_OVERRIDE_PTR( ColorPointer ) |
|
|
|
GL2_OVERRIDE_PTR( TexCoordPointer ) |
|
|
|
GL2_OVERRIDE_PTR( TexCoordPointer ) |
|
|
|
//pglMapBufferRange = gEngfuncs.GL_GetProcAddress("glMapBufferRange");
|
|
|
|
|
|
|
|
//pglUnmapBufferARB = gEngfuncs.GL_GetProcAddress("glUnmapBuffer");
|
|
|
|
|
|
|
|
//pglFlushMappedBufferRange = gEngfuncs.GL_GetProcAddress("glFlushMappedBufferRange");
|
|
|
|
|
|
|
|
//pglBufferStorage = gEngfuncs.GL_GetProcAddress("glBufferStorage");
|
|
|
|
|
|
|
|
//_pglMemoryBarrier = gEngfuncs.GL_GetProcAddress("glMemoryBarrier");
|
|
|
|
|
|
|
|
//_pglFenceSync = gEngfuncs.GL_GetProcAddress("glFenceSync");
|
|
|
|
|
|
|
|
//_pglWaitSync = gEngfuncs.GL_GetProcAddress("glWaitSync");
|
|
|
|
|
|
|
|
//_pglClientWaitSync = gEngfuncs.GL_GetProcAddress("glClientWaitSync");
|
|
|
|
|
|
|
|
//_pglDeleteSync = gEngfuncs.GL_GetProcAddress("glDeleteSync");
|
|
|
|
|
|
|
|
//pglDrawRangeElementsBaseVertex = gEngfuncs.GL_GetProcAddress("glDrawRangeElementsBaseVertex");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QUAD_BATCH |
|
|
|
#ifdef QUAD_BATCH |
|
|
|
GL2_OVERRIDE_PTR_B( BindTexture ) |
|
|
|
GL2_OVERRIDE_PTR_B( BindTexture ) |
|
|
|