mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-21 23:50:58 +00:00
bring in Despair's (Ragnvald Maartmann-Moe IV, rmmiv@earthlink.net) clean up
of the gl setup code.
This commit is contained in:
parent
07322ef780
commit
27465bc765
7 changed files with 572 additions and 1629 deletions
|
@ -67,6 +67,7 @@ extern unsigned short d_8to16table[256];
|
|||
extern unsigned int d_8to24table[256];
|
||||
extern void (*vid_menudrawfn)(void);
|
||||
extern void (*vid_menukeyfn)(int key);
|
||||
extern int scr_width, scr_height;
|
||||
|
||||
void VID_SetPalette (unsigned char *palette);
|
||||
// called at startup and after any gamma correction
|
||||
|
|
|
@ -190,7 +190,7 @@ qf_client_mgl_DEPENDENCIES=libqfsys_cl.a libqfsnd.a libqfcd.a libqfjs.a
|
|||
#
|
||||
# ... Sam Lantinga's Simple DirectMedia Layer, version 1.0 and higher
|
||||
#
|
||||
sdl_SOURCES= vid_sdl.c
|
||||
sdl_SOURCES= vid_sdl.c in_sdl.c
|
||||
|
||||
qf_client_sdl_SOURCES= $(common_SOURCES) $(client_SOURCES) $(soft_SOURCES) $(sdl_SOURCES)
|
||||
qf_client_sdl_LDADD= $(SDL_LIBS) $(CLIENT_LIBS)
|
||||
|
@ -228,7 +228,7 @@ ogl_SOURCES= gl_draw.c gl_mesh.c gl_ngraph.c gl_part.c \
|
|||
#
|
||||
# ... 3Dfx Voodoo 1 and 2 SVGAlib-based console GL
|
||||
#
|
||||
tdfx_SOURCES= vid_3dfxsvga.c in_svgalib.c
|
||||
tdfx_SOURCES= vid_3dfxsvga.c vid_common_gl.c in_svgalib.c
|
||||
|
||||
qf_client_3dfx_SOURCES= $(common_SOURCES) $(client_SOURCES) $(ogl_SOURCES) $(tdfx_SOURCES)
|
||||
qf_client_3dfx_LDADD= $(TDFXGL_LIBS) $(SVGA_LIBS) $(CLIENT_LIBS) $(DL_LIBS)
|
||||
|
@ -237,7 +237,7 @@ qf_client_3dfx_DEPENDENCIES=libqfsys_cl.a libqfsnd.a libqfcd.a libqfjs.a
|
|||
#
|
||||
# ... OpenGL in X Window
|
||||
#
|
||||
glx_SOURCES= vid_glx.c in_x11.c context_x11.c dga_check.c
|
||||
glx_SOURCES= vid_glx.c vid_common_gl.c in_x11.c context_x11.c dga_check.c
|
||||
|
||||
qf_client_glx_SOURCES= $(common_SOURCES) $(client_SOURCES) $(ogl_SOURCES) $(glx_SOURCES)
|
||||
qf_client_glx_LDADD= $(GLX_LIBS) $(X_PRE_LIBS) $(VIDMODE_LIBS) $(DGA_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) $(CLIENT_LIBS) $(DL_LIBS)
|
||||
|
@ -246,7 +246,7 @@ qf_client_glx_DEPENDENCIES=libqfsys_cl.a libqfsnd.a libqfcd.a libqfjs.a
|
|||
#
|
||||
# ... Sam Lantinga's Simple DirectMedia Layer, version 1.1 and higher, in GL mode
|
||||
#
|
||||
sgl_SOURCES= vid_sgl.c
|
||||
sgl_SOURCES= vid_sgl.c vid_common_gl.c in_sdl.c
|
||||
|
||||
qf_client_sgl_SOURCES= $(common_SOURCES) $(client_SOURCES) $(ogl_SOURCES) $(sgl_SOURCES)
|
||||
qf_client_sgl_LDADD= $(SDL_LIBS) $(GLX_LIBS) $(CLIENT_LIBS) $(DL_LIBS)
|
||||
|
|
|
@ -29,31 +29,10 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "quakedef.h"
|
||||
#include "vid_common.h"
|
||||
#include "va.h"
|
||||
#include "glquake.h"
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "cvar.h"
|
||||
#include "sbar.h"
|
||||
#include "qendian.h"
|
||||
#include "qargs.h"
|
||||
//#include "lib_replace.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
#ifndef RTLD_LAZY
|
||||
# ifdef DL_LAZY
|
||||
# define RTLD_LAZY DL_LAZY
|
||||
# else
|
||||
# define RTLD_LAZY 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/fxmesa.h>
|
||||
|
@ -62,54 +41,16 @@
|
|||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
|
||||
//unsigned short d_8to16table[256];
|
||||
unsigned int d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
static void *dlhand = NULL;
|
||||
#endif
|
||||
|
||||
static fxMesaContext fc = NULL;
|
||||
extern int scr_width, scr_height;
|
||||
static qboolean is8bit = 0;
|
||||
|
||||
int VID_options_items = 0;
|
||||
|
||||
extern void GL_Init_Common(void);
|
||||
extern void VID_Init8bitPalette(void);
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//int texture_mode = GL_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
||||
int texture_mode = GL_LINEAR;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
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;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
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 VID_Shutdown(void)
|
||||
void
|
||||
VID_Shutdown(void)
|
||||
{
|
||||
if (!fc)
|
||||
return;
|
||||
|
@ -117,7 +58,8 @@ void VID_Shutdown(void)
|
|||
fxMesaDestroyContext(fc);
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
void
|
||||
signal_handler(int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
Host_Shutdown();
|
||||
|
@ -126,7 +68,8 @@ void signal_handler(int sig)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
void InitSig(void)
|
||||
void
|
||||
InitSig(void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
|
@ -140,151 +83,6 @@ void InitSig(void)
|
|||
signal(SIGTERM, signal_handler);
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
// VID_SetPalette(p);
|
||||
}
|
||||
|
||||
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];
|
||||
//#endif
|
||||
float dist, bestdist;
|
||||
//
|
||||
// 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.
|
||||
{
|
||||
static qboolean palflag = false;
|
||||
|
||||
// FIXME: Precalculate this and cache to disk.
|
||||
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", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = Qopen(s, "wb")) != NULL) {
|
||||
Qwrite(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CheckMultiTextureExtensions
|
||||
|
||||
Check for ARB, SGIS, or EXT multitexture support
|
||||
*/
|
||||
void
|
||||
CheckMultiTextureExtensions ( void )
|
||||
{
|
||||
Con_Printf ("Checking for multitexture... ");
|
||||
if (COM_CheckParm ("-nomtex"))
|
||||
{
|
||||
Con_Printf ("disabled\n");
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
if (dlhand == NULL)
|
||||
{
|
||||
Con_Printf ("unable to check\n");
|
||||
return;
|
||||
}
|
||||
if (strstr(gl_extensions, "GL_ARB_multitexture "))
|
||||
{
|
||||
Con_Printf ("GL_ARB_multitexture\n");
|
||||
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "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 *)dlsym(dlhand, "glMTexCoord2fSGIS");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "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 *)dlsym(dlhand, "glMTexCoord2fEXT");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
} else {
|
||||
Con_Printf ("none found\n");
|
||||
}
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
#else
|
||||
gl_mtexable = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
|
||||
|
||||
/*
|
||||
|
@ -292,40 +90,10 @@ typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
|
|||
GL_Init
|
||||
===============
|
||||
*/
|
||||
void GL_Init (void)
|
||||
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);
|
||||
|
||||
CheckMultiTextureExtensions ();
|
||||
|
||||
glClearColor (1,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_Init_Common ();
|
||||
|
||||
Con_Printf ("Dithering: ");
|
||||
|
||||
|
@ -356,21 +124,8 @@ void GL_Init (void)
|
|||
dlhand = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
|
||||
=================
|
||||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
void
|
||||
GL_EndRendering (void)
|
||||
{
|
||||
glFlush();
|
||||
fxMesaSwapBuffers();
|
||||
|
@ -448,80 +203,12 @@ findres(int *width, int *height)
|
|||
return GR_RESOLUTION_640x480;
|
||||
}
|
||||
|
||||
qboolean VID_Is8bit(void)
|
||||
{
|
||||
return is8bit;
|
||||
}
|
||||
|
||||
typedef void (GLAPIENTRY *glColorTableEXT_FUNC) (GLenum, GLenum, GLsizei,
|
||||
GLenum, GLenum, const GLvoid *);
|
||||
typedef void (GLAPIENTRY *gl3DfxSetPaletteEXT_FUNC) (GLuint *pal);
|
||||
|
||||
void VID_Init8bitPalette()
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
|
||||
Con_Printf ("8-bit GL extensions: ");
|
||||
|
||||
if (dlhand == NULL) {
|
||||
Con_Printf ("unable to check.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (COM_CheckParm("-no8bit")) {
|
||||
Con_Printf("disabled.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette")) {
|
||||
char *oldpal;
|
||||
GLubyte table[256][4];
|
||||
gl3DfxSetPaletteEXT_FUNC load_texture = NULL;
|
||||
|
||||
Con_Printf("3DFX_set_global_palette.\n");
|
||||
load_texture = (void *) dlsym(dlhand, "gl3DfxSetPaletteEXT");
|
||||
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldpal = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
for (i=0;i<256;i++) {
|
||||
table[i][2] = *oldpal++;
|
||||
table[i][1] = *oldpal++;
|
||||
table[i][0] = *oldpal++;
|
||||
table[i][3] = 255;
|
||||
oldpal++;
|
||||
}
|
||||
load_texture((GLuint *)table);
|
||||
is8bit = true;
|
||||
} else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette")) {
|
||||
char thePalette[256*3];
|
||||
char *oldPalette, *newPalette;
|
||||
glColorTableEXT_FUNC load_texture = NULL;
|
||||
|
||||
Con_Printf("GL_EXT_shared.\n");
|
||||
load_texture = (void *) dlsym(dlhand, "glColorTableEXT");
|
||||
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i=0;i<256;i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
load_texture(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
is8bit = true;
|
||||
}
|
||||
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
Con_Printf ("not found.\n");
|
||||
}
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
void
|
||||
VID_Init(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
GLint attribs[32];
|
||||
|
@ -562,8 +249,8 @@ void VID_Init(unsigned char *palette)
|
|||
if (vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
|
||||
fc = fxMesaCreateContext(0, findres(&scr_width, &scr_height), GR_REFRESH_75Hz,
|
||||
attribs);
|
||||
fc = fxMesaCreateContext(0, findres(&scr_width, &scr_height),
|
||||
GR_REFRESH_75Hz, attribs);
|
||||
if (!fc)
|
||||
Sys_Error("Unable to create 3DFX context.\n");
|
||||
|
||||
|
@ -591,17 +278,19 @@ void VID_Init(unsigned char *palette)
|
|||
// Check for 3DFX Extensions and initialize them.
|
||||
VID_Init8bitPalette();
|
||||
|
||||
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);
|
||||
Con_Printf ("Video mode %dx%d initialized.\n", width, height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void VID_ExtraOptionDraw(unsigned int options_draw_cursor)
|
||||
void
|
||||
VID_ExtraOptionDraw(unsigned int options_draw_cursor)
|
||||
{
|
||||
/* Port specific Options menu entrys */
|
||||
}
|
||||
|
||||
void VID_ExtraOptionCmd(int option_cursor)
|
||||
void
|
||||
VID_ExtraOptionCmd(int option_cursor)
|
||||
{
|
||||
/*
|
||||
switch(option_cursor)
|
||||
|
@ -611,20 +300,8 @@ void VID_ExtraOptionCmd(int option_cursor)
|
|||
}
|
||||
*/
|
||||
}
|
||||
void VID_InitCvars ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_LockBuffer ( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_UnlockBuffer ( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VID_SetCaption (char *text)
|
||||
VID_SetCaption (char *text)
|
||||
{
|
||||
}
|
||||
|
|
402
source/vid_common_gl.c
Normal file
402
source/vid_common_gl.c
Normal file
|
@ -0,0 +1,402 @@
|
|||
/*
|
||||
vid_common_gl.c
|
||||
|
||||
Common OpenGL video driver functions
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
#ifndef RTLD_LAZY
|
||||
# ifdef DL_LAZY
|
||||
# define RTLD_LAZY DL_LAZY
|
||||
# else
|
||||
# define RTLD_LAZY 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "quakefs.h"
|
||||
#include "input.h"
|
||||
#include "sbar.h"
|
||||
#include "glquake.h"
|
||||
#include "console.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
static void *dlhand = NULL;
|
||||
#endif
|
||||
|
||||
//unsigned short d_8to16table[256];
|
||||
unsigned int d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
cvar_t *vid_mode;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
int texture_mode = GL_LINEAR;
|
||||
int texture_extension_number = 1;
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
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 is8bit = false;
|
||||
cvar_t *vid_use8bit;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
CheckMultiTextureExtensions
|
||||
|
||||
Check for ARB, SGIS, or EXT multitexture support
|
||||
*/
|
||||
|
||||
void
|
||||
CheckMultiTextureExtensions ( void )
|
||||
{
|
||||
Con_Printf ("Checking for multitexture... ");
|
||||
if (COM_CheckParm ("-nomtex")) {
|
||||
Con_Printf ("disabled\n");
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
if (dlhand == NULL) {
|
||||
Con_Printf ("unable to check\n");
|
||||
return;
|
||||
}
|
||||
if (strstr(gl_extensions, "GL_ARB_multitexture ")) {
|
||||
Con_Printf ("GL_ARB_multitexture\n");
|
||||
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "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 *)dlsym(dlhand, "glMTexCoord2fSGIS");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "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 *)dlsym(dlhand, "glMTexCoord2fEXT");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
} else {
|
||||
Con_Printf ("none found\n");
|
||||
}
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
#else
|
||||
gl_mtexable = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
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<255 ; i++) { // used to be i<256, see d_8to24table below
|
||||
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.
|
||||
// FIXME: Precalculate this and cache to disk.
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_Init_Common
|
||||
===============
|
||||
*/
|
||||
void
|
||||
GL_Init_Common (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);
|
||||
|
||||
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);
|
||||
|
||||
CheckMultiTextureExtensions ();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
=================
|
||||
*/
|
||||
void
|
||||
GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
}
|
||||
|
||||
qboolean VID_Is8bit(void)
|
||||
{
|
||||
return is8bit;
|
||||
}
|
||||
|
||||
#ifdef HAVE_TDFXGL
|
||||
void 3dfx_Init8bitPalette()
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
|
||||
Con_Printf ("8-bit GL extensions: ");
|
||||
|
||||
if (dlhand == NULL) {
|
||||
Con_Printf ("unable to check.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette")) {
|
||||
char *oldpal;
|
||||
GLubyte table[256][4];
|
||||
gl3DfxSetPaletteEXT_FUNC load_texture = NULL;
|
||||
|
||||
Con_Printf("3DFX_set_global_palette.\n");
|
||||
load_texture = (void *) dlsym(dlhand, "gl3DfxSetPaletteEXT");
|
||||
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldpal = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
for (i=0;i<256;i++) {
|
||||
table[i][2] = *oldpal++;
|
||||
table[i][1] = *oldpal++;
|
||||
table[i][0] = *oldpal++;
|
||||
table[i][3] = 255;
|
||||
oldpal++;
|
||||
}
|
||||
load_texture((GLuint *)table);
|
||||
is8bit = true;
|
||||
} else Shared_Init8bitPalette();
|
||||
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
Con_Printf ("not found.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GL_SHARED_TEXTURE_PALETTE_EXT
|
||||
void
|
||||
Shared_Init8bitPalette()
|
||||
{
|
||||
int i;
|
||||
char thePalette[256*3];
|
||||
char *oldPalette, *newPalette;
|
||||
|
||||
if (strstr(gl_extensions, "GL_EXT_shared_texture_palette") == NULL)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_TDFXGL
|
||||
glColorTableEXT_FUNC load_texture = NULL;
|
||||
load_texture = (void *) dlsym(dlhand, "glColorTableEXT");
|
||||
#endif
|
||||
|
||||
Con_Printf("8-bit GL extensions enabled.\n");
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i=0;i<256;i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
is8bit = true;
|
||||
|
||||
if strstr(gl_renderer, "Mesa Glide") {
|
||||
#ifdef HAVE_TDFXGL
|
||||
load_texture(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
glColorTable(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
VID_Init8bitPalette(void)
|
||||
{
|
||||
if (COM_CheckParm("-no8bit")) {
|
||||
Con_Printf("disabled.\n");
|
||||
return;
|
||||
}
|
||||
vid_use8bit = Cvar_Get ("vid_use8bit", "0", CVAR_ROM,
|
||||
"Whether to use Shared Palettes.");
|
||||
if (vid_use8bit->value) {
|
||||
#ifdef HAVE_TDFXGL
|
||||
3dfx_Init8bitPalette();
|
||||
#else
|
||||
#ifdef GL_SHARED_TEXTURE_PALETTE_EXT
|
||||
Shared_Init8bitPalette();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_InitCvars()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_LockBuffer ( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_UnlockBuffer ( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
D_EndDirectRect (int x, int y, int width, int height)
|
||||
{
|
||||
}
|
377
source/vid_glx.c
377
source/vid_glx.c
|
@ -31,23 +31,8 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
#ifndef RTLD_LAZY
|
||||
# ifdef DL_LAZY
|
||||
# define RTLD_LAZY DL_LAZY
|
||||
# else
|
||||
# define RTLD_LAZY 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
@ -57,27 +42,17 @@
|
|||
# include <X11/extensions/xf86dga.h>
|
||||
#endif
|
||||
|
||||
#ifdef XMESA
|
||||
# include <GL/xmesa.h>
|
||||
#endif
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "va.h"
|
||||
#include "quakedef.h"
|
||||
#include "qendian.h"
|
||||
#include "glquake.h"
|
||||
#include "cvar.h"
|
||||
#include "qargs.h"
|
||||
#include "console.h"
|
||||
#include "keys.h"
|
||||
#include "menu.h"
|
||||
#include "sys.h"
|
||||
#include "glquake.h"
|
||||
#include "quakefs.h"
|
||||
#include "draw.h"
|
||||
#include "input.h"
|
||||
#include "sbar.h"
|
||||
#include "context_x11.h"
|
||||
#include "dga_check.h"
|
||||
#include "quakedef.h"
|
||||
#include "qendian.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
@ -86,65 +61,28 @@ static qboolean vid_initialized = false;
|
|||
|
||||
static GLXContext ctx = NULL;
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned int d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
extern cvar_t *in_dga_mouseaccel;
|
||||
|
||||
#ifdef HAVE_DGA
|
||||
static int hasdgavideo = 0;
|
||||
static int hasdga = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
static void *dlhand = NULL;
|
||||
#endif
|
||||
static GLboolean (*QF_XMesaSetFXmode)(GLint mode) = NULL;
|
||||
|
||||
|
||||
int scr_width, scr_height;
|
||||
|
||||
#if defined(XMESA) || defined(HAVE_DGA)
|
||||
#if defined(HAVE_DGA)
|
||||
int VID_options_items = 2;
|
||||
#else
|
||||
int VID_options_items = 1;
|
||||
#endif
|
||||
|
||||
extern void GL_Init_Common(void);
|
||||
extern void VID_Init8bitPalette(void);
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//int texture_mode = GL_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
||||
int texture_mode = GL_LINEAR;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
qboolean is8bit = false;
|
||||
|
||||
// ARB Multitexture
|
||||
int gl_mtex_enum = TEXTURE0_SGIS;
|
||||
qboolean gl_arb_mtex = false;
|
||||
qboolean gl_mtexable = false;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
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
|
||||
VID_Shutdown(void)
|
||||
{
|
||||
|
@ -152,18 +90,12 @@ VID_Shutdown(void)
|
|||
return;
|
||||
|
||||
Con_Printf("VID_Shutdown\n");
|
||||
glXDestroyContext(x_disp, ctx);
|
||||
XDestroyWindow(x_disp, x_win);
|
||||
|
||||
x11_restore_vidmode();
|
||||
#ifdef HAVE_DLOPEN
|
||||
if (dlhand) {
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
}
|
||||
#endif
|
||||
x11_close_display();
|
||||
x_disp=0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
signal_handler(int sig)
|
||||
|
@ -188,253 +120,31 @@ InitSig(void)
|
|||
signal(SIGTERM, signal_handler);
|
||||
}
|
||||
#endif
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
VID_SetPalette(p);
|
||||
}
|
||||
|
||||
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.
|
||||
// FIXME: Precalculate this and cache to disk.
|
||||
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", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = Qopen(s, "wb")) != NULL) {
|
||||
Qwrite(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CheckMultiTextureExtensions
|
||||
|
||||
Check for ARB, SGIS, or EXT multitexture support
|
||||
*/
|
||||
void
|
||||
CheckMultiTextureExtensions ( void )
|
||||
{
|
||||
Con_Printf ("Checking for multitexture... ");
|
||||
if (COM_CheckParm ("-nomtex"))
|
||||
{
|
||||
Con_Printf ("disabled\n");
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
if (dlhand == NULL)
|
||||
{
|
||||
Con_Printf ("unable to check\n");
|
||||
return;
|
||||
}
|
||||
if (strstr(gl_extensions, "GL_ARB_multitexture "))
|
||||
{
|
||||
Con_Printf ("GL_ARB_multitexture\n");
|
||||
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "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 *)dlsym(dlhand, "glMTexCoord2fSGIS");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "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 *)dlsym(dlhand, "glMTexCoord2fEXT");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
} else {
|
||||
Con_Printf ("none found\n");
|
||||
}
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
#else
|
||||
gl_mtexable = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_Init
|
||||
===============
|
||||
*/
|
||||
void GL_Init (void)
|
||||
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);
|
||||
|
||||
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_Init_Common();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
|
||||
=================
|
||||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
void
|
||||
GL_EndRendering (void)
|
||||
{
|
||||
glFlush();
|
||||
glXSwapBuffers(x_disp, x_win);
|
||||
Sbar_Changed ();
|
||||
}
|
||||
|
||||
qboolean VID_Is8bit(void)
|
||||
{
|
||||
return is8bit;
|
||||
}
|
||||
|
||||
#ifdef GL_EXT_SHARED
|
||||
void VID_Init8bitPalette()
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
char thePalette[256*3];
|
||||
char *oldPalette, *newPalette;
|
||||
|
||||
if (strstr(gl_extensions, "GL_EXT_shared_texture_palette") == NULL)
|
||||
return;
|
||||
|
||||
Con_Printf("8-bit GL extensions enabled.\n");
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i=0;i<256;i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
glColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
is8bit = true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void VID_Init8bitPalette(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
void
|
||||
VID_Init(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
static int attrib[] = {
|
||||
int attrib[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
|
@ -443,7 +153,6 @@ void VID_Init(unsigned char *palette)
|
|||
GLX_DEPTH_SIZE, 1,
|
||||
None
|
||||
};
|
||||
char gldir[MAX_OSPATH];
|
||||
|
||||
VID_GetWindowSize (640, 480);
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
|
@ -494,37 +203,6 @@ void VID_Init(unsigned char *palette)
|
|||
}
|
||||
Con_Printf ("hasdga = %i\nhasdgavideo = %i\n", hasdga, hasdgavideo);
|
||||
#endif
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlhand = dlopen(NULL, RTLD_LAZY);
|
||||
if (dlhand) {
|
||||
QF_XMesaSetFXmode = dlsym(dlhand, "XMesaSetFXmode");
|
||||
if (!QF_XMesaSetFXmode) {
|
||||
QF_XMesaSetFXmode = dlsym(dlhand, "_XMesaSetFXmode");
|
||||
}
|
||||
} else {
|
||||
QF_XMesaSetFXmode = NULL;
|
||||
}
|
||||
#else
|
||||
#ifdef XMESA
|
||||
QF_XMesaSetFXmode = XMesaSetFXmode;
|
||||
#endif
|
||||
#endif
|
||||
if (QF_XMesaSetFXmode) {
|
||||
#ifdef XMESA
|
||||
const char *str = getenv("MESA_GLX_FX");
|
||||
if (str != NULL && *str != 'd') {
|
||||
if (tolower(*str) == 'w') {
|
||||
Cvar_Set (vid_fullscreen, "0");
|
||||
} else {
|
||||
Cvar_Set (vid_fullscreen, "1");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Glide uses DGA internally, so we don't want to
|
||||
mess with it. */
|
||||
// hasdga = 0;
|
||||
}
|
||||
|
||||
x11_set_vidmode(scr_width, scr_height);
|
||||
x11_create_window(scr_width, scr_height);
|
||||
/* Invisible cursor */
|
||||
|
@ -552,9 +230,6 @@ void VID_Init(unsigned char *palette)
|
|||
|
||||
GL_Init();
|
||||
|
||||
snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
|
||||
VID_SetPalette (palette);
|
||||
|
||||
// Check for 3DFX Extensions and initialize them.
|
||||
|
@ -568,22 +243,6 @@ void VID_Init(unsigned char *palette)
|
|||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void
|
||||
VID_InitCvars (void)
|
||||
{
|
||||
// It may not look like it, but this is important
|
||||
}
|
||||
|
||||
void
|
||||
VID_LockBuffer (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_UnlockBuffer (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_SetCaption (char *text)
|
||||
{
|
||||
|
|
301
source/vid_sdl.c
301
source/vid_sdl.c
|
@ -33,29 +33,22 @@
|
|||
#include <SDL.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "va.h"
|
||||
#include "console.h"
|
||||
#include "cvar.h"
|
||||
#include "draw.h"
|
||||
#include "d_iface.h"
|
||||
#include "d_local.h"
|
||||
#include "input.h"
|
||||
#include "joystick.h"
|
||||
#include "keys.h"
|
||||
#include "menu.h"
|
||||
#include "sys.h"
|
||||
#include "qargs.h"
|
||||
#include "qendian.h"
|
||||
#include "qtypes.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
cvar_t *_windowed_mouse;
|
||||
cvar_t *vid_fullscreen;
|
||||
|
||||
int old_windowed_mouse;
|
||||
#include "va.h"
|
||||
|
||||
// static float oldin_grab = 0;
|
||||
|
||||
cvar_t *vid_fullscreen;
|
||||
extern viddef_t vid; // global video state
|
||||
unsigned short d_8to16table[256];
|
||||
|
||||
|
@ -79,10 +72,6 @@ byte *VGA_pagebase;
|
|||
|
||||
static SDL_Surface *screen = NULL;
|
||||
|
||||
static qboolean mouse_avail;
|
||||
static float mouse_x, mouse_y;
|
||||
static int mouse_oldbuttonstate = 0;
|
||||
|
||||
void
|
||||
VID_InitBuffers (int width, int height)
|
||||
{
|
||||
|
@ -124,7 +113,6 @@ VID_InitBuffers (int width, int height)
|
|||
D_InitCaches (vid_surfcache, tcachesize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VID_SetPalette (unsigned char *palette)
|
||||
{
|
||||
|
@ -199,7 +187,6 @@ VID_Init (unsigned char *palette)
|
|||
// could replace this with SDL_SysWMInfo
|
||||
mainwindow=GetActiveWindow();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -225,9 +212,7 @@ VID_Update (vrect_t *rects)
|
|||
// Second, copy them to SDL rectangles and update
|
||||
if(!(sdlrects=(SDL_Rect *)calloc(1,n*sizeof(SDL_Rect))))
|
||||
Sys_Error("Out of memory!");
|
||||
|
||||
i = 0;
|
||||
|
||||
for (rect = rects; rect; rect = rect->pnext) {
|
||||
sdlrects[i].x = rect->x;
|
||||
sdlrects[i].y = rect->y;
|
||||
|
@ -248,12 +233,9 @@ D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
|||
{
|
||||
Uint8 *offset;
|
||||
|
||||
if (!screen)
|
||||
return;
|
||||
|
||||
if ( x < 0 )
|
||||
x = screen->w+x-1;
|
||||
|
||||
if (!screen) return;
|
||||
if ( x < 0 ) x = screen->w+x-1;
|
||||
offset = (Uint8 *)screen->pixels + y*screen->pitch + x;
|
||||
while ( height-- ) {
|
||||
memcpy(offset, pbitmap, width);
|
||||
|
@ -262,7 +244,6 @@ D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
D_EndDirectRect
|
||||
|
@ -271,280 +252,13 @@ D_EndDirectRect
|
|||
void
|
||||
D_EndDirectRect (int x, int y, int width, int height)
|
||||
{
|
||||
if (!screen)
|
||||
return;
|
||||
|
||||
if (x < 0)
|
||||
x = screen->w+x-1;
|
||||
|
||||
if (!screen) return;
|
||||
if (x < 0) x = screen->w+x-1;
|
||||
SDL_UpdateRect(screen, x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
IN_SendKeyEvents
|
||||
================
|
||||
*/
|
||||
|
||||
void IN_SendKeyEvents (void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int sym, state, but;
|
||||
int modstate;
|
||||
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type) {
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
sym = event.key.keysym.sym;
|
||||
state = event.key.state;
|
||||
modstate = SDL_GetModState();
|
||||
switch(sym)
|
||||
{
|
||||
case SDLK_DELETE: sym = K_DEL; break;
|
||||
case SDLK_BACKSPACE: sym = K_BACKSPACE; break;
|
||||
case SDLK_F1: sym = K_F1; break;
|
||||
case SDLK_F2: sym = K_F2; break;
|
||||
case SDLK_F3: sym = K_F3; break;
|
||||
case SDLK_F4: sym = K_F4; break;
|
||||
case SDLK_F5: sym = K_F5; break;
|
||||
case SDLK_F6: sym = K_F6; break;
|
||||
case SDLK_F7: sym = K_F7; break;
|
||||
case SDLK_F8: sym = K_F8; break;
|
||||
case SDLK_F9: sym = K_F9; break;
|
||||
case SDLK_F10: sym = K_F10; break;
|
||||
case SDLK_F11: sym = K_F11; break;
|
||||
case SDLK_F12: sym = K_F12; break;
|
||||
case SDLK_BREAK:
|
||||
case SDLK_PAUSE: sym = K_PAUSE; break;
|
||||
case SDLK_UP: sym = K_UPARROW; break;
|
||||
case SDLK_DOWN: sym = K_DOWNARROW; break;
|
||||
case SDLK_RIGHT: sym = K_RIGHTARROW; break;
|
||||
case SDLK_LEFT: sym = K_LEFTARROW; break;
|
||||
case SDLK_INSERT: sym = K_INS; break;
|
||||
case SDLK_HOME: sym = K_HOME; break;
|
||||
case SDLK_END: sym = K_END; break;
|
||||
case SDLK_PAGEUP: sym = K_PGUP; break;
|
||||
case SDLK_PAGEDOWN: sym = K_PGDN; break;
|
||||
case SDLK_RSHIFT:
|
||||
case SDLK_LSHIFT: sym = K_SHIFT; break;
|
||||
case SDLK_RCTRL:
|
||||
case SDLK_LCTRL: sym = K_CTRL; break;
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT: sym = K_ALT; break;
|
||||
case SDLK_CAPSLOCK: sym = K_CAPSLOCK; break;
|
||||
case SDLK_KP0:
|
||||
if(modstate & KMOD_NUM) sym = K_INS;
|
||||
else sym = SDLK_0;
|
||||
break;
|
||||
case SDLK_KP1:
|
||||
if(modstate & KMOD_NUM) sym = K_END;
|
||||
else sym = SDLK_1;
|
||||
break;
|
||||
case SDLK_KP2:
|
||||
if(modstate & KMOD_NUM) sym = K_DOWNARROW;
|
||||
else sym = SDLK_2;
|
||||
break;
|
||||
case SDLK_KP3:
|
||||
if(modstate & KMOD_NUM) sym = K_PGDN;
|
||||
else sym = SDLK_3;
|
||||
break;
|
||||
case SDLK_KP4:
|
||||
if(modstate & KMOD_NUM) sym = K_LEFTARROW;
|
||||
else sym = SDLK_4;
|
||||
break;
|
||||
case SDLK_KP5: sym = SDLK_5; break;
|
||||
case SDLK_KP6:
|
||||
if(modstate & KMOD_NUM) sym = K_RIGHTARROW;
|
||||
else sym = SDLK_6;
|
||||
break;
|
||||
case SDLK_KP7:
|
||||
if(modstate & KMOD_NUM) sym = K_HOME;
|
||||
else sym = SDLK_7;
|
||||
break;
|
||||
case SDLK_KP8:
|
||||
if(modstate & KMOD_NUM) sym = K_UPARROW;
|
||||
else sym = SDLK_8;
|
||||
break;
|
||||
case SDLK_KP9:
|
||||
if(modstate & KMOD_NUM) sym = K_PGUP;
|
||||
else sym = SDLK_9;
|
||||
break;
|
||||
case SDLK_KP_PERIOD:
|
||||
if(modstate & KMOD_NUM) sym = K_DEL;
|
||||
else sym = SDLK_PERIOD;
|
||||
break;
|
||||
case SDLK_KP_DIVIDE: sym = SDLK_SLASH; break;
|
||||
case SDLK_KP_MULTIPLY: sym = SDLK_ASTERISK; break;
|
||||
case SDLK_KP_MINUS: sym = SDLK_MINUS; break;
|
||||
case SDLK_KP_PLUS: sym = SDLK_PLUS; break;
|
||||
case SDLK_KP_ENTER: sym = SDLK_RETURN; break;
|
||||
case SDLK_KP_EQUALS: sym = SDLK_EQUALS; break;
|
||||
}
|
||||
// If we're not directly handled and still above 255
|
||||
// just force it to 0
|
||||
if(sym > 255) sym = 0;
|
||||
Key_Event(sym, state);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
but = event.button.button;
|
||||
if (but == 2)
|
||||
but = 3;
|
||||
else if (but == 3)
|
||||
but = 2;
|
||||
|
||||
switch (but)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
Key_Event(K_MOUSE1 + but - 1, event.type
|
||||
== SDL_MOUSEBUTTONDOWN);
|
||||
break;
|
||||
case 4:
|
||||
Key_Event(K_MWHEELUP, 1);
|
||||
Key_Event(K_MWHEELUP, 0);
|
||||
break;
|
||||
case 5:
|
||||
Key_Event(K_MWHEELDOWN, 1);
|
||||
Key_Event(K_MWHEELDOWN, 0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
if (_windowed_mouse->int_val)
|
||||
{
|
||||
if ((event.motion.x != (vid.width/2))
|
||||
|| (event.motion.y != (vid.height/2)) )
|
||||
{
|
||||
mouse_x = event.motion.xrel*10;
|
||||
mouse_y = event.motion.yrel*10;
|
||||
if ((event.motion.x < ((vid.width/2)-(vid.width/4))) ||
|
||||
(event.motion.x > ((vid.width/2)+(vid.width/4))) ||
|
||||
(event.motion.y < ((vid.height/2)-(vid.height/4))) ||
|
||||
(event.motion.y > ((vid.height/2)+(vid.height/4))) )
|
||||
SDL_WarpMouse(vid.width/2, vid.height/2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mouse_x = event.motion.xrel*10;
|
||||
mouse_y = event.motion.yrel*10;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
CL_Disconnect ();
|
||||
Sys_Quit ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
IN_Commands (void)
|
||||
{
|
||||
JOY_Command ();
|
||||
|
||||
if (old_windowed_mouse != _windowed_mouse->int_val) {
|
||||
old_windowed_mouse = _windowed_mouse->int_val;
|
||||
|
||||
if (_windowed_mouse->int_val) { // grab the pointer
|
||||
SDL_ShowCursor (0);
|
||||
SDL_WM_GrabInput (SDL_GRAB_ON);
|
||||
} else { // ungrab the pointer
|
||||
SDL_WM_GrabInput (SDL_GRAB_OFF);
|
||||
SDL_ShowCursor (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IN_Init (void)
|
||||
{
|
||||
JOY_Init ();
|
||||
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
|
||||
|
||||
if ( COM_CheckParm("-nomouse") && !_windowed_mouse->int_val)
|
||||
return;
|
||||
|
||||
mouse_x = mouse_y = 0.0;
|
||||
mouse_avail = 1;
|
||||
}
|
||||
|
||||
void
|
||||
IN_Shutdown (void)
|
||||
{
|
||||
JOY_Shutdown ();
|
||||
|
||||
Con_Printf ("IN_Shutdown\n");
|
||||
mouse_avail = 0;
|
||||
}
|
||||
|
||||
void IN_Frame(void)
|
||||
{
|
||||
int i;
|
||||
int mouse_buttonstate;
|
||||
|
||||
if (!mouse_avail) return;
|
||||
|
||||
i = SDL_GetMouseState(NULL, NULL);
|
||||
/* Quake swaps the second and third buttons */
|
||||
mouse_buttonstate = (i & ~0x06) | ((i & 0x02)<<1) | ((i & 0x04)>>1);
|
||||
for (i=0 ; i<3 ; i++) {
|
||||
if ( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) )
|
||||
Key_Event (K_MOUSE1 + i, true);
|
||||
|
||||
if ( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) )
|
||||
Key_Event (K_MOUSE1 + i, false);
|
||||
}
|
||||
mouse_oldbuttonstate = mouse_buttonstate;
|
||||
}
|
||||
|
||||
void
|
||||
IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
JOY_Move (cmd);
|
||||
|
||||
if (!mouse_avail)
|
||||
return;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->int_val && freelook))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if (freelook)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if (freelook && !(in_strafe.state & 1)) {
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||
} else {
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
cmd->upmove -= m_forward->value * mouse_y;
|
||||
else
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
mouse_x = mouse_y = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VID_InitCvars (void)
|
||||
VID_InitCvars ()
|
||||
{
|
||||
// It may not look like it, but this is important
|
||||
}
|
||||
|
@ -570,4 +284,3 @@ VID_SetCaption (char *text)
|
|||
SDL_WM_SetCaption(va ("%s %s", PROGRAM, VERSION), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
531
source/vid_sgl.c
531
source/vid_sgl.c
|
@ -26,32 +26,10 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <values.h>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "cvar.h"
|
||||
#include "draw.h"
|
||||
#include "vid_common.h"
|
||||
#include "va.h"
|
||||
#include <SDL.h>
|
||||
#include "glquake.h"
|
||||
#include "input.h"
|
||||
#include "joystick.h"
|
||||
#include "keys.h"
|
||||
#include "menu.h"
|
||||
#include "sys.h"
|
||||
#include "qargs.h"
|
||||
#include "qendian.h"
|
||||
#include "qtypes.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
@ -59,53 +37,19 @@
|
|||
static qboolean vid_initialized = false;
|
||||
|
||||
cvar_t *vid_fullscreen;
|
||||
cvar_t *_windowed_mouse;
|
||||
cvar_t *m_filter;
|
||||
|
||||
#ifdef WIN32
|
||||
/* fixme: this is evil hack */
|
||||
/* FIXME: this is evil hack */
|
||||
#include <windows.h>
|
||||
HWND mainwindow;
|
||||
#endif
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned int d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
extern int scr_width, scr_height;
|
||||
int VID_options_items = 1;
|
||||
|
||||
int texture_mode = GL_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
qboolean is8bit = false;
|
||||
qboolean gl_mtexable = false;
|
||||
int gl_mtex_enum = TEXTURE0_SGIS;
|
||||
|
||||
int modestate;
|
||||
|
||||
static qboolean mouse_avail;
|
||||
static float mouse_x, mouse_y;
|
||||
static float old_mouse_x, old_mouse_y;
|
||||
static float old_windowed_mouse;
|
||||
|
||||
void
|
||||
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
D_EndDirectRect (int x, int y, int width, int height)
|
||||
{
|
||||
}
|
||||
extern void GL_Init_Common(void);
|
||||
extern void VID_Init8bitPalette(void);
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
VID_Shutdown (void)
|
||||
|
@ -117,6 +61,7 @@ VID_Shutdown (void)
|
|||
|
||||
SDL_Quit ();
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
static void
|
||||
signal_handler(int sig)
|
||||
|
@ -142,139 +87,10 @@ InitSig (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
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[256];
|
||||
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.
|
||||
// FIXME: Precalculate this and cache to disk.
|
||||
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", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof (s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = Qopen (s, "wb")) != NULL) {
|
||||
Qwrite (f, d_15to8table, 1<<15);
|
||||
Qclose (f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_ShiftPalette (unsigned char *palette)
|
||||
{
|
||||
VID_SetPalette(palette);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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 = scr_width;
|
||||
*height = scr_height;
|
||||
GL_Init_Common();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -284,47 +100,6 @@ GL_EndRendering (void)
|
|||
SDL_GL_SwapBuffers ();
|
||||
}
|
||||
|
||||
qboolean
|
||||
VID_Is8bit (void)
|
||||
{
|
||||
return is8bit;
|
||||
}
|
||||
|
||||
#ifdef GL_EXT_SHARED
|
||||
void
|
||||
VID_Init8bitPalette (void)
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
char thePalette[256*3];
|
||||
char *oldPalette, *newPalette;
|
||||
|
||||
if (strstr (gl_extensions, "GL_EXT_shared_texture_palette") == NULL)
|
||||
return;
|
||||
|
||||
Con_Printf ("8-bit GL extensions enabled.\n");
|
||||
glEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
|
||||
oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i=0; i<256; i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
glColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
is8bit = true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
VID_Init8bitPalette (void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
VID_Init (unsigned char *palette)
|
||||
{
|
||||
|
@ -334,7 +109,7 @@ VID_Init (unsigned char *palette)
|
|||
|
||||
VID_GetWindowSize (640, 480);
|
||||
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"Toggles fullscreen game mode");
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"None");
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
|
@ -365,7 +140,7 @@ VID_Init (unsigned char *palette)
|
|||
Sys_Error ("Couldn't initialize SDL: %s\n", SDL_GetError ());
|
||||
|
||||
// Check if we want fullscreen
|
||||
if (vid_fullscreen->int_val) {
|
||||
if (vid_fullscreen->value) {
|
||||
flags |= SDL_FULLSCREEN;
|
||||
// Don't annoy Mesa/3dfx folks
|
||||
#ifndef WIN32
|
||||
|
@ -415,7 +190,7 @@ VID_Init (unsigned char *palette)
|
|||
|
||||
vid_initialized = true;
|
||||
#ifdef WIN32
|
||||
// fixme: EVIL thing - but needed for win32 until we get
|
||||
// FIXME: EVIL thing - but needed for win32 until we get
|
||||
// SDL_sound ready - without this DirectSound fails.
|
||||
// could replace this with SDL_SysWMInfo
|
||||
mainwindow=GetActiveWindow();
|
||||
|
@ -423,289 +198,6 @@ VID_Init (unsigned char *palette)
|
|||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void
|
||||
VID_InitCvars ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
IN_SendKeyEvents
|
||||
================
|
||||
*/
|
||||
|
||||
void
|
||||
IN_SendKeyEvents (void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int sym, state, but;
|
||||
int modstate;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
sym = event.key.keysym.sym;
|
||||
state = event.key.state;
|
||||
modstate = SDL_GetModState ();
|
||||
switch (sym) {
|
||||
case SDLK_DELETE: sym = K_DEL; break;
|
||||
case SDLK_BACKSPACE: sym = K_BACKSPACE; break;
|
||||
case SDLK_F1: sym = K_F1; break;
|
||||
case SDLK_F2: sym = K_F2; break;
|
||||
case SDLK_F3: sym = K_F3; break;
|
||||
case SDLK_F4: sym = K_F4; break;
|
||||
case SDLK_F5: sym = K_F5; break;
|
||||
case SDLK_F6: sym = K_F6; break;
|
||||
case SDLK_F7: sym = K_F7; break;
|
||||
case SDLK_F8: sym = K_F8; break;
|
||||
case SDLK_F9: sym = K_F9; break;
|
||||
case SDLK_F10: sym = K_F10; break;
|
||||
case SDLK_F11: sym = K_F11; break;
|
||||
case SDLK_F12: sym = K_F12; break;
|
||||
case SDLK_BREAK:
|
||||
case SDLK_PAUSE: sym = K_PAUSE; break;
|
||||
case SDLK_UP: sym = K_UPARROW; break;
|
||||
case SDLK_DOWN: sym = K_DOWNARROW; break;
|
||||
case SDLK_RIGHT: sym = K_RIGHTARROW; break;
|
||||
case SDLK_LEFT: sym = K_LEFTARROW; break;
|
||||
case SDLK_INSERT: sym = K_INS; break;
|
||||
case SDLK_HOME: sym = K_HOME; break;
|
||||
case SDLK_END: sym = K_END; break;
|
||||
case SDLK_PAGEUP: sym = K_PGUP; break;
|
||||
case SDLK_PAGEDOWN: sym = K_PGDN; break;
|
||||
case SDLK_RSHIFT:
|
||||
case SDLK_LSHIFT: sym = K_SHIFT; break;
|
||||
case SDLK_RCTRL:
|
||||
case SDLK_LCTRL: sym = K_CTRL; break;
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT: sym = K_ALT; break;
|
||||
case SDLK_CAPSLOCK: sym = K_CAPSLOCK; break;
|
||||
case SDLK_KP0:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_INS;
|
||||
else
|
||||
sym = SDLK_0;
|
||||
break;
|
||||
case SDLK_KP1:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_END;
|
||||
else
|
||||
sym = SDLK_1;
|
||||
break;
|
||||
case SDLK_KP2:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_DOWNARROW;
|
||||
else
|
||||
sym = SDLK_2;
|
||||
break;
|
||||
case SDLK_KP3:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_PGDN;
|
||||
else
|
||||
sym = SDLK_3;
|
||||
break;
|
||||
case SDLK_KP4:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_LEFTARROW;
|
||||
else
|
||||
sym = SDLK_4;
|
||||
break;
|
||||
case SDLK_KP5: sym = SDLK_5; break;
|
||||
case SDLK_KP6:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_RIGHTARROW;
|
||||
else
|
||||
sym = SDLK_6;
|
||||
break;
|
||||
case SDLK_KP7:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_HOME;
|
||||
else
|
||||
sym = SDLK_7;
|
||||
break;
|
||||
case SDLK_KP8:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_UPARROW;
|
||||
else
|
||||
sym = SDLK_8;
|
||||
break;
|
||||
case SDLK_KP9:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_PGUP;
|
||||
else
|
||||
sym = SDLK_9;
|
||||
break;
|
||||
case SDLK_KP_PERIOD:
|
||||
if (modstate & KMOD_NUM)
|
||||
sym = K_DEL;
|
||||
else
|
||||
sym = SDLK_PERIOD;
|
||||
break;
|
||||
case SDLK_KP_DIVIDE: sym = SDLK_SLASH; break;
|
||||
case SDLK_KP_MULTIPLY: sym = SDLK_ASTERISK; break;
|
||||
case SDLK_KP_MINUS: sym = SDLK_MINUS; break;
|
||||
case SDLK_KP_PLUS: sym = SDLK_PLUS; break;
|
||||
case SDLK_KP_ENTER: sym = SDLK_RETURN; break;
|
||||
case SDLK_KP_EQUALS: sym = SDLK_EQUALS; break;
|
||||
}
|
||||
// If we're not directly handled and still above 255
|
||||
// just force it to 0
|
||||
if (sym > 255)
|
||||
sym = 0;
|
||||
Key_Event(sym, state);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
but = event.button.button;
|
||||
if (but == 2) {
|
||||
but = 3;
|
||||
} else if (but == 3) {
|
||||
but = 2;
|
||||
}
|
||||
switch (but) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
Key_Event(K_MOUSE1 + but - 1, event.type == SDL_MOUSEBUTTONDOWN);
|
||||
break;
|
||||
case 4:
|
||||
Key_Event(K_MWHEELUP, 1);
|
||||
Key_Event(K_MWHEELUP, 0);
|
||||
break;
|
||||
case 5:
|
||||
Key_Event(K_MWHEELDOWN, 1);
|
||||
Key_Event(K_MWHEELDOWN, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
if (_windowed_mouse->int_val) {
|
||||
if ((event.motion.x != (vid.width/2)) ||
|
||||
(event.motion.y != (vid.height/2)) ) {
|
||||
mouse_x = event.motion.xrel*2;
|
||||
mouse_y = event.motion.yrel*2;
|
||||
if ( (event.motion.x < ((vid.width/2)-(vid.width/4))) ||
|
||||
(event.motion.x > ((vid.width/2)+(vid.width/4))) ||
|
||||
(event.motion.y < ((vid.height/2)-(vid.height/4))) ||
|
||||
(event.motion.y > ((vid.height/2)+(vid.height/4))) ) {
|
||||
SDL_WarpMouse(vid.width/2, vid.height/2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mouse_x = event.motion.xrel*2;
|
||||
mouse_y = event.motion.yrel*2;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
CL_Disconnect ();
|
||||
Sys_Quit ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IN_Init (void)
|
||||
{
|
||||
JOY_Init ();
|
||||
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "Grab mouse and keyboard input");
|
||||
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None");
|
||||
|
||||
if (COM_CheckParm ("-nomouse") && !_windowed_mouse->int_val)
|
||||
return;
|
||||
|
||||
mouse_x = mouse_y = 0.0;
|
||||
mouse_avail = 1;
|
||||
SDL_ShowCursor (0);
|
||||
SDL_WM_GrabInput (SDL_GRAB_ON);
|
||||
// FIXME: disable DGA if in_dgamouse says to
|
||||
}
|
||||
|
||||
void
|
||||
IN_Shutdown (void)
|
||||
{
|
||||
JOY_Shutdown ();
|
||||
|
||||
Con_Printf ("IN_Shutdown\n");
|
||||
mouse_avail = 0;
|
||||
}
|
||||
|
||||
void
|
||||
IN_Commands (void)
|
||||
{
|
||||
JOY_Command ();
|
||||
|
||||
if (old_windowed_mouse != _windowed_mouse->int_val) {
|
||||
old_windowed_mouse = _windowed_mouse->int_val;
|
||||
|
||||
if (_windowed_mouse->int_val) { // grab the pointer
|
||||
SDL_ShowCursor (0);
|
||||
SDL_WM_GrabInput (SDL_GRAB_ON);
|
||||
} else { // ungrab the pointer
|
||||
SDL_WM_GrabInput (SDL_GRAB_OFF);
|
||||
SDL_ShowCursor (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
JOY_Move (cmd);
|
||||
|
||||
if (!mouse_avail)
|
||||
return;
|
||||
|
||||
if (m_filter->int_val) {
|
||||
mouse_x = (mouse_x + old_mouse_x) * 0.5;
|
||||
mouse_y = (mouse_y + old_mouse_y) * 0.5;
|
||||
}
|
||||
|
||||
old_mouse_x = mouse_x;
|
||||
old_mouse_y = mouse_y;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
if ((in_strafe.state & 1) || (lookstrafe->int_val && freelook))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if (freelook)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if (freelook && !(in_strafe.state & 1)) {
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
|
||||
} else {
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
cmd->upmove -= m_forward->value * mouse_y;
|
||||
else
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
mouse_x = mouse_y = 0.0;
|
||||
}
|
||||
|
||||
void
|
||||
VID_LockBuffer (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_UnlockBuffer (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_SetCaption (char *text)
|
||||
{
|
||||
|
@ -717,4 +209,3 @@ VID_SetCaption (char *text)
|
|||
SDL_WM_SetCaption(va ("%s %s", PROGRAM, VERSION), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue