mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
GL1 multitexture, initialization
While it is based on the old, buggy multitexture implementation (removed in68a12d4e
&8fe8f832
), rework will be done to make it function as intended this time. For this commit, just init and function declarations.
This commit is contained in:
parent
79bb13d3a7
commit
3faa3db167
6 changed files with 187 additions and 3 deletions
|
@ -144,6 +144,30 @@ R_SetTexturePalette(unsigned palette[256])
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
R_SelectTexture(GLenum texture)
|
||||
{
|
||||
int tmu;
|
||||
|
||||
if (!gl_config.multitexture)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tmu = texture - GL_TEXTURE0;
|
||||
|
||||
if (tmu == gl_state.currenttmu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gl_state.currenttmu = tmu;
|
||||
gl_state.currenttarget = texture;
|
||||
|
||||
qglActiveTexture(texture);
|
||||
qglClientActiveTexture(texture);
|
||||
}
|
||||
|
||||
void
|
||||
R_TexEnv(GLenum mode)
|
||||
{
|
||||
|
@ -151,7 +175,7 @@ R_TexEnv(GLenum mode)
|
|||
|
||||
if (mode != lastmodes[gl_state.currenttmu])
|
||||
{
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode); // FIXME: shouldn't this be glTexEnvi() ?
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
|
||||
lastmodes[gl_state.currenttmu] = mode;
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +199,93 @@ R_Bind(int texnum)
|
|||
glBindTexture(GL_TEXTURE_2D, texnum);
|
||||
}
|
||||
|
||||
void
|
||||
R_MBind(GLenum target, int texnum)
|
||||
{
|
||||
const int tmu = target - GL_TEXTURE0;
|
||||
|
||||
if (target != gl_state.currenttarget)
|
||||
{
|
||||
R_SelectTexture(target);
|
||||
}
|
||||
|
||||
if (gl_state.currenttextures[tmu] == texnum)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
R_Bind(texnum);
|
||||
}
|
||||
|
||||
void
|
||||
R_EnableMultitexture(qboolean enable)
|
||||
{
|
||||
static qboolean active;
|
||||
|
||||
if (!gl_config.multitexture || enable == active)
|
||||
{
|
||||
return; // current state is the right one
|
||||
}
|
||||
|
||||
active = enable;
|
||||
R_SelectTexture(GL_TEXTURE1);
|
||||
|
||||
if (active && !r_fullbright->value)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
if (gl_config.mtexcombine)
|
||||
{
|
||||
R_TexEnv(GL_COMBINE);
|
||||
|
||||
if (gl_lightmap->value)
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS);
|
||||
}
|
||||
|
||||
R_SelectTexture(GL_TEXTURE0);
|
||||
R_TexEnv(GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gl_lightmap->value)
|
||||
{
|
||||
R_TexEnv(GL_REPLACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
R_TexEnv(GL_MODULATE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else // disable multitexturing
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
R_TexEnv(GL_REPLACE);
|
||||
}
|
||||
|
||||
R_SelectTexture(GL_TEXTURE0);
|
||||
R_TexEnv(GL_REPLACE);
|
||||
}
|
||||
|
||||
void
|
||||
R_TextureMode(char *string)
|
||||
{
|
||||
|
|
|
@ -90,6 +90,7 @@ cvar_t *gl1_particle_square;
|
|||
|
||||
cvar_t *gl1_palettedtexture;
|
||||
cvar_t *gl1_pointparameters;
|
||||
cvar_t *gl1_multitexture;
|
||||
|
||||
cvar_t *gl_drawbuffer;
|
||||
cvar_t *gl_lightmap;
|
||||
|
@ -1211,6 +1212,7 @@ R_Register(void)
|
|||
|
||||
gl1_palettedtexture = ri.Cvar_Get("r_palettedtextures", "0", CVAR_ARCHIVE);
|
||||
gl1_pointparameters = ri.Cvar_Get("gl1_pointparameters", "1", CVAR_ARCHIVE);
|
||||
gl1_multitexture = ri.Cvar_Get("gl1_multitexture", "2", CVAR_ARCHIVE);
|
||||
|
||||
gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
|
||||
r_vsync = ri.Cvar_Get("r_vsync", "1", CVAR_ARCHIVE);
|
||||
|
@ -1574,6 +1576,65 @@ RI_Init(void)
|
|||
|
||||
// ----
|
||||
|
||||
/* Multitexturing */
|
||||
gl_config.multitexture = gl_config.mtexcombine = false;
|
||||
|
||||
R_Printf(PRINT_ALL, " - Multitexturing: ");
|
||||
|
||||
if (strstr(gl_config.extensions_string, "GL_ARB_multitexture"))
|
||||
{
|
||||
qglActiveTexture = (void (APIENTRY *)(GLenum))RI_GetProcAddress ("glActiveTexture");
|
||||
qglClientActiveTexture = (void (APIENTRY *)(GLenum))RI_GetProcAddress ("glClientActiveTexture");
|
||||
|
||||
if (!qglActiveTexture || !qglClientActiveTexture)
|
||||
{
|
||||
qglActiveTexture = (void (APIENTRY *)(GLenum))RI_GetProcAddress ("glActiveTextureARB");
|
||||
qglClientActiveTexture = (void (APIENTRY *)(GLenum))RI_GetProcAddress ("glClientActiveTextureARB");
|
||||
}
|
||||
}
|
||||
|
||||
if (gl1_multitexture->value)
|
||||
{
|
||||
if (qglActiveTexture && qglClientActiveTexture)
|
||||
{
|
||||
gl_config.multitexture = true;
|
||||
R_Printf(PRINT_ALL, "Okay\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Failed\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Disabled\n");
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
/* Multi texturing combine */
|
||||
R_Printf(PRINT_ALL, " - Multitexturing combine: ");
|
||||
|
||||
if ( ( strstr(gl_config.extensions_string, "GL_ARB_texture_env_combine")
|
||||
|| strstr(gl_config.extensions_string, "GL_EXT_texture_env_combine") ) )
|
||||
{
|
||||
if (gl_config.multitexture && gl1_multitexture->value > 1)
|
||||
{
|
||||
gl_config.mtexcombine = true;
|
||||
R_Printf(PRINT_ALL, "Okay\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Disabled\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Failed\n");
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
R_SetDefaultState();
|
||||
|
||||
R_InitImages();
|
||||
|
|
|
@ -762,8 +762,6 @@ R_DrawBrushModel(entity_t *currententity, const model_t *currentmodel)
|
|||
currententity->angles[0] = -currententity->angles[0];
|
||||
currententity->angles[2] = -currententity->angles[2];
|
||||
|
||||
R_TexEnv(GL_REPLACE);
|
||||
|
||||
if (gl_lightmap->value)
|
||||
{
|
||||
R_TexEnv(GL_REPLACE);
|
||||
|
|
|
@ -162,6 +162,7 @@ extern cvar_t *gl1_overbrightbits;
|
|||
|
||||
extern cvar_t *gl1_palettedtexture;
|
||||
extern cvar_t *gl1_pointparameters;
|
||||
extern cvar_t *gl1_multitexture;
|
||||
|
||||
extern cvar_t *gl1_particle_min_size;
|
||||
extern cvar_t *gl1_particle_max_size;
|
||||
|
@ -230,6 +231,9 @@ void R_TranslatePlayerSkin(int playernum);
|
|||
void R_Bind(int texnum);
|
||||
|
||||
void R_TexEnv(GLenum value);
|
||||
void R_SelectTexture(GLenum);
|
||||
void R_MBind(GLenum target, int texnum);
|
||||
void R_EnableMultitexture(qboolean enable);
|
||||
|
||||
void R_LightPoint(entity_t *currententity, vec3_t p, vec3_t color);
|
||||
void R_PushDlights(void);
|
||||
|
@ -359,6 +363,8 @@ typedef struct
|
|||
qboolean npottextures;
|
||||
qboolean palettedtexture;
|
||||
qboolean pointparameters;
|
||||
qboolean multitexture;
|
||||
qboolean mtexcombine;
|
||||
|
||||
// ----
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#endif
|
||||
|
||||
#ifndef GL_VERSION_1_3
|
||||
#define GL_TEXTURE0 0x84C0
|
||||
#define GL_TEXTURE1 0x84C1
|
||||
#define GL_MULTISAMPLE 0x809D
|
||||
#define GL_COMBINE 0x8570
|
||||
#define GL_COMBINE_RGB 0x8571
|
||||
|
@ -95,5 +97,7 @@ extern void ( APIENTRY *qglPointParameterfv ) ( GLenum param,
|
|||
const GLfloat *value );
|
||||
extern void ( APIENTRY *qglColorTableEXT ) ( GLenum, GLenum, GLsizei, GLenum,
|
||||
GLenum, const GLvoid * );
|
||||
extern void ( APIENTRY *qglActiveTexture ) ( GLenum texture );
|
||||
extern void ( APIENTRY *qglClientActiveTexture ) ( GLenum texture );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,6 +42,8 @@ void (APIENTRY *qglPointParameterf)(GLenum param, GLfloat value);
|
|||
void (APIENTRY *qglPointParameterfv)(GLenum param, const GLfloat *value);
|
||||
void (APIENTRY *qglColorTableEXT)(GLenum, GLenum, GLsizei, GLenum, GLenum,
|
||||
const GLvoid *);
|
||||
void (APIENTRY *qglActiveTexture) (GLenum texture);
|
||||
void (APIENTRY *qglClientActiveTexture) (GLenum texture);
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
|
@ -50,6 +52,8 @@ void QGL_EXT_Reset ( void )
|
|||
qglPointParameterf = NULL;
|
||||
qglPointParameterfv = NULL;
|
||||
qglColorTableEXT = NULL;
|
||||
qglActiveTexture = NULL;
|
||||
qglClientActiveTexture = NULL;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
|
Loading…
Reference in a new issue