vid_wgl in qw now uses vid_common_gl. probably doesn't work

compile fix for merged glquake.h in vid_wg.c in nq
This commit is contained in:
Bill Currie 2001-04-15 03:17:03 +00:00
parent 9f583076f8
commit bd0fab4ce1
4 changed files with 16 additions and 229 deletions

View file

@ -157,7 +157,7 @@ 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;
GLenum gl_mtex_enum = TEXTURE0_SGIS;
qboolean gl_arb_mtex = false;
qboolean gl_mtexable = false;

View file

@ -235,7 +235,7 @@ qw_client_sgl_DEPENDENCIES= $(CLIENT_LIB_DEPS)
#
# SGI/Microsoft WGL (Windows OpenGL)
#
wgl_SOURCES= vid_wgl.c
wgl_SOURCES= vid_wgl.c vid_common_gl.c
qw_client_wgl_SOURCES= $(common_SOURCES) $(client_SOURCES) $(ogl_SOURCES) $(wgl_SOURCES) in_win.c
qw_client_wgl_LDADD= $(CLIENT_LIBS) $(GLX_LIBS) -lgdi32

View file

@ -427,8 +427,10 @@ IN_Init_Cvars (void)
// mouse variables
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, NULL,
"Toggle mouse input filtering.");
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, NULL,
"Grab the mouse from X while playing quake");
JOY_Init_Cvars();
JOY_Init_Cvars();
}
/*

View file

@ -50,6 +50,9 @@
#include "QF/sys.h"
#include "QF/va.h"
extern void GL_Init_Common (void);
extern void VID_Init8bitPalette (void);
extern void (*vid_menudrawfn) (void);
extern void (*vid_menukeyfn) (int);
@ -95,13 +98,7 @@ 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 ..
@ -183,33 +180,12 @@ VID_ForceLockState (int lk)
{
}
void
VID_LockBuffer (void)
{
}
void
VID_UnlockBuffer (void)
{
}
int
VID_ForceUnlockedAndReturnState (void)
{
return 0;
}
void
D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height)
{
}
void
D_EndDirectRect (int x, int y, int width, int height)
{
}
void
CenterWindow (HWND hWndCenter, int width, int height, BOOL lefttopjustify)
{
@ -486,94 +462,18 @@ VID_UpdateWindowStatus (void)
IN_UpdateClipCursor ();
}
int texture_extension_number = 1;
void
CheckMultiTextureExtensions (void)
{
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex")) {
Con_Printf ("disabled.\n");
return;
}
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_mtex_capable = true;
} else {
Con_Printf ("disabled, not enough TMUs.\n");
}
} else {
Con_Printf ("not found.\n");
}
}
/*
GL_Init
*/
void
GL_Init (void)
{
gl_vendor = glGetString (GL_VENDOR);
Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
gl_renderer = glGetString (GL_RENDERER);
Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
gl_version = glGetString (GL_VERSION);
Con_Printf ("GL_VERSION: %s\n", gl_version);
gl_extensions = glGetString (GL_EXTENSIONS);
Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
GL_Init_Common ();
if (strnicmp (gl_renderer, "PowerVR", 7) == 0)
fullsbardraw = true;
if (strnicmp (gl_renderer, "Permedia", 8) == 0)
isPermedia = true;
CheckMultiTextureExtensions ();
glClearColor (0, 0, 0, 0);
glCullFace (GL_FRONT);
glEnable (GL_TEXTURE_2D);
glEnable (GL_ALPHA_TEST);
glAlphaFunc (GL_GREATER, 0.666);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glShadeModel (GL_FLAT);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
/*
GL_BeginRendering
*/
void
GL_BeginRendering (int *x, int *y, int *width, int *height)
{
*x = *y = 0;
*width = WindowRect.right - WindowRect.left;
*height = WindowRect.bottom - WindowRect.top;
}
void
@ -605,81 +505,6 @@ GL_EndRendering (void)
Sbar_Changed ();
}
void
VID_SetPalette (unsigned char *palette)
{
byte *pal;
unsigned int r, g, b;
unsigned int v;
int r1, g1, b1;
int k;
unsigned short i;
unsigned int *table;
QFile *f;
char s[255];
float dist, bestdist;
static qboolean palflag = false;
//
// 8 8 8 encoding
//
// Con_Printf("Converting 8to24\n");
pal = palette;
table = d_8to24table;
for (i = 0; i < 256; i++) {
r = pal[0];
g = pal[1];
b = pal[2];
pal += 3;
// v = (255<<24) + (r<<16) + (g<<8) + (b<<0);
// v = (255<<0) + (r<<8) + (g<<16) + (b<<24);
v = (255 << 24) + (r << 0) + (g << 8) + (b << 16);
*table++ = v;
}
d_8to24table[255] &= 0; // 255 is transparent
// JACK: 3D distance calcs - k is last closest, l is the distance.
if (palflag)
return;
palflag = true;
COM_FOpenFile ("glquake/15to8.pal", &f);
if (f) {
Qread (f, d_15to8table, 1 << 15);
Qclose (f);
} else {
for (i = 0; i < (1 << 15); i++) {
/* Maps 000000000000000 000000000011111 = Red = 0x1F
000001111100000 = Blue = 0x03E0 111110000000000 = Grn =
0x7C00 */
r = ((i & 0x1F) << 3) + 4;
g = ((i & 0x03E0) >> 2) + 4;
b = ((i & 0x7C00) >> 7) + 4;
pal = (unsigned char *) d_8to24table;
for (v = 0, k = 0, bestdist = 10000.0; v < 256; v++, pal += 4) {
r1 = (int) r - (int) pal[0];
g1 = (int) g - (int) pal[1];
b1 = (int) b - (int) pal[2];
dist = sqrt (((r1 * r1) + (g1 * g1) + (b1 * b1)));
if (dist < bestdist) {
k = v;
bestdist = dist;
}
}
d_15to8table[i] = k;
}
snprintf (s, sizeof (s), "%s/glquake/15to8.pal", com_gamedir);
COM_CreatePath (s);
if ((f = Qopen (s, "wb")) != NULL) {
Qwrite (f, d_15to8table, 1 << 15);
Qclose (f);
}
}
}
void
VID_ShiftPalette (unsigned char *palette)
{
@ -1374,51 +1199,6 @@ VID_InitFullDIB (HINSTANCE hInstance)
Con_Printf ("No fullscreen DIB modes found\n");
}
qboolean
VID_Is8bit ()
{
return is8bit;
}
void
VID_Init8bitPalette (void)
{
int i;
GLubyte thePalette[256 * 3];
GLubyte *oldPalette, *newPalette;
vid_use8bit =
Cvar_Get ("vid_use8bit", "0", CVAR_ROM, NULL,
"Use 8-bit shared palettes.");
if (!vid_use8bit->int_val) return;
if (is8bit) { // already done...
return;
}
if (QFGL_ExtensionPresent ("GL_EXT_shared_texture_palette")) {
if (!(qglColorTableEXT = QFGL_ExtensionAddress ("glColorTableEXT"))) {
return;
}
Con_Printf ("8-bit GL extension enabled.\n");
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;
}
}
/*
VID_Init
*/
@ -1657,8 +1437,6 @@ VID_Init (unsigned char *palette)
void
VID_Init_Cvars ()
{
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, NULL,
"Grab the mouse from X while playing quake");
}
@ -1692,3 +1470,10 @@ VID_SetCaption (char *text)
SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION));
}
}
qboolean
VID_SetGamma (double gamma)
{
// FIXME: Need function for HW gamma correction
return false;
}