mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-19 08:51:59 +00:00
Optimize fullbright testing for brushes, assorted other cleanups, test for
functions built into current GL drivers, as well as the old extensions, and add incorrectly rendering BGRA support. Whee!
This commit is contained in:
parent
56f293d49c
commit
44c89c1904
10 changed files with 632 additions and 478 deletions
File diff suppressed because it is too large
Load diff
|
@ -51,6 +51,11 @@
|
|||
#include "QF/GL/ati.h" // Uses defines, types, APIENTRY
|
||||
|
||||
// OpenGL numbers for extensions we use or want to use
|
||||
#ifndef GL_EXT_abgr
|
||||
# define GL_EXT_abgr
|
||||
# define GL_ABGR_EXT 0x8000
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_bgra
|
||||
# define GL_EXT_bgra
|
||||
# define GL_BGR_EXT 0x80E0
|
||||
|
@ -151,6 +156,12 @@
|
|||
# define GL_COMBINE_RGB_ARB 0x8571
|
||||
# define GL_COMBINE_ALPHA_ARB 0x8572
|
||||
# define GL_RGB_SCALE_ARB 0x8573
|
||||
# define GL_ADD_SIGNED_ARB 0x8574
|
||||
# define GL_INTERPOLATE_ARB 0x8575
|
||||
# define GL_SUBTRACT_ARB 0x84E7
|
||||
# define GL_CONSTANT_ARB 0x8576
|
||||
# define GL_PRIMARY_COLOR_ARB 0x8577
|
||||
# define GL_PREVIOUS_ARB 0x8578
|
||||
# define GL_SOURCE0_RGB_ARB 0x8580
|
||||
# define GL_SOURCE1_RGB_ARB 0x8581
|
||||
# define GL_SOURCE2_RGB_ARB 0x8582
|
||||
|
@ -163,13 +174,6 @@
|
|||
# define GL_OPERAND0_ALPHA_ARB 0x8598
|
||||
# define GL_OPERAND1_ALPHA_ARB 0x8599
|
||||
# define GL_OPERAND2_ALPHA_ARB 0x859A
|
||||
# define GL_RGB_SCALE_ARB 0x8573
|
||||
# define GL_ADD_SIGNED_ARB 0x8574
|
||||
# define GL_INTERPOLATE_ARB 0x8575
|
||||
# define GL_SUBTRACT_ARB 0x84E7
|
||||
# define GL_CONSTANT_ARB 0x8576
|
||||
# define GL_PRIMARY_COLOR_ARB 0x8577
|
||||
# define GL_PREVIOUS_ARB 0x8578
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_env_dot3
|
||||
|
@ -226,40 +230,40 @@ typedef void (GLAPIENTRY *QF_glTexSubImage3D) (GLenum target, GLint level, GLint
|
|||
typedef void (GLAPIENTRY *QF_glCopyTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
// GL_ARB_multitexture
|
||||
typedef void (GLAPIENTRY *QF_glActiveTextureARB) (GLenum texture);
|
||||
typedef void (GLAPIENTRY *QF_glClientActiveTextureARB) (GLenum texture);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1dARB) (GLenum target, GLdouble s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2dARB) (GLenum target, GLdouble s, GLdouble t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3dARB) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4dARB) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1dvARB) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2dvARB) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3dvARB) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4dvARB) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1fARB) (GLenum target, GLfloat s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2fARB) (GLenum target, GLfloat s, GLfloat t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3fARB) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4fARB) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1fvARB) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2fvARB) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3fvARB) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4fvARB) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1iARB) (GLenum target, GLint s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2iARB) (GLenum target, GLint s, GLint t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3iARB) (GLenum target, GLint s, GLint t, GLint r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4iARB) (GLenum target, GLint s, GLint t, GLint r, GLint q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1ivARB) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2ivARB) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3ivARB) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4ivARB) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1sARB) (GLenum target, GLshort s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2sARB) (GLenum target, GLshort s, GLshort t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3sARB) (GLenum target, GLshort s, GLshort t, GLshort r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4sARB) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1svARB) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2svARB) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3svARB) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4svARB) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glActiveTexture) (GLenum texture);
|
||||
typedef void (GLAPIENTRY *QF_glClientActiveTexture) (GLenum texture);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1d) (GLenum target, GLdouble s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2d) (GLenum target, GLdouble s, GLdouble t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3d) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4d) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1dv) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2dv) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3dv) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4dv) (GLenum target, const GLdouble *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1f) (GLenum target, GLfloat s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2f) (GLenum target, GLfloat s, GLfloat t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3f) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4f) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1fv) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2fv) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3fv) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4fv) (GLenum target, const GLfloat *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1i) (GLenum target, GLint s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2i) (GLenum target, GLint s, GLint t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3i) (GLenum target, GLint s, GLint t, GLint r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4i) (GLenum target, GLint s, GLint t, GLint r, GLint q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1iv) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2iv) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3iv) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4iv) (GLenum target, const GLint *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1s) (GLenum target, GLshort s);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2s) (GLenum target, GLshort s, GLshort t);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3s) (GLenum target, GLshort s, GLshort t, GLshort r);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4s) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord1sv) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord2sv) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord3sv) (GLenum target, const GLshort *v);
|
||||
typedef void (GLAPIENTRY *QF_glMultiTexCoord4sv) (GLenum target, const GLshort *v);
|
||||
|
||||
// GL_EXT_paletted_texture
|
||||
typedef void (GLAPIENTRY *QF_glColorTableEXT) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
|
||||
|
|
|
@ -34,18 +34,20 @@
|
|||
#include "QF/GL/extensions.h"
|
||||
|
||||
// Multitexturing
|
||||
extern QF_glActiveTextureARB qglActiveTexture;
|
||||
extern QF_glMultiTexCoord2fARB qglMultiTexCoord2f;
|
||||
extern QF_glMultiTexCoord2fvARB qglMultiTexCoord2fv;
|
||||
extern qboolean gl_mtex_active;
|
||||
extern QF_glActiveTexture qglActiveTexture;
|
||||
extern QF_glMultiTexCoord2f qglMultiTexCoord2f;
|
||||
extern QF_glMultiTexCoord2fv qglMultiTexCoord2fv;
|
||||
extern int gl_mtex_active_tmus;
|
||||
extern qboolean gl_mtex_capable;
|
||||
extern qboolean gl_mtex_fullbright;
|
||||
extern GLenum gl_mtex_enum;
|
||||
extern int use_bgra;
|
||||
//extern int use_tmus;
|
||||
extern qboolean gl_combine_capable;
|
||||
extern float gldepthmin, gldepthmax;
|
||||
extern int texture_extension_number;
|
||||
extern int tess;
|
||||
extern qboolean gl_feature_mach64;
|
||||
extern qboolean gl_combine_capable;
|
||||
|
||||
void GL_EndRendering (void);
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height);
|
||||
|
|
|
@ -42,6 +42,7 @@ extern struct cvar_s *gl_sky_divide;
|
|||
extern struct cvar_s *gl_sky_multipass;
|
||||
extern struct cvar_s *gl_tessellate;
|
||||
extern struct cvar_s *gl_texsort;
|
||||
extern struct cvar_s *gl_textures_bgra;
|
||||
extern struct cvar_s *gl_triplebuffer;
|
||||
|
||||
extern struct cvar_s *r_aliasstats;
|
||||
|
|
|
@ -470,7 +470,7 @@ R_BuildLightMap_4 (msurface_t *surf)
|
|||
bl++;
|
||||
*dest++ = min (*bl >> 9, 255);
|
||||
bl++;
|
||||
*dest++ = 0;
|
||||
*dest++ = 255;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -483,7 +483,7 @@ R_BuildLightMap_4 (msurface_t *surf)
|
|||
bl++;
|
||||
*dest++ = min ((*bl >> 9) + (*bl >> 10), 255);
|
||||
bl++;
|
||||
*dest++ = 0;
|
||||
*dest++ = 255;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -496,7 +496,7 @@ R_BuildLightMap_4 (msurface_t *surf)
|
|||
bl++;
|
||||
*dest++ = min (*bl >> 8, 255);
|
||||
bl++;
|
||||
*dest++ = 0;
|
||||
*dest++ = 255;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -762,14 +762,20 @@ GL_BuildLightmaps (model_t **models, int num_models)
|
|||
break;
|
||||
case 3:
|
||||
gl_internalformat = 3;
|
||||
gl_lightmap_format = GL_RGB;
|
||||
if (use_bgra)
|
||||
gl_lightmap_format = GL_BGR;
|
||||
else
|
||||
gl_lightmap_format = GL_RGB;
|
||||
lightmap_bytes = 3;
|
||||
R_BuildLightMap = R_BuildLightMap_3;
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
gl_internalformat = 3;
|
||||
gl_lightmap_format = GL_RGBA;
|
||||
if (use_bgra)
|
||||
gl_lightmap_format = GL_BGRA;
|
||||
else
|
||||
gl_lightmap_format = GL_RGBA;
|
||||
lightmap_bytes = 4;
|
||||
R_BuildLightMap = R_BuildLightMap_4;
|
||||
break;
|
||||
|
|
|
@ -724,7 +724,7 @@ R_DrawAliasModel (entity_t *e)
|
|||
else
|
||||
GL_DrawAliasFrame (vo);
|
||||
} else { // try multitexture
|
||||
if (gl_mtex_active) { // set up the textures
|
||||
if (gl_mtex_active_tmus >= 2) { // set up the textures
|
||||
qglActiveTexture (gl_mtex_enum + 0);
|
||||
qfglBindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
|
|
|
@ -276,8 +276,8 @@ R_DrawEntitiesOnList (void)
|
|||
qfglDisable (GL_PN_TRIANGLES_ATI);
|
||||
if (gl_affinemodels->int_val)
|
||||
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
||||
if (gl_mtex_active) { // FIXME: Ugly, but faster than cleaning up in every
|
||||
// R_DrawAliasModel()!
|
||||
if (gl_mtex_active_tmus >= 2) { // FIXME: Ugly, but faster than cleaning
|
||||
// up in every R_DrawAliasModel()!
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
if (gl_combine_capable && gl_doublebright->int_val) {
|
||||
|
@ -323,8 +323,8 @@ R_DrawViewModel (void)
|
|||
|
||||
R_DrawAliasModel (currententity);
|
||||
qfglColor3ubv (color_white);
|
||||
if (gl_mtex_active) { // FIXME: Ugly, but faster than cleaning up in every
|
||||
// R_DrawAliasModel()!
|
||||
if (gl_mtex_active_tmus) { // FIXME: Ugly, but faster than cleaning up in
|
||||
// every R_DrawAliasModel()!
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
if (gl_combine_capable && gl_doublebright->int_val) {
|
||||
|
|
|
@ -280,14 +280,14 @@ R_DrawWaterSurfaces (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static inline void
|
||||
DrawTextureChains (void)
|
||||
{
|
||||
int i;
|
||||
msurface_t *s;
|
||||
texture_t *tex;
|
||||
|
||||
if (gl_mtex_active) {
|
||||
if (gl_mtex_active_tmus >= 2) {
|
||||
// Lightmaps
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
|
@ -302,8 +302,7 @@ DrawTextureChains (void)
|
|||
continue;
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright
|
||||
&& gl_fb_bmodels->int_val) {
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum);
|
||||
|
@ -450,7 +449,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
R_AddToLightmapChain (psurf);
|
||||
}
|
||||
|
||||
if (gl_mtex_active)
|
||||
if (gl_mtex_active_tmus >= 2)
|
||||
R_CalcLightmaps ();
|
||||
|
||||
psurf = &model->surfaces[model->firstmodelsurface];
|
||||
|
@ -491,9 +490,8 @@ R_DrawBrushModel (entity_t *e)
|
|||
else
|
||||
tex = R_TextureAnimation (psurf);
|
||||
|
||||
if (gl_mtex_active) {
|
||||
if (tex->gl_fb_texturenum && gl_fb_bmodels->int_val
|
||||
&& gl_mtex_fullbright) {
|
||||
if (gl_mtex_active_tmus >= 2) {
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright) {
|
||||
qglActiveTexture (gl_mtex_enum + 2);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum);
|
||||
|
@ -533,7 +531,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
R_RenderBrushPoly_1 (psurf);
|
||||
|
||||
if (tex->gl_fb_texturenum && gl_fb_bmodels->int_val) {
|
||||
if (tex->gl_fb_texturenum && gl_mtex_fullbright) {
|
||||
psurf->polys->fb_chain =
|
||||
fullbright_polys[tex->gl_fb_texturenum];
|
||||
fullbright_polys[tex->gl_fb_texturenum] = psurf->polys;
|
||||
|
@ -543,7 +541,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
}
|
||||
}
|
||||
|
||||
if (gl_mtex_active) {
|
||||
if (gl_mtex_active_tmus >= 2) {
|
||||
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
} else {
|
||||
R_CalcAndBlendLightmaps ();
|
||||
|
@ -713,7 +711,7 @@ R_DrawWorld (void)
|
|||
|
||||
DrawTextureChains ();
|
||||
|
||||
if (!gl_mtex_active)
|
||||
if (gl_mtex_active_tmus <= 1)
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->int_val && !gl_mtex_fullbright)
|
||||
|
|
|
@ -63,7 +63,6 @@ cvar_t *gl_constretch;
|
|||
cvar_t *gl_dlight_polyblend;
|
||||
cvar_t *gl_dlight_smooth;
|
||||
cvar_t *gl_driver;
|
||||
cvar_t *gl_fb_bmodels;
|
||||
cvar_t *gl_fb_models;
|
||||
cvar_t *gl_keeptjunctions;
|
||||
cvar_t *gl_lerp_anim;
|
||||
|
@ -262,8 +261,6 @@ R_Init_Cvars (void)
|
|||
"effect faster on GL");
|
||||
gl_dlight_smooth = Cvar_Get ("gl_dlight_smooth", "1", CVAR_ARCHIVE, NULL,
|
||||
"Smooth dynamic vertex lighting");
|
||||
gl_fb_bmodels = Cvar_Get ("gl_fb_bmodels", "1", CVAR_ARCHIVE, NULL,
|
||||
"Toggles fullbright color support for bmodels");
|
||||
gl_fb_models = Cvar_Get ("gl_fb_models", "1", CVAR_ARCHIVE, NULL,
|
||||
"Toggles fullbright color support for models");
|
||||
gl_keeptjunctions = Cvar_Get ("gl_keeptjunctions", "1", CVAR_ARCHIVE, NULL,
|
||||
|
|
|
@ -64,9 +64,9 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
QF_glActiveTextureARB qglActiveTexture = NULL;
|
||||
QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL;
|
||||
QF_glMultiTexCoord2fvARB qglMultiTexCoord2fv = NULL;
|
||||
QF_glActiveTexture qglActiveTexture = NULL;
|
||||
QF_glMultiTexCoord2f qglMultiTexCoord2f = NULL;
|
||||
QF_glMultiTexCoord2fv qglMultiTexCoord2fv = NULL;
|
||||
|
||||
const char *gl_extensions;
|
||||
const char *gl_renderer;
|
||||
|
@ -77,6 +77,7 @@ int gl_major;
|
|||
int gl_minor;
|
||||
int gl_release_number;
|
||||
|
||||
int gl_bgra_capable, use_bgra;
|
||||
int gl_va_capable;
|
||||
int vaelements;
|
||||
int texture_extension_number = 1;
|
||||
|
@ -84,14 +85,14 @@ int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
|
|||
int gl_filter_max = GL_LINEAR;
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
// ARB Multitexture
|
||||
// Multitexture
|
||||
qboolean gl_mtex_capable = false;
|
||||
qboolean gl_mtex_active = false;
|
||||
qboolean gl_mtex_fullbright = false;
|
||||
int gl_mtex_active_tmus = 0;
|
||||
|
||||
GLenum gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
GLenum gl_mtex_enum;
|
||||
|
||||
// ARB Combine
|
||||
// Combine
|
||||
qboolean gl_combine_capable = false;
|
||||
|
||||
QF_glColorTableEXT qglColorTableEXT = NULL;
|
||||
|
@ -104,9 +105,11 @@ qboolean TruForm;
|
|||
GLint tess, tess_max;
|
||||
|
||||
cvar_t *gl_doublebright;
|
||||
cvar_t *gl_fb_bmodels;
|
||||
cvar_t *gl_max_size;
|
||||
cvar_t *gl_multitexture;
|
||||
cvar_t *gl_tessellate;
|
||||
cvar_t *gl_textures_bgra;
|
||||
cvar_t *gl_vaelements_max;
|
||||
cvar_t *gl_screenshot_byte_swap;
|
||||
cvar_t *vid_mode;
|
||||
|
@ -132,10 +135,43 @@ gl_max_size_f (cvar_t *var)
|
|||
static void
|
||||
gl_doublebright_f (cvar_t *var)
|
||||
{
|
||||
if (!gl_combine_capable && gl_mtex_capable)
|
||||
Con_Printf ("Warning: gl_doublebright has no effect with "
|
||||
"gl_multitexture enabled if you don't have GL_COMBINE_ARB "
|
||||
"support in your driver.\n");
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
if (var->int_val) {
|
||||
if (!gl_combine_capable && gl_mtex_capable)
|
||||
Con_Printf ("Warning: gl_doublebright has no effect with "
|
||||
"gl_multitexture enabled if you don't have "
|
||||
"GL_COMBINE_ARB support in your driver.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gl_textures_bgra_f (cvar_t *var)
|
||||
{
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
if (var->int_val) {
|
||||
if (gl_bgra_capable)
|
||||
use_bgra = 1;
|
||||
else
|
||||
use_bgra = 0;
|
||||
} else {
|
||||
use_bgra = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gl_fb_bmodels_f (cvar_t *var)
|
||||
{
|
||||
if (!var)
|
||||
return;
|
||||
if (var->int_val && gl_mtex_tmus >= 3) {
|
||||
gl_mtex_fullbright = true;
|
||||
} else {
|
||||
gl_mtex_fullbright = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -145,16 +181,22 @@ gl_multitexture_f (cvar_t *var)
|
|||
return;
|
||||
|
||||
if (var->int_val && gl_mtex_capable) {
|
||||
gl_mtex_active = true;
|
||||
gl_mtex_active_tmus = gl_mtex_tmus;
|
||||
|
||||
if (gl_mtex_tmus >= 3) {
|
||||
gl_mtex_fullbright = true;
|
||||
if (gl_fb_bmodels) {
|
||||
if (gl_fb_bmodels->int_val) {
|
||||
if (gl_mtex_tmus >= 3) {
|
||||
gl_mtex_fullbright = true;
|
||||
} else {
|
||||
gl_mtex_fullbright = false;
|
||||
Con_Printf ("Not enough TMUs for BSP fullbrights.\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gl_mtex_fullbright = false;
|
||||
Con_Printf ("Not enough TMUs for BSP fullbrights.\n");
|
||||
}
|
||||
} else {
|
||||
gl_mtex_active = false;
|
||||
gl_mtex_active_tmus = 0;
|
||||
gl_mtex_fullbright = false;
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +215,8 @@ gl_tessellate_f (cvar_t * var)
|
|||
if (TruForm) {
|
||||
if (var)
|
||||
tess = (bound (0, var->int_val, tess_max));
|
||||
else
|
||||
tess = 0;
|
||||
qfglPNTrianglesiATI (GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI, tess);
|
||||
} else {
|
||||
tess = 0;
|
||||
|
@ -187,10 +231,16 @@ GL_Common_Init_Cvars (void)
|
|||
{
|
||||
vid_use8bit = Cvar_Get ("vid_use8bit", "0", CVAR_ROM, NULL, "Use 8-bit "
|
||||
"shared palettes.");
|
||||
gl_textures_bgra = Cvar_Get ("gl_textures_bgra", "0", CVAR_ROM,
|
||||
gl_textures_bgra_f, "If set to 1, try to use "
|
||||
"BGR & BGRA textures instead of RGB & RGBA.");
|
||||
gl_doublebright = Cvar_Get ("gl_doublebright", "1", CVAR_ARCHIVE,
|
||||
gl_doublebright_f, "Use different lighting "
|
||||
"algorithm to increase brightness of map "
|
||||
"surfaces.");
|
||||
gl_fb_bmodels = Cvar_Get ("gl_fb_bmodels", "1", CVAR_ARCHIVE,
|
||||
gl_fb_bmodels_f, "Toggles fullbright color "
|
||||
"support for bmodels");
|
||||
gl_max_size = Cvar_Get ("gl_max_size", "0", CVAR_NONE, gl_max_size_f,
|
||||
"Texture dimension");
|
||||
gl_multitexture = Cvar_Get ("gl_multitexture", "0", CVAR_ARCHIVE,
|
||||
|
@ -220,16 +270,18 @@ CheckGLVersionString (void)
|
|||
if (gl_major >= 1) {
|
||||
if (gl_minor >= 1) {
|
||||
gl_va_capable = true;
|
||||
} else
|
||||
} else {
|
||||
gl_va_capable = false;
|
||||
}
|
||||
}
|
||||
} else if (sscanf (gl_version, "%d.%d.%d", &gl_major, &gl_minor,
|
||||
&gl_release_number) == 3) {
|
||||
if (gl_major >= 1) {
|
||||
if (gl_minor >= 1) {
|
||||
gl_va_capable = true;
|
||||
} else
|
||||
} else {
|
||||
gl_va_capable = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Sys_Error ("Malformed OpenGL version string!");
|
||||
|
@ -247,14 +299,30 @@ CheckGLVersionString (void)
|
|||
gl_feature_mach64 = true;
|
||||
}
|
||||
|
||||
static void
|
||||
CheckBGRAExtensions (void)
|
||||
{
|
||||
if (gl_major >= 1 && gl_minor >= 3) {
|
||||
gl_bgra_capable = true;
|
||||
} else if (QFGL_ExtensionPresent ("GL_EXT_bgra")) {
|
||||
gl_bgra_capable = true;
|
||||
} else {
|
||||
gl_bgra_capable = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CheckCombineExtensions (void)
|
||||
{
|
||||
if (QFGL_ExtensionPresent ("GL_ARB_texture_env_combine")) {
|
||||
if (gl_major >= 1 && gl_minor >= 3) {
|
||||
gl_combine_capable = true;
|
||||
Con_Printf ("COMBINE active, multitextured doublebright enabled.\n");
|
||||
} else if (QFGL_ExtensionPresent ("GL_ARB_texture_env_combine")) {
|
||||
gl_combine_capable = true;
|
||||
Con_Printf ("COMBINE_ARB active, multitextured doublebright "
|
||||
"enabled.\n");
|
||||
} else {
|
||||
gl_combine_capable = false;
|
||||
Con_Printf ("GL_ARB_texture_env_combine not found. gl_doublebright "
|
||||
"will have no effect with gl_multitexture on.\n");
|
||||
}
|
||||
|
@ -273,8 +341,25 @@ CheckMultiTextureExtensions (void)
|
|||
Con_Printf ("disabled.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QFGL_ExtensionPresent ("GL_ARB_multitexture")) {
|
||||
if (gl_major >= 1 && gl_minor >= 3) {
|
||||
qfglGetIntegerv (GL_MAX_TEXTURE_UNITS, &gl_mtex_tmus);
|
||||
if (gl_mtex_tmus >= 2) {
|
||||
Con_Printf ("enabled, %d TMUs.\n", gl_mtex_tmus);
|
||||
qglMultiTexCoord2f =
|
||||
QFGL_ExtensionAddress ("glMultiTexCoord2f");
|
||||
qglMultiTexCoord2fv =
|
||||
QFGL_ExtensionAddress ("glMultiTexCoord2fv");
|
||||
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTexture");
|
||||
gl_mtex_enum = GL_TEXTURE0;
|
||||
if (qglMultiTexCoord2f && gl_mtex_enum)
|
||||
gl_mtex_capable = true;
|
||||
else
|
||||
Con_Printf ("Multitexture disabled, could not find required "
|
||||
"functions\n");
|
||||
} else {
|
||||
Con_Printf ("Multitexture disabled, not enough TMUs.\n");
|
||||
}
|
||||
} else if (QFGL_ExtensionPresent ("GL_ARB_multitexture")) {
|
||||
qfglGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &gl_mtex_tmus);
|
||||
if (gl_mtex_tmus >= 2) {
|
||||
Con_Printf ("enabled, %d TMUs.\n", gl_mtex_tmus);
|
||||
|
@ -426,6 +511,7 @@ GL_Init_Common (void)
|
|||
|
||||
CheckMultiTextureExtensions ();
|
||||
CheckCombineExtensions ();
|
||||
CheckBGRAExtensions ();
|
||||
CheckTruFormExtensions ();
|
||||
GL_Common_Init_Cvars ();
|
||||
CheckVertexArraySize ();
|
||||
|
|
Loading…
Reference in a new issue