Cleanup of extensions, they are no longer defined in glquake.h. In

addition, removed support (for now) for SGIS and EXT multitexture. It
allowed me to enhance support for ARB multitexture, which is better anyway
(especially for Radeon, but that won't get special support yet until we
need a third texture pass).

Updated the Unix 8-bit GL code to be more like the Windows version, which
may work better. It still defaults off, because many drivers have bugs in
their handling of the shared texture palette extension.
This commit is contained in:
Jeff Teunissen 2001-01-06 07:29:17 +00:00
parent cc8d6c5827
commit fc005fc215
7 changed files with 294 additions and 228 deletions

View file

@ -33,13 +33,7 @@
# include "config.h"
#endif
#if defined(_WIN32) && !defined(__GNUC__)
// disable data conversion warnings
// FIXME: move that somewhere else -- yan
# pragma warning(disable : 4244) // MIPS
# pragma warning(disable : 4136) // X86
# pragma warning(disable : 4051) // ALPHA
# pragma warning(disable : 4305) // thousands of double to float truncation warnings
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
@ -49,40 +43,12 @@
#include "cvar.h"
#include "model.h"
#include "render.h"
#include "qfgl_ext.h"
#include "wad.h"
#ifndef GL_BGR
# define GL_BGR 0x80E0
#endif
#ifndef GL_BGRA
# define GL_BGRA 0x80E1
#endif
#ifndef GLAPIENTRY
# ifdef APIENTRY
# define GLAPIENTRY APIENTRY
# else
# define GLAPIENTRY
# endif
#endif
void GL_BeginRendering (int *x, int *y, int *width, int *height);
void GL_EndRendering (void);
// Function prototypes for the Texture Object Extension routines
typedef GLboolean (GLAPIENTRY *ARETEXRESFUNCPTR)(GLsizei, const GLuint *,const GLboolean *);
typedef void (GLAPIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);
typedef void (GLAPIENTRY *DELTEXFUNCPTR)(GLsizei, const GLuint *);
typedef void (GLAPIENTRY *GENTEXFUNCPTR)(GLsizei, GLuint *);
typedef GLboolean (GLAPIENTRY *ISTEXFUNCPTR)(GLuint);
typedef void (GLAPIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,
const GLclampf *);
typedef void (GLAPIENTRY *TEXSUBIMAGEPTR)(int, int, int, int, int, int, int, int, void *);
extern DELTEXFUNCPTR delTexFunc;
extern TEXSUBIMAGEPTR TexSubImage2DFunc;
extern int texture_extension_number;
extern int texture_mode;
@ -92,8 +58,7 @@ void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean a
void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel);
typedef struct
{
typedef struct {
float x, y, z;
float s, t;
float r, g, b;
@ -103,13 +68,6 @@ extern glvert_t glv;
extern int glx, gly, glwidth, glheight;
#ifdef _WIN32
extern PROC glArrayElementEXT;
extern PROC glColorPointerEXT;
extern PROC glTexturePointerEXT;
extern PROC glVertexPointerEXT;
#endif
// r_local.h -- private refresh defs
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
@ -134,8 +92,7 @@ void R_TimeRefresh_f (void);
void R_ReadPointFile_f (void);
texture_t *R_TextureAnimation (texture_t *base);
typedef struct surfcache_s
{
typedef struct surfcache_s {
struct surfcache_s *next;
struct surfcache_s **owner; // NULL is an empty chunk of memory
int lightadj[MAXLIGHTMAPS]; // checked for strobe flush
@ -212,10 +169,6 @@ extern cvar_t *gl_particles;
extern cvar_t *gl_fb_models;
extern cvar_t *gl_fb_bmodels;
extern int gl_lightmap_format;
extern int gl_solid_format;
extern int gl_alpha_format;
extern cvar_t *gl_max_size;
extern cvar_t *gl_playermip;
@ -224,6 +177,10 @@ extern cvar_t *gl_skymultipass;
extern cvar_t *gl_sky_clip;
extern cvar_t *gl_sky_divide;
extern int gl_lightmap_format;
extern int gl_solid_format;
extern int gl_alpha_format;
extern float r_world_matrix[16];
extern const char *gl_vendor;
@ -233,20 +190,11 @@ extern const char *gl_extensions;
void R_TranslatePlayerSkin (int playernum);
// Multitexture
#define TEXTURE0_SGIS 0x835E
#define TEXTURE1_SGIS 0x835F
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
typedef void (GLAPIENTRY *lpMTexFUNC) (GLenum, GLfloat, GLfloat);
typedef void (GLAPIENTRY *lpSelTexFUNC) (GLenum);
extern lpMTexFUNC qglMTexCoord2f;
extern lpSelTexFUNC qglSelectTexture;
extern qboolean gl_mtexable;
extern qboolean gl_arb_mtex;
extern int gl_mtex_enum;
// Multitexturing
extern QF_glActiveTextureARB qglActiveTexture;
extern QF_glMultiTexCoord2fARB qglMultiTexCoord2f;
extern qboolean gl_mtex_capable;
extern GLenum gl_mtex_enum;
void GL_DisableMultitexture (void);
void GL_EnableMultitexture (void);
@ -348,4 +296,3 @@ void GL_BuildLightmaps (void);
void R_NetGraph (void);
#endif // _GLQUAKE_H

View file

@ -33,20 +33,90 @@
# include "config.h"
#endif
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include <GL/gl.h>
#ifdef HAVE_GL_GLX_H
# include <GL/glx.h>
#endif
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include "qtypes.h"
// Define GLAPIENTRY to a useful value
#ifndef GLAPIENTRY
# ifdef APIENTRY
# define GLAPIENTRY APIENTRY
# else
# define GLAPIENTRY
# endif
#endif
// OpenGL numbers for extensions we use or want to use
#ifndef GL_EXT_bgra
# define GL_BGR_EXT 0x80E0
# define GL_BGRA_EXT 0x80E1
#endif
#ifndef GL_EXT_texture_object
#define GL_TEXTURE_PRIORITY_EXT 0x8066
#define GL_TEXTURE_RESIDENT_EXT 0x8067
#define GL_TEXTURE_1D_BINDING_EXT 0x8068
#define GL_TEXTURE_2D_BINDING_EXT 0x8069
#define GL_TEXTURE_3D_BINDING_EXT 0x806A
#endif
#ifndef GL_EXT_point_parameters
#define GL_POINT_SIZE_MIN_EXT 0x8126
#define GL_POINT_SIZE_MAX_EXT 0x8127
#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
#define GL_DISTANCE_ATTENUATION_EXT 0x8129
#endif
#ifndef GL_ARB_multitexture
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
#define GL_TEXTURE2_ARB 0x84C2
#define GL_TEXTURE3_ARB 0x84C3
#define GL_TEXTURE4_ARB 0x84C4
#define GL_TEXTURE5_ARB 0x84C5
#define GL_TEXTURE6_ARB 0x84C6
#define GL_TEXTURE7_ARB 0x84C7
#define GL_TEXTURE8_ARB 0x84C8
#define GL_TEXTURE9_ARB 0x84C9
#define GL_TEXTURE10_ARB 0x84CA
#define GL_TEXTURE11_ARB 0x84CB
#define GL_TEXTURE12_ARB 0x84CC
#define GL_TEXTURE13_ARB 0x84CD
#define GL_TEXTURE14_ARB 0x84CE
#define GL_TEXTURE15_ARB 0x84CF
#define GL_TEXTURE16_ARB 0x84D0
#define GL_TEXTURE17_ARB 0x84D1
#define GL_TEXTURE18_ARB 0x84D2
#define GL_TEXTURE19_ARB 0x84D3
#define GL_TEXTURE20_ARB 0x84D4
#define GL_TEXTURE21_ARB 0x84D5
#define GL_TEXTURE22_ARB 0x84D6
#define GL_TEXTURE23_ARB 0x84D7
#define GL_TEXTURE24_ARB 0x84D8
#define GL_TEXTURE25_ARB 0x84D9
#define GL_TEXTURE26_ARB 0x84DA
#define GL_TEXTURE27_ARB 0x84DB
#define GL_TEXTURE28_ARB 0x84DC
#define GL_TEXTURE29_ARB 0x84DD
#define GL_TEXTURE30_ARB 0x84DE
#define GL_TEXTURE31_ARB 0x84DF
#define GL_ACTIVE_TEXTURE_ARB 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
#endif
/* Standard OpenGL external function defs */
typedef void (GLAPIENTRY *QF_glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
typedef void (GLAPIENTRY *QF_glBlendEquation) (GLenum mode);
@ -87,12 +157,75 @@ typedef void (GLAPIENTRY *QF_glTexImage3D) (GLenum target, GLint level, GLint in
typedef void (GLAPIENTRY *QF_glTexSubImage3D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
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);
// GL_EXT_paletted_texture
typedef void (GLAPIENTRY *QF_glColorTableEXT) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
typedef void (GLAPIENTRY *QF_glGetColorTableEXT) (GLenum target, GLenum format, GLenum type, GLvoid *data);
typedef void (GLAPIENTRY *QF_glGetColorTableParameterivEXT) (GLenum target, GLenum pname, GLint *params);
typedef void (GLAPIENTRY *QF_glGetColorTableParameterfvEXT) (GLenum target, GLenum pname, GLfloat *params);
// GL_EXT_point_parameters
typedef void (GLAPIENTRY *QF_glPointParameterfEXT) (GLenum pname, GLfloat param);
typedef void (GLAPIENTRY *QF_glPointParameterfvEXT) (GLenum pname, const GLfloat *params);
// GL_EXT_subtexture
typedef void (GLAPIENTRY *QF_glTexSubImage1DEXT) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (GLAPIENTRY *QF_glTexSubImage2DEXT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
// GL_EXT_texture_object
typedef GLboolean (GLAPIENTRY *QF_glAreTexturesResidentEXT) (GLsizei n, const GLuint *textures, GLboolean *residences);
typedef void (GLAPIENTRY *QF_glBindTextureEXT) (GLenum target, GLuint texture);
typedef void (GLAPIENTRY *QF_glDeleteTexturesEXT) (GLsizei n, const GLuint *textures);
typedef void (GLAPIENTRY *QF_glGenTexturesEXT) (GLsizei n, GLuint *textures);
typedef GLboolean (GLAPIENTRY *QF_glIsTextureEXT) (GLuint texture);
typedef void (GLAPIENTRY *QF_glPrioritizeTexturesEXT) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
// GL_EXT_vertex_array
typedef void (GLAPIENTRY *QF_glArrayElementEXT) (GLint i);
typedef void (GLAPIENTRY *QF_glColorPointerEXT) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (GLAPIENTRY *QF_glDrawArraysEXT) (GLenum mode, GLint first, GLsizei count);
typedef void (GLAPIENTRY *QF_glEdgeFlagPointerEXT) (GLsizei stride, GLsizei count, const GLboolean *pointer);
typedef void (GLAPIENTRY *QF_glGetPointervEXT) (GLenum pname, GLvoid* *params);
typedef void (GLAPIENTRY *QF_glIndexPointerEXT) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (GLAPIENTRY *QF_glNormalPointerEXT) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (GLAPIENTRY *QF_glTexCoordPointerEXT) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (GLAPIENTRY *QF_glVertexPointerEXT) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
// 3Dfx
typedef void (GLAPIENTRY *QF_gl3DfxSetPaletteEXT) (GLuint *pal);

View file

@ -36,6 +36,12 @@
#pragma warning( disable : 4761)
// disable data conversion warnings
# pragma warning(disable : 4051) // ALPHA
# pragma warning(disable : 4136) // X86
# pragma warning(disable : 4244) // MIPS
# pragma warning(disable : 4305) // thousands of double to float truncation warnings
/* Define to empty if the keyword does not work. */
#undef const
@ -227,6 +233,7 @@
/* Define if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H
/* Define if you have the <unistd.h> header file. */

View file

@ -381,8 +381,8 @@ extern int solidskytexture;
extern int alphaskytexture;
extern float speedscale; // for top sky and bottom sky
lpMTexFUNC qglMTexCoord2f = NULL;
lpSelTexFUNC qglSelectTexture = NULL;
QF_glActiveTextureARB qglActiveTexture = NULL;
QF_glMultiTexCoord2fARB qglMultiTexCoord2f = NULL;
void
GL_UploadLightmap (int i, int x, int y, int w, int h)
@ -414,12 +414,12 @@ R_DrawMultitexturePoly (msurface_t *s)
glColor3f (1, 1, 1);
// Binds world to texture env 0
qglSelectTexture (gl_mtex_enum + 0);
qglActiveTexture (gl_mtex_enum + 0);
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable (GL_TEXTURE_2D);
// Binds lightmap to texenv 1
qglSelectTexture (gl_mtex_enum + 1);
qglActiveTexture (gl_mtex_enum + 1);
glBindTexture (GL_TEXTURE_2D, lightmap_textures + i);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable (GL_TEXTURE_2D);
@ -448,13 +448,13 @@ R_DrawMultitexturePoly (msurface_t *s)
glBegin (GL_POLYGON);
v = s->polys->verts[0];
for (i = 0; i < s->polys->numverts; i++, v += VERTEXSIZE) {
qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
qglMultiTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMultiTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
glVertex3fv (v);
}
glEnd ();
glDisable (GL_TEXTURE_2D);
qglSelectTexture (gl_mtex_enum + 0);
qglActiveTexture (gl_mtex_enum + 0);
glEnable (GL_TEXTURE_2D);
if (texture->gl_fb_texturenum > 0) {
@ -785,7 +785,7 @@ R_DrawBrushModel (entity_t *e)
e->angles[0] = -e->angles[0]; // stupid quake bug
// LordHavoc: anyone without multitexture won't want texsort 0 anyway...
if (!gl_mtexable)
if (!gl_mtex_capable)
Cvar_SetValue (gl_texsort, 1);
//
@ -966,7 +966,7 @@ R_DrawWorld (void)
currententity = &ent;
// LordHavoc: anyone without multitexture won't want texsort 0 anyway...
if (!gl_mtexable)
if (!gl_mtex_capable)
Cvar_SetValue (gl_texsort, 1);
memset (lightmap_polys, 0, sizeof (lightmap_polys));
@ -1266,8 +1266,8 @@ GL_BuildLightmaps (void)
}
}
if (gl_mtexable && !gl_texsort->int_val)
qglSelectTexture (gl_mtex_enum + 1);
if (gl_mtex_capable && !gl_texsort->int_val)
qglActiveTexture (gl_mtex_enum + 1);
//
// upload all lightmaps that were filled
@ -1288,6 +1288,6 @@ GL_BuildLightmaps (void)
GL_UNSIGNED_BYTE, lightmaps[i]);
}
if (gl_mtexable && !gl_texsort->int_val)
qglSelectTexture (gl_mtex_enum + 0);
if (gl_mtex_capable && !gl_texsort->int_val)
qglActiveTexture (gl_mtex_enum + 0);
}

View file

@ -651,7 +651,7 @@ SCR_ScreenShot_f (void)
return;
}
buffer = malloc (glwidth * glheight * 3);
glReadPixels (glx, gly, glwidth, glheight, GL_BGR, GL_UNSIGNED_BYTE,
glReadPixels (glx, gly, glwidth, glheight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
buffer);
WriteTGAfile (pcxname, buffer, glwidth, glheight);
free (buffer);

View file

@ -72,11 +72,11 @@ const char *gl_version;
const char *gl_extensions;
// ARB Multitexture
int gl_mtex_enum = TEXTURE0_SGIS;
qboolean gl_arb_mtex = false;
qboolean gl_mtexable = false;
qboolean gl_mtex_capable = false;
GLenum gl_mtex_enum = GL_TEXTURE0_ARB;
static qboolean is8bit = false;
QF_glColorTableEXT qglColorTableEXT = NULL;
qboolean is8bit = false;
cvar_t *vid_use8bit;
/*-----------------------------------------------------------------------*/
@ -84,41 +84,33 @@ cvar_t *vid_use8bit;
/*
CheckMultiTextureExtensions
Check for ARB, SGIS, or EXT multitexture support
Check for ARB multitexture support
*/
void
CheckMultiTextureExtensions (void)
{
Con_Printf ("Checking for multitexture: ");
if (COM_CheckParm ("-nomtex")) {
Con_Printf ("disabled\n");
Con_Printf ("disabled.\n");
return;
}
if (QFGL_ExtensionPresent ("GL_ARB_multitexture")) {
Con_Printf ("GL_ARB_multitexture\n");
qglMTexCoord2f = QFGL_ExtensionAddress ("glMultiTexCoord2fARB");
qglSelectTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
int max_texture_units = 0;
glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &max_texture_units);
if (max_texture_units >= 2) {
Con_Printf ("enabled, %d TMUs.\n", max_texture_units);
qglMultiTexCoord2f = QFGL_ExtensionAddress ("glMultiTexCoord2fARB");
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
gl_arb_mtex = true;
} else if (QFGL_ExtensionPresent ("GL_SGIS_multitexture")) {
Con_Printf ("GL_SGIS_multitexture\n");
qglMTexCoord2f = QFGL_ExtensionAddress ("glMTexCoord2fSGIS");
qglSelectTexture = QFGL_ExtensionAddress ("glSelectTextureSGIS");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else if (QFGL_ExtensionPresent ("GL_EXT_multitexture")) {
Con_Printf ("GL_EXT_multitexture\n");
qglMTexCoord2f = QFGL_ExtensionAddress ("glMTexCoord2fEXT");
qglSelectTexture = QFGL_ExtensionAddress ("glSelectTextureEXT");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
gl_mtex_capable = true;
} else {
Con_Printf ("none\n");
Con_Printf ("disabled, not enough TMUs.\n");
}
} else {
Con_Printf ("not found.\n");
}
}
@ -312,15 +304,12 @@ Tdfx_Init8bitPalette (void)
* the GL_EXT_shared_texture_palette spec might be a very good idea in
* general.
*/
#if 0
void
Shared_Init8bitPalette (void)
{
int i;
GLubyte thePalette[256][3];
GLubyte *oldPalette;
QF_glColorTableEXT qglColorTableEXT = NULL;
GLubyte thePalette[256 * 3];
GLubyte *oldPalette, *newPalette;
if (is8bit) {
return;
@ -333,20 +322,21 @@ Shared_Init8bitPalette (void)
Con_Printf ("GL_EXT_shared_texture_palette\n");
oldPalette = (GLubyte *) d_8to24table; // d_8to24table3dfx;
for (i = 0; i < 256; i++) {
thePalette[i][0] = *oldPalette++;
thePalette[i][1] = *oldPalette++;
thePalette[i][2] = *oldPalette++;
}
glEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
oldPalette = (GLubyte *) d_8to24table; // d_8to24table3dfx;
newPalette = thePalette;
for (i = 0; i < 256; i++) {
*newPalette++ = *oldPalette++;
*newPalette++ = *oldPalette++;
*newPalette++ = *oldPalette++;
oldPalette++;
}
qglColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *) thePalette);
is8bit = true;
}
}
#endif
#endif
void
VID_Init8bitPalette (void)
@ -358,10 +348,10 @@ VID_Init8bitPalette (void)
if (vid_use8bit->int_val) {
#ifdef GL_SHARED_TEXTURE_PALETTE_EXT
Tdfx_Init8bitPalette ();
//Shared_Init8bitPalette ();
Shared_Init8bitPalette ();
#endif
if (!is8bit) {
Con_Printf ("none\n");
Con_Printf ("not found.\n");
}
} else {
Con_Printf ("disabled.\n");

View file

@ -93,6 +93,15 @@ const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;
// ARB Multitexture
qboolean gl_mtex_capable = false;
GLenum gl_mtex_enum = GL_TEXTURE0_ARB;
// 8-bit and permedia support
QF_glColorTableEXT qglColorTableEXT = NULL;
qboolean is8bit = false;
qboolean isPermedia = false;
// fixme: Only used by MGL ..
qboolean DDActive;
@ -154,14 +163,6 @@ void ClearAllStates (void);
void VID_UpdateWindowStatus (void);
void GL_Init (void);
typedef void (APIENTRY * lp3DFXFUNC) (int, int, int, int, int, const void *);
lp3DFXFUNC glColorTableEXT;
qboolean is8bit = false;
qboolean isPermedia = false;
int gl_mtex_enum = TEXTURE0_SGIS;
qboolean gl_arb_mtex = false;
qboolean gl_mtexable = false;
//====================================
cvar_t *_windowed_mouse;
@ -490,47 +491,33 @@ VID_UpdateWindowStatus (void)
int texture_extension_number = 1;
#ifdef _WIN32
void
CheckMultiTextureExtensions (void)
{
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex")) {
Con_Printf ("disabled\n");
Con_Printf ("disabled.\n");
return;
}
if (strstr (gl_extensions, "GL_ARB_multitexture ")) {
Con_Printf ("GL_ARB_multitexture\n");
qglMTexCoord2f = (void *) wglGetProcAddress ("glMultiTexCoord2fARB");
qglSelectTexture = (void *) wglGetProcAddress ("glActiveTextureARB");
if (QFGL_ExtensionPresent ("GL_ARB_multitexture")) {
int max_texture_units = 0;
glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &max_texture_units);
if (max_texture_units >= 2) {
Con_Printf ("enabled, %d TMUs.\n", max_texture_units);
qglMultiTexCoord2f = QFGL_ExtensionAddress ("glMultiTexCoord2fARB");
qglActiveTexture = QFGL_ExtensionAddress ("glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
gl_arb_mtex = true;
} else if (strstr (gl_extensions, "GL_SGIS_multitexture ")) {
Con_Printf ("GL_SGIS_multitexture\n");
qglMTexCoord2f = (void *) wglGetProcAddress ("glMTexCoord2fSGIS");
qglSelectTexture = (void *) wglGetProcAddress ("glSelectTextureSGIS");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else if (strstr (gl_extensions, "GL_EXT_multitexture ")) {
Con_Printf ("GL_EXT_multitexture\n");
qglMTexCoord2f = (void *) wglGetProcAddress ("glMTexCoord2fEXT");
qglSelectTexture = (void *) wglGetProcAddress ("glSelectTextureEXT");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
gl_mtex_capable = true;
} else {
Con_Printf ("none found\n");
Con_Printf ("disabled, not enough TMUs.\n");
}
} else {
Con_Printf ("not found.\n");
}
}
#else
void
CheckMultiTextureExtensions (void)
{
gl_mtexable = true;
}
#endif
/*
===============
@ -1428,25 +1415,26 @@ VID_Is8bit ()
return is8bit;
}
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
void
VID_Init8bitPalette ()
VID_Init8bitPalette (void)
{
// Check for 8bit Extensions and initialize them.
int i;
char thePalette[256 * 3];
char *oldPalette, *newPalette;
GLubyte thePalette[256 * 3];
GLubyte *oldPalette, *newPalette;
glColorTableEXT = (void *) wglGetProcAddress ("glColorTableEXT");
if (!glColorTableEXT
|| strstr (gl_extensions, "GL_EXT_shared_texture_palette")
|| COM_CheckParm ("-no8bit"))
if (COM_CheckParm ("-no8bit") || is8bit) {
return;
}
if (QFGL_ExtensionPresent ("GL_EXT_shared_texture_palette")) {
if (!(qglColorTableEXT = QFGL_ExtensionAddress ("glColorTableEXT"))) {
return;
}
Con_Printf ("8-bit GL extension enabled.\n");
Con_Printf ("8-bit GL extensions enabled.\n");
glEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
oldPalette = (char *) d_8to24table; // d_8to24table3dfx;
oldPalette = (GLubyte *) d_8to24table; // d_8to24table3dfx;
newPalette = thePalette;
for (i = 0; i < 256; i++) {
*newPalette++ = *oldPalette++;
@ -1454,9 +1442,10 @@ VID_Init8bitPalette ()
*newPalette++ = *oldPalette++;
oldPalette++;
}
glColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
GL_UNSIGNED_BYTE, (void *) thePalette);
is8bit = TRUE;
qglColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *) thePalette);
is8bit = true;
}
}
/*