mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-21 19:51:18 +00:00
All Q_ funcs obliterated (excpet Q_log2 which isn't used anyway). cat's still work :)
This commit is contained in:
parent
1cee02c55c
commit
e0d986364e
46 changed files with 7751 additions and 2072 deletions
211
include/common.h
Normal file
211
include/common.h
Normal file
|
@ -0,0 +1,211 @@
|
|||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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 the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// common.h -- general definitions
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
//#include "protocol.h" // for struct usercmd_s
|
||||
|
||||
#ifndef _DEF_BYTE_
|
||||
# define _DEF_BYTE_
|
||||
typedef unsigned char byte;
|
||||
#endif
|
||||
|
||||
// KJB Undefined true and false defined in SciTech's DEBUG.H header
|
||||
#undef true
|
||||
#undef false
|
||||
|
||||
typedef enum {false, true} qboolean;
|
||||
|
||||
#define MAX_INFO_STRING 196
|
||||
#define MAX_SERVERINFO_STRING 512
|
||||
#define MAX_LOCALINFO_STRING 32768
|
||||
|
||||
//============================================================================
|
||||
|
||||
typedef struct sizebuf_s
|
||||
{
|
||||
qboolean allowoverflow; // if false, do a Sys_Error
|
||||
qboolean overflowed; // set to true if the buffer size failed
|
||||
byte *data;
|
||||
int maxsize;
|
||||
int cursize;
|
||||
} sizebuf_t;
|
||||
|
||||
void SZ_Clear (sizebuf_t *buf);
|
||||
void *SZ_GetSpace (sizebuf_t *buf, int length);
|
||||
void SZ_Write (sizebuf_t *buf, void *data, int length);
|
||||
void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
|
||||
|
||||
//============================================================================
|
||||
|
||||
typedef struct link_s
|
||||
{
|
||||
struct link_s *prev, *next;
|
||||
} link_t;
|
||||
|
||||
void ClearLink (link_t *l);
|
||||
void RemoveLink (link_t *l);
|
||||
void InsertLinkBefore (link_t *l, link_t *before);
|
||||
void InsertLinkAfter (link_t *l, link_t *after);
|
||||
|
||||
// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
|
||||
// ent = STRUCT_FROM_LINK(link,entity_t,order)
|
||||
// FIXME: remove this mess!
|
||||
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
|
||||
|
||||
//============================================================================
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#define Q_MAXCHAR ((char)0x7f)
|
||||
#define Q_MAXSHORT ((short)0x7fff)
|
||||
#define Q_MAXINT ((int)0x7fffffff)
|
||||
#define Q_MAXLONG ((int)0x7fffffff)
|
||||
#define Q_MAXFLOAT ((int)0x7fffffff)
|
||||
|
||||
#define Q_MINCHAR ((char)0x80)
|
||||
#define Q_MINSHORT ((short)0x8000)
|
||||
#define Q_MININT ((int)0x80000000)
|
||||
#define Q_MINLONG ((int)0x80000000)
|
||||
#define Q_MINFLOAT ((int)0x7fffffff)
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern qboolean bigendien;
|
||||
|
||||
extern short (*BigShort) (short l);
|
||||
extern short (*LittleShort) (short l);
|
||||
extern int (*BigLong) (int l);
|
||||
extern int (*LittleLong) (int l);
|
||||
extern float (*BigFloat) (float l);
|
||||
extern float (*LittleFloat) (float l);
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern struct usercmd_s nullcmd;
|
||||
|
||||
void MSG_WriteChar (sizebuf_t *sb, int c);
|
||||
void MSG_WriteByte (sizebuf_t *sb, int c);
|
||||
void MSG_WriteShort (sizebuf_t *sb, int c);
|
||||
void MSG_WriteLong (sizebuf_t *sb, int c);
|
||||
void MSG_WriteFloat (sizebuf_t *sb, float f);
|
||||
void MSG_WriteString (sizebuf_t *sb, char *s);
|
||||
void MSG_WriteCoord (sizebuf_t *sb, float f);
|
||||
void MSG_WriteAngle (sizebuf_t *sb, float f);
|
||||
void MSG_WriteAngle16 (sizebuf_t *sb, float f);
|
||||
void MSG_WriteDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd);
|
||||
|
||||
extern int msg_readcount;
|
||||
extern qboolean msg_badread; // set if a read goes beyond end of message
|
||||
|
||||
void MSG_BeginReading (void);
|
||||
int MSG_GetReadCount(void);
|
||||
int MSG_ReadChar (void);
|
||||
int MSG_ReadByte (void);
|
||||
int MSG_ReadShort (void);
|
||||
int MSG_ReadLong (void);
|
||||
float MSG_ReadFloat (void);
|
||||
char *MSG_ReadString (void);
|
||||
char *MSG_ReadStringLine (void);
|
||||
|
||||
float MSG_ReadCoord (void);
|
||||
float MSG_ReadAngle (void);
|
||||
float MSG_ReadAngle16 (void);
|
||||
void MSG_ReadDeltaUsercmd (struct usercmd_s *from, struct usercmd_s *cmd);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define strcasecmp(s1, s2) stricmp((s1), (s2))
|
||||
#define strncasecmp(s1, s2, n) strnicmp((s1), (s2), (n))
|
||||
|
||||
#else
|
||||
#define strcasecmp(s1, s2) _stricmp((s1), (s2))
|
||||
#define strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern char com_token[1024];
|
||||
extern qboolean com_eof;
|
||||
|
||||
char *COM_Parse (char *data);
|
||||
|
||||
|
||||
extern int com_argc;
|
||||
extern char **com_argv;
|
||||
|
||||
int COM_CheckParm (char *parm);
|
||||
void COM_AddParm (char *parm);
|
||||
|
||||
void COM_Init (void);
|
||||
void COM_InitArgv (int argc, char **argv);
|
||||
|
||||
char *COM_SkipPath (char *pathname);
|
||||
void COM_StripExtension (char *in, char *out);
|
||||
void COM_FileBase (char *in, char *out);
|
||||
void COM_DefaultExtension (char *path, char *extension);
|
||||
|
||||
char *va(char *format, ...);
|
||||
// does a varargs printf into a temp buffer
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern int com_filesize;
|
||||
struct cache_user_s;
|
||||
|
||||
extern char com_gamedir[MAX_OSPATH];
|
||||
|
||||
void COM_WriteFile (char *filename, void *data, int len);
|
||||
int COM_FOpenFile (char *filename, FILE **file);
|
||||
void COM_CloseFile (FILE *h);
|
||||
|
||||
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
|
||||
byte *COM_LoadTempFile (char *path);
|
||||
byte *COM_LoadHunkFile (char *path);
|
||||
void COM_LoadCacheFile (char *path, struct cache_user_s *cu);
|
||||
void COM_CreatePath (char *path);
|
||||
void COM_Gamedir (char *dir);
|
||||
|
||||
extern struct cvar_s *registered;
|
||||
extern qboolean standard_quake, rogue, hipnotic;
|
||||
|
||||
char *Info_ValueForKey (char *s, char *key);
|
||||
void Info_RemoveKey (char *s, char *key);
|
||||
void Info_RemovePrefixedKeys (char *start, char prefix);
|
||||
void Info_SetValueForKey (char *s, char *key, char *value, int maxsize);
|
||||
void Info_SetValueForStarKey (char *s, char *key, char *value, int maxsize);
|
||||
void Info_Print (char *s);
|
||||
|
||||
unsigned Com_BlockChecksum (void *buffer, int length);
|
||||
void Com_BlockFullChecksum (void *buffer, int len, unsigned char *outbuf);
|
||||
byte COM_BlockSequenceCheckByte (byte *base, int length, int sequence, unsigned mapchecksum);
|
||||
byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence);
|
||||
|
||||
int build_number( void );
|
||||
|
||||
#endif // _COMMON_H
|
|
@ -33,6 +33,8 @@
|
|||
#include "quakedef.h"
|
||||
#include "dosisms.h"
|
||||
|
||||
/* extern cvar_t bgmvolume;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *bgmvolume;
|
||||
|
||||
#define ADDRESS_MODE_HSG 0
|
||||
|
@ -626,13 +628,13 @@ static void CD_f (void)
|
|||
|
||||
command = Cmd_Argv (1);
|
||||
|
||||
if (Q_strcasecmp(command, "on") == 0)
|
||||
if (strcasecmp(command, "on") == 0)
|
||||
{
|
||||
enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "off") == 0)
|
||||
if (strcasecmp(command, "off") == 0)
|
||||
{
|
||||
if (playing)
|
||||
CDAudio_Stop();
|
||||
|
@ -640,7 +642,7 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "reset") == 0)
|
||||
if (strcasecmp(command, "reset") == 0)
|
||||
{
|
||||
enabled = true;
|
||||
if (playing)
|
||||
|
@ -652,7 +654,7 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "remap") == 0)
|
||||
if (strcasecmp(command, "remap") == 0)
|
||||
{
|
||||
ret = Cmd_Argc() - 2;
|
||||
if (ret <= 0)
|
||||
|
@ -663,7 +665,7 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
for (n = 1; n <= ret; n++)
|
||||
remap[n] = Q_atoi(Cmd_Argv (n+1));
|
||||
remap[n] = atoi(Cmd_Argv (n+1));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -673,31 +675,31 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "play") == 0)
|
||||
if (strcasecmp(command, "play") == 0)
|
||||
{
|
||||
CDAudio_Play(Q_atoi(Cmd_Argv (2)), false);
|
||||
CDAudio_Play(atoi(Cmd_Argv (2)), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "loop") == 0)
|
||||
if (strcasecmp(command, "loop") == 0)
|
||||
{
|
||||
CDAudio_Play(Q_atoi(Cmd_Argv (2)), true);
|
||||
CDAudio_Play(atoi(Cmd_Argv (2)), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "stop") == 0)
|
||||
if (strcasecmp(command, "stop") == 0)
|
||||
{
|
||||
CDAudio_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "resume") == 0)
|
||||
if (strcasecmp(command, "resume") == 0)
|
||||
{
|
||||
CDAudio_Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "eject") == 0)
|
||||
if (strcasecmp(command, "eject") == 0)
|
||||
{
|
||||
if (playing)
|
||||
CDAudio_Stop();
|
||||
|
@ -706,7 +708,7 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "info") == 0)
|
||||
if (strcasecmp(command, "info") == 0)
|
||||
{
|
||||
Con_Printf("%u tracks\n", cd.highTrack - cd.lowTrack + 1);
|
||||
for (n = cd.lowTrack; n <= cd.highTrack; n++)
|
||||
|
@ -757,6 +759,8 @@ void CDAudio_Update(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* newVolume = (int)(bgmvolume.value * 255.0);
|
||||
CVAR_FIXME */
|
||||
newVolume = (int)(bgmvolume->value * 255.0);
|
||||
if (newVolume < 0)
|
||||
{
|
||||
|
|
|
@ -42,11 +42,7 @@
|
|||
|
||||
#include <linux/cdrom.h>
|
||||
|
||||
#include "qargs.h"
|
||||
#include "cmd.h"
|
||||
#include "cdaudio.h"
|
||||
#include "console.h"
|
||||
#include "sound.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
static qboolean cdValid = false;
|
||||
static qboolean playing = false;
|
||||
|
@ -346,17 +342,23 @@ void CDAudio_Update(void)
|
|||
if (!enabled)
|
||||
return;
|
||||
|
||||
/* if (bgmvolume.value != cdvolume)
|
||||
CVAR_FIXME */
|
||||
if (bgmvolume->value != cdvolume)
|
||||
{
|
||||
if (cdvolume)
|
||||
{
|
||||
Cvar_SetValue (bgmvolume, 0.0);
|
||||
bgmvolume->value = 0.0;
|
||||
/* cdvolume = bgmvolume.value;
|
||||
CVAR_FIXME */
|
||||
cdvolume = bgmvolume->value;
|
||||
CDAudio_Pause ();
|
||||
}
|
||||
else
|
||||
{
|
||||
bgmvolume->value = 1.0;
|
||||
/* cdvolume = bgmvolume.value;
|
||||
CVAR_FIXME */
|
||||
cdvolume = bgmvolume->value;
|
||||
CDAudio_Resume ();
|
||||
}
|
||||
|
|
|
@ -31,12 +31,10 @@
|
|||
#endif
|
||||
#include <windows.h>
|
||||
#include "quakedef.h"
|
||||
#include "qargs.h"
|
||||
#include "console.h"
|
||||
#include "cdaudio.h"
|
||||
#include "cmd.h"
|
||||
|
||||
extern HWND mainwindow;
|
||||
/* extern cvar_t bgmvolume;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *bgmvolume;
|
||||
|
||||
static qboolean cdValid = false;
|
||||
|
@ -421,17 +419,23 @@ void CDAudio_Update(void)
|
|||
if (!enabled)
|
||||
return;
|
||||
|
||||
/* if (bgmvolume.value != cdvolume)
|
||||
CVAR_FIXME */
|
||||
if (bgmvolume->value != cdvolume)
|
||||
{
|
||||
if (cdvolume)
|
||||
{
|
||||
Cvar_SetValue (bgmvolume, 0.0);
|
||||
/* cdvolume = bgmvolume.value;
|
||||
CVAR_FIXME */
|
||||
cdvolume = bgmvolume->value;
|
||||
CDAudio_Pause ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Cvar_SetValue (bgmvolume, 1.0);
|
||||
/* cdvolume = bgmvolume.value;
|
||||
CVAR_FIXME */
|
||||
cdvolume = bgmvolume->value;
|
||||
CDAudio_Resume ();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
cl_cmd.c
|
||||
|
||||
Client-side script command processing module
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -26,15 +26,12 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
// cmd.c -- Quake script command processing module
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "client.h"
|
||||
#include "console.h"
|
||||
#include "cmd.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
/*
|
||||
===================
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
cl_input.c
|
||||
|
||||
builds an intended movement command to send to the server
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,28 +25,16 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// cl.input.c -- builds an intended movement command to send to the server
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "in_win.h"
|
||||
#include "sys.h"
|
||||
#include "sys.h"
|
||||
#include "cvar.h"
|
||||
#include "sizebuf.h"
|
||||
#include "msg.h"
|
||||
#include "client.h"
|
||||
#include "commdef.h"
|
||||
#include "cmd.h"
|
||||
#include "console.h"
|
||||
#include "qendian.h"
|
||||
#include "quakefs.h"
|
||||
#include "quakedef.h"
|
||||
#include "pmove.h"
|
||||
#include "view.h"
|
||||
#include "checksum.h"
|
||||
#include "keys.h"
|
||||
#include "in_win.h"
|
||||
|
||||
/* cvar_t cl_nodelta = {"cl_nodelta","0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_nodelta;
|
||||
|
||||
/*
|
||||
|
@ -144,7 +132,9 @@ void IN_KLookUp (void) {KeyUp(&in_klook);}
|
|||
void IN_MLookDown (void) {KeyDown(&in_mlook);}
|
||||
void IN_MLookUp (void) {
|
||||
KeyUp(&in_mlook);
|
||||
if ( !(in_mlook.state&1 || cl_freelook->value) && lookspring->value)
|
||||
/* if ( !(in_mlook.state&1) && lookspring.value)
|
||||
CVAR_FIXME */
|
||||
if ( !(in_mlook.state&1) && lookspring->value)
|
||||
V_StartPitchDrift();
|
||||
}
|
||||
void IN_UpDown(void) {KeyDown(&in_up);}
|
||||
|
@ -238,16 +228,32 @@ float CL_KeyState (kbutton_t *key)
|
|||
|
||||
//==========================================================================
|
||||
|
||||
/* cvar_t cl_upspeed = {"cl_upspeed","200"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_upspeed;
|
||||
/* cvar_t cl_forwardspeed = {"cl_forwardspeed","200", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_forwardspeed;
|
||||
/* cvar_t cl_backspeed = {"cl_backspeed","200", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_backspeed;
|
||||
/* cvar_t cl_sidespeed = {"cl_sidespeed","350"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_sidespeed;
|
||||
|
||||
/* cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_movespeedkey;
|
||||
|
||||
/* cvar_t cl_yawspeed = {"cl_yawspeed","140"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_yawspeed;
|
||||
/* cvar_t cl_pitchspeed = {"cl_pitchspeed","150"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_pitchspeed;
|
||||
|
||||
/* cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_anglespeedkey;
|
||||
|
||||
|
||||
|
@ -264,27 +270,41 @@ void CL_AdjustAngles (void)
|
|||
float up, down;
|
||||
|
||||
if (in_speed.state & 1)
|
||||
/* speed = host_frametime * cl_anglespeedkey.value;
|
||||
CVAR_FIXME */
|
||||
speed = host_frametime * cl_anglespeedkey->value;
|
||||
else
|
||||
speed = host_frametime;
|
||||
|
||||
if (!(in_strafe.state & 1))
|
||||
{
|
||||
/* cl.viewangles[YAW] -= speed*cl_yawspeed.value*CL_KeyState (&in_right);
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right);
|
||||
/* cl.viewangles[YAW] += speed*cl_yawspeed.value*CL_KeyState (&in_left);
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left);
|
||||
cl.viewangles[YAW] = anglemod(cl.viewangles[YAW]);
|
||||
}
|
||||
if (in_klook.state & 1)
|
||||
{
|
||||
V_StopPitchDrift ();
|
||||
/* cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * CL_KeyState (&in_forward);
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_forward);
|
||||
/* cl.viewangles[PITCH] += speed*cl_pitchspeed.value * CL_KeyState (&in_back);
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_back);
|
||||
}
|
||||
|
||||
up = CL_KeyState (&in_lookup);
|
||||
down = CL_KeyState(&in_lookdown);
|
||||
|
||||
/* cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * up;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] -= speed*cl_pitchspeed->value * up;
|
||||
/* cl.viewangles[PITCH] += speed*cl_pitchspeed.value * down;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] += speed*cl_pitchspeed->value * down;
|
||||
|
||||
if (up || down)
|
||||
|
@ -318,19 +338,35 @@ void CL_BaseMove (usercmd_t *cmd)
|
|||
VectorCopy (cl.viewangles, cmd->angles);
|
||||
if (in_strafe.state & 1)
|
||||
{
|
||||
/* cmd->sidemove += cl_sidespeed.value * CL_KeyState (&in_right);
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right);
|
||||
/* cmd->sidemove -= cl_sidespeed.value * CL_KeyState (&in_left);
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left);
|
||||
}
|
||||
|
||||
/* cmd->sidemove += cl_sidespeed.value * CL_KeyState (&in_moveright);
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright);
|
||||
/* cmd->sidemove -= cl_sidespeed.value * CL_KeyState (&in_moveleft);
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft);
|
||||
|
||||
/* cmd->upmove += cl_upspeed.value * CL_KeyState (&in_up);
|
||||
CVAR_FIXME */
|
||||
cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up);
|
||||
/* cmd->upmove -= cl_upspeed.value * CL_KeyState (&in_down);
|
||||
CVAR_FIXME */
|
||||
cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down);
|
||||
|
||||
if (! (in_klook.state & 1) )
|
||||
{
|
||||
/* cmd->forwardmove += cl_forwardspeed.value * CL_KeyState (&in_forward);
|
||||
CVAR_FIXME */
|
||||
cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward);
|
||||
/* cmd->forwardmove -= cl_backspeed.value * CL_KeyState (&in_back);
|
||||
CVAR_FIXME */
|
||||
cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back);
|
||||
}
|
||||
|
||||
|
@ -339,8 +375,14 @@ void CL_BaseMove (usercmd_t *cmd)
|
|||
//
|
||||
if (in_speed.state & 1)
|
||||
{
|
||||
/* cmd->forwardmove *= cl_movespeedkey.value;
|
||||
CVAR_FIXME */
|
||||
cmd->forwardmove *= cl_movespeedkey->value;
|
||||
/* cmd->sidemove *= cl_movespeedkey.value;
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove *= cl_movespeedkey->value;
|
||||
/* cmd->upmove *= cl_movespeedkey.value;
|
||||
CVAR_FIXME */
|
||||
cmd->upmove *= cl_movespeedkey->value;
|
||||
}
|
||||
}
|
||||
|
@ -485,6 +527,8 @@ void CL_SendCmd (void)
|
|||
if (cls.netchan.outgoing_sequence - cl.validsequence >= UPDATE_BACKUP-1)
|
||||
cl.validsequence = 0;
|
||||
|
||||
/* if (cl.validsequence && !cl_nodelta.value && cls.state == ca_active &&
|
||||
CVAR_FIXME */
|
||||
if (cl.validsequence && !cl_nodelta->value && cls.state == ca_active &&
|
||||
!cls.demorecording)
|
||||
{
|
||||
|
@ -549,26 +593,17 @@ void CL_InitInput (void)
|
|||
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
||||
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
||||
|
||||
/* Cvar_RegisterVariable (&cl_nodelta);
|
||||
CVAR_FIXME */
|
||||
cl_nodelta = Cvar_Get("cl_nodelta", "0", CVAR_NONE, "None");
|
||||
}
|
||||
|
||||
|
||||
extern qboolean keydown[256];
|
||||
|
||||
/*
|
||||
============
|
||||
CL_ClearStates
|
||||
============
|
||||
Generate key up event for each key that is down
|
||||
*/
|
||||
void CL_ClearStates (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// send an up event for each key, to make sure the server clears them all
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
if (keydown[i])
|
||||
Key_Event (i, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
cl_model.c
|
||||
model.c
|
||||
|
||||
model loading and caching
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// models.c -- model loading and caching
|
||||
|
||||
// models are the only shared resource between a client and server running
|
||||
// on the same machine.
|
||||
|
@ -32,11 +33,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "model.h"
|
||||
#include "crc.h"
|
||||
#include "msg.h"
|
||||
#include "console.h"
|
||||
#include "qendian.h"
|
||||
#include "quakedef.h"
|
||||
#include "r_local.h"
|
||||
|
||||
void SV_Error (char *error, ...);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
cl_parse.c
|
||||
|
||||
parse a message received from the server
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,24 +25,17 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// cl_parse.c -- parse a message received from the server
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "client.h"
|
||||
#include "cmd.h"
|
||||
#include "screen.h"
|
||||
#include "cdaudio.h"
|
||||
#include "quakedef.h"
|
||||
#include "bothdefs.h"
|
||||
#include "console.h"
|
||||
#include "msg.h"
|
||||
#include "pmove.h"
|
||||
#include "sbar.h"
|
||||
|
||||
/* extern cvar_t gl_flashblend;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *gl_flashblend;
|
||||
extern cvar_t *cl_autoexec;
|
||||
|
||||
char *svc_strings[] =
|
||||
{
|
||||
|
@ -389,7 +382,7 @@ void CL_ParseDownload (void)
|
|||
if (strncmp(cls.downloadtempname,"skins/",6))
|
||||
snprintf (name, sizeof(name), "%s/%s", com_gamedir, cls.downloadtempname);
|
||||
else
|
||||
snprintf (name, sizeof(name), "%s/qw/%s", fs_userpath->string, cls.downloadtempname);
|
||||
snprintf (name, sizeof(name), "qw/%s", cls.downloadtempname);
|
||||
|
||||
COM_CreatePath (name);
|
||||
|
||||
|
@ -440,8 +433,8 @@ void CL_ParseDownload (void)
|
|||
snprintf (oldn, sizeof(oldn), "%s/%s", com_gamedir, cls.downloadtempname);
|
||||
snprintf (newn, sizeof(newn), "%s/%s", com_gamedir, cls.downloadname);
|
||||
} else {
|
||||
snprintf (oldn, sizeof(oldn), "%s/qw/%s", fs_userpath->string, cls.downloadtempname);
|
||||
snprintf (newn, sizeof(newn), "%s/qw/%s", fs_userpath->string, cls.downloadname);
|
||||
snprintf (oldn, sizeof(oldn), "qw/%s", cls.downloadtempname);
|
||||
snprintf (newn, sizeof(newn), "qw/%s", cls.downloadname);
|
||||
}
|
||||
r = rename (oldn, newn);
|
||||
if (r)
|
||||
|
@ -582,29 +575,15 @@ void CL_ParseServerData (void)
|
|||
//ZOID--run the autoexec.cfg in the gamedir
|
||||
//if it exists
|
||||
if (cflag) {
|
||||
int cl_warncmd_val = cl_warncmd->value;
|
||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
|
||||
snprintf (fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
|
||||
if ((f = fopen(fn, "r")) != NULL) {
|
||||
fclose(f);
|
||||
Cbuf_AddText ("cl_warncmd 0\n");
|
||||
Cbuf_AddText ("exec config.cfg\n");
|
||||
Cbuf_AddText("exec config.cfg\n");
|
||||
Cbuf_AddText("exec frontend.cfg\n");
|
||||
Cbuf_AddText("exec autoexec.cfg\n");
|
||||
Cbuf_AddText ("cl_warncmd 1\n");
|
||||
}
|
||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "frontend.cfg");
|
||||
if ((f = fopen(fn, "r")) != NULL) {
|
||||
fclose(f);
|
||||
Cbuf_AddText ("cl_warncmd 0\n");
|
||||
Cbuf_AddText ("exec frontend.cfg\n");
|
||||
}
|
||||
if (cl_autoexec->value) {
|
||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "autoexec.cfg");
|
||||
if ((f = fopen(fn, "r")) != NULL) {
|
||||
fclose(f);
|
||||
Cbuf_AddText ("cl_warncmd 0\n");
|
||||
Cbuf_AddText ("exec autoexec.cfg\n");
|
||||
}
|
||||
}
|
||||
snprintf(fn,sizeof(fn), "cl_warncmd %d\n", cl_warncmd_val);
|
||||
Cbuf_AddText(fn);
|
||||
}
|
||||
|
||||
// parse player slot, high bit means spectator
|
||||
|
@ -1035,6 +1014,8 @@ void CL_MuzzleFlash (void)
|
|||
return;
|
||||
|
||||
// don't draw our own muzzle flash in gl if flashblending
|
||||
/* if (i-1 == cl.playernum && gl_flashblend.value)
|
||||
CVAR_FIXME */
|
||||
if (i-1 == cl.playernum && gl_flashblend->value)
|
||||
return;
|
||||
|
||||
|
@ -1055,6 +1036,8 @@ void CL_MuzzleFlash (void)
|
|||
}
|
||||
|
||||
|
||||
/* #define SHOWNET(x) if(cl_shownet.value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x);
|
||||
CVAR_FIXME */
|
||||
#define SHOWNET(x) if(cl_shownet->value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x);
|
||||
/*
|
||||
=====================
|
||||
|
@ -1075,8 +1058,12 @@ void CL_ParseServerMessage (void)
|
|||
//
|
||||
// if recording demos, copy the message out
|
||||
//
|
||||
/* if (cl_shownet.value == 1)
|
||||
CVAR_FIXME */
|
||||
if (cl_shownet->value == 1)
|
||||
Con_Printf ("%i ",net_message.cursize);
|
||||
/* else if (cl_shownet.value == 2)
|
||||
CVAR_FIXME */
|
||||
else if (cl_shownet->value == 2)
|
||||
Con_Printf ("------------------\n");
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <sys/mman.h>
|
||||
|
||||
#include "sys.h"
|
||||
#include "qargs.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
int noconinput = 0;
|
||||
|
@ -53,6 +52,8 @@ qboolean is_server = false;
|
|||
|
||||
#define BASEDIR "."
|
||||
|
||||
/* cvar_t sys_linerefresh = {"sys_linerefresh","0"};// set for entity display
|
||||
CVAR_FIXME */
|
||||
cvar_t *sys_linerefresh;// set for entity display
|
||||
|
||||
|
||||
|
@ -235,7 +236,7 @@ int main (int c, char **v)
|
|||
parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
|
||||
parms.membase = malloc (parms.memsize);
|
||||
if (!parms.membase) {
|
||||
printf("Can't allocate memory for zone.\n");
|
||||
printf("Can't allocate memroy for zone.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
sys_win.c
|
||||
sys_win.c.client
|
||||
|
||||
(description)
|
||||
|
||||
|
@ -26,25 +26,40 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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 the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// sys_win.h
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include "quakedef.h"
|
||||
#include "winquake.h"
|
||||
#include "resource.h"
|
||||
#include "sys.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <io.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "winquake.h"
|
||||
#include "resource.h"
|
||||
#include "sys.h"
|
||||
#include "screen.h"
|
||||
#include "qargs.h"
|
||||
#include "client.h"
|
||||
#include "console.h"
|
||||
|
||||
qboolean is_server = false;
|
||||
|
||||
#define MINIMUM_WIN_MEMORY 0x0c00000
|
||||
|
@ -365,7 +380,7 @@ void Sys_Sleep (void)
|
|||
}
|
||||
|
||||
|
||||
void IN_SendKeyEvents (void)
|
||||
void Sys_SendKeyEvents (void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
|
|
268
source/cmd.c
268
source/cmd.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
cmd.c
|
||||
|
||||
script command processing module
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,22 +25,13 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// cmd.c -- Quake script command processing module
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "cmd.h"
|
||||
#include "cvar.h"
|
||||
#include "sizebuf.h"
|
||||
#include "zone.h"
|
||||
#include "console.h"
|
||||
#include "qargs.h"
|
||||
#include "quakefs.h"
|
||||
#include "commdef.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
void Cmd_ForwardToServer (void);
|
||||
|
||||
|
@ -57,7 +48,10 @@ cmdalias_t *cmd_alias;
|
|||
|
||||
qboolean cmd_wait;
|
||||
|
||||
/* cvar_t cl_warncmd = {"cl_warncmd", "0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_warncmd;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
|
@ -154,54 +148,52 @@ void Cbuf_InsertText (char *text)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
extract_line(char *line)
|
||||
/*
|
||||
============
|
||||
Cbuf_Execute
|
||||
============
|
||||
*/
|
||||
void Cbuf_Execute (void)
|
||||
{
|
||||
int i;
|
||||
char *text;
|
||||
char line[1024];
|
||||
int quotes;
|
||||
|
||||
// find a \n or ; line break
|
||||
while (cmd_text.cursize)
|
||||
{
|
||||
// find a \n or ; line break
|
||||
text = (char *)cmd_text.data;
|
||||
|
||||
quotes = 0;
|
||||
for (i=0 ; i< cmd_text.cursize ; i++) {
|
||||
for (i=0 ; i< cmd_text.cursize ; i++)
|
||||
{
|
||||
if (text[i] == '"')
|
||||
quotes++;
|
||||
if ( !(quotes&1) && text[i] == ';')
|
||||
break; // don't break if inside a quoted string
|
||||
if (text[i] == '\n' || text[i] == '\r')
|
||||
if (text[i] == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
memcpy (line, text, i);
|
||||
line[i] = '\0';
|
||||
// delete the text from the command buffer and move remaining commands down
|
||||
// this is necessary because commands (exec, alias) can insert data at the
|
||||
// beginning of the text buffer
|
||||
line[i] = 0;
|
||||
|
||||
// delete the text from the command buffer and move remaining commands down
|
||||
// this is necessary because commands (exec, alias) can insert data at the
|
||||
// beginning of the text buffer
|
||||
|
||||
if (i == cmd_text.cursize)
|
||||
cmd_text.cursize = 0;
|
||||
else {
|
||||
else
|
||||
{
|
||||
i++;
|
||||
cmd_text.cursize -= i;
|
||||
memcpy (text, text+i, cmd_text.cursize);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Cbuf_Execute
|
||||
|
||||
*/
|
||||
void
|
||||
Cbuf_Execute (void)
|
||||
{
|
||||
char line[1024] = {0};
|
||||
|
||||
while (cmd_text.cursize) {
|
||||
extract_line (line);
|
||||
// execute the command line
|
||||
//Con_DPrintf("+%s\n",line),
|
||||
// execute the command line
|
||||
Cmd_ExecuteString (line);
|
||||
|
||||
if (cmd_wait)
|
||||
|
@ -212,25 +204,6 @@ Cbuf_Execute (void)
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
Cbuf_Execute
|
||||
|
||||
*/
|
||||
void
|
||||
Cbuf_Execute_Sets (void)
|
||||
{
|
||||
char line[1024] = {0};
|
||||
|
||||
while (cmd_text.cursize) {
|
||||
extract_line (line);
|
||||
// execute the command line
|
||||
if (strncmp(line,"set",3)==0
|
||||
&& isspace((int) line[3]))
|
||||
//Con_DPrintf("+%s\n",line),
|
||||
Cmd_ExecuteString (line);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
@ -254,74 +227,60 @@ void Cmd_StuffCmds_f (void)
|
|||
{
|
||||
int i, j;
|
||||
int s;
|
||||
char *build, c;
|
||||
char *text, *build, c;
|
||||
|
||||
s = strlen (com_cmdline);
|
||||
// build the combined string to parse from
|
||||
s = 0;
|
||||
for (i=1 ; i<com_argc ; i++)
|
||||
{
|
||||
if (!com_argv[i])
|
||||
continue; // NEXTSTEP nulls out -NXHost
|
||||
s += strlen (com_argv[i]) + 1;
|
||||
}
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
text = Z_Malloc (s+1);
|
||||
text[0] = 0;
|
||||
for (i=1 ; i<com_argc ; i++)
|
||||
{
|
||||
if (!com_argv[i])
|
||||
continue; // NEXTSTEP nulls out -NXHost
|
||||
strcat (text,com_argv[i]);
|
||||
if (i != com_argc-1)
|
||||
strcat (text, " ");
|
||||
}
|
||||
|
||||
// pull out the commands
|
||||
build = Z_Malloc (s+1);
|
||||
build[0] = 0;
|
||||
|
||||
for (i=0 ; i<s-1 ; i++)
|
||||
{
|
||||
if (com_cmdline[i] == '+')
|
||||
if (text[i] == '+')
|
||||
{
|
||||
i++;
|
||||
|
||||
for (j=i ; ((com_cmdline[j] != '+')
|
||||
&& (com_cmdline[j] != '-')
|
||||
&& (com_cmdline[j] != 0)) ; j++)
|
||||
for (j=i ; (text[j] != '+') && (text[j] != '-') && (text[j] != 0) ; j++)
|
||||
;
|
||||
|
||||
c = com_cmdline[j];
|
||||
com_cmdline[j] = 0;
|
||||
c = text[j];
|
||||
text[j] = 0;
|
||||
|
||||
strcat (build, com_cmdline+i);
|
||||
strcat (build, text+i);
|
||||
strcat (build, "\n");
|
||||
com_cmdline[j] = c;
|
||||
text[j] = c;
|
||||
i = j-1;
|
||||
}
|
||||
}
|
||||
|
||||
//Con_Printf("[\n%s]\n",build);
|
||||
|
||||
if (build[0])
|
||||
Cbuf_InsertText (build);
|
||||
|
||||
Z_Free (text);
|
||||
Z_Free (build);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Cmd_Exec_File
|
||||
|
||||
*/
|
||||
void
|
||||
Cmd_Exec_File (char *path)
|
||||
{
|
||||
char *f;
|
||||
int mark;
|
||||
int len;
|
||||
char base[32];
|
||||
FILE *file;
|
||||
|
||||
if ((file = fopen (path, "r")) != NULL) {
|
||||
// extract the filename base name for hunk tag
|
||||
COM_FileBase (path, base);
|
||||
len = COM_filelength (file);
|
||||
mark = Hunk_LowMark ();
|
||||
f = (char *)Hunk_AllocName (len+1, base);
|
||||
if (f) {
|
||||
f[len] = 0;
|
||||
fread (f, 1, len, file);
|
||||
fclose (file);
|
||||
Cbuf_InsertText (f);
|
||||
}
|
||||
Hunk_FreeToLowMark (mark);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -347,6 +306,8 @@ void Cmd_Exec_f (void)
|
|||
Con_Printf ("couldn't exec %s\n",Cmd_Argv(1));
|
||||
return;
|
||||
}
|
||||
/* if (!Cvar_Command () && (cl_warncmd.value || developer.value))
|
||||
CVAR_FIXME */
|
||||
if (!Cvar_Command () && (cl_warncmd->value || developer->value))
|
||||
Con_Printf ("execing %s\n",Cmd_Argv(1));
|
||||
|
||||
|
@ -442,41 +403,6 @@ void Cmd_Alias_f (void)
|
|||
a->value = CopyString (cmd);
|
||||
}
|
||||
|
||||
void Cmd_UnAlias_f (void)
|
||||
{
|
||||
cmdalias_t *a, *prev;
|
||||
char *s;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("unalias <alias>: erase an existing alias\n");
|
||||
return;
|
||||
}
|
||||
|
||||
s = Cmd_Argv(1);
|
||||
if (strlen(s) >= MAX_ALIAS_NAME)
|
||||
{
|
||||
Con_Printf ("Alias name is too long\n");
|
||||
return;
|
||||
}
|
||||
|
||||
prev = cmd_alias;
|
||||
for (a = cmd_alias ; a ; a = a->next)
|
||||
{
|
||||
if (!strcmp(s, a->name))
|
||||
{
|
||||
Z_Free (a->value);
|
||||
prev->next = a->next;
|
||||
if (a == cmd_alias)
|
||||
cmd_alias = a->next;
|
||||
Z_Free (a);
|
||||
return;
|
||||
}
|
||||
prev = a;
|
||||
}
|
||||
Con_Printf ("Unknown alias \"%s\"\n", s);
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
|
@ -717,10 +643,6 @@ void Cmd_ExecuteString (char *text)
|
|||
}
|
||||
}
|
||||
|
||||
// Tonik: check cvars
|
||||
if (Cvar_Command())
|
||||
return;
|
||||
|
||||
// check alias
|
||||
for (a=cmd_alias ; a ; a=a->next)
|
||||
{
|
||||
|
@ -731,7 +653,10 @@ void Cmd_ExecuteString (char *text)
|
|||
}
|
||||
}
|
||||
|
||||
if (cl_warncmd->value || developer->value)
|
||||
// check cvars
|
||||
/* if (!Cvar_Command () && (cl_warncmd.value || developer.value))
|
||||
CVAR_FIXME */
|
||||
if (!Cvar_Command () && (cl_warncmd->value || developer->value))
|
||||
Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0));
|
||||
|
||||
}
|
||||
|
@ -787,76 +712,7 @@ void Cmd_Init (void)
|
|||
Cmd_AddCommand ("exec",Cmd_Exec_f);
|
||||
Cmd_AddCommand ("echo",Cmd_Echo_f);
|
||||
Cmd_AddCommand ("alias",Cmd_Alias_f);
|
||||
Cmd_AddCommand ("unalias",Cmd_UnAlias_f);
|
||||
Cmd_AddCommand ("wait", Cmd_Wait_f);
|
||||
Cmd_AddCommand ("cmdlist", Cmd_CmdList_f);
|
||||
}
|
||||
|
||||
|
||||
char com_token[1024];
|
||||
|
||||
/*
|
||||
==============
|
||||
COM_Parse
|
||||
|
||||
Parse a token out of a string
|
||||
==============
|
||||
*/
|
||||
char *COM_Parse (char *data)
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
com_token[0] = 0;
|
||||
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
// skip whitespace
|
||||
skipwhite:
|
||||
while ( (c = *data) <= ' ')
|
||||
{
|
||||
if (c == 0)
|
||||
return NULL; // end of file;
|
||||
data++;
|
||||
}
|
||||
|
||||
// skip // comments
|
||||
if (c=='/' && data[1] == '/')
|
||||
{
|
||||
while (*data && *data != '\n')
|
||||
data++;
|
||||
goto skipwhite;
|
||||
}
|
||||
|
||||
|
||||
// handle quoted strings specially
|
||||
if (c == '\"')
|
||||
{
|
||||
data++;
|
||||
while (1)
|
||||
{
|
||||
c = *data++;
|
||||
if (c=='\"' || !c)
|
||||
{
|
||||
com_token[len] = 0;
|
||||
return data;
|
||||
}
|
||||
com_token[len] = c;
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
// parse a regular word
|
||||
do
|
||||
{
|
||||
com_token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
c = *data;
|
||||
} while (c>32);
|
||||
|
||||
com_token[len] = 0;
|
||||
return data;
|
||||
}
|
||||
|
|
1958
source/common.c
Normal file
1958
source/common.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -29,19 +29,8 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "input.h"
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "keys.h"
|
||||
#include "client.h"
|
||||
#include "draw.h"
|
||||
#include "commdef.h"
|
||||
#include "qargs.h"
|
||||
#include "cmd.h"
|
||||
#include "screen.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
int con_ormask;
|
||||
console_t con_main;
|
||||
|
@ -54,6 +43,8 @@ int con_totallines; // total lines in console scrollback
|
|||
float con_cursorspeed = 4;
|
||||
|
||||
|
||||
/* cvar_t con_notifytime = {"con_notifytime","3"}; //seconds
|
||||
CVAR_FIXME */
|
||||
cvar_t *con_notifytime; //seconds
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
|
@ -127,8 +118,6 @@ Con_Clear_f
|
|||
*/
|
||||
void Con_Clear_f (void)
|
||||
{
|
||||
con_main.numlines = 0;
|
||||
con_chat.numlines = 0;
|
||||
memset (con_main.text, ' ', CON_TEXTSIZE);
|
||||
memset (con_chat.text, ' ', CON_TEXTSIZE);
|
||||
}
|
||||
|
@ -155,8 +144,6 @@ Con_MessageMode_f
|
|||
*/
|
||||
void Con_MessageMode_f (void)
|
||||
{
|
||||
if (cls.state != ca_active)
|
||||
return;
|
||||
chat_team = false;
|
||||
key_dest = key_message;
|
||||
}
|
||||
|
@ -168,8 +155,6 @@ Con_MessageMode2_f
|
|||
*/
|
||||
void Con_MessageMode2_f (void)
|
||||
{
|
||||
if (cls.state != ca_active)
|
||||
return;
|
||||
chat_team = true;
|
||||
key_dest = key_message;
|
||||
}
|
||||
|
@ -266,6 +251,8 @@ void Con_Init (void)
|
|||
//
|
||||
// register our commands
|
||||
//
|
||||
/* Cvar_RegisterVariable (&con_notifytime);
|
||||
CVAR_FIXME */
|
||||
con_notifytime = Cvar_Get("con_notifytime", "3", CVAR_NONE, "None");
|
||||
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
||||
|
@ -288,8 +275,6 @@ void Con_Linefeed (void)
|
|||
if (con->display == con->current)
|
||||
con->display++;
|
||||
con->current++;
|
||||
if (con->numlines < con_totallines)
|
||||
con->numlines++;
|
||||
memset (&con->text[(con->current%con_totallines)*con_linewidth]
|
||||
, ' ', con_linewidth);
|
||||
}
|
||||
|
@ -429,6 +414,8 @@ void Con_DPrintf (char *fmt, ...)
|
|||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
|
||||
/* if (!developer.value)
|
||||
CVAR_FIXME */
|
||||
if (!developer->value)
|
||||
return; // don't confuse non-developers with techie stuff...
|
||||
|
||||
|
@ -460,20 +447,18 @@ void Con_DrawInput (void)
|
|||
int y;
|
||||
int i;
|
||||
char *text;
|
||||
char temp[MAXCMDLINE];
|
||||
|
||||
if (key_dest != key_console && cls.state == ca_active)
|
||||
return; // don't draw anything (allways draw if not active)
|
||||
|
||||
text = strcpy (temp, key_lines[edit_line]);
|
||||
|
||||
// fill out remainder with spaces
|
||||
for (i=strlen(text) ; i < MAXCMDLINE ; i++)
|
||||
text[i] = ' ';
|
||||
text = key_lines[edit_line];
|
||||
|
||||
// add the cursor frame
|
||||
if ( (int)(realtime*con_cursorspeed) & 1 )
|
||||
text[key_linepos] = 11;
|
||||
text[key_linepos] = 10+((int)(realtime*con_cursorspeed)&1);
|
||||
|
||||
// fill out remainder with spaces
|
||||
for (i=key_linepos+1 ; i< con_linewidth ; i++)
|
||||
text[i] = ' ';
|
||||
|
||||
// prestep if horizontally scrolling
|
||||
if (key_linepos >= con_linewidth)
|
||||
|
@ -484,6 +469,9 @@ void Con_DrawInput (void)
|
|||
|
||||
for (i=0 ; i<con_linewidth ; i++)
|
||||
Draw_Character ( (i+1)<<3, con_vislines - 22, text[i]);
|
||||
|
||||
// remove cursor
|
||||
key_lines[edit_line][key_linepos] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -512,6 +500,8 @@ void Con_DrawNotify (void)
|
|||
if (time == 0)
|
||||
continue;
|
||||
time = realtime - time;
|
||||
/* if (time > con_notifytime.value)
|
||||
CVAR_FIXME */
|
||||
if (time > con_notifytime->value)
|
||||
continue;
|
||||
text = con->text + (i % con_totallines)*con_linewidth;
|
||||
|
@ -686,7 +676,7 @@ void Con_NotifyBox (char *text)
|
|||
{
|
||||
t1 = Sys_DoubleTime ();
|
||||
SCR_UpdateScreen ();
|
||||
IN_SendKeyEvents ();
|
||||
Sys_SendKeyEvents ();
|
||||
t2 = Sys_DoubleTime ();
|
||||
realtime += t2-t1; // make the cursor blink
|
||||
} while (key_count < 0);
|
||||
|
|
|
@ -32,18 +32,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "commdef.h"
|
||||
#include "cvar.h"
|
||||
#include "zone.h"
|
||||
#include "console.h"
|
||||
#include "qargs.h"
|
||||
#include "cmd.h"
|
||||
#include "commdef.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
cvar_t *cvar_vars;
|
||||
char *cvar_null_string = "";
|
||||
|
@ -186,28 +175,6 @@ Cvar_Set
|
|||
============
|
||||
*/
|
||||
void Cvar_Set (cvar_t *var, char *value)
|
||||
{
|
||||
if (!var)
|
||||
return;
|
||||
if(var->flags&CVAR_ROM)
|
||||
return;
|
||||
|
||||
Z_Free (var->string); // free the old value string
|
||||
|
||||
var->string = Z_Malloc (strlen(value)+1);
|
||||
strcpy (var->string, value);
|
||||
var->value = atof (var->string);
|
||||
|
||||
Cvar_Info(var);
|
||||
}
|
||||
/*
|
||||
|
||||
Cvar_SetROM
|
||||
|
||||
doesn't check for CVAR_ROM flag
|
||||
|
||||
*/
|
||||
void Cvar_SetROM (cvar_t *var, char *value)
|
||||
{
|
||||
if (!var)
|
||||
return;
|
||||
|
@ -228,7 +195,10 @@ Cvar_SetValue
|
|||
*/
|
||||
void Cvar_SetValue (cvar_t *var_name, float value)
|
||||
{
|
||||
Cvar_Set (var_name, va("%f", value));
|
||||
char val[32];
|
||||
|
||||
sprintf (val, "%f",value);
|
||||
Cvar_Set (var_name, val);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -305,32 +275,6 @@ void Cvar_Set_f(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Cvar_Setrom_f(void)
|
||||
{
|
||||
cvar_t *var;
|
||||
char *value;
|
||||
char *var_name;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("usage: setrom <cvar>\n");
|
||||
return;
|
||||
}
|
||||
var_name = Cmd_Argv (1);
|
||||
value = Cmd_Argv (2);
|
||||
var = Cvar_FindVar (var_name);
|
||||
if (!var)
|
||||
var = Cvar_FindAlias (var_name);
|
||||
if (var)
|
||||
{
|
||||
var->flags |= CVAR_ROM;
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf ("cvar %s not found\n", var_name);
|
||||
}
|
||||
}
|
||||
|
||||
void Cvar_Toggle_f (void)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
@ -393,7 +337,6 @@ void Cvar_Init()
|
|||
developer = Cvar_Get ("developer","0",0,"None");
|
||||
|
||||
Cmd_AddCommand ("set", Cvar_Set_f);
|
||||
Cmd_AddCommand ("setrom", Cvar_Setrom_f);
|
||||
Cmd_AddCommand ("toggle", Cvar_Toggle_f);
|
||||
Cmd_AddCommand ("help",Cvar_Help_f);
|
||||
Cmd_AddCommand ("cvarlist",Cvar_CvarList_f);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
d_surf.c
|
||||
|
||||
rasterization driver surface heap manager
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,17 +25,16 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// d_surf.c: rasterization driver surface heap manager
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "qargs.h"
|
||||
#include "quakedef.h"
|
||||
#include "d_local.h"
|
||||
#include "r_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
float surfscale;
|
||||
qboolean r_cache_thrash; // set if surface cache is thrashing
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
draw.c
|
||||
|
||||
this is the only file outside the refresh that touches the vid buffer
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,17 +25,14 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// draw.c -- this is the only file outside the refresh that touches the
|
||||
// vid buffer
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "draw.h"
|
||||
#include "vid.h"
|
||||
#include "d_iface.h"
|
||||
#include "console.h"
|
||||
#include "quakefs.h"
|
||||
#include "sound.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
typedef struct {
|
||||
vrect_t rect;
|
||||
|
@ -51,6 +48,8 @@ byte *draw_chars; // 8*8 graphic characters
|
|||
qpic_t *draw_disc;
|
||||
qpic_t *draw_backtile;
|
||||
|
||||
/* cvar_t cl_verstring = {"cl_verstring", "QuakeForge " QF_VERSION};
|
||||
CVAR_FIXME */
|
||||
cvar_t *cl_verstring;
|
||||
|
||||
//=============================================================================
|
||||
|
@ -134,6 +133,8 @@ void Draw_Init (void)
|
|||
r_rectdesc.ptexbytes = draw_backtile->data;
|
||||
r_rectdesc.rowbytes = draw_backtile->width;
|
||||
|
||||
/* Cvar_RegisterVariable (&cl_verstring);
|
||||
CVAR_FIXME */
|
||||
cl_verstring = Cvar_Get("cl_verstring", PROGRAM " " VERSION, CVAR_NONE, "None");
|
||||
}
|
||||
|
||||
|
@ -289,12 +290,22 @@ void Draw_Pixel(int x, int y, byte color)
|
|||
void Draw_Crosshair(void)
|
||||
{
|
||||
int x, y;
|
||||
/* extern cvar_t crosshair, cl_crossx, cl_crossy, crosshaircolor;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor;
|
||||
extern vrect_t scr_vrect;
|
||||
/* byte c = (byte)crosshaircolor.value;
|
||||
CVAR_FIXME */
|
||||
byte c = (byte)crosshaircolor->value;
|
||||
|
||||
/* if (crosshair.value == 2) {
|
||||
CVAR_FIXME */
|
||||
if (crosshair->value == 2) {
|
||||
/* x = scr_vrect.x + scr_vrect.width/2 + cl_crossx.value;
|
||||
CVAR_FIXME */
|
||||
x = scr_vrect.x + scr_vrect.width/2 + cl_crossx->value;
|
||||
/* y = scr_vrect.y + scr_vrect.height/2 + cl_crossy.value;
|
||||
CVAR_FIXME */
|
||||
y = scr_vrect.y + scr_vrect.height/2 + cl_crossy->value;
|
||||
Draw_Pixel(x - 1, y, c);
|
||||
Draw_Pixel(x - 3, y, c);
|
||||
|
@ -304,9 +315,15 @@ void Draw_Crosshair(void)
|
|||
Draw_Pixel(x, y - 3, c);
|
||||
Draw_Pixel(x, y + 1, c);
|
||||
Draw_Pixel(x, y + 3, c);
|
||||
/* } else if (crosshair.value)
|
||||
CVAR_FIXME */
|
||||
} else if (crosshair->value)
|
||||
Draw_Character (
|
||||
/* scr_vrect.x + scr_vrect.width/2-4 + cl_crossx.value,
|
||||
CVAR_FIXME */
|
||||
scr_vrect.x + scr_vrect.width/2-4 + cl_crossx->value,
|
||||
/* scr_vrect.y + scr_vrect.height/2-4 + cl_crossy.value,
|
||||
CVAR_FIXME */
|
||||
scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value,
|
||||
'+');
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
|
||||
#include "common.h"
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
|
@ -60,6 +60,8 @@ extern unsigned char d_15to8table[65536];
|
|||
CVAR_FIXME */
|
||||
extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor;
|
||||
|
||||
/* cvar_t gl_nobind = {"gl_nobind", "0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_nobind;
|
||||
/* cvar_t gl_max_size = {"gl_max_size", "1024"};
|
||||
CVAR_FIXME */
|
||||
|
@ -125,6 +127,8 @@ int numgltextures;
|
|||
|
||||
void GL_Bind (int texnum)
|
||||
{
|
||||
/* if (gl_nobind.value)
|
||||
CVAR_FIXME */
|
||||
if (gl_nobind->value)
|
||||
texnum = char_texture;
|
||||
if (currenttexture == texnum)
|
||||
|
@ -384,7 +388,7 @@ void Draw_TextureMode_f (void)
|
|||
|
||||
for (i=0 ; i< 6 ; i++)
|
||||
{
|
||||
if (!stricmp (modes[i].name, Cmd_Argv(1) ) )
|
||||
if (!strcasecmp (modes[i].name, Cmd_Argv(1) ) )
|
||||
break;
|
||||
}
|
||||
if (i == 6)
|
||||
|
@ -431,7 +435,10 @@ void Draw_Init (void)
|
|||
CVAR_FIXME */
|
||||
gl_picmip = Cvar_Get("gl_picmip", "0", CVAR_NONE, "None");
|
||||
|
||||
cl_verstring = Cvar_Get("cl_verstring", PROGRAM " " VERSION, CVAR_NONE, "Client version string");
|
||||
/* Cvar_RegisterVariable (&cl_verstring);
|
||||
CVAR_FIXME */
|
||||
/* Oddone: Why did you remove this? */
|
||||
cl_verstring = Cvar_Get("cl_verstring", PROGRAM " " VERSION, CVAR_NONE, "None");
|
||||
|
||||
// 3dfx can only handle 256 wide textures
|
||||
if (!strncasecmp ((char *)gl_renderer, "3dfx",4) ||
|
||||
|
@ -606,11 +613,19 @@ void Draw_Crosshair(void)
|
|||
extern vrect_t scr_vrect;
|
||||
unsigned char *pColor;
|
||||
|
||||
/* if (crosshair.value == 2) {
|
||||
CVAR_FIXME */
|
||||
if (crosshair->value == 2) {
|
||||
/* x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx.value;
|
||||
CVAR_FIXME */
|
||||
x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value;
|
||||
/* y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy.value;
|
||||
CVAR_FIXME */
|
||||
y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->value;
|
||||
|
||||
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
/* pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor.value];
|
||||
CVAR_FIXME */
|
||||
pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value];
|
||||
glColor4ubv ( pColor );
|
||||
GL_Bind (cs_texture);
|
||||
|
@ -627,9 +642,16 @@ void Draw_Crosshair(void)
|
|||
glEnd ();
|
||||
|
||||
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
||||
/* } else if (crosshair.value)
|
||||
CVAR_FIXME */
|
||||
} else if (crosshair->value)
|
||||
/* Draw_Character (scr_vrect.x + scr_vrect.width/2-4 + cl_crossx.value,
|
||||
CVAR_FIXME */
|
||||
Draw_Character (scr_vrect.x + scr_vrect.width/2-4 + cl_crossx->value,
|
||||
scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value, '+');
|
||||
/* scr_vrect.y + scr_vrect.height/2-4 + cl_crossy.value,
|
||||
CVAR_FIXME */
|
||||
scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value,
|
||||
'+');
|
||||
}
|
||||
|
||||
|
||||
|
@ -686,9 +708,9 @@ void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
|
|||
gl = (glpic_t *)pic->data;
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glCullFace(GL_FRONT);
|
||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // FIXME deek: these cause problems with text. Looking for the real problem
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColor4f (1,1,1,alpha);
|
||||
GL_Bind (gl->texnum);
|
||||
glBegin (GL_QUADS);
|
||||
|
@ -702,7 +724,7 @@ void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
|
|||
glVertex2f (x, y+pic->height);
|
||||
glEnd ();
|
||||
glColor4f (1,1,1,1);
|
||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); // FIXME
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable (GL_BLEND);
|
||||
}
|
||||
|
@ -1123,11 +1145,25 @@ static unsigned scaled[1024*512]; // [512*256];
|
|||
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
|
||||
;
|
||||
|
||||
/* scaled_width >>= (int)gl_picmip.value;
|
||||
CVAR_FIXME */
|
||||
scaled_width >>= (int)gl_picmip->value;
|
||||
/* scaled_height >>= (int)gl_picmip.value;
|
||||
CVAR_FIXME */
|
||||
scaled_height >>= (int)gl_picmip->value;
|
||||
|
||||
scaled_width = min(scaled_width, gl_max_size->value);
|
||||
scaled_height = min(scaled_height, gl_max_size->value);
|
||||
/* if (scaled_width > gl_max_size.value)
|
||||
CVAR_FIXME */
|
||||
if (scaled_width > gl_max_size->value)
|
||||
/* scaled_width = gl_max_size.value;
|
||||
CVAR_FIXME */
|
||||
scaled_width = gl_max_size->value;
|
||||
/* if (scaled_height > gl_max_size.value)
|
||||
CVAR_FIXME */
|
||||
if (scaled_height > gl_max_size->value)
|
||||
/* scaled_height = gl_max_size.value;
|
||||
CVAR_FIXME */
|
||||
scaled_height = gl_max_size->value;
|
||||
|
||||
if (scaled_width * scaled_height > sizeof(scaled)/4)
|
||||
Sys_Error ("GL_LoadTexture: too big");
|
||||
|
@ -1223,11 +1259,25 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
|
|||
for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
|
||||
;
|
||||
|
||||
/* scaled_width >>= (int)gl_picmip.value;
|
||||
CVAR_FIXME */
|
||||
scaled_width >>= (int)gl_picmip->value;
|
||||
/* scaled_height >>= (int)gl_picmip.value;
|
||||
CVAR_FIXME */
|
||||
scaled_height >>= (int)gl_picmip->value;
|
||||
|
||||
scaled_width = min(scaled_width, gl_max_size->value);
|
||||
scaled_height = min(scaled_height, gl_max_size->value);
|
||||
/* if (scaled_width > gl_max_size.value)
|
||||
CVAR_FIXME */
|
||||
if (scaled_width > gl_max_size->value)
|
||||
/* scaled_width = gl_max_size.value;
|
||||
CVAR_FIXME */
|
||||
scaled_width = gl_max_size->value;
|
||||
/* if (scaled_height > gl_max_size.value)
|
||||
CVAR_FIXME */
|
||||
if (scaled_height > gl_max_size->value)
|
||||
/* scaled_height = gl_max_size.value;
|
||||
CVAR_FIXME */
|
||||
scaled_height = gl_max_size->value;
|
||||
|
||||
if (scaled_width * scaled_height > sizeof(scaled))
|
||||
Sys_Error ("GL_LoadTexture: too big");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
gl_model.c
|
||||
|
||||
model loading and caching
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// models.c -- model loading and caching
|
||||
|
||||
// models are the only shared resource between a client and server running
|
||||
// on the same machine.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
@ -37,8 +37,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
#include "qendian.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
|
|
|
@ -29,32 +29,8 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "qargs.h"
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
#include "d_iface.h"
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
#include "zone.h" // needed by: client.h, gl_model.h
|
||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||
// modelgen.h, glmodel.h
|
||||
#include "wad.h"
|
||||
#include "draw.h"
|
||||
#include "cvar.h"
|
||||
#include "menu.h"
|
||||
#include "net.h" // needed by: client.h
|
||||
#include "protocol.h" // needed by: client.h
|
||||
#include "cmd.h"
|
||||
#include "sbar.h"
|
||||
#include "render.h" // needed by: client.h, gl_model.h, glquake.h
|
||||
#include "client.h" // need cls in this file
|
||||
#include "model.h" // needed by: glquake.h
|
||||
#include "console.h"
|
||||
#include "glquake.h"
|
||||
#include "quakefs.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "glquake.h"
|
||||
|
||||
#define MAX_PARTICLES 2048 // default max # of particles at one
|
||||
// time
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
@ -34,6 +33,7 @@
|
|||
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
|
||||
#include "common.h"
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
|
@ -227,35 +227,83 @@ void R_Init (void)
|
|||
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
|
||||
Cmd_AddCommand ("loadsky", R_LoadSky_f);
|
||||
|
||||
/* Cvar_RegisterVariable (&r_norefresh);
|
||||
CVAR_FIXME */
|
||||
r_norefresh = Cvar_Get("r_norefresh", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_lightmap);
|
||||
CVAR_FIXME */
|
||||
r_lightmap = Cvar_Get("r_lightmap", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_fullbright);
|
||||
CVAR_FIXME */
|
||||
r_fullbright = Cvar_Get("r_fullbright", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_drawentities);
|
||||
CVAR_FIXME */
|
||||
r_drawentities = Cvar_Get("r_drawentities", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_drawviewmodel);
|
||||
CVAR_FIXME */
|
||||
r_drawviewmodel = Cvar_Get("r_drawviewmodel", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_shadows);
|
||||
CVAR_FIXME */
|
||||
r_shadows = Cvar_Get("r_shadows", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_mirroralpha);
|
||||
CVAR_FIXME */
|
||||
r_mirroralpha = Cvar_Get("r_mirroralpha", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_wateralpha);
|
||||
CVAR_FIXME */
|
||||
r_wateralpha = Cvar_Get("r_wateralpha", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_dynamic);
|
||||
CVAR_FIXME */
|
||||
r_dynamic = Cvar_Get("r_dynamic", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_novis);
|
||||
CVAR_FIXME */
|
||||
r_novis = Cvar_Get("r_novis", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_speeds);
|
||||
CVAR_FIXME */
|
||||
r_speeds = Cvar_Get("r_speeds", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&r_netgraph);
|
||||
CVAR_FIXME */
|
||||
r_netgraph = Cvar_Get("r_netgraph", "0", CVAR_NONE, "None");
|
||||
|
||||
/* Cvar_RegisterVariable (&gl_clear);
|
||||
CVAR_FIXME */
|
||||
gl_clear = Cvar_Get("gl_clear", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_texsort);
|
||||
CVAR_FIXME */
|
||||
gl_texsort = Cvar_Get("gl_texsort", "1", CVAR_NONE, "None");
|
||||
|
||||
if (gl_mtexable)
|
||||
gl_texsort->value = 0.0;
|
||||
|
||||
/* Cvar_RegisterVariable (&gl_cull);
|
||||
CVAR_FIXME */
|
||||
gl_cull = Cvar_Get("gl_cull", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_smoothmodels);
|
||||
CVAR_FIXME */
|
||||
gl_smoothmodels = Cvar_Get("gl_smoothmodels", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_affinemodels);
|
||||
CVAR_FIXME */
|
||||
gl_affinemodels = Cvar_Get("gl_affinemodels", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_polyblend);
|
||||
CVAR_FIXME */
|
||||
gl_polyblend = Cvar_Get("gl_polyblend", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_flashblend);
|
||||
CVAR_FIXME */
|
||||
gl_flashblend = Cvar_Get("gl_flashblend", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_playermip);
|
||||
CVAR_FIXME */
|
||||
gl_playermip = Cvar_Get("gl_playermip", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_nocolors);
|
||||
CVAR_FIXME */
|
||||
gl_nocolors = Cvar_Get("gl_nocolors", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_finish);
|
||||
CVAR_FIXME */
|
||||
gl_finish = Cvar_Get("gl_finish", "0", CVAR_NONE, "None");
|
||||
|
||||
/* Cvar_RegisterVariable (&gl_keeptjunctions);
|
||||
CVAR_FIXME */
|
||||
gl_keeptjunctions = Cvar_Get("gl_keeptjunctions", "1", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_reporttjunctions);
|
||||
CVAR_FIXME */
|
||||
gl_reporttjunctions = Cvar_Get("gl_reporttjunctions", "0", CVAR_NONE, "None");
|
||||
|
||||
r_skyname = Cvar_Get("r_skyname", "none", CVAR_NONE,
|
||||
|
@ -266,6 +314,10 @@ void R_Init (void)
|
|||
R_InitParticles ();
|
||||
R_InitParticleTexture ();
|
||||
|
||||
#ifdef GLTEST
|
||||
Test_Init ();
|
||||
#endif
|
||||
|
||||
netgraphtexture = texture_extension_number;
|
||||
texture_extension_number++;
|
||||
|
||||
|
@ -378,12 +430,18 @@ void R_TranslatePlayerSkin (int playernum)
|
|||
false, false, true);
|
||||
#endif
|
||||
|
||||
// FIXME deek: This 512x256 limit sucks!
|
||||
scaled_width = min(gl_max_size->value, 512);
|
||||
scaled_height = min(gl_max_size->value, 256);
|
||||
|
||||
/* scaled_width = gl_max_size.value < 512 ? gl_max_size.value : 512;
|
||||
CVAR_FIXME */
|
||||
scaled_width = gl_max_size->value < 512 ? gl_max_size->value : 512;
|
||||
/* scaled_height = gl_max_size->value < 256 ? gl_max_size.value : 256;
|
||||
CVAR_FIXME */
|
||||
scaled_height = gl_max_size->value < 256 ? gl_max_size->value : 256;
|
||||
// allow users to crunch sizes down even more if they want
|
||||
/* scaled_width >>= (int)gl_playermip.value;
|
||||
CVAR_FIXME */
|
||||
scaled_width >>= (int)gl_playermip->value;
|
||||
/* scaled_height >>= (int)gl_playermip.value;
|
||||
CVAR_FIXME */
|
||||
scaled_height >>= (int)gl_playermip->value;
|
||||
|
||||
if (VID_Is8bit()) { // 8bit texture upload
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
gl_screen.c
|
||||
|
||||
master for refresh, status bar, console, chat, notify, etc
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,20 +25,19 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
// screen.c -- master for refresh, status bar, console, chat, notify, etc
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "input.h"
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
#include "qendian.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
|
@ -122,16 +121,38 @@ float scr_con_current;
|
|||
float scr_conlines; // lines of console to display
|
||||
|
||||
float oldscreensize, oldfov;
|
||||
/* cvar_t scr_viewsize = {"viewsize","100", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_viewsize;
|
||||
/* cvar_t scr_fov = {"fov","90"}; // 10 - 170
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_fov; // 10 - 170
|
||||
/* cvar_t scr_conspeed = {"scr_conspeed","300"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_conspeed;
|
||||
/* cvar_t scr_centertime = {"scr_centertime","2"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_centertime;
|
||||
/* cvar_t scr_showram = {"showram","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_showram;
|
||||
/* cvar_t scr_showturtle = {"showturtle","0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_showturtle;
|
||||
/* cvar_t scr_showpause = {"showpause","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_showpause;
|
||||
/* cvar_t scr_printspeed = {"scr_printspeed","8"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_printspeed;
|
||||
/* cvar_t scr_allowsnap = {"scr_allowsnap", "1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *scr_allowsnap;
|
||||
/* cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", true };
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_triplebuffer;
|
||||
/* extern cvar_t crosshair;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *crosshair;
|
||||
|
||||
qboolean scr_initialized; // ready to draw
|
||||
|
@ -186,6 +207,8 @@ for a few moments
|
|||
void SCR_CenterPrint (char *str)
|
||||
{
|
||||
strncpy (scr_centerstring, str, sizeof(scr_centerstring)-1);
|
||||
/* scr_centertime_off = scr_centertime.value;
|
||||
CVAR_FIXME */
|
||||
scr_centertime_off = scr_centertime->value;
|
||||
scr_centertime_start = cl.time;
|
||||
|
||||
|
@ -210,6 +233,8 @@ void SCR_DrawCenterString (void)
|
|||
|
||||
// the finale prints the characters one at a time
|
||||
if (cl.intermission)
|
||||
/* remaining = scr_printspeed.value * (cl.time - scr_centertime_start);
|
||||
CVAR_FIXME */
|
||||
remaining = scr_printspeed->value * (cl.time - scr_centertime_start);
|
||||
else
|
||||
remaining = 9999;
|
||||
|
@ -311,14 +336,22 @@ static void SCR_CalcRefdef (void)
|
|||
//========================================
|
||||
|
||||
// bound viewsize
|
||||
/* if (scr_viewsize.value < 30)
|
||||
CVAR_FIXME */
|
||||
if (scr_viewsize->value < 30)
|
||||
Cvar_Set (scr_viewsize,"30");
|
||||
/* if (scr_viewsize.value > 120)
|
||||
CVAR_FIXME */
|
||||
if (scr_viewsize->value > 120)
|
||||
Cvar_Set (scr_viewsize,"120");
|
||||
|
||||
// bound field of view
|
||||
/* if (scr_fov.value < 10)
|
||||
CVAR_FIXME */
|
||||
if (scr_fov->value < 10)
|
||||
Cvar_Set (scr_fov,"10");
|
||||
/* if (scr_fov.value > 170)
|
||||
CVAR_FIXME */
|
||||
if (scr_fov->value > 170)
|
||||
Cvar_Set (scr_fov,"170");
|
||||
|
||||
|
@ -326,6 +359,8 @@ static void SCR_CalcRefdef (void)
|
|||
if (cl.intermission)
|
||||
size = 120;
|
||||
else
|
||||
/* size = scr_viewsize.value;
|
||||
CVAR_FIXME */
|
||||
size = scr_viewsize->value;
|
||||
|
||||
if (size >= 120)
|
||||
|
@ -335,10 +370,14 @@ static void SCR_CalcRefdef (void)
|
|||
else
|
||||
sb_lines = 24+16+8;
|
||||
|
||||
/* if (scr_viewsize.value >= 100.0) {
|
||||
CVAR_FIXME */
|
||||
if (scr_viewsize->value >= 100.0) {
|
||||
full = true;
|
||||
size = 100.0;
|
||||
} else
|
||||
/* size = scr_viewsize.value;
|
||||
CVAR_FIXME */
|
||||
size = scr_viewsize->value;
|
||||
if (cl.intermission)
|
||||
{
|
||||
|
@ -348,6 +387,8 @@ static void SCR_CalcRefdef (void)
|
|||
}
|
||||
size /= 100.0;
|
||||
|
||||
/* if (!cl_sbar.value && full)
|
||||
CVAR_FIXME */
|
||||
if (!cl_sbar->value && full)
|
||||
h = vid.height;
|
||||
else
|
||||
|
@ -361,6 +402,8 @@ static void SCR_CalcRefdef (void)
|
|||
}
|
||||
|
||||
r_refdef.vrect.height = vid.height * size;
|
||||
/* if (cl_sbar.value || !full) {
|
||||
CVAR_FIXME */
|
||||
if (cl_sbar->value || !full) {
|
||||
if (r_refdef.vrect.height > vid.height - sb_lines)
|
||||
r_refdef.vrect.height = vid.height - sb_lines;
|
||||
|
@ -372,6 +415,8 @@ static void SCR_CalcRefdef (void)
|
|||
else
|
||||
r_refdef.vrect.y = (h - r_refdef.vrect.height)/2;
|
||||
|
||||
/* r_refdef.fov_x = scr_fov.value;
|
||||
CVAR_FIXME */
|
||||
r_refdef.fov_x = scr_fov->value;
|
||||
r_refdef.fov_y = CalcFov (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);
|
||||
|
||||
|
@ -388,6 +433,8 @@ Keybinding command
|
|||
*/
|
||||
void SCR_SizeUp_f (void)
|
||||
{
|
||||
/* Cvar_SetValue ("viewsize",scr_viewsize.value+10);
|
||||
CVAR_FIXME */
|
||||
Cvar_SetValue (scr_viewsize, scr_viewsize->value+10);
|
||||
|
||||
vid.recalc_refdef = 1;
|
||||
|
@ -403,6 +450,8 @@ Keybinding command
|
|||
*/
|
||||
void SCR_SizeDown_f (void)
|
||||
{
|
||||
/* Cvar_SetValue ("viewsize",scr_viewsize.value-10);
|
||||
CVAR_FIXME */
|
||||
Cvar_SetValue (scr_viewsize, scr_viewsize->value-10);
|
||||
vid.recalc_refdef = 1;
|
||||
}
|
||||
|
@ -455,6 +504,8 @@ SCR_DrawRam
|
|||
*/
|
||||
void SCR_DrawRam (void)
|
||||
{
|
||||
/* if (!scr_showram.value)
|
||||
CVAR_FIXME */
|
||||
if (!scr_showram->value)
|
||||
return;
|
||||
|
||||
|
@ -473,6 +524,8 @@ void SCR_DrawTurtle (void)
|
|||
{
|
||||
static int count;
|
||||
|
||||
/* if (!scr_showturtle.value)
|
||||
CVAR_FIXME */
|
||||
if (!scr_showturtle->value)
|
||||
return;
|
||||
|
||||
|
@ -506,6 +559,8 @@ void SCR_DrawNet (void)
|
|||
|
||||
void SCR_DrawFPS (void)
|
||||
{
|
||||
/* extern cvar_t show_fps;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *show_fps;
|
||||
static double lastframetime;
|
||||
double t;
|
||||
|
@ -514,6 +569,8 @@ void SCR_DrawFPS (void)
|
|||
int x, y;
|
||||
char st[80];
|
||||
|
||||
/* if (!show_fps.value)
|
||||
CVAR_FIXME */
|
||||
if (!show_fps->value)
|
||||
return;
|
||||
|
||||
|
@ -541,6 +598,8 @@ void SCR_DrawPause (void)
|
|||
{
|
||||
qpic_t *pic;
|
||||
|
||||
/* if (!scr_showpause.value) // turn off for screenshots
|
||||
CVAR_FIXME */
|
||||
if (!scr_showpause->value) // turn off for screenshots
|
||||
return;
|
||||
|
||||
|
@ -601,6 +660,8 @@ void SCR_SetUpToDrawConsole (void)
|
|||
|
||||
if (scr_conlines < scr_con_current)
|
||||
{
|
||||
/* scr_con_current -= scr_conspeed.value*host_frametime;
|
||||
CVAR_FIXME */
|
||||
scr_con_current -= scr_conspeed->value*host_frametime;
|
||||
if (scr_conlines > scr_con_current)
|
||||
scr_con_current = scr_conlines;
|
||||
|
@ -608,6 +669,8 @@ void SCR_SetUpToDrawConsole (void)
|
|||
}
|
||||
else if (scr_conlines > scr_con_current)
|
||||
{
|
||||
/* scr_con_current += scr_conspeed.value*host_frametime;
|
||||
CVAR_FIXME */
|
||||
scr_con_current += scr_conspeed->value*host_frametime;
|
||||
if (scr_conlines < scr_con_current)
|
||||
scr_con_current = scr_conlines;
|
||||
|
@ -1058,7 +1121,7 @@ int SCR_ModalMessage (char *text)
|
|||
do
|
||||
{
|
||||
key_count = -1; // wait for a key down and up
|
||||
IN_SendKeyEvents ();
|
||||
Sys_SendKeyEvents ();
|
||||
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);
|
||||
|
||||
scr_fullupdate = 0;
|
||||
|
@ -1132,7 +1195,9 @@ void SCR_UpdateScreen (void)
|
|||
if (block_drawing)
|
||||
return;
|
||||
|
||||
vid.numpages = 2 + (int) gl_triplebuffer->value;
|
||||
/* vid.numpages = 2 + gl_triplebuffer.value;
|
||||
CVAR_FIXME */
|
||||
vid.numpages = 2 + gl_triplebuffer->value;
|
||||
|
||||
scr_copytop = 0;
|
||||
scr_copyeverything = 0;
|
||||
|
@ -1152,7 +1217,11 @@ void SCR_UpdateScreen (void)
|
|||
return; // not initialized yet
|
||||
|
||||
|
||||
/* if (oldsbar != cl_sbar.value) {
|
||||
CVAR_FIXME */
|
||||
if (oldsbar != cl_sbar->value) {
|
||||
/* oldsbar = cl_sbar.value;
|
||||
CVAR_FIXME */
|
||||
oldsbar = cl_sbar->value;
|
||||
vid.recalc_refdef = true;
|
||||
}
|
||||
|
@ -1162,8 +1231,12 @@ void SCR_UpdateScreen (void)
|
|||
//
|
||||
// determine size of refresh window
|
||||
//
|
||||
/* if (oldfov != scr_fov.value)
|
||||
CVAR_FIXME */
|
||||
if (oldfov != scr_fov->value)
|
||||
{
|
||||
/* oldfov = scr_fov.value;
|
||||
CVAR_FIXME */
|
||||
oldfov = scr_fov->value;
|
||||
vid.recalc_refdef = true;
|
||||
}
|
||||
|
@ -1185,6 +1258,8 @@ void SCR_UpdateScreen (void)
|
|||
//
|
||||
SCR_TileClear ();
|
||||
|
||||
/* if (r_netgraph.value)
|
||||
CVAR_FIXME */
|
||||
if (r_netgraph->value)
|
||||
R_NetGraph ();
|
||||
|
||||
|
@ -1211,6 +1286,8 @@ void SCR_UpdateScreen (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* if (crosshair.value)
|
||||
CVAR_FIXME */
|
||||
if (crosshair->value)
|
||||
Draw_Crosshair();
|
||||
|
||||
|
|
868
source/gl_vidlinux.c
Normal file
868
source/gl_vidlinux.c
Normal file
|
@ -0,0 +1,868 @@
|
|||
/*
|
||||
gl_vidlinux.c
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vt.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <asm/io.h>
|
||||
|
||||
#include "vga.h"
|
||||
#include "vgakeyboard.h"
|
||||
#include "vgamouse.h"
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "GL/fxmesa.h"
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
static fxMesaContext fc = NULL;
|
||||
#define stringify(m) { #m, m }
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
int num_shades=32;
|
||||
|
||||
struct
|
||||
{
|
||||
char *name;
|
||||
int num;
|
||||
} mice[] =
|
||||
{
|
||||
stringify(MOUSE_MICROSOFT),
|
||||
stringify(MOUSE_MOUSESYSTEMS),
|
||||
stringify(MOUSE_MMSERIES),
|
||||
stringify(MOUSE_LOGITECH),
|
||||
stringify(MOUSE_BUSMOUSE),
|
||||
stringify(MOUSE_PS2),
|
||||
};
|
||||
|
||||
static unsigned char scantokey[128];
|
||||
|
||||
int num_mice = sizeof (mice) / sizeof(mice[0]);
|
||||
|
||||
int d_con_indirect = 0;
|
||||
|
||||
int svgalib_inited=0;
|
||||
int UseMouse = 1;
|
||||
int UseKeyboard = 1;
|
||||
|
||||
int mouserate = MOUSE_DEFAULTSAMPLERATE;
|
||||
|
||||
/* cvar_t _windowed_mouse = {"_windowed_mouse","0", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_windowed_mouse;
|
||||
|
||||
/* cvar_t vid_mode = {"vid_mode","5",false};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_mode;
|
||||
/* cvar_t vid_redrawfull = {"vid_redrawfull","0",false};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_redrawfull;
|
||||
/* cvar_t vid_waitforrefresh = {"vid_waitforrefresh","0",true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_waitforrefresh;
|
||||
|
||||
char *framebuffer_ptr;
|
||||
|
||||
cvar_t mouse_button_commands[3] =
|
||||
{
|
||||
{"mouse1","+attack"},
|
||||
{"mouse2","+strafe"},
|
||||
{"mouse3","+forward"},
|
||||
};
|
||||
|
||||
int mouse_buttons;
|
||||
int mouse_buttonstate;
|
||||
int mouse_oldbuttonstate;
|
||||
float mouse_x, mouse_y;
|
||||
float old_mouse_x, old_mouse_y;
|
||||
int mx, my;
|
||||
|
||||
/* cvar_t m_filter = {"m_filter","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *m_filter;
|
||||
|
||||
int scr_width, scr_height;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//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;
|
||||
|
||||
/* cvar_t gl_ztrick = {"gl_ztrick","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_ztrick;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
qboolean is8bit = false;
|
||||
qboolean isPermedia = 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)
|
||||
{
|
||||
}
|
||||
|
||||
int matchmouse(int mouse, char *name)
|
||||
{
|
||||
int i;
|
||||
for (i=0 ; i<num_mice ; i++)
|
||||
if (!strcmp(mice[i].name, name))
|
||||
return i;
|
||||
return mouse;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
void vtswitch(int newconsole)
|
||||
{
|
||||
|
||||
int fd;
|
||||
struct vt_stat x;
|
||||
|
||||
// switch consoles and wait until reactivated
|
||||
fd = open("/dev/console", O_RDONLY);
|
||||
ioctl(fd, VT_GETSTATE, &x);
|
||||
ioctl(fd, VT_ACTIVATE, newconsole);
|
||||
ioctl(fd, VT_WAITACTIVE, x.v_active);
|
||||
close(fd);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void keyhandler(int scancode, int state)
|
||||
{
|
||||
|
||||
int sc;
|
||||
|
||||
sc = scancode & 0x7f;
|
||||
|
||||
Key_Event(scantokey[sc], state == KEY_EVENTPRESS);
|
||||
|
||||
}
|
||||
|
||||
void VID_Shutdown(void)
|
||||
{
|
||||
if (!fc)
|
||||
return;
|
||||
|
||||
fxMesaDestroyContext(fc);
|
||||
|
||||
if (UseKeyboard)
|
||||
keyboard_close();
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
Sys_Quit();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void InitSig(void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
signal(SIGILL, signal_handler);
|
||||
signal(SIGTRAP, signal_handler);
|
||||
signal(SIGIOT, signal_handler);
|
||||
signal(SIGBUS, signal_handler);
|
||||
signal(SIGFPE, signal_handler);
|
||||
signal(SIGSEGV, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
// VID_SetPalette(p);
|
||||
}
|
||||
|
||||
void VID_SetPalette (unsigned char *palette)
|
||||
{
|
||||
byte *pal;
|
||||
unsigned r,g,b;
|
||||
unsigned v;
|
||||
int r1,g1,b1;
|
||||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *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] &= 0xffffff; // 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) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(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 = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
|
||||
=================
|
||||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
/* extern cvar_t gl_clear;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *gl_clear;
|
||||
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
|
||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||
// Sys_Error ("wglMakeCurrent failed");
|
||||
|
||||
// glViewport (*x, *y, *width, *height);
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
{
|
||||
glFlush();
|
||||
fxMesaSwapBuffers();
|
||||
}
|
||||
|
||||
void Init_KBD(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
|
||||
|
||||
if (UseKeyboard)
|
||||
{
|
||||
for (i=0 ; i<128 ; i++)
|
||||
scantokey[i] = ' ';
|
||||
|
||||
scantokey[42] = K_SHIFT;
|
||||
scantokey[54] = K_SHIFT;
|
||||
scantokey[72] = K_UPARROW;
|
||||
scantokey[103] = K_UPARROW;
|
||||
scantokey[80] = K_DOWNARROW;
|
||||
scantokey[108] = K_DOWNARROW;
|
||||
scantokey[75] = K_LEFTARROW;
|
||||
scantokey[105] = K_LEFTARROW;
|
||||
scantokey[77] = K_RIGHTARROW;
|
||||
scantokey[106] = K_RIGHTARROW;
|
||||
scantokey[29] = K_CTRL;
|
||||
scantokey[97] = K_CTRL;
|
||||
scantokey[56] = K_ALT;
|
||||
scantokey[100] = K_ALT;
|
||||
// scantokey[58] = JK_CAPS;
|
||||
// scantokey[69] = JK_NUM_LOCK;
|
||||
scantokey[71] = K_HOME;
|
||||
scantokey[73] = K_PGUP;
|
||||
scantokey[79] = K_END;
|
||||
scantokey[81] = K_PGDN;
|
||||
scantokey[82] = K_INS;
|
||||
scantokey[83] = K_DEL;
|
||||
scantokey[1 ] = K_ESCAPE;
|
||||
scantokey[28] = K_ENTER;
|
||||
scantokey[15] = K_TAB;
|
||||
scantokey[14] = K_BACKSPACE;
|
||||
scantokey[119] = K_PAUSE;
|
||||
scantokey[57] = ' ';
|
||||
|
||||
scantokey[102] = K_HOME;
|
||||
scantokey[104] = K_PGUP;
|
||||
scantokey[107] = K_END;
|
||||
scantokey[109] = K_PGDN;
|
||||
scantokey[110] = K_INS;
|
||||
scantokey[111] = K_DEL;
|
||||
|
||||
scantokey[2] = '1';
|
||||
scantokey[3] = '2';
|
||||
scantokey[4] = '3';
|
||||
scantokey[5] = '4';
|
||||
scantokey[6] = '5';
|
||||
scantokey[7] = '6';
|
||||
scantokey[8] = '7';
|
||||
scantokey[9] = '8';
|
||||
scantokey[10] = '9';
|
||||
scantokey[11] = '0';
|
||||
scantokey[12] = '-';
|
||||
scantokey[13] = '=';
|
||||
scantokey[41] = '`';
|
||||
scantokey[26] = '[';
|
||||
scantokey[27] = ']';
|
||||
scantokey[39] = ';';
|
||||
scantokey[40] = '\'';
|
||||
scantokey[51] = ',';
|
||||
scantokey[52] = '.';
|
||||
scantokey[53] = '/';
|
||||
scantokey[43] = '\\';
|
||||
|
||||
scantokey[59] = K_F1;
|
||||
scantokey[60] = K_F2;
|
||||
scantokey[61] = K_F3;
|
||||
scantokey[62] = K_F4;
|
||||
scantokey[63] = K_F5;
|
||||
scantokey[64] = K_F6;
|
||||
scantokey[65] = K_F7;
|
||||
scantokey[66] = K_F8;
|
||||
scantokey[67] = K_F9;
|
||||
scantokey[68] = K_F10;
|
||||
scantokey[87] = K_F11;
|
||||
scantokey[88] = K_F12;
|
||||
scantokey[30] = 'a';
|
||||
scantokey[48] = 'b';
|
||||
scantokey[46] = 'c';
|
||||
scantokey[32] = 'd';
|
||||
scantokey[18] = 'e';
|
||||
scantokey[33] = 'f';
|
||||
scantokey[34] = 'g';
|
||||
scantokey[35] = 'h';
|
||||
scantokey[23] = 'i';
|
||||
scantokey[36] = 'j';
|
||||
scantokey[37] = 'k';
|
||||
scantokey[38] = 'l';
|
||||
scantokey[50] = 'm';
|
||||
scantokey[49] = 'n';
|
||||
scantokey[24] = 'o';
|
||||
scantokey[25] = 'p';
|
||||
scantokey[16] = 'q';
|
||||
scantokey[19] = 'r';
|
||||
scantokey[31] = 's';
|
||||
scantokey[20] = 't';
|
||||
scantokey[22] = 'u';
|
||||
scantokey[47] = 'v';
|
||||
scantokey[17] = 'w';
|
||||
scantokey[45] = 'x';
|
||||
scantokey[21] = 'y';
|
||||
scantokey[44] = 'z';
|
||||
|
||||
scantokey[78] = '+';
|
||||
scantokey[74] = '-';
|
||||
|
||||
if (keyboard_init())
|
||||
Sys_Error("keyboard_init() failed");
|
||||
keyboard_seteventhandler(keyhandler);
|
||||
}
|
||||
}
|
||||
|
||||
#define NUM_RESOLUTIONS 3
|
||||
|
||||
static resolutions[NUM_RESOLUTIONS][3]={
|
||||
{ 512, 384, GR_RESOLUTION_512x384 },
|
||||
{ 640, 400, GR_RESOLUTION_640x400 },
|
||||
{ 640, 480, GR_RESOLUTION_640x480 }
|
||||
};
|
||||
|
||||
int findres(int *width, int *height)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<NUM_RESOLUTIONS;i++)
|
||||
if((*width<=resolutions[i][0]) && (*height<=resolutions[i][1])) {
|
||||
*width = resolutions[i][0];
|
||||
*height = resolutions[i][1];
|
||||
return resolutions[i][2];
|
||||
}
|
||||
|
||||
*width = 640;
|
||||
*height = 480;
|
||||
return GR_RESOLUTION_640x480;
|
||||
}
|
||||
|
||||
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_SafePrintf("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
|
||||
extern void gl3DfxSetPaletteEXT(GLuint *pal);
|
||||
|
||||
void VID_Init8bitPalette(void)
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
GLubyte table[256][4];
|
||||
char *oldpal;
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette") == NULL)
|
||||
return;
|
||||
|
||||
Con_SafePrintf("8-bit GL extensions enabled.\n");
|
||||
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++;
|
||||
}
|
||||
gl3DfxSetPaletteEXT((GLuint *)table);
|
||||
is8bit = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
GLint attribs[32];
|
||||
char gldir[MAX_OSPATH];
|
||||
int width = 640, height = 480;
|
||||
|
||||
// S_Init();
|
||||
|
||||
Init_KBD();
|
||||
|
||||
/* Cvar_RegisterVariable (&vid_mode);
|
||||
CVAR_FIXME */
|
||||
vid_mode = Cvar_Get("vid_mode", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_redrawfull);
|
||||
CVAR_FIXME */
|
||||
vid_redrawfull = Cvar_Get("vid_redrawfull", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_waitforrefresh);
|
||||
CVAR_FIXME */
|
||||
vid_waitforrefresh = Cvar_Get("vid_waitforrefresh", "0", CVAR_NONE|CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_ztrick);
|
||||
CVAR_FIXME */
|
||||
gl_ztrick = Cvar_Get("gl_ztrick", "1", CVAR_NONE, "None");
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
vid.colormap = host_colormap;
|
||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||
|
||||
// interpret command-line params
|
||||
|
||||
// set vid parameters
|
||||
attribs[0] = FXMESA_DOUBLEBUFFER;
|
||||
attribs[1] = FXMESA_ALPHA_SIZE;
|
||||
attribs[2] = 1;
|
||||
attribs[3] = FXMESA_DEPTH_SIZE;
|
||||
attribs[4] = 1;
|
||||
attribs[5] = FXMESA_NONE;
|
||||
|
||||
if ((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i+1]);
|
||||
if ((i = COM_CheckParm("-height")) != 0)
|
||||
height = atoi(com_argv[i+1]);
|
||||
|
||||
if ((i = COM_CheckParm("-conwidth")) != 0)
|
||||
vid.conwidth = atoi(com_argv[i+1]);
|
||||
else
|
||||
vid.conwidth = 640;
|
||||
|
||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||
|
||||
if (vid.conwidth < 320)
|
||||
vid.conwidth = 320;
|
||||
|
||||
// pick a conheight that matches with correct aspect
|
||||
vid.conheight = vid.conwidth*3 / 4;
|
||||
|
||||
if ((i = COM_CheckParm("-conheight")) != 0)
|
||||
vid.conheight = atoi(com_argv[i+1]);
|
||||
if (vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
|
||||
fc = fxMesaCreateContext(0, findres(&width, &height), GR_REFRESH_75Hz,
|
||||
attribs);
|
||||
if (!fc)
|
||||
Sys_Error("Unable to create 3DFX context.\n");
|
||||
|
||||
scr_width = width;
|
||||
scr_height = height;
|
||||
|
||||
fxMesaMakeCurrent(fc);
|
||||
|
||||
if (vid.conheight > height)
|
||||
vid.conheight = height;
|
||||
if (vid.conwidth > width)
|
||||
vid.conwidth = width;
|
||||
vid.width = vid.conwidth;
|
||||
vid.height = vid.conheight;
|
||||
|
||||
vid.aspect = ((float)vid.height / (float)vid.width) *
|
||||
(320.0 / 240.0);
|
||||
vid.numpages = 2;
|
||||
|
||||
InitSig(); // trap evil signals
|
||||
|
||||
GL_Init();
|
||||
|
||||
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
|
||||
VID_SetPalette(palette);
|
||||
|
||||
// Check for 3DFX Extensions and initialize them.
|
||||
VID_Init8bitPalette();
|
||||
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
if (UseKeyboard)
|
||||
while (keyboard_update());
|
||||
}
|
||||
|
||||
void Force_CenterView_f (void)
|
||||
{
|
||||
cl.viewangles[PITCH] = 0;
|
||||
}
|
||||
|
||||
|
||||
void mousehandler(int buttonstate, int dx, int dy)
|
||||
{
|
||||
mouse_buttonstate = buttonstate;
|
||||
mx += dx;
|
||||
my += dy;
|
||||
}
|
||||
|
||||
void IN_Init(void)
|
||||
{
|
||||
|
||||
int mtype;
|
||||
char *mousedev;
|
||||
int mouserate;
|
||||
|
||||
if (UseMouse)
|
||||
{
|
||||
|
||||
Cvar_RegisterVariable (&mouse_button_commands[0]);
|
||||
Cvar_RegisterVariable (&mouse_button_commands[1]);
|
||||
Cvar_RegisterVariable (&mouse_button_commands[2]);
|
||||
Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
||||
|
||||
mouse_buttons = 3;
|
||||
|
||||
mtype = vga_getmousetype();
|
||||
|
||||
mousedev = "/dev/mouse";
|
||||
if (getenv("MOUSEDEV")) mousedev = getenv("MOUSEDEV");
|
||||
if (COM_CheckParm("-mdev"))
|
||||
mousedev = com_argv[COM_CheckParm("-mdev")+1];
|
||||
|
||||
mouserate = 1200;
|
||||
if (getenv("MOUSERATE")) mouserate = atoi(getenv("MOUSERATE"));
|
||||
if (COM_CheckParm("-mrate"))
|
||||
mouserate = atoi(com_argv[COM_CheckParm("-mrate")+1]);
|
||||
|
||||
if (mouse_init(mousedev, mtype, mouserate))
|
||||
{
|
||||
Con_Printf("No mouse found\n");
|
||||
UseMouse = 0;
|
||||
}
|
||||
else
|
||||
mouse_seteventhandler(mousehandler);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void IN_Shutdown(void)
|
||||
{
|
||||
if (UseMouse)
|
||||
mouse_close();
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Commands
|
||||
===========
|
||||
*/
|
||||
void IN_Commands (void)
|
||||
{
|
||||
if (UseMouse)
|
||||
{
|
||||
// poll mouse values
|
||||
while (mouse_update())
|
||||
;
|
||||
|
||||
// perform button actions
|
||||
if ((mouse_buttonstate & MOUSE_LEFTBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
|
||||
Key_Event (K_MOUSE1, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_LEFTBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
|
||||
Key_Event (K_MOUSE1, false);
|
||||
|
||||
if ((mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
|
||||
Key_Event (K_MOUSE2, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
|
||||
Key_Event (K_MOUSE2, false);
|
||||
|
||||
if ((mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
|
||||
Key_Event (K_MOUSE3, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
|
||||
Key_Event (K_MOUSE3, false);
|
||||
|
||||
mouse_oldbuttonstate = mouse_buttonstate;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void IN_MouseMove (usercmd_t *cmd)
|
||||
{
|
||||
if (!UseMouse)
|
||||
return;
|
||||
|
||||
// poll mouse values
|
||||
while (mouse_update())
|
||||
;
|
||||
|
||||
/* if (m_filter.value)
|
||||
CVAR_FIXME */
|
||||
if (m_filter->value)
|
||||
{
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouse_x = mx;
|
||||
mouse_y = my;
|
||||
}
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
mx = my = 0; // clear for next update
|
||||
|
||||
/* mouse_x *= sensitivity.value;
|
||||
CVAR_FIXME */
|
||||
mouse_x *= sensitivity->value;
|
||||
/* mouse_y *= sensitivity.value;
|
||||
CVAR_FIXME */
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
/* if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||
CVAR_FIXME */
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
/* cmd->sidemove += m_side.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
/* cl.viewangles[YAW] -= m_yaw.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
{
|
||||
/* cl.viewangles[PITCH] += m_pitch.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (cl.viewangles[PITCH] > 80)
|
||||
cl.viewangles[PITCH] = 80;
|
||||
if (cl.viewangles[PITCH] < -70)
|
||||
cl.viewangles[PITCH] = -70;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
/* cmd->upmove -= m_forward.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cmd->upmove -= m_forward->value * mouse_y;
|
||||
else
|
||||
/* cmd->forwardmove -= m_forward.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
}
|
||||
|
||||
void IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
IN_MouseMove(cmd);
|
||||
}
|
||||
|
||||
void VID_UnlockBuffer() {}
|
||||
void VID_LockBuffer() {}
|
||||
|
907
source/gl_vidlinux_svga.c
Normal file
907
source/gl_vidlinux_svga.c
Normal file
|
@ -0,0 +1,907 @@
|
|||
/*
|
||||
gl_vidlinux_svga.c
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vt.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <asm/io.h>
|
||||
|
||||
/*#include "vga.h" */
|
||||
#include "vgakeyboard.h"
|
||||
#include "vgamouse.h"
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "GL/fxmesa.h"
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
static fxMesaContext fc = NULL;
|
||||
#define stringify(m) { #m, m }
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
int num_shades=32;
|
||||
|
||||
struct
|
||||
{
|
||||
char *name;
|
||||
int num;
|
||||
} mice[] =
|
||||
{
|
||||
stringify(MOUSE_MICROSOFT),
|
||||
stringify(MOUSE_MOUSESYSTEMS),
|
||||
stringify(MOUSE_MMSERIES),
|
||||
stringify(MOUSE_LOGITECH),
|
||||
stringify(MOUSE_BUSMOUSE),
|
||||
stringify(MOUSE_PS2),
|
||||
};
|
||||
|
||||
static unsigned char scantokey[128];
|
||||
|
||||
int num_mice = sizeof (mice) / sizeof(mice[0]);
|
||||
|
||||
int d_con_indirect = 0;
|
||||
|
||||
int svgalib_inited=0;
|
||||
int UseMouse = 1;
|
||||
int UseKeyboard = 1;
|
||||
|
||||
int mouserate = MOUSE_DEFAULTSAMPLERATE;
|
||||
|
||||
/* cvar_t vid_mode = {"vid_mode","5",false};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_mode;
|
||||
/* cvar_t vid_redrawfull = {"vid_redrawfull","0",false};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_redrawfull;
|
||||
/* cvar_t vid_waitforrefresh = {"vid_waitforrefresh","0",true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_waitforrefresh;
|
||||
|
||||
char *framebuffer_ptr;
|
||||
|
||||
cvar_t mouse_button_commands[3] =
|
||||
{
|
||||
{"mouse1","+attack"},
|
||||
{"mouse2","+strafe"},
|
||||
{"mouse3","+forward"},
|
||||
};
|
||||
|
||||
int mouse_buttons;
|
||||
int mouse_buttonstate;
|
||||
int mouse_oldbuttonstate;
|
||||
float mouse_x, mouse_y;
|
||||
float old_mouse_x, old_mouse_y;
|
||||
int mx, my;
|
||||
|
||||
/* cvar_t _windowed_mouse = {"_windowed_mouse", "1", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_windowed_mouse;
|
||||
/* cvar_t m_filter = {"m_filter","0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *m_filter;
|
||||
|
||||
int scr_width, scr_height;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//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;
|
||||
|
||||
/* cvar_t gl_ztrick = {"gl_ztrick","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_ztrick;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
qboolean is8bit = false;
|
||||
qboolean isPermedia = 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)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VID_Gamma_f
|
||||
|
||||
Keybinding command
|
||||
=================
|
||||
*/
|
||||
void VID_Gamma_f (void)
|
||||
{
|
||||
float gamma, f, inf;
|
||||
unsigned char palette[768];
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc () == 2)
|
||||
{
|
||||
gamma = atof (Cmd_Argv(1));
|
||||
|
||||
for (i=0 ; i<768 ; i++)
|
||||
{
|
||||
f = pow ( (host_basepal[i]+1)/256.0 , gamma );
|
||||
inf = f*255 + 0.5;
|
||||
if (inf < 0)
|
||||
inf = 0;
|
||||
if (inf > 255)
|
||||
inf = 255;
|
||||
palette[i] = inf;
|
||||
}
|
||||
|
||||
VID_SetPalette (palette);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
}
|
||||
|
||||
int matchmouse(int mouse, char *name)
|
||||
{
|
||||
int i;
|
||||
for (i=0 ; i<num_mice ; i++)
|
||||
if (!strcmp(mice[i].name, name))
|
||||
return i;
|
||||
return mouse;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
void vtswitch(int newconsole)
|
||||
{
|
||||
|
||||
int fd;
|
||||
struct vt_stat x;
|
||||
|
||||
// switch consoles and wait until reactivated
|
||||
fd = open("/dev/console", O_RDONLY);
|
||||
ioctl(fd, VT_GETSTATE, &x);
|
||||
ioctl(fd, VT_ACTIVATE, newconsole);
|
||||
ioctl(fd, VT_WAITACTIVE, x.v_active);
|
||||
close(fd);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void keyhandler(int scancode, int state)
|
||||
{
|
||||
|
||||
int sc;
|
||||
|
||||
sc = scancode & 0x7f;
|
||||
// Con_Printf("scancode=%x (%d%s)\n", scancode, sc, scancode&0x80?"+128":"");
|
||||
Key_Event(scantokey[sc], state == KEY_EVENTPRESS);
|
||||
|
||||
}
|
||||
|
||||
void VID_Shutdown(void)
|
||||
{
|
||||
if (!fc)
|
||||
return;
|
||||
|
||||
fxMesaDestroyContext(fc);
|
||||
|
||||
if (UseKeyboard)
|
||||
keyboard_close();
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
VID_Shutdown();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void InitSig(void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
signal(SIGILL, signal_handler);
|
||||
signal(SIGTRAP, signal_handler);
|
||||
signal(SIGIOT, signal_handler);
|
||||
signal(SIGBUS, signal_handler);
|
||||
signal(SIGFPE, signal_handler);
|
||||
signal(SIGSEGV, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
VID_SetPalette(p);
|
||||
}
|
||||
|
||||
void VID_SetPalette (unsigned char *palette)
|
||||
{
|
||||
byte *pal;
|
||||
unsigned short r,g,b;
|
||||
int v;
|
||||
int r1,g1,b1;
|
||||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
char s[255];
|
||||
float dist, bestdist;
|
||||
static qboolean palflag = false;
|
||||
|
||||
//
|
||||
// 8 8 8 encoding
|
||||
//
|
||||
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] &= 0xffffff; // 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) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(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 = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
|
||||
=================
|
||||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
/* extern cvar_t gl_clear;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *gl_clear;
|
||||
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
|
||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||
// Sys_Error ("wglMakeCurrent failed");
|
||||
|
||||
// glViewport (*x, *y, *width, *height);
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
{
|
||||
glFlush();
|
||||
fxMesaSwapBuffers();
|
||||
}
|
||||
|
||||
void Init_KBD(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
|
||||
|
||||
if (UseKeyboard)
|
||||
{
|
||||
for (i=0 ; i<128 ; i++)
|
||||
scantokey[i] = ' ';
|
||||
|
||||
scantokey[ 1] = K_ESCAPE;
|
||||
scantokey[ 2] = '1';
|
||||
scantokey[ 3] = '2';
|
||||
scantokey[ 4] = '3';
|
||||
scantokey[ 5] = '4';
|
||||
scantokey[ 6] = '5';
|
||||
scantokey[ 7] = '6';
|
||||
scantokey[ 8] = '7';
|
||||
scantokey[ 9] = '8';
|
||||
scantokey[ 10] = '9';
|
||||
scantokey[ 11] = '0';
|
||||
scantokey[ 12] = '-';
|
||||
scantokey[ 13] = '=';
|
||||
scantokey[ 14] = K_BACKSPACE;
|
||||
scantokey[ 15] = K_TAB;
|
||||
scantokey[ 16] = 'q';
|
||||
scantokey[ 17] = 'w';
|
||||
scantokey[ 18] = 'e';
|
||||
scantokey[ 19] = 'r';
|
||||
scantokey[ 20] = 't';
|
||||
scantokey[ 21] = 'y';
|
||||
scantokey[ 22] = 'u';
|
||||
scantokey[ 23] = 'i';
|
||||
scantokey[ 24] = 'o';
|
||||
scantokey[ 25] = 'p';
|
||||
scantokey[ 26] = '[';
|
||||
scantokey[ 27] = ']';
|
||||
scantokey[ 28] = K_ENTER;
|
||||
scantokey[ 29] = K_CTRL; //left
|
||||
scantokey[ 30] = 'a';
|
||||
scantokey[ 31] = 's';
|
||||
scantokey[ 32] = 'd';
|
||||
scantokey[ 33] = 'f';
|
||||
scantokey[ 34] = 'g';
|
||||
scantokey[ 35] = 'h';
|
||||
scantokey[ 36] = 'j';
|
||||
scantokey[ 37] = 'k';
|
||||
scantokey[ 38] = 'l';
|
||||
scantokey[ 39] = ';';
|
||||
scantokey[ 40] = '\'';
|
||||
scantokey[ 41] = '`';
|
||||
scantokey[ 42] = K_SHIFT; //left
|
||||
scantokey[ 43] = '\\';
|
||||
scantokey[ 44] = 'z';
|
||||
scantokey[ 45] = 'x';
|
||||
scantokey[ 46] = 'c';
|
||||
scantokey[ 47] = 'v';
|
||||
scantokey[ 48] = 'b';
|
||||
scantokey[ 49] = 'n';
|
||||
scantokey[ 50] = 'm';
|
||||
scantokey[ 51] = ',';
|
||||
scantokey[ 52] = '.';
|
||||
scantokey[ 53] = '/';
|
||||
scantokey[ 54] = K_SHIFT; //right
|
||||
scantokey[ 55] = '*'; //keypad
|
||||
scantokey[ 56] = K_ALT; //left
|
||||
scantokey[ 57] = ' ';
|
||||
// 58 caps lock
|
||||
scantokey[ 59] = K_F1;
|
||||
scantokey[ 60] = K_F2;
|
||||
scantokey[ 61] = K_F3;
|
||||
scantokey[ 62] = K_F4;
|
||||
scantokey[ 63] = K_F5;
|
||||
scantokey[ 64] = K_F6;
|
||||
scantokey[ 65] = K_F7;
|
||||
scantokey[ 66] = K_F8;
|
||||
scantokey[ 67] = K_F9;
|
||||
scantokey[ 68] = K_F10;
|
||||
// 69 numlock
|
||||
// 70 scrollock
|
||||
scantokey[ 71] = K_HOME;
|
||||
scantokey[ 72] = K_UPARROW;
|
||||
scantokey[ 73] = K_PGUP;
|
||||
scantokey[ 74] = '-';
|
||||
scantokey[ 75] = K_LEFTARROW;
|
||||
scantokey[ 76] = '5';
|
||||
scantokey[ 77] = K_RIGHTARROW;
|
||||
scantokey[ 79] = K_END;
|
||||
scantokey[ 78] = '+';
|
||||
scantokey[ 80] = K_DOWNARROW;
|
||||
scantokey[ 81] = K_PGDN;
|
||||
scantokey[ 82] = K_INS;
|
||||
scantokey[ 83] = K_DEL;
|
||||
// 84 to 86 not used
|
||||
scantokey[ 87] = K_F11;
|
||||
scantokey[ 88] = K_F12;
|
||||
// 89 to 95 not used
|
||||
scantokey[ 96] = K_ENTER; //keypad enter
|
||||
scantokey[ 97] = K_CTRL; //right
|
||||
scantokey[ 98] = '/';
|
||||
scantokey[ 99] = K_F12; // print screen, bind to screenshot by default
|
||||
scantokey[100] = K_ALT; // right
|
||||
|
||||
|
||||
scantokey[101] = K_PAUSE; // break
|
||||
scantokey[102] = K_HOME;
|
||||
scantokey[103] = K_UPARROW;
|
||||
scantokey[104] = K_PGUP;
|
||||
scantokey[105] = K_LEFTARROW;
|
||||
scantokey[106] = K_RIGHTARROW;
|
||||
scantokey[107] = K_END;
|
||||
scantokey[108] = K_DOWNARROW;
|
||||
scantokey[109] = K_PGDN;
|
||||
scantokey[110] = K_INS;
|
||||
scantokey[111] = K_DEL;
|
||||
|
||||
scantokey[119] = K_PAUSE;
|
||||
|
||||
if (keyboard_init())
|
||||
Sys_Error("keyboard_init() failed");
|
||||
keyboard_seteventhandler(keyhandler);
|
||||
}
|
||||
}
|
||||
|
||||
#define NUM_RESOLUTIONS 3
|
||||
|
||||
static resolutions[NUM_RESOLUTIONS][3]={
|
||||
{ 512, 384, GR_RESOLUTION_512x384 },
|
||||
{ 640, 400, GR_RESOLUTION_640x400 },
|
||||
{ 640, 480, GR_RESOLUTION_640x480 }
|
||||
};
|
||||
|
||||
int findres(int *width, int *height)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<NUM_RESOLUTIONS;i++)
|
||||
if((*width<=resolutions[i][0]) && (*height<=resolutions[i][1])) {
|
||||
*width = resolutions[i][0];
|
||||
*height = resolutions[i][1];
|
||||
return resolutions[i][2];
|
||||
}
|
||||
|
||||
*width = 640;
|
||||
*height = 480;
|
||||
return GR_RESOLUTION_640x480;
|
||||
}
|
||||
|
||||
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_SafePrintf("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
|
||||
extern void gl3DfxSetPaletteEXT(GLuint *pal);
|
||||
|
||||
void VID_Init8bitPalette(void)
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
GLubyte table[256][4];
|
||||
char *oldpal;
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette") == NULL)
|
||||
return;
|
||||
|
||||
Con_SafePrintf("8-bit GL extensions enabled.\n");
|
||||
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++;
|
||||
}
|
||||
gl3DfxSetPaletteEXT((GLuint *)table);
|
||||
is8bit = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
GLint attribs[32];
|
||||
char gldir[MAX_OSPATH];
|
||||
int width = 640, height = 480;
|
||||
|
||||
// S_Init();
|
||||
|
||||
Init_KBD();
|
||||
|
||||
/* Cvar_RegisterVariable (&vid_mode);
|
||||
CVAR_FIXME */
|
||||
vid_mode = Cvar_Get("vid_mode", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_redrawfull);
|
||||
CVAR_FIXME */
|
||||
vid_redrawfull = Cvar_Get("vid_redrawfull", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_waitforrefresh);
|
||||
CVAR_FIXME */
|
||||
vid_waitforrefresh = Cvar_Get("vid_waitforrefresh", "0", CVAR_NONE|CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_ztrick);
|
||||
CVAR_FIXME */
|
||||
gl_ztrick = Cvar_Get("gl_ztrick", "1", CVAR_NONE, "None");
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
vid.colormap = host_colormap;
|
||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||
|
||||
// interpret command-line params
|
||||
|
||||
// set vid parameters
|
||||
attribs[0] = FXMESA_DOUBLEBUFFER;
|
||||
attribs[1] = FXMESA_ALPHA_SIZE;
|
||||
attribs[2] = 1;
|
||||
attribs[3] = FXMESA_DEPTH_SIZE;
|
||||
attribs[4] = 1;
|
||||
attribs[5] = FXMESA_NONE;
|
||||
|
||||
if ((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i+1]);
|
||||
if ((i = COM_CheckParm("-height")) != 0)
|
||||
height = atoi(com_argv[i+1]);
|
||||
|
||||
if ((i = COM_CheckParm("-conwidth")) != 0)
|
||||
vid.conwidth = atoi(com_argv[i+1]);
|
||||
else
|
||||
vid.conwidth = 640;
|
||||
|
||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||
|
||||
if (vid.conwidth < 320)
|
||||
vid.conwidth = 320;
|
||||
|
||||
// pick a conheight that matches with correct aspect
|
||||
vid.conheight = vid.conwidth*3 / 4;
|
||||
|
||||
if ((i = COM_CheckParm("-conheight")) != 0)
|
||||
vid.conheight = atoi(com_argv[i+1]);
|
||||
if (vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
|
||||
fc = fxMesaCreateContext(0, findres(&width, &height), GR_REFRESH_75Hz,
|
||||
attribs);
|
||||
if (!fc)
|
||||
Sys_Error("Unable to create 3DFX context.\n");
|
||||
|
||||
scr_width = width;
|
||||
scr_height = height;
|
||||
|
||||
fxMesaMakeCurrent(fc);
|
||||
|
||||
if (vid.conheight > height)
|
||||
vid.conheight = height;
|
||||
if (vid.conwidth > width)
|
||||
vid.conwidth = width;
|
||||
vid.width = vid.conwidth;
|
||||
vid.height = vid.conheight;
|
||||
|
||||
vid.aspect = ((float)vid.height / (float)vid.width) *
|
||||
(320.0 / 240.0);
|
||||
vid.numpages = 2;
|
||||
|
||||
InitSig(); // trap evil signals
|
||||
|
||||
GL_Init();
|
||||
|
||||
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
|
||||
VID_SetPalette(palette);
|
||||
|
||||
// Check for 3DFX Extensions and initialize them.
|
||||
VID_Init8bitPalette();
|
||||
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
if (UseKeyboard)
|
||||
while (keyboard_update());
|
||||
}
|
||||
|
||||
void Force_CenterView_f (void)
|
||||
{
|
||||
cl.viewangles[PITCH] = 0;
|
||||
}
|
||||
|
||||
|
||||
void mousehandler(int buttonstate, int dx, int dy)
|
||||
{
|
||||
mouse_buttonstate = buttonstate;
|
||||
mx += dx;
|
||||
my += dy;
|
||||
}
|
||||
|
||||
void IN_Init(void)
|
||||
{
|
||||
|
||||
int mtype;
|
||||
char *mousedev;
|
||||
int mouserate;
|
||||
|
||||
if (UseMouse)
|
||||
{
|
||||
|
||||
Cvar_RegisterVariable (&mouse_button_commands[0]);
|
||||
Cvar_RegisterVariable (&mouse_button_commands[1]);
|
||||
Cvar_RegisterVariable (&mouse_button_commands[2]);
|
||||
Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
||||
|
||||
mouse_buttons = 3;
|
||||
|
||||
mtype = vga_getmousetype();
|
||||
|
||||
mousedev = "/dev/mouse";
|
||||
if (getenv("MOUSEDEV")) mousedev = getenv("MOUSEDEV");
|
||||
if (COM_CheckParm("-mdev"))
|
||||
mousedev = com_argv[COM_CheckParm("-mdev")+1];
|
||||
|
||||
mouserate = 1200;
|
||||
if (getenv("MOUSERATE")) mouserate = atoi(getenv("MOUSERATE"));
|
||||
if (COM_CheckParm("-mrate"))
|
||||
mouserate = atoi(com_argv[COM_CheckParm("-mrate")+1]);
|
||||
|
||||
if (mouse_init(mousedev, mtype, mouserate))
|
||||
{
|
||||
Con_Printf("No mouse found\n");
|
||||
UseMouse = 0;
|
||||
}
|
||||
else
|
||||
mouse_seteventhandler(mousehandler);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void IN_Shutdown(void)
|
||||
{
|
||||
if (UseMouse)
|
||||
mouse_close();
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Commands
|
||||
===========
|
||||
*/
|
||||
void IN_Commands (void)
|
||||
{
|
||||
if (UseMouse)
|
||||
{
|
||||
// poll mouse values
|
||||
while (mouse_update())
|
||||
;
|
||||
|
||||
// perform button actions
|
||||
if ((mouse_buttonstate & MOUSE_LEFTBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
|
||||
Key_Event (K_MOUSE1, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_LEFTBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
|
||||
Key_Event (K_MOUSE1, false);
|
||||
|
||||
if ((mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
|
||||
Key_Event (K_MOUSE2, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
|
||||
Key_Event (K_MOUSE2, false);
|
||||
|
||||
if ((mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
|
||||
Key_Event (K_MOUSE3, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
|
||||
Key_Event (K_MOUSE3, false);
|
||||
|
||||
mouse_oldbuttonstate = mouse_buttonstate;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void IN_MouseMove (usercmd_t *cmd)
|
||||
{
|
||||
if (!UseMouse)
|
||||
return;
|
||||
|
||||
// poll mouse values
|
||||
while (mouse_update())
|
||||
;
|
||||
|
||||
/* if (m_filter.value)
|
||||
CVAR_FIXME */
|
||||
if (m_filter->value)
|
||||
{
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouse_x = mx;
|
||||
mouse_y = my;
|
||||
}
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
mx = my = 0; // clear for next update
|
||||
|
||||
/* mouse_x *= sensitivity.value;
|
||||
CVAR_FIXME */
|
||||
mouse_x *= sensitivity->value;
|
||||
/* mouse_y *= sensitivity.value;
|
||||
CVAR_FIXME */
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
/* if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||
CVAR_FIXME */
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
/* cmd->sidemove += m_side.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
/* cl.viewangles[YAW] -= m_yaw.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
{
|
||||
/* cl.viewangles[PITCH] += m_pitch.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (cl.viewangles[PITCH] > 80)
|
||||
cl.viewangles[PITCH] = 80;
|
||||
if (cl.viewangles[PITCH] < -70)
|
||||
cl.viewangles[PITCH] = -70;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
/* cmd->upmove -= m_forward.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cmd->upmove -= m_forward->value * mouse_y;
|
||||
else
|
||||
/* cmd->forwardmove -= m_forward.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
}
|
||||
|
||||
void IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
IN_MouseMove(cmd);
|
||||
}
|
||||
|
||||
|
||||
void VID_LockBuffer (void) {}
|
||||
void VID_UnlockBuffer (void) {}
|
||||
|
926
source/gl_vidlinux_x11.c
Normal file
926
source/gl_vidlinux_x11.c
Normal file
|
@ -0,0 +1,926 @@
|
|||
/*
|
||||
gl_vidlinux_x11.c
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vt.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
//#include <X11/cursorfont.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GL/glx.h"
|
||||
|
||||
#include "quakedef.h"
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
static Display *dpy = NULL;
|
||||
static Window win;
|
||||
static GLXContext ctx = NULL;
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned int d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
static qboolean usedga = false;
|
||||
|
||||
#define stringify(m) { #m, m }
|
||||
|
||||
/* cvar_t vid_mode = {"vid_mode","0",false};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_mode;
|
||||
|
||||
cvar_t mouse_button_commands[3] =
|
||||
{
|
||||
{"mouse1","+attack"},
|
||||
{"mouse2","+strafe"},
|
||||
{"mouse3","+forward"},
|
||||
};
|
||||
|
||||
static int mouse_buttons=3;
|
||||
static int mouse_buttonstate;
|
||||
static int mouse_oldbuttonstate;
|
||||
static float mouse_x, mouse_y;
|
||||
static float p_mouse_x, p_mouse_y;
|
||||
static float old_mouse_x, old_mouse_y;
|
||||
|
||||
/* cvar_t _windowed_mouse = {"_windowed_mouse", "1", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_windowed_mouse;
|
||||
/* cvar_t m_filter = {"m_filter","0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *m_filter;
|
||||
static float old_windowed_mouse;
|
||||
|
||||
static int scr_width, scr_height;
|
||||
|
||||
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
|
||||
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
|
||||
PointerMotionMask | ButtonMotionMask)
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//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;
|
||||
|
||||
/* cvar_t gl_ztrick = {"gl_ztrick","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_ztrick;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
qboolean is8bit = false;
|
||||
qboolean isPermedia = 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)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VID_Gamma_f
|
||||
|
||||
Keybinding command
|
||||
=================
|
||||
*/
|
||||
void VID_Gamma_f (void)
|
||||
{
|
||||
float gamma, f, inf;
|
||||
unsigned char palette[768];
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc () == 2)
|
||||
{
|
||||
gamma = atof (Cmd_Argv(1));
|
||||
|
||||
for (i=0 ; i<768 ; i++)
|
||||
{
|
||||
f = pow ( (host_basepal[i]+1)/256.0 , gamma );
|
||||
inf = f*255 + 0.5;
|
||||
if (inf < 0)
|
||||
inf = 0;
|
||||
if (inf > 255)
|
||||
inf = 255;
|
||||
palette[i] = inf;
|
||||
}
|
||||
|
||||
VID_SetPalette (palette);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
}
|
||||
|
||||
void VID_Shutdown(void)
|
||||
{
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
XUngrabPointer(dpy,CurrentTime);
|
||||
XUngrabKeyboard(dpy,CurrentTime);
|
||||
|
||||
glXDestroyContext(dpy,ctx);
|
||||
|
||||
#ifdef USE_DGA
|
||||
if (usedga)
|
||||
XF86DGADirectVideo(dpy,DefaultScreen(dpy),0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int XLateKey(XKeyEvent *ev)
|
||||
{
|
||||
|
||||
int key;
|
||||
char buf[64];
|
||||
KeySym keysym;
|
||||
|
||||
key = 0;
|
||||
|
||||
XLookupString(ev, buf, sizeof buf, &keysym, 0);
|
||||
|
||||
switch(keysym)
|
||||
{
|
||||
case XK_KP_Page_Up:
|
||||
case XK_Page_Up: key = K_PGUP; break;
|
||||
|
||||
case XK_KP_Page_Down:
|
||||
case XK_Page_Down: key = K_PGDN; break;
|
||||
|
||||
case XK_KP_Home:
|
||||
case XK_Home: key = K_HOME; break;
|
||||
|
||||
case XK_KP_End:
|
||||
case XK_End: key = K_END; break;
|
||||
|
||||
case XK_KP_Left:
|
||||
case XK_Left: key = K_LEFTARROW; break;
|
||||
|
||||
case XK_KP_Right:
|
||||
case XK_Right: key = K_RIGHTARROW; break;
|
||||
|
||||
case XK_KP_Down:
|
||||
case XK_Down: key = K_DOWNARROW; break;
|
||||
|
||||
case XK_KP_Up:
|
||||
case XK_Up: key = K_UPARROW; break;
|
||||
|
||||
case XK_Escape: key = K_ESCAPE; break;
|
||||
|
||||
case XK_KP_Enter:
|
||||
case XK_Return: key = K_ENTER; break;
|
||||
|
||||
case XK_Tab: key = K_TAB; break;
|
||||
|
||||
case XK_F1: key = K_F1; break;
|
||||
|
||||
case XK_F2: key = K_F2; break;
|
||||
|
||||
case XK_F3: key = K_F3; break;
|
||||
|
||||
case XK_F4: key = K_F4; break;
|
||||
|
||||
case XK_F5: key = K_F5; break;
|
||||
|
||||
case XK_F6: key = K_F6; break;
|
||||
|
||||
case XK_F7: key = K_F7; break;
|
||||
|
||||
case XK_F8: key = K_F8; break;
|
||||
|
||||
case XK_F9: key = K_F9; break;
|
||||
|
||||
case XK_F10: key = K_F10; break;
|
||||
|
||||
case XK_F11: key = K_F11; break;
|
||||
|
||||
case XK_F12: key = K_F12; break;
|
||||
|
||||
case XK_BackSpace: key = K_BACKSPACE; break;
|
||||
|
||||
case XK_KP_Delete:
|
||||
case XK_Delete: key = K_DEL; break;
|
||||
|
||||
case XK_Pause: key = K_PAUSE; break;
|
||||
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R: key = K_SHIFT; break;
|
||||
|
||||
case XK_Execute:
|
||||
case XK_Control_L:
|
||||
case XK_Control_R: key = K_CTRL; break;
|
||||
|
||||
case XK_Alt_L:
|
||||
case XK_Meta_L:
|
||||
case XK_Alt_R:
|
||||
case XK_Meta_R: key = K_ALT; break;
|
||||
|
||||
case XK_KP_Begin: key = K_AUX30; break;
|
||||
|
||||
case XK_Insert:
|
||||
case XK_KP_Insert: key = K_INS; break;
|
||||
|
||||
case XK_KP_Multiply: key = '*'; break;
|
||||
case XK_KP_Add: key = '+'; break;
|
||||
case XK_KP_Subtract: key = '-'; break;
|
||||
case XK_KP_Divide: key = '/'; break;
|
||||
|
||||
#if 0
|
||||
case 0x021: key = '1';break;/* [!] */
|
||||
case 0x040: key = '2';break;/* [@] */
|
||||
case 0x023: key = '3';break;/* [#] */
|
||||
case 0x024: key = '4';break;/* [$] */
|
||||
case 0x025: key = '5';break;/* [%] */
|
||||
case 0x05e: key = '6';break;/* [^] */
|
||||
case 0x026: key = '7';break;/* [&] */
|
||||
case 0x02a: key = '8';break;/* [*] */
|
||||
case 0x028: key = '9';;break;/* [(] */
|
||||
case 0x029: key = '0';break;/* [)] */
|
||||
case 0x05f: key = '-';break;/* [_] */
|
||||
case 0x02b: key = '=';break;/* [+] */
|
||||
case 0x07c: key = '\'';break;/* [|] */
|
||||
case 0x07d: key = '[';break;/* [}] */
|
||||
case 0x07b: key = ']';break;/* [{] */
|
||||
case 0x022: key = '\'';break;/* ["] */
|
||||
case 0x03a: key = ';';break;/* [:] */
|
||||
case 0x03f: key = '/';break;/* [?] */
|
||||
case 0x03e: key = '.';break;/* [>] */
|
||||
case 0x03c: key = ',';break;/* [<] */
|
||||
#endif
|
||||
|
||||
default:
|
||||
key = *(unsigned char*)buf;
|
||||
if (key >= 'A' && key <= 'Z')
|
||||
key = key - 'A' + 'a';
|
||||
// fprintf(stdout, "case 0x0%x: key = ___;break;/* [%c] */\n", keysym);
|
||||
break;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
struct
|
||||
{
|
||||
int key;
|
||||
int down;
|
||||
} keyq[64];
|
||||
int keyq_head=0;
|
||||
int keyq_tail=0;
|
||||
|
||||
int config_notify=0;
|
||||
int config_notify_width;
|
||||
int config_notify_height;
|
||||
|
||||
qboolean Keyboard_Update(void)
|
||||
{
|
||||
XEvent x_event;
|
||||
|
||||
if(!XCheckMaskEvent(dpy,KEY_MASK,&x_event))
|
||||
return false;
|
||||
|
||||
switch(x_event.type) {
|
||||
case KeyPress:
|
||||
keyq[keyq_head].key = XLateKey(&x_event.xkey);
|
||||
keyq[keyq_head].down = true;
|
||||
keyq_head = (keyq_head + 1) & 63;
|
||||
break;
|
||||
case KeyRelease:
|
||||
keyq[keyq_head].key = XLateKey(&x_event.xkey);
|
||||
keyq[keyq_head].down = false;
|
||||
keyq_head = (keyq_head + 1) & 63;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean Mouse_Update(void)
|
||||
{
|
||||
XEvent x_event;
|
||||
int b;
|
||||
|
||||
if(!XCheckMaskEvent(dpy,MOUSE_MASK,&x_event))
|
||||
return false;
|
||||
|
||||
switch(x_event.type) {
|
||||
case MotionNotify:
|
||||
if (usedga) {
|
||||
mouse_x += x_event.xmotion.x_root;
|
||||
mouse_y += x_event.xmotion.y_root;
|
||||
/* } else if (_windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
} else if (_windowed_mouse->value) {
|
||||
mouse_x += (float) ((int)x_event.xmotion.x - (int)(scr_width/2));
|
||||
mouse_y += (float) ((int)x_event.xmotion.y - (int)(scr_height/2));
|
||||
|
||||
/* move the mouse to the window center again */
|
||||
XSelectInput(dpy,win, (KEY_MASK | MOUSE_MASK) & ~PointerMotionMask);
|
||||
XWarpPointer(dpy,None,win,0,0,0,0, (scr_width/2),(scr_height/2));
|
||||
XSelectInput(dpy,win, KEY_MASK | MOUSE_MASK);
|
||||
} else {
|
||||
mouse_x = (float) (x_event.xmotion.x-p_mouse_x);
|
||||
mouse_y = (float) (x_event.xmotion.y-p_mouse_y);
|
||||
p_mouse_x=x_event.xmotion.x;
|
||||
p_mouse_y=x_event.xmotion.y;
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
b=-1;
|
||||
if (x_event.xbutton.button == 1)
|
||||
b = 0;
|
||||
else if (x_event.xbutton.button == 2)
|
||||
b = 2;
|
||||
else if (x_event.xbutton.button == 3)
|
||||
b = 1;
|
||||
if (b>=0)
|
||||
mouse_buttonstate |= 1<<b;
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
b=-1;
|
||||
if (x_event.xbutton.button == 1)
|
||||
b = 0;
|
||||
else if (x_event.xbutton.button == 2)
|
||||
b = 2;
|
||||
else if (x_event.xbutton.button == 3)
|
||||
b = 1;
|
||||
if (b>=0)
|
||||
mouse_buttonstate &= ~(1<<b);
|
||||
break;
|
||||
}
|
||||
|
||||
/* if (old_windowed_mouse != _windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (old_windowed_mouse != _windowed_mouse->value) {
|
||||
/* old_windowed_mouse = _windowed_mouse.value;
|
||||
CVAR_FIXME */
|
||||
old_windowed_mouse = _windowed_mouse->value;
|
||||
|
||||
/* if (!_windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (!_windowed_mouse->value) {
|
||||
/* ungrab the pointer */
|
||||
Con_Printf("Releasing mouse.\n");
|
||||
|
||||
XUngrabPointer(dpy,CurrentTime);
|
||||
XUngrabKeyboard(dpy,CurrentTime);
|
||||
} else {
|
||||
/* grab the pointer */
|
||||
Con_Printf("Grabbing mouse.\n");
|
||||
|
||||
XGrabPointer(dpy,win,False,MOUSE_MASK,GrabModeAsync,
|
||||
GrabModeAsync,win,None,CurrentTime);
|
||||
XWarpPointer(dpy,None,win, 0,0,0,0, scr_width/2, scr_height/2);
|
||||
XGrabKeyboard(dpy,win,
|
||||
False,
|
||||
GrabModeAsync,GrabModeAsync,
|
||||
CurrentTime);
|
||||
|
||||
//XSync(dpy,True);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
VID_Shutdown();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void InitSig(void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
signal(SIGILL, signal_handler);
|
||||
signal(SIGTRAP, signal_handler);
|
||||
signal(SIGIOT, signal_handler);
|
||||
signal(SIGBUS, signal_handler);
|
||||
signal(SIGFPE, signal_handler);
|
||||
signal(SIGSEGV, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
VID_SetPalette(p);
|
||||
}
|
||||
|
||||
void VID_SetPalette (unsigned char *palette)
|
||||
{
|
||||
byte *pal;
|
||||
unsigned short r,g,b;
|
||||
int v;
|
||||
int r1,g1,b1;
|
||||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
char s[255];
|
||||
float dist, bestdist;
|
||||
static qboolean palflag = false;
|
||||
|
||||
//
|
||||
// 8 8 8 encoding
|
||||
//
|
||||
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] &= 0xffffff; // 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) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(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 = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
|
||||
=================
|
||||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
/* extern cvar_t gl_clear;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *gl_clear;
|
||||
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
|
||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||
// Sys_Error ("wglMakeCurrent failed");
|
||||
|
||||
// glViewport (*x, *y, *width, *height);
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
{
|
||||
glFlush();
|
||||
glXSwapBuffers(dpy,win);
|
||||
}
|
||||
|
||||
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_SafePrintf("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
|
||||
extern void gl3DfxSetPaletteEXT(GLuint *pal);
|
||||
|
||||
void VID_Init8bitPalette(void)
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
GLubyte table[256][4];
|
||||
char *oldpal;
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette") == NULL)
|
||||
return;
|
||||
|
||||
Con_SafePrintf("8-bit GL extensions enabled.\n");
|
||||
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++;
|
||||
}
|
||||
gl3DfxSetPaletteEXT((GLuint *)table);
|
||||
is8bit = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
char gldir[MAX_OSPATH];
|
||||
int width = 640, height = 480;
|
||||
int attrib[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
None };
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
XVisualInfo *visinfo;
|
||||
|
||||
// S_Init();
|
||||
|
||||
/* Cvar_RegisterVariable (&vid_mode);
|
||||
CVAR_FIXME */
|
||||
vid_mode = Cvar_Get("vid_mode", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_ztrick);
|
||||
CVAR_FIXME */
|
||||
gl_ztrick = Cvar_Get("gl_ztrick", "1", CVAR_NONE, "None");
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
vid.colormap = host_colormap;
|
||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||
|
||||
// interpret command-line params
|
||||
|
||||
// set vid parameters
|
||||
|
||||
if ((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i+1]);
|
||||
if ((i = COM_CheckParm("-height")) != 0)
|
||||
height = atoi(com_argv[i+1]);
|
||||
|
||||
if ((i = COM_CheckParm("-conwidth")) != 0)
|
||||
vid.conwidth = atoi(com_argv[i+1]);
|
||||
else
|
||||
vid.conwidth = 640;
|
||||
|
||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||
|
||||
if (vid.conwidth < 320)
|
||||
vid.conwidth = 320;
|
||||
|
||||
// pick a conheight that matches with correct aspect
|
||||
vid.conheight = vid.conwidth*3 / 4;
|
||||
|
||||
if ((i = COM_CheckParm("-conheight")) != 0)
|
||||
vid.conheight = atoi(com_argv[i+1]);
|
||||
if (vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
|
||||
if (!(dpy = XOpenDisplay(NULL))) {
|
||||
fprintf(stderr, "Error couldn't open the X display\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
scrnum = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, scrnum);
|
||||
|
||||
visinfo=glXChooseVisual(dpy,scrnum,attrib);
|
||||
if (!visinfo) {
|
||||
fprintf(stderr, "Error couldn't get an RGB, Double-buffered, Depth visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel=0;
|
||||
attr.border_pixel=0;
|
||||
attr.colormap=XCreateColormap(dpy,root,visinfo->visual,AllocNone);
|
||||
attr.event_mask=KEY_MASK|MOUSE_MASK|VisibilityChangeMask;
|
||||
mask=CWBackPixel|CWBorderPixel|CWColormap|CWEventMask;
|
||||
|
||||
win=XCreateWindow(dpy,root,0,0,width,height,
|
||||
0,visinfo->depth,InputOutput,
|
||||
visinfo->visual,mask,&attr);
|
||||
XMapWindow(dpy,win);
|
||||
|
||||
XMoveWindow(dpy,win,0,0);
|
||||
|
||||
XFlush(dpy);
|
||||
|
||||
if (COM_CheckParm("-window"))
|
||||
putenv("MESA_GLX_FX=window");
|
||||
else
|
||||
putenv("MESA_GLX_FX=fullscreen");
|
||||
|
||||
ctx = glXCreateContext(dpy,visinfo,NULL,True);
|
||||
|
||||
if (!ctx) {
|
||||
fprintf(stderr, "Unable to create glX context.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glXMakeCurrent(dpy,win,ctx);
|
||||
|
||||
scr_width = width;
|
||||
scr_height = height;
|
||||
|
||||
if (vid.conheight > height)
|
||||
vid.conheight = height;
|
||||
if (vid.conwidth > width)
|
||||
vid.conwidth = width;
|
||||
vid.width = vid.conwidth;
|
||||
vid.height = vid.conheight;
|
||||
|
||||
vid.aspect = ((float)vid.height / (float)vid.width) *
|
||||
(320.0 / 240.0);
|
||||
vid.numpages = 2;
|
||||
|
||||
InitSig(); // trap evil signals
|
||||
|
||||
GL_Init();
|
||||
|
||||
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
|
||||
VID_SetPalette(palette);
|
||||
|
||||
// Check for 3DFX Extensions and initialize them.
|
||||
VID_Init8bitPalette();
|
||||
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
if (dpy)
|
||||
{
|
||||
while (Keyboard_Update())
|
||||
;
|
||||
|
||||
while (keyq_head != keyq_tail)
|
||||
{
|
||||
Key_Event(keyq[keyq_tail].key, keyq[keyq_tail].down);
|
||||
keyq_tail = (keyq_tail + 1) & 63;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Force_CenterView_f (void)
|
||||
{
|
||||
cl.viewangles[PITCH] = 0;
|
||||
}
|
||||
|
||||
|
||||
void IN_Init(void)
|
||||
{
|
||||
/* Cvar_RegisterVariable (&_windowed_mouse);
|
||||
CVAR_FIXME */
|
||||
_windowed_mouse = Cvar_Get("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&m_filter);
|
||||
CVAR_FIXME */
|
||||
m_filter = Cvar_Get("m_filter", "0", CVAR_NONE, "None");
|
||||
Cvar_RegisterVariable (&mouse_button_commands[0]);
|
||||
Cvar_RegisterVariable (&mouse_button_commands[1]);
|
||||
Cvar_RegisterVariable (&mouse_button_commands[2]);
|
||||
Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
||||
}
|
||||
|
||||
void IN_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Commands
|
||||
===========
|
||||
*/
|
||||
void IN_Commands (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<mouse_buttons ; 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;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
while (Mouse_Update())
|
||||
;
|
||||
|
||||
/* if (m_filter.value) {
|
||||
CVAR_FIXME */
|
||||
if (m_filter->value) {
|
||||
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;
|
||||
CVAR_FIXME */
|
||||
mouse_x *= sensitivity->value;
|
||||
/* mouse_y *= sensitivity.value;
|
||||
CVAR_FIXME */
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
/* if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||
CVAR_FIXME */
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
/* cmd->sidemove += m_side.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
/* cl.viewangles[YAW] -= m_yaw.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
||||
/* cl.viewangles[PITCH] += m_pitch.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (cl.viewangles[PITCH] > 80)
|
||||
cl.viewangles[PITCH] = 80;
|
||||
if (cl.viewangles[PITCH] < -70)
|
||||
cl.viewangles[PITCH] = -70;
|
||||
} else {
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
/* cmd->upmove -= m_forward.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cmd->upmove -= m_forward->value * mouse_y;
|
||||
else
|
||||
/* cmd->forwardmove -= m_forward.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
mouse_x = mouse_y = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void VID_LockBuffer (void) {}
|
||||
void VID_UnlockBuffer (void) {}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
in_win.c
|
||||
|
||||
windows 95 mouse and joystick code
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
// in_win.c -- windows 95 mouse and joystick code
|
||||
// 02/21/97 JCB Added extended DirectInput code to support external controllers.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -37,12 +37,7 @@
|
|||
#include "quakedef.h"
|
||||
#include "winquake.h"
|
||||
#include <dinput.h>
|
||||
#include "client.h"
|
||||
#include "keys.h"
|
||||
#include "console.h"
|
||||
#include "qargs.h"
|
||||
#include "cmd.h"
|
||||
#include "input.h"
|
||||
|
||||
//#include "dosisms.h"
|
||||
|
||||
#define DINPUT_BUFFERSIZE 16
|
||||
|
@ -805,7 +800,7 @@ void IN_MouseMove (usercmd_t *cmd)
|
|||
// add mouse X/Y movement to cmd
|
||||
/* if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||
CVAR_FIXME */
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && freelook ))
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
/* cmd->sidemove += m_side.value * mouse_x;
|
||||
CVAR_FIXME */
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
|
@ -814,10 +809,10 @@ void IN_MouseMove (usercmd_t *cmd)
|
|||
CVAR_FIXME */
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if (freelook)
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if ( freelook && !(in_strafe.state & 1))
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
{
|
||||
/* cl.viewangles[PITCH] += m_pitch.value * mouse_y;
|
||||
CVAR_FIXME */
|
||||
|
@ -1265,7 +1260,7 @@ static void IN_JoyMove (usercmd_t *cmd)
|
|||
case AxisForward:
|
||||
/* if ((joy_advanced.value == 0.0) && (in_mlook.state & 1))
|
||||
CVAR_FIXME */
|
||||
if ((joy_advanced->value == 0.0) && freelook)
|
||||
if ((joy_advanced->value == 0.0) && (in_mlook.state & 1))
|
||||
{
|
||||
// user wants forward control to become look control
|
||||
/* if (fabs(fAxisValue) > joy_pitchthreshold.value)
|
||||
|
@ -1330,7 +1325,7 @@ static void IN_JoyMove (usercmd_t *cmd)
|
|||
case AxisTurn:
|
||||
/* if ((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
|
||||
CVAR_FIXME */
|
||||
if ((in_strafe.state & 1) || (lookstrafe->value && freelook))
|
||||
if ((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
|
||||
{
|
||||
// user wants turn control to become side control
|
||||
/* if (fabs(fAxisValue) > joy_sidethreshold.value)
|
||||
|
@ -1367,7 +1362,7 @@ static void IN_JoyMove (usercmd_t *cmd)
|
|||
break;
|
||||
|
||||
case AxisLook:
|
||||
if (freelook)
|
||||
if (in_mlook.state & 1)
|
||||
{
|
||||
/* if (fabs(fAxisValue) > joy_pitchthreshold.value)
|
||||
CVAR_FIXME */
|
||||
|
|
173
source/keys.c
173
source/keys.c
|
@ -26,26 +26,15 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "sys.h"
|
||||
#include "keys.h"
|
||||
#include "menu.h"
|
||||
#include "cmd.h"
|
||||
#include "zone.h"
|
||||
#include "console.h"
|
||||
#include "cvar.h"
|
||||
#include "screen.h"
|
||||
#include "client.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
/*
|
||||
|
||||
|
@ -53,7 +42,6 @@ key up events are sent even if in console mode
|
|||
|
||||
*/
|
||||
|
||||
cvar_t *cl_chatmode;
|
||||
|
||||
#define MAXCMDLINE 256
|
||||
char key_lines[32][MAXCMDLINE];
|
||||
|
@ -265,77 +253,55 @@ Interactive line editing and console scrollback
|
|||
*/
|
||||
void Key_Console (int key)
|
||||
{
|
||||
int i;
|
||||
#ifdef _WIN32
|
||||
// char *cmd, *s;
|
||||
int i;
|
||||
HANDLE th;
|
||||
char *clipText, *textCopied;
|
||||
#endif
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case K_ENTER:
|
||||
// backslash text are commands
|
||||
if (key_lines[edit_line][1] == '/' && key_lines[edit_line][2] == '/')
|
||||
goto no_lf;
|
||||
else if (key_lines[edit_line][1] == '\\' || key_lines[edit_line][1] == '/')
|
||||
Cbuf_AddText (key_lines[edit_line]+2); // skip the ]/
|
||||
else if (cl_chatmode->value != 2 && CheckForCommand())
|
||||
if (key == K_ENTER)
|
||||
{ // backslash text are commands, else chat
|
||||
if (key_lines[edit_line][1] == '\\' || key_lines[edit_line][1] == '/')
|
||||
Cbuf_AddText (key_lines[edit_line]+2); // skip the >
|
||||
else if (CheckForCommand())
|
||||
Cbuf_AddText (key_lines[edit_line]+1); // valid command
|
||||
else if ((cls.state >= ca_connected && cl_chatmode->value == 1) || cl_chatmode->value == 2)
|
||||
{
|
||||
if (cls.state < ca_connected) // can happen if cl_constyle == 2
|
||||
goto no_lf; // drop the whole line
|
||||
|
||||
// convert to a chat message
|
||||
Cbuf_AddText ("say ");
|
||||
Cbuf_AddText (key_lines[edit_line]+1);
|
||||
}
|
||||
else
|
||||
Cbuf_AddText (key_lines[edit_line]+1); // skip the ]
|
||||
{ // convert to a chat message
|
||||
if (cls.state >= ca_connected)
|
||||
Cbuf_AddText ("say ");
|
||||
Cbuf_AddText (key_lines[edit_line]+1); // skip the >
|
||||
}
|
||||
|
||||
Cbuf_AddText ("\n");
|
||||
no_lf:
|
||||
Con_Printf ("%s\n",key_lines[edit_line]);
|
||||
edit_line = (edit_line + 1) & 31;
|
||||
history_line = edit_line;
|
||||
key_lines[edit_line][0] = ']';
|
||||
key_lines[edit_line][1] = 0;
|
||||
key_linepos = 1;
|
||||
if (cls.state == ca_disconnected)
|
||||
SCR_UpdateScreen (); // force an update, because the command
|
||||
// may take some time
|
||||
return;
|
||||
}
|
||||
|
||||
case K_TAB:
|
||||
// command completion
|
||||
if (key == K_TAB)
|
||||
{ // command completion
|
||||
CompleteCommand ();
|
||||
return;
|
||||
|
||||
case K_BACKSPACE:
|
||||
if (key_linepos > 1)
|
||||
{
|
||||
strcpy(key_lines[edit_line] + key_linepos - 1, key_lines[edit_line] + key_linepos);
|
||||
key_linepos--;
|
||||
}
|
||||
return;
|
||||
|
||||
case K_DEL:
|
||||
if (key_linepos < strlen(key_lines[edit_line]))
|
||||
strcpy(key_lines[edit_line] + key_linepos, key_lines[edit_line] + key_linepos + 1);
|
||||
return;
|
||||
|
||||
case K_RIGHTARROW:
|
||||
if (key_linepos < strlen(key_lines[edit_line]))
|
||||
key_linepos++;
|
||||
return;
|
||||
|
||||
case K_LEFTARROW:
|
||||
if (key == K_BACKSPACE || key == K_LEFTARROW)
|
||||
{
|
||||
if (key_linepos > 1)
|
||||
key_linepos--;
|
||||
return;
|
||||
}
|
||||
|
||||
case K_UPARROW:
|
||||
do {
|
||||
if (key == K_UPARROW)
|
||||
{
|
||||
do
|
||||
{
|
||||
history_line = (history_line - 1) & 31;
|
||||
} while (history_line != edit_line
|
||||
&& !key_lines[history_line][1]);
|
||||
|
@ -344,54 +310,56 @@ no_lf:
|
|||
strcpy(key_lines[edit_line], key_lines[history_line]);
|
||||
key_linepos = strlen(key_lines[edit_line]);
|
||||
return;
|
||||
}
|
||||
|
||||
case K_DOWNARROW:
|
||||
if (key == K_DOWNARROW)
|
||||
{
|
||||
if (history_line == edit_line) return;
|
||||
do {
|
||||
do
|
||||
{
|
||||
history_line = (history_line + 1) & 31;
|
||||
} while (history_line != edit_line
|
||||
}
|
||||
while (history_line != edit_line
|
||||
&& !key_lines[history_line][1]);
|
||||
|
||||
if (history_line == edit_line) {
|
||||
if (history_line == edit_line)
|
||||
{
|
||||
key_lines[edit_line][0] = ']';
|
||||
key_lines[edit_line][1] = 0;
|
||||
key_linepos = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(key_lines[edit_line], key_lines[history_line]);
|
||||
key_linepos = strlen(key_lines[edit_line]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case K_MWHEELUP:
|
||||
case K_PGUP:
|
||||
if (con->display - con->current + con->numlines > 2)
|
||||
if (key == K_PGUP || key==K_MWHEELUP)
|
||||
{
|
||||
con->display -= 2;
|
||||
return;
|
||||
}
|
||||
|
||||
case K_MWHEELDOWN:
|
||||
case K_PGDN:
|
||||
if (key == K_PGDN || key==K_MWHEELDOWN)
|
||||
{
|
||||
con->display += 2;
|
||||
if (con->display > con->current)
|
||||
con->display = con->current;
|
||||
return;
|
||||
}
|
||||
|
||||
case K_HOME:
|
||||
if (keydown[K_CTRL])
|
||||
if (key == K_HOME)
|
||||
{
|
||||
if (con->numlines > 10)
|
||||
con->display = con->current - con->numlines + 10;
|
||||
}
|
||||
else
|
||||
key_linepos = 1;
|
||||
con->display = con->current - con_totallines + 10;
|
||||
return;
|
||||
}
|
||||
|
||||
case K_END:
|
||||
if (keydown[K_CTRL])
|
||||
if (key == K_END)
|
||||
{
|
||||
con->display = con->current;
|
||||
else
|
||||
key_linepos = strlen(key_lines[edit_line]);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if ((key=='V' || key=='v') && GetKeyState(VK_CONTROL)<0) {
|
||||
if (OpenClipboard(NULL)) {
|
||||
|
@ -403,14 +371,12 @@ no_lf:
|
|||
strcpy(textCopied, clipText);
|
||||
/* Substitutes a NULL for every token */strtok(textCopied, "\n\r\b");
|
||||
i = strlen(textCopied);
|
||||
if (i + strlen(key_lines[edit_line]) >= MAXCMDLINE-1)
|
||||
i = MAXCMDLINE-1 - strlen(key_lines[edit_line]);
|
||||
if (i > 0)
|
||||
{ // insert the string
|
||||
memcpy (key_lines[edit_line] + key_linepos + i,
|
||||
key_lines[edit_line] + key_linepos, strlen(key_lines[edit_line]) - key_linepos + 1);
|
||||
memcpy (key_lines[edit_line] + key_linepos, textCopied, i);
|
||||
key_linepos += i;
|
||||
if (i+key_linepos>=MAXCMDLINE)
|
||||
i=MAXCMDLINE-key_linepos;
|
||||
if (i>0) {
|
||||
textCopied[i]=0;
|
||||
strcat(key_lines[edit_line], textCopied);
|
||||
key_linepos+=i;;
|
||||
}
|
||||
free(textCopied);
|
||||
}
|
||||
|
@ -427,14 +393,8 @@ no_lf:
|
|||
|
||||
if (key_linepos < MAXCMDLINE-1)
|
||||
{
|
||||
i = strlen(key_lines[edit_line]) - 1;
|
||||
if (i == MAXCMDLINE-2) i--;
|
||||
for (; i >= key_linepos; i--)
|
||||
key_lines[edit_line][i + 1] = key_lines[edit_line][i];
|
||||
i = key_lines[edit_line][key_linepos];
|
||||
key_lines[edit_line][key_linepos] = key;
|
||||
key_linepos++;
|
||||
if (!i) // // only null terminate if at the end
|
||||
key_lines[edit_line][key_linepos] = 0;
|
||||
}
|
||||
|
||||
|
@ -705,7 +665,6 @@ void Key_Init (void)
|
|||
consolekeys[K_UPARROW] = true;
|
||||
consolekeys[K_DOWNARROW] = true;
|
||||
consolekeys[K_BACKSPACE] = true;
|
||||
consolekeys[K_DEL] = true;
|
||||
consolekeys[K_HOME] = true;
|
||||
consolekeys[K_END] = true;
|
||||
consolekeys[K_PGUP] = true;
|
||||
|
@ -753,9 +712,7 @@ void Key_Init (void)
|
|||
Cmd_AddCommand ("unbind",Key_Unbind_f);
|
||||
Cmd_AddCommand ("unbindall",Key_Unbindall_f);
|
||||
|
||||
cl_chatmode = Cvar_Get ("cl_chatmode", "1", 0,
|
||||
"Controls when console text will be treated as a chat message"
|
||||
"0 - never, 1 - smart, 2 - always");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -789,22 +746,17 @@ void Key_Event (int key, qboolean down)
|
|||
if (down)
|
||||
{
|
||||
key_repeats[key]++;
|
||||
if (key_repeats[key] > 1)
|
||||
{
|
||||
if ((key != K_BACKSPACE && key != K_DEL
|
||||
&& key != K_LEFTARROW && key != K_RIGHTARROW
|
||||
&& key != K_PGUP && key != K_PGDN)
|
||||
|| (key_dest == key_game && cls.state == ca_active))
|
||||
if (key != K_BACKSPACE
|
||||
&& key != K_PAUSE
|
||||
&& key != K_PGUP
|
||||
&& key != K_PGDN
|
||||
&& key_repeats[key] > 1)
|
||||
return; // ignore most autorepeats
|
||||
}
|
||||
|
||||
if (key >= 200 && !keybindings[key])
|
||||
Con_Printf ("%s is unbound, hit F4 to set.\n", Key_KeynumToString (key) );
|
||||
}
|
||||
|
||||
// Exit message mode is disconnected
|
||||
if (key_dest == key_message && cls.state != ca_active)
|
||||
key_dest = key_console;
|
||||
|
||||
//
|
||||
// handle escape specialy, so the user can never unbind it
|
||||
|
@ -861,8 +813,7 @@ void Key_Event (int key, qboolean down)
|
|||
//
|
||||
// during demo playback, most keys bring up the main menu
|
||||
//
|
||||
if (cls.demoplayback && down && consolekeys[key] && key_dest == key_game
|
||||
&& key != K_CTRL && key != K_DEL && key != K_HOME && key != K_END && key != K_TAB)
|
||||
if (cls.demoplayback && down && consolekeys[key] && key_dest == key_game)
|
||||
{
|
||||
M_ToggleMenu_f ();
|
||||
return;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
model.c
|
||||
|
||||
model loading and caching
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// models.c -- model loading and caching
|
||||
|
||||
// models are the only shared resource between a client and server running
|
||||
// on the same machine.
|
||||
|
@ -32,15 +33,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "model.h"
|
||||
#include "quakefs.h"
|
||||
#include "qendian.h"
|
||||
#include "checksum.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
void SV_Error (char *error, ...);
|
||||
#include "qwsvdef.h"
|
||||
|
||||
extern int texture_mode;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
pr_edict.c
|
||||
|
||||
entity dictionary
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,27 +25,12 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// sv_edict.c -- entity dictionary
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "pr_comp.h"
|
||||
#include "progs.h"
|
||||
#include "console.h"
|
||||
#include "server.h"
|
||||
#include "world.h"
|
||||
#include "msg.h"
|
||||
#include "cmd.h"
|
||||
#include "commdef.h"
|
||||
#include "crc.h"
|
||||
#include "qendian.h"
|
||||
#include "quakefs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
void SV_Error (char *error, ...);
|
||||
#include "qwsvdef.h"
|
||||
|
||||
dprograms_t *progs;
|
||||
dfunction_t *pr_functions;
|
||||
|
|
|
@ -29,13 +29,8 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "qargs.h"
|
||||
#include "r_local.h"
|
||||
#include "console.h"
|
||||
#include "quakefs.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "r_local.h"
|
||||
|
||||
#define MAX_PARTICLES 2048 // default max # of particles at one
|
||||
// time
|
||||
|
|
|
@ -30,11 +30,9 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "quakedef.h"
|
||||
#include "r_local.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
static int clip_current;
|
||||
static vec5_t clip_verts[2][MAXWORKINGVERTS];
|
||||
static int sprite_width, sprite_height;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
screen.c
|
||||
|
||||
master for refresh, status bar, console, chat, notify, etc
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,28 +25,16 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// screen.c -- master for refresh, status bar, console, chat, notify, etc
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "input.h"
|
||||
#include "sys.h"
|
||||
#include "screen.h"
|
||||
#include "r_local.h"
|
||||
#include "wad.h"
|
||||
#include "compat.h"
|
||||
#include "draw.h"
|
||||
#include "quakedef.h"
|
||||
#include "keys.h"
|
||||
#include "console.h"
|
||||
#include "msg.h"
|
||||
#include "sbar.h"
|
||||
#include "menu.h"
|
||||
#include "qendian.h"
|
||||
#include "cmd.h"
|
||||
#include "r_local.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
|
||||
|
@ -1061,7 +1049,7 @@ int SCR_ModalMessage (char *text)
|
|||
do
|
||||
{
|
||||
key_count = -1; // wait for a key down and up
|
||||
IN_SendKeyEvents ();
|
||||
Sys_SendKeyEvents ();
|
||||
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);
|
||||
|
||||
scr_fullupdate = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
snd_dma.c
|
||||
|
||||
main control for any streaming sound output device
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,16 +25,12 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// snd_dma.c -- main control for any streaming sound output device
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "sound.h"
|
||||
#include "cmd.h"
|
||||
#include "console.h"
|
||||
#include "client.h"
|
||||
#include "qargs.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -42,9 +38,6 @@
|
|||
#include "in_win.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void S_Play(void);
|
||||
void S_PlayVol(void);
|
||||
void S_SoundList(void);
|
||||
|
@ -168,7 +161,7 @@ void S_SoundInfo_f(void)
|
|||
Con_Printf("%5d samplebits\n", shm->samplebits);
|
||||
Con_Printf("%5d submission_chunk\n", shm->submission_chunk);
|
||||
Con_Printf("%5d speed\n", shm->speed);
|
||||
Con_Printf("0x%x dma buffer\n", (unsigned)shm->buffer);
|
||||
Con_Printf("0x%x dma buffer\n", shm->buffer);
|
||||
Con_Printf("%5d total_channels\n", total_channels);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
snd_mem.c
|
||||
|
||||
sound caching
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,17 +25,13 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// snd_mem.c: sound caching
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "sound.h"
|
||||
#include "qendian.h"
|
||||
#include "quakefs.h"
|
||||
#include "console.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
int cache_full_cycle;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
snd_mix.c
|
||||
|
||||
portable code to mix sounds for snd_dma.c
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,12 +25,12 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// snd_mix.c -- portable code to mix sounds for snd_dma.c
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "sound.h"
|
||||
#include "console.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winquake.h"
|
||||
|
|
|
@ -29,22 +29,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "server.h"
|
||||
#include "crc.h"
|
||||
#include "msg.h"
|
||||
#include "world.h"
|
||||
#include "commdef.h"
|
||||
#include "cmd.h"
|
||||
#include "sys.h"
|
||||
#include "pmove.h"
|
||||
#include "compat.h"
|
||||
#include "quakefs.h"
|
||||
#include "bothdefs.h"
|
||||
#include "qendian.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "qwsvdef.h"
|
||||
|
||||
qboolean sv_allow_cheats;
|
||||
|
||||
|
@ -754,6 +739,43 @@ void SV_Floodprotmsg_f (void)
|
|||
snprintf (fp_msg, sizeof(fp_msg), "%s", Cmd_Argv(1));
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SV_Gamedir_f
|
||||
|
||||
Sets the gamedir and path to a different directory.
|
||||
================
|
||||
*/
|
||||
char gamedirfile[MAX_OSPATH];
|
||||
void SV_Gamedir_f (void)
|
||||
{
|
||||
char *dir;
|
||||
|
||||
if (Cmd_Argc() == 1)
|
||||
{
|
||||
Con_Printf ("Current gamedir: %s\n", com_gamedir);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("Usage: gamedir <newdir>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dir = Cmd_Argv(1);
|
||||
|
||||
if (strstr(dir, "..") || strstr(dir, "/")
|
||||
|| strstr(dir, "\\") || strstr(dir, ":") )
|
||||
{
|
||||
Con_Printf ("Gamedir should be a single filename, not a path\n");
|
||||
return;
|
||||
}
|
||||
|
||||
COM_Gamedir (dir);
|
||||
Info_SetValueForStarKey (svs.info, "*gamedir", dir, MAX_SERVERINFO_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SV_Snap
|
||||
|
@ -780,15 +802,15 @@ void SV_Snap (int uid)
|
|||
|
||||
sprintf(pcxname, "%d-00.pcx", uid);
|
||||
|
||||
snprintf (checkname, sizeof(checkname), "%s/snap", com_gamedir);
|
||||
Sys_mkdir(com_gamedir);
|
||||
snprintf (checkname, sizeof(checkname), "%s/snap", gamedirfile);
|
||||
Sys_mkdir(gamedirfile);
|
||||
Sys_mkdir(checkname);
|
||||
|
||||
for (i=0 ; i<=99 ; i++)
|
||||
{
|
||||
pcxname[strlen(pcxname) - 6] = i/10 + '0';
|
||||
pcxname[strlen(pcxname) - 5] = i%10 + '0';
|
||||
snprintf (checkname, sizeof(checkname), "%s/snap/%s", com_gamedir, pcxname);
|
||||
snprintf (checkname, sizeof(checkname), "%s/snap/%s", gamedirfile, pcxname);
|
||||
if (Sys_FileTime(checkname) == -1)
|
||||
break; // file doesn't exist
|
||||
}
|
||||
|
@ -881,6 +903,7 @@ void SV_InitOperatorCommands (void)
|
|||
Cmd_AddCommand ("serverinfo", SV_Serverinfo_f);
|
||||
Cmd_AddCommand ("localinfo", SV_Localinfo_f);
|
||||
Cmd_AddCommand ("user", SV_User_f);
|
||||
Cmd_AddCommand ("gamedir", SV_Gamedir_f);
|
||||
Cmd_AddCommand ("sv_gamedir", SV_Gamedir);
|
||||
Cmd_AddCommand ("floodprot", SV_Floodprot_f);
|
||||
Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f);
|
||||
|
|
|
@ -29,14 +29,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "server.h"
|
||||
#include "crc.h"
|
||||
#include "msg.h"
|
||||
#include "world.h"
|
||||
#include "commdef.h"
|
||||
#include "cmd.h"
|
||||
#include "sys.h"
|
||||
#include "pmove.h"
|
||||
#include "qwsvdef.h"
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
|
|
@ -31,16 +31,12 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include "qargs.h"
|
||||
#include "cvar.h"
|
||||
#include "server.h"
|
||||
#include "sys.h"
|
||||
#include "qwsvdef.h"
|
||||
|
||||
#ifdef NeXT
|
||||
#include <libc.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
@ -171,7 +167,7 @@ int main(int argc, char *argv[])
|
|||
if (j)
|
||||
parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
|
||||
if ((parms.membase = malloc (parms.memsize)) == NULL)
|
||||
Sys_Error("Can't allocate %d\n", parms.memsize);
|
||||
Sys_Error("Can't allocate %ld\n", parms.memsize);
|
||||
|
||||
parms.basedir = BASEDIR;
|
||||
|
||||
|
|
|
@ -27,24 +27,21 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "qwsvdef.h"
|
||||
#include <winsock.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "qargs.h"
|
||||
#include "cvar.h"
|
||||
#include "server.h"
|
||||
#include "sys.h"
|
||||
|
||||
|
||||
qboolean is_server = true;
|
||||
qboolean WinNT;
|
||||
|
||||
/* cvar_t sys_nostdout = {"sys_nostdout","0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *sys_nostdout;
|
||||
/* cvar_t sys_sleep = {"sys_sleep","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *sys_sleep;
|
||||
|
||||
/*
|
||||
|
@ -142,6 +139,8 @@ void Sys_Printf (char *fmt, ...)
|
|||
{
|
||||
va_list argptr;
|
||||
|
||||
/* if (sys_nostdout.value)
|
||||
CVAR_FIXME */
|
||||
if (sys_nostdout->value)
|
||||
return;
|
||||
|
||||
|
@ -173,8 +172,12 @@ void Sys_Init (void)
|
|||
{
|
||||
OSVERSIONINFO vinfo;
|
||||
|
||||
/* Cvar_RegisterVariable (&sys_nostdout);
|
||||
CVAR_FIXME */
|
||||
sys_nostdout = Cvar_Get("sys_nostdout", "0", CVAR_NONE, "None");
|
||||
sys_sleep = Cvar_Get("sys_sleep", "8", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&sys_sleep);
|
||||
CVAR_FIXME */
|
||||
sys_sleep = Cvar_Get("sys_sleep", "1", CVAR_NONE, "None");
|
||||
|
||||
// make sure the timer is high precision, otherwise
|
||||
// NT gets 18ms resolution
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
sv_user.c
|
||||
|
||||
server code for moving users
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,29 +25,12 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
// sv_user.c -- server code for moving users
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "server.h"
|
||||
#include "crc.h"
|
||||
#include "console.h"
|
||||
#include "msg.h"
|
||||
#include "world.h"
|
||||
#include "commdef.h"
|
||||
#include "cmd.h"
|
||||
#include "sys.h"
|
||||
#include "pmove.h"
|
||||
#include "compat.h"
|
||||
#include "bothdefs.h"
|
||||
#include "quakefs.h"
|
||||
#include "checksum.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "qwsvdef.h"
|
||||
|
||||
edict_t *sv_player;
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 1999 Marcus Sundberg [mackan@stacken.kth.se]
|
||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||
Please see the file "AUTHORS" for a list of contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -39,34 +41,9 @@
|
|||
#include <string.h>
|
||||
#include <ggi/ggi.h>
|
||||
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
|
||||
#include "quakedef.h"
|
||||
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
#include "zone.h" // needed by: client.h, gl_model.h
|
||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||
// modelgen.h, glmodel.h
|
||||
#include "wad.h"
|
||||
#include "draw.h"
|
||||
#include "cvar.h"
|
||||
#include "net.h" // needed by: client.h
|
||||
#include "protocol.h" // needed by: client.h
|
||||
#include "cmd.h"
|
||||
#include "keys.h"
|
||||
#include "sbar.h"
|
||||
#include "sound.h"
|
||||
#include "render.h" // needed by: client.h, gl_model.h, glquake.h
|
||||
#include "client.h" // need cls in this file
|
||||
#include "model.h" // needed by: glquake.h
|
||||
#include "console.h"
|
||||
#include "qendian.h"
|
||||
#include "qargs.h"
|
||||
#include "compat.h"
|
||||
#include "quakedef.h"
|
||||
#include "d_local.h"
|
||||
#include "input.h"
|
||||
|
||||
extern viddef_t vid; // global video state
|
||||
unsigned short d_8to16table[256];
|
||||
|
@ -894,7 +871,7 @@ static void GetEvent(void)
|
|||
}
|
||||
|
||||
|
||||
void IN_SendKeyEvents(void)
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
/* Get events from LibGGI */
|
||||
if (ggivis) {
|
||||
|
@ -966,14 +943,14 @@ IN_Move(usercmd_t *cmd)
|
|||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && freelook ))
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
if (freelook)
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if ( freelook && !(in_strafe.state & 1)) {
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (cl.viewangles[PITCH] > 80)
|
||||
cl.viewangles[PITCH] = 80;
|
||||
|
|
736
source/vid_glx.c
736
source/vid_glx.c
|
@ -4,7 +4,6 @@
|
|||
OpenGL GLX video driver
|
||||
|
||||
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
|
||||
|
@ -27,96 +26,83 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#include <values.h>
|
||||
#include "qtypes.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 "draw.h"
|
||||
#include "context_x11.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <math.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 "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
|
||||
#include <quakedef.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "bspfile.h" // needed by: glquake.h
|
||||
#include "vid.h"
|
||||
#include "sys.h"
|
||||
#include "zone.h" // needed by: client.h, gl_model.h
|
||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||
// modelgen.h, glmodel.h
|
||||
#include "wad.h"
|
||||
#include "draw.h"
|
||||
#include "cvar.h"
|
||||
#include "net.h" // needed by: client.h
|
||||
#include "protocol.h" // needed by: client.h
|
||||
#include "cmd.h"
|
||||
#include "keys.h"
|
||||
#include "sbar.h"
|
||||
#include "sound.h"
|
||||
#include "render.h" // needed by: client.h, gl_model.h, glquake.h
|
||||
#include "client.h" // need cls in this file
|
||||
#include "model.h" // needed by: glquake.h
|
||||
#include "console.h"
|
||||
#include "glquake.h"
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#ifdef HAVE_DGA
|
||||
# include <X11/extensions/xf86dga.h>
|
||||
#ifdef USE_DGA
|
||||
#include <X11/extensions/xf86dga.h>
|
||||
#endif
|
||||
#ifdef HAVE_VIDMODE
|
||||
# include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
#include "dga_check.h"
|
||||
|
||||
#ifdef XMESA
|
||||
# include <GL/xmesa.h>
|
||||
#endif
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
static qboolean vid_initialized = false;
|
||||
extern byte *host_colormap;
|
||||
extern qboolean noclip_anglehack;
|
||||
|
||||
static int screen;
|
||||
Window x_win;
|
||||
static Display *x_disp = NULL;
|
||||
static Window x_win;
|
||||
static GLXContext ctx = NULL;
|
||||
|
||||
#define X_MASK (VisibilityChangeMask | StructureNotifyMask)
|
||||
static float old_windowed_mouse = 0;
|
||||
|
||||
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
|
||||
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
|
||||
PointerMotionMask)
|
||||
|
||||
#define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask)
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
cvar_t *_windowed_mouse;
|
||||
cvar_t *vid_mode;
|
||||
cvar_t *vid_fullscreen;
|
||||
extern cvar_t *gl_triplebuffer;
|
||||
extern cvar_t *vid_dga_mouseaccel;
|
||||
|
||||
#ifdef HAVE_VIDMODE
|
||||
static XF86VidModeModeInfo **vidmodes;
|
||||
static int nummodes, hasvidmode = 0;
|
||||
#endif
|
||||
#ifdef HAVE_DGA
|
||||
static int hasdgavideo = 0;
|
||||
static int hasdga = 0;
|
||||
#endif
|
||||
static float mouse_x, mouse_y;
|
||||
static float old_mouse_x, old_mouse_y;
|
||||
|
||||
cvar_t *m_filter;
|
||||
|
||||
#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)
|
||||
int VID_options_items = 2;
|
||||
#else
|
||||
int VID_options_items = 1;
|
||||
#endif
|
||||
static int scr_width, scr_height;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
|
@ -131,6 +117,8 @@ int texture_extension_number = 1;
|
|||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
/* cvar_t gl_ztrick = {"gl_ztrick","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_ztrick;
|
||||
|
||||
const char *gl_vendor;
|
||||
|
@ -150,48 +138,318 @@ void D_EndDirectRect (int x, int y, int width, int height)
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_Shutdown(void)
|
||||
/*
|
||||
========================================================================
|
||||
Create an empty cursor
|
||||
========================================================================
|
||||
*/
|
||||
|
||||
static Cursor nullcursor = None;
|
||||
|
||||
static Cursor
|
||||
CreateNullCursor(Display *display, Window root)
|
||||
{
|
||||
if (!vid_initialized)
|
||||
return;
|
||||
Pixmap cursormask;
|
||||
XGCValues xgc;
|
||||
GC gc;
|
||||
XColor dummycolour;
|
||||
|
||||
Con_Printf("VID_Shutdown\n");
|
||||
if (nullcursor != None) return nullcursor;
|
||||
|
||||
glXDestroyContext(x_disp, ctx);
|
||||
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
|
||||
xgc.function = GXclear;
|
||||
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
|
||||
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
|
||||
dummycolour.pixel = 0;
|
||||
dummycolour.red = 0;
|
||||
dummycolour.flags = 04;
|
||||
nullcursor = XCreatePixmapCursor(display, cursormask, cursormask,
|
||||
&dummycolour,&dummycolour, 0,0);
|
||||
XFreePixmap(display,cursormask);
|
||||
XFreeGC(display,gc);
|
||||
|
||||
#ifdef HAVE_VIDMODE
|
||||
if (hasvidmode) {
|
||||
int i;
|
||||
|
||||
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
|
||||
vidmodes[0]);
|
||||
for (i = 0; i < nummodes; i++) {
|
||||
if (vidmodes[i]->private) XFree(vidmodes[i]->private);
|
||||
}
|
||||
XFree(vidmodes);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_DLOPEN
|
||||
if (dlhand) {
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
}
|
||||
#endif
|
||||
x11_close_display();
|
||||
return nullcursor;
|
||||
}
|
||||
|
||||
static void
|
||||
signal_handler(int sig)
|
||||
static int XLateKey(XKeyEvent *ev)
|
||||
{
|
||||
|
||||
int key;
|
||||
char buf[64];
|
||||
KeySym keysym;
|
||||
|
||||
key = 0;
|
||||
|
||||
XLookupString(ev, buf, sizeof buf, &keysym, 0);
|
||||
|
||||
switch(keysym)
|
||||
{
|
||||
case XK_KP_Page_Up:
|
||||
case XK_Page_Up: key = K_PGUP; break;
|
||||
|
||||
case XK_KP_Page_Down:
|
||||
case XK_Page_Down: key = K_PGDN; break;
|
||||
|
||||
case XK_KP_Home:
|
||||
case XK_Home: key = K_HOME; break;
|
||||
|
||||
case XK_KP_End:
|
||||
case XK_End: key = K_END; break;
|
||||
|
||||
case XK_KP_Left:
|
||||
case XK_Left: key = K_LEFTARROW; break;
|
||||
|
||||
case XK_KP_Right:
|
||||
case XK_Right: key = K_RIGHTARROW; break;
|
||||
|
||||
case XK_KP_Down:
|
||||
case XK_Down: key = K_DOWNARROW; break;
|
||||
|
||||
case XK_KP_Up:
|
||||
case XK_Up: key = K_UPARROW; break;
|
||||
|
||||
case XK_Escape: key = K_ESCAPE; break;
|
||||
|
||||
case XK_KP_Enter:
|
||||
case XK_Return: key = K_ENTER; break;
|
||||
|
||||
case XK_Tab: key = K_TAB; break;
|
||||
|
||||
case XK_F1: key = K_F1; break;
|
||||
|
||||
case XK_F2: key = K_F2; break;
|
||||
|
||||
case XK_F3: key = K_F3; break;
|
||||
|
||||
case XK_F4: key = K_F4; break;
|
||||
|
||||
case XK_F5: key = K_F5; break;
|
||||
|
||||
case XK_F6: key = K_F6; break;
|
||||
|
||||
case XK_F7: key = K_F7; break;
|
||||
|
||||
case XK_F8: key = K_F8; break;
|
||||
|
||||
case XK_F9: key = K_F9; break;
|
||||
|
||||
case XK_F10: key = K_F10; break;
|
||||
|
||||
case XK_F11: key = K_F11; break;
|
||||
|
||||
case XK_F12: key = K_F12; break;
|
||||
|
||||
case XK_BackSpace: key = K_BACKSPACE; break;
|
||||
|
||||
case XK_KP_Delete:
|
||||
case XK_Delete: key = K_DEL; break;
|
||||
|
||||
case XK_Pause: key = K_PAUSE; break;
|
||||
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R: key = K_SHIFT; break;
|
||||
|
||||
case XK_Execute:
|
||||
case XK_Control_L:
|
||||
case XK_Control_R: key = K_CTRL; break;
|
||||
|
||||
case XK_Alt_L:
|
||||
case XK_Meta_L:
|
||||
case XK_Alt_R:
|
||||
case XK_Meta_R: key = K_ALT; break;
|
||||
|
||||
case XK_KP_Begin: key = '5'; break;
|
||||
|
||||
case XK_KP_Insert:
|
||||
case XK_Insert:key = K_INS; break;
|
||||
|
||||
case XK_KP_Multiply: key = '*'; break;
|
||||
case XK_KP_Add: key = '+'; break;
|
||||
case XK_KP_Subtract: key = '-'; break;
|
||||
case XK_KP_Divide: key = '/'; break;
|
||||
|
||||
#if 0
|
||||
case 0x021: key = '1';break;/* [!] */
|
||||
case 0x040: key = '2';break;/* [@] */
|
||||
case 0x023: key = '3';break;/* [#] */
|
||||
case 0x024: key = '4';break;/* [$] */
|
||||
case 0x025: key = '5';break;/* [%] */
|
||||
case 0x05e: key = '6';break;/* [^] */
|
||||
case 0x026: key = '7';break;/* [&] */
|
||||
case 0x02a: key = '8';break;/* [*] */
|
||||
case 0x028: key = '9';;break;/* [(] */
|
||||
case 0x029: key = '0';break;/* [)] */
|
||||
case 0x05f: key = '-';break;/* [_] */
|
||||
case 0x02b: key = '=';break;/* [+] */
|
||||
case 0x07c: key = '\'';break;/* [|] */
|
||||
case 0x07d: key = '[';break;/* [}] */
|
||||
case 0x07b: key = ']';break;/* [{] */
|
||||
case 0x022: key = '\'';break;/* ["] */
|
||||
case 0x03a: key = ';';break;/* [:] */
|
||||
case 0x03f: key = '/';break;/* [?] */
|
||||
case 0x03e: key = '.';break;/* [>] */
|
||||
case 0x03c: key = ',';break;/* [<] */
|
||||
#endif
|
||||
|
||||
default:
|
||||
key = *(unsigned char*)buf;
|
||||
if (key >= 'A' && key <= 'Z')
|
||||
key = key - 'A' + 'a';
|
||||
break;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
static void install_grabs(void)
|
||||
{
|
||||
XGrabPointer(x_disp, x_win,
|
||||
True,
|
||||
0,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
x_win,
|
||||
None,
|
||||
CurrentTime);
|
||||
|
||||
#ifdef USE_DGA
|
||||
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), XF86DGADirectMouse);
|
||||
dgamouse = 1;
|
||||
#else
|
||||
XWarpPointer(x_disp, None, x_win,
|
||||
0, 0, 0, 0,
|
||||
vid.width / 2, vid.height / 2);
|
||||
#endif
|
||||
|
||||
XGrabKeyboard(x_disp, x_win,
|
||||
False,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
CurrentTime);
|
||||
|
||||
// XSync(x_disp, True);
|
||||
}
|
||||
|
||||
static void uninstall_grabs(void)
|
||||
{
|
||||
#ifdef USE_DGA
|
||||
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), 0);
|
||||
dgamouse = 0;
|
||||
#endif
|
||||
|
||||
XUngrabPointer(x_disp, CurrentTime);
|
||||
XUngrabKeyboard(x_disp, CurrentTime);
|
||||
|
||||
// XSync(x_disp, True);
|
||||
}
|
||||
|
||||
static void GetEvent(void)
|
||||
{
|
||||
XEvent event;
|
||||
int b;
|
||||
|
||||
if (!x_disp)
|
||||
return;
|
||||
|
||||
XNextEvent(x_disp, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
Key_Event(XLateKey(&event.xkey), event.type == KeyPress);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
#ifdef USE_DGA
|
||||
/* if (dgamouse && _windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (dgamouse && _windowed_mouse->value) {
|
||||
mouse_x = event.xmotion.x_root;
|
||||
mouse_y = event.xmotion.y_root;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* if (_windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (_windowed_mouse->value) {
|
||||
mouse_x = (float) ((int)event.xmotion.x - (int)(vid.width/2));
|
||||
mouse_y = (float) ((int)event.xmotion.y - (int)(vid.height/2));
|
||||
|
||||
/* move the mouse to the window center again */
|
||||
XSelectInput(x_disp, x_win, X_MASK & ~PointerMotionMask);
|
||||
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
|
||||
(vid.width/2), (vid.height/2));
|
||||
XSelectInput(x_disp, x_win, X_MASK);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
b=-1;
|
||||
if (event.xbutton.button == 1)
|
||||
b = 0;
|
||||
else if (event.xbutton.button == 2)
|
||||
b = 2;
|
||||
else if (event.xbutton.button == 3)
|
||||
b = 1;
|
||||
if (b>=0)
|
||||
Key_Event(K_MOUSE1 + b, true);
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
b=-1;
|
||||
if (event.xbutton.button == 1)
|
||||
b = 0;
|
||||
else if (event.xbutton.button == 2)
|
||||
b = 2;
|
||||
else if (event.xbutton.button == 3)
|
||||
b = 1;
|
||||
if (b>=0)
|
||||
Key_Event(K_MOUSE1 + b, false);
|
||||
break;
|
||||
}
|
||||
|
||||
/* if (old_windowed_mouse != _windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (old_windowed_mouse != _windowed_mouse->value) {
|
||||
/* old_windowed_mouse = _windowed_mouse.value;
|
||||
CVAR_FIXME */
|
||||
old_windowed_mouse = _windowed_mouse->value;
|
||||
|
||||
/* if (!_windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (!_windowed_mouse->value) {
|
||||
/* ungrab the pointer */
|
||||
uninstall_grabs();
|
||||
} else {
|
||||
/* grab the pointer */
|
||||
install_grabs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VID_Shutdown(void)
|
||||
{
|
||||
Con_Printf("VID_Shutdown\n");
|
||||
if (ctx) {
|
||||
glXDestroyContext(x_disp, ctx);
|
||||
}
|
||||
if (nullcursor != None) {
|
||||
XFreeCursor(x_disp, nullcursor);
|
||||
nullcursor = None;
|
||||
}
|
||||
XCloseDisplay(x_disp);
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
Sys_Quit();
|
||||
exit(sig);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
InitSig(void)
|
||||
void InitSig(void)
|
||||
{
|
||||
#if 0
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
|
@ -199,9 +457,10 @@ InitSig(void)
|
|||
signal(SIGTRAP, signal_handler);
|
||||
signal(SIGIOT, signal_handler);
|
||||
signal(SIGBUS, signal_handler);
|
||||
/* signal(SIGFPE, signal_handler); */
|
||||
signal(SIGFPE, signal_handler);
|
||||
signal(SIGSEGV, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
|
@ -226,7 +485,7 @@ void VID_SetPalette (unsigned char *palette)
|
|||
//
|
||||
// 8 8 8 encoding
|
||||
//
|
||||
// Con_Printf("Converting 8to24\n");
|
||||
// Con_DPrintf("Converting 8to24\n");
|
||||
|
||||
pal = palette;
|
||||
table = d_8to24table;
|
||||
|
@ -278,9 +537,9 @@ void VID_SetPalette (unsigned char *palette)
|
|||
}
|
||||
d_15to8table[i]=k;
|
||||
}
|
||||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||
snprintf (s, sizeof(s), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
snprintf (s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
|
@ -288,7 +547,6 @@ void VID_SetPalette (unsigned char *palette)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_Init
|
||||
|
@ -308,7 +566,7 @@ void GL_Init (void)
|
|||
|
||||
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
|
||||
|
||||
glClearColor (0,0,0,0);
|
||||
glClearColor (1,0,0,0);
|
||||
glCullFace(GL_FRONT);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
@ -364,7 +622,7 @@ qboolean VID_Is8bit(void)
|
|||
return is8bit;
|
||||
}
|
||||
|
||||
#ifdef GL_EXT_SHARED
|
||||
#ifdef GLX_EXT_SHARED
|
||||
void VID_Init8bitPalette()
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
|
@ -395,6 +653,34 @@ void VID_Init8bitPalette(void)
|
|||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
extern void gl3DfxSetPaletteEXT(GLuint *pal);
|
||||
|
||||
void VID_Init8bitPalette(void)
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
GLubyte table[256][4];
|
||||
char *oldpal;
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette") == NULL)
|
||||
return;
|
||||
|
||||
Con_SafePrintf("8-bit GL extensions enabled.\n");
|
||||
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++;
|
||||
}
|
||||
gl3DfxSetPaletteEXT((GLuint *)table);
|
||||
is8bit = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
|
@ -411,27 +697,25 @@ void VID_Init(unsigned char *palette)
|
|||
};
|
||||
char gldir[MAX_OSPATH];
|
||||
int width = 640, height = 480;
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
XVisualInfo *visinfo;
|
||||
|
||||
vid_mode = Cvar_Get ("vid_mode","0",0,"None");
|
||||
gl_ztrick = Cvar_Get ("gl_ztrick","0",CVAR_ARCHIVE,"None");
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"None");
|
||||
#ifdef HAVE_DGA
|
||||
vid_dga_mouseaccel = Cvar_Get("vid_dga_mouseaccel","1",CVAR_ARCHIVE,
|
||||
"None");
|
||||
#endif
|
||||
|
||||
vid_mode = Cvar_Get("vid_mode", "0", CVAR_NONE, "None");
|
||||
gl_ztrick = Cvar_Get("gl_ztrick", "0", CVAR_NONE, "None");
|
||||
_windowed_mouse = Cvar_Get("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
vid.colormap = host_colormap;
|
||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||
|
||||
/* Interpret command-line params
|
||||
*/
|
||||
// interpret command-line params
|
||||
|
||||
/* Set vid parameters */
|
||||
// set vid parameters
|
||||
if ((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i+1]);
|
||||
if ((i = COM_CheckParm("-height")) != 0)
|
||||
|
@ -443,82 +727,28 @@ void VID_Init(unsigned char *palette)
|
|||
vid.conwidth = width;
|
||||
|
||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||
if (vid.conwidth < 320)
|
||||
vid.conwidth = 320;
|
||||
|
||||
vid.conwidth = max(vid.conwidth, 320);
|
||||
|
||||
// pick a conheight that matches with correct aspect
|
||||
vid.conheight = vid.conwidth * 3 / 4;
|
||||
vid.conheight = vid.conwidth*3 / 4;
|
||||
|
||||
i = COM_CheckParm ("-conheight");
|
||||
if ( i != 0 ) // Set console height, but no smaller than 200 px
|
||||
vid.conheight = atoi(com_argv[i+1]);
|
||||
if (vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
if ((i = COM_CheckParm("-conheight")) != 0)
|
||||
vid.conheight = max(atoi(com_argv[i+1]), 200);
|
||||
|
||||
x11_open_display();
|
||||
|
||||
screen = DefaultScreen(x_disp);
|
||||
root = RootWindow(x_disp, screen);
|
||||
|
||||
visinfo = glXChooseVisual(x_disp, screen, attrib);
|
||||
if (!visinfo) {
|
||||
fprintf(stderr, "Error couldn't get an RGB, Double-buffered, Depth visual\n");
|
||||
if (!(x_disp = XOpenDisplay(NULL))) {
|
||||
fprintf(stderr, "Error couldn't open the X display\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_DGA
|
||||
{
|
||||
int maj_ver;
|
||||
scrnum = DefaultScreen(x_disp);
|
||||
root = RootWindow(x_disp, scrnum);
|
||||
|
||||
hasdga = VID_CheckDGA(x_disp, &maj_ver, NULL, &hasdgavideo);
|
||||
if (!hasdga || maj_ver < 1) {
|
||||
hasdga = hasdgavideo = 0;
|
||||
visinfo = glXChooseVisual(x_disp, scrnum, attrib);
|
||||
if (!visinfo) {
|
||||
fprintf(stderr, "qkHack: Error couldn't get an RGB, Double-buffered, Depth visual\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
Con_SafePrintf ("hasdga = %i\nhasdgavideo = %i\n", hasdga, hasdgavideo);
|
||||
#endif
|
||||
#ifdef HAVE_VIDMODE
|
||||
hasvidmode = VID_CheckVMode(x_disp, NULL, NULL);
|
||||
if (hasvidmode) {
|
||||
if (! XF86VidModeGetAllModeLines(x_disp, DefaultScreen(x_disp),
|
||||
&nummodes, &vidmodes)
|
||||
|| nummodes <= 0) {
|
||||
hasvidmode = 0;
|
||||
}
|
||||
}
|
||||
Con_SafePrintf ("hasvidmode = %i\nnummodes = %i\n", hasvidmode, nummodes);
|
||||
#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;
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
|
@ -526,52 +756,18 @@ void VID_Init(unsigned char *palette)
|
|||
attr.event_mask = X_MASK;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
#ifdef HAVE_VIDMODE
|
||||
if (hasvidmode && vid_fullscreen->value) {
|
||||
int smallest_mode=0, x=MAXINT, y=MAXINT;
|
||||
|
||||
attr.override_redirect=1;
|
||||
mask|=CWOverrideRedirect;
|
||||
|
||||
// FIXME: does this depend on mode line order in XF86Config?
|
||||
for (i=0; i<nummodes; i++) {
|
||||
if (x>vidmodes[i]->hdisplay || y>vidmodes[i]->vdisplay) {
|
||||
smallest_mode=i;
|
||||
x=vidmodes[i]->hdisplay;
|
||||
y=vidmodes[i]->vdisplay;
|
||||
}
|
||||
printf("%dx%d\n",vidmodes[i]->hdisplay,vidmodes[i]->vdisplay);
|
||||
}
|
||||
// chose the smallest mode that our window fits into;
|
||||
for (i=smallest_mode;
|
||||
i!=(smallest_mode+1)%nummodes;
|
||||
i=(i?i-1:nummodes-1)) {
|
||||
if (vidmodes[i]->hdisplay>=width
|
||||
&& vidmodes[i]->vdisplay>=height) {
|
||||
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
|
||||
vidmodes[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
XF86VidModeSetViewPort(x_disp, DefaultScreen (x_disp), 0, 0);
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse","1",CVAR_ARCHIVE|CVAR_ROM,"None");
|
||||
} else
|
||||
#endif
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
|
||||
|
||||
x_win = XCreateWindow(x_disp, root, 0, 0, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr);
|
||||
XMapWindow(x_disp, x_win);
|
||||
#ifdef HAVE_VIDMODE
|
||||
if (hasvidmode && vid_fullscreen->value) {
|
||||
XRaiseWindow(x_disp, x_win);
|
||||
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
|
||||
CurrentTime);
|
||||
}
|
||||
#endif
|
||||
/* Invisible Cursor */
|
||||
XDefineCursor(x_disp, x_win, CreateNullCursor(x_disp, x_win));
|
||||
|
||||
XSync(x_disp, 0);
|
||||
/* Map the window */
|
||||
XMapWindow(x_disp, x_win);
|
||||
|
||||
XMoveWindow(x_disp, x_win, 0, 0);
|
||||
|
||||
XFlush(x_disp);
|
||||
|
||||
ctx = glXCreateContext(x_disp, visinfo, NULL, True);
|
||||
|
||||
|
@ -580,12 +776,8 @@ void VID_Init(unsigned char *palette)
|
|||
scr_width = width;
|
||||
scr_height = height;
|
||||
|
||||
if (vid.conheight > height)
|
||||
vid.conheight = height;
|
||||
if (vid.conwidth > width)
|
||||
vid.conwidth = width;
|
||||
vid.width = vid.conwidth;
|
||||
vid.height = vid.conheight;
|
||||
vid.height = vid.conheight = min(height, vid.conheight);
|
||||
vid.width = vid.conwidth = min(width, vid.conwidth);
|
||||
|
||||
vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
|
||||
vid.numpages = 2;
|
||||
|
@ -594,7 +786,7 @@ void VID_Init(unsigned char *palette)
|
|||
|
||||
GL_Init();
|
||||
|
||||
snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
|
||||
VID_SetPalette(palette);
|
||||
|
@ -602,26 +794,96 @@ void VID_Init(unsigned char *palette)
|
|||
// Check for 3DFX Extensions and initialize them.
|
||||
VID_Init8bitPalette();
|
||||
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n",
|
||||
width, height);
|
||||
|
||||
vid_initialized = true;
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void VID_InitCvars()
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
gl_triplebuffer = Cvar_Get("gl_triplebuffer","1",CVAR_ARCHIVE,"None");
|
||||
if (x_disp) {
|
||||
while (XPending(x_disp))
|
||||
GetEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_LockBuffer ( void )
|
||||
void Force_CenterView_f (void)
|
||||
{
|
||||
cl.viewangles[PITCH] = 0;
|
||||
}
|
||||
|
||||
void IN_Init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_UnlockBuffer ( void )
|
||||
void IN_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Commands
|
||||
===========
|
||||
*/
|
||||
void IN_Commands (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void IN_MouseMove (usercmd_t *cmd)
|
||||
{
|
||||
if (m_filter->value)
|
||||
{
|
||||
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;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
{
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (cl.viewangles[PITCH] > 80)
|
||||
cl.viewangles[PITCH] = 80;
|
||||
if (cl.viewangles[PITCH] < -70)
|
||||
cl.viewangles[PITCH] = -70;
|
||||
}
|
||||
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 IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
IN_MouseMove(cmd);
|
||||
}
|
||||
|
||||
void VID_InitCvars ()
|
||||
{
|
||||
m_filter = Cvar_Get("m_filter", "0", CVAR_NONE, "None");
|
||||
}
|
||||
|
||||
void VID_UnlockBuffer() {}
|
||||
void VID_LockBuffer() {}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
vid_mgl.c
|
||||
vid_win.c
|
||||
|
||||
Win32 Scitech MGL video driver
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,28 +25,17 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// vid_win.c -- Win32 video driver
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "winquake.h"
|
||||
#include "sys.h"
|
||||
#include "d_local.h"
|
||||
#include "resource.h"
|
||||
#include "in_win.h"
|
||||
#include "keys.h"
|
||||
#include "screen.h"
|
||||
#include "wad.h"
|
||||
#include "cmd.h"
|
||||
#include "qendian.h"
|
||||
#include "draw.h"
|
||||
#include "console.h"
|
||||
#include "sound.h"
|
||||
#include "cdaudio.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#define MINIMUM_MEMORY 0x550000
|
||||
|
||||
|
@ -285,7 +274,7 @@ void VID_UpdateWindowStatus (void)
|
|||
}
|
||||
|
||||
|
||||
extern void CL_ClearStates ();
|
||||
extern qboolean keydown[256];
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -294,7 +283,15 @@ ClearAllStates
|
|||
*/
|
||||
void ClearAllStates (void)
|
||||
{
|
||||
CL_ClearStates ();
|
||||
int i;
|
||||
|
||||
// send an up event for each key, to make sure the server clears them all
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
if (keydown[i])
|
||||
Key_Event (i, false);
|
||||
}
|
||||
|
||||
Key_ClearStates ();
|
||||
IN_ClearStates ();
|
||||
}
|
||||
|
@ -1398,7 +1395,7 @@ qboolean VID_SetWindowedMode (int modenum)
|
|||
mainwindow = CreateWindowEx (
|
||||
ExWindowStyle,
|
||||
"WinQuake",
|
||||
PROGRAM,
|
||||
"WinQuake",
|
||||
WindowStyle,
|
||||
0, 0,
|
||||
WindowRect.right - WindowRect.left,
|
||||
|
@ -2777,51 +2774,27 @@ void D_EndDirectRect (int x, int y, int width, int height)
|
|||
//==========================================================================
|
||||
|
||||
byte scantokey[128] =
|
||||
{
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0 , 27, '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
|
||||
'o', 'p', '[', ']', 13, K_CTRL, 'a', 's', // 1
|
||||
'o', 'p', '[', ']', 13 , K_CTRL,'a', 's', // 1
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
'\'', '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', '/', K_SHIFT,KP_MULTIPLY,
|
||||
K_ALT, ' ', K_CAPSLOCK,K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE,K_SCRLCK,KP_HOME,
|
||||
KP_UPARROW,KP_PGUP,KP_MINUS,KP_LEFTARROW,KP_5,KP_RIGHTARROW,KP_PLUS,KP_END, // 4
|
||||
KP_DOWNARROW,KP_PGDN,KP_INS,KP_DEL,0, 0, 0, K_F11,
|
||||
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
'\'' , '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', '/', K_SHIFT,'*',
|
||||
K_ALT,' ', 0 , K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE, 0 , K_HOME,
|
||||
K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+',K_END, //4
|
||||
K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11,
|
||||
K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
|
||||
};
|
||||
|
||||
byte extscantokey[128] =
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0 , 27, '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
|
||||
'o', 'p', '[', ']', KP_ENTER,K_CTRL,'a', 's', // 1
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
'\'', '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', KP_DIVIDE,K_SHIFT,'*',
|
||||
K_ALT, ' ', K_CAPSLOCK,K_F1,K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, KP_NUMLCK,0, K_HOME,
|
||||
K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+', K_END, // 4
|
||||
K_DOWNARROW,K_PGDN,K_INS,K_DEL, 0, 0, 0, K_F11,
|
||||
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=======
|
||||
MapKey
|
||||
|
@ -2831,21 +2804,13 @@ Map from windows to quake keynums
|
|||
*/
|
||||
int MapKey (int key)
|
||||
{
|
||||
int extended;
|
||||
|
||||
extended = (key >> 24) & 1;
|
||||
|
||||
key = (key>>16)&255;
|
||||
if (key > 127)
|
||||
return 0;
|
||||
|
||||
if (extended)
|
||||
return extscantokey[key];
|
||||
else
|
||||
return scantokey[key];
|
||||
}
|
||||
|
||||
|
||||
void AppActivate(BOOL fActive, BOOL minimize)
|
||||
/****************************************************************************
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load diff
165
source/vid_wgl.c
165
source/vid_wgl.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
vid_wgl.c
|
||||
gl_vidnt.c
|
||||
|
||||
Win32 WGL vid component
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
$Id$
|
||||
*/
|
||||
// gl_vidnt.c -- NT GL vid component
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
|
@ -36,12 +37,6 @@
|
|||
#include "glquake.h"
|
||||
#include "in_win.h"
|
||||
#include <commctrl.h>
|
||||
#include "screen.h"
|
||||
#include "keys.h"
|
||||
#include "qargs.h"
|
||||
#include "cmd.h"
|
||||
#include "qendian.h"
|
||||
#include "draw.h"
|
||||
|
||||
#define MAX_MODE_LIST 30
|
||||
#define VID_ROW_SIZE 3
|
||||
|
@ -121,6 +116,8 @@ HDC maindc;
|
|||
|
||||
glvert_t glv;
|
||||
|
||||
/* cvar_t gl_ztrick = {"gl_ztrick","1"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *gl_ztrick;
|
||||
|
||||
HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
|
||||
|
@ -158,15 +155,37 @@ qboolean gl_mtexable = false;
|
|||
|
||||
//====================================
|
||||
|
||||
/* cvar_t vid_mode = {"vid_mode","0", false};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_mode;
|
||||
// Note that 0 is MODE_WINDOWED
|
||||
/* cvar_t _vid_default_mode = {"_vid_default_mode","0", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_vid_default_mode;
|
||||
// Note that 3 is MODE_FULLSCREEN_DEFAULT
|
||||
/* cvar_t _vid_default_mode_win = {"_vid_default_mode_win","3", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_vid_default_mode_win;
|
||||
/* cvar_t vid_wait = {"vid_wait","0"};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_wait;
|
||||
/* cvar_t vid_nopageflip = {"vid_nopageflip","0", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_nopageflip;
|
||||
/* cvar_t _vid_wait_override = {"_vid_wait_override", "0", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_vid_wait_override;
|
||||
/* cvar_t vid_config_x = {"vid_config_x","800", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_config_x;
|
||||
/* cvar_t vid_config_y = {"vid_config_y","600", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_config_y;
|
||||
/* cvar_t vid_stretch_by_2 = {"vid_stretch_by_2","1", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *vid_stretch_by_2;
|
||||
/* cvar_t _windowed_mouse = {"_windowed_mouse","1", true};
|
||||
CVAR_FIXME */
|
||||
cvar_t *_windowed_mouse;
|
||||
|
||||
int window_center_x, window_center_y, window_x, window_y, window_width, window_height;
|
||||
|
@ -425,6 +444,8 @@ int VID_SetMode (int modenum, unsigned char *palette)
|
|||
// Set either the fullscreen or windowed mode
|
||||
if (modelist[modenum].type == MS_WINDOWED)
|
||||
{
|
||||
/* if (_windowed_mouse.value && key_dest == key_game)
|
||||
CVAR_FIXME */
|
||||
if (_windowed_mouse->value && key_dest == key_game)
|
||||
{
|
||||
stat = VID_SetWindowedMode(modenum);
|
||||
|
@ -685,6 +706,8 @@ GL_BeginRendering
|
|||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
/* extern cvar_t gl_clear;
|
||||
CVAR_FIXME */
|
||||
extern cvar_t *gl_clear;
|
||||
|
||||
*x = *y = 0;
|
||||
|
@ -706,6 +729,8 @@ void GL_EndRendering (void)
|
|||
// handle the mouse state when windowed if that's changed
|
||||
if (modestate == MS_WINDOWED)
|
||||
{
|
||||
/* if (!_windowed_mouse.value) {
|
||||
CVAR_FIXME */
|
||||
if (!_windowed_mouse->value) {
|
||||
if (windowed_mouse) {
|
||||
IN_DeactivateMouse ();
|
||||
|
@ -878,52 +903,50 @@ BOOL bSetupPixelFormat(HDC hDC)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
||||
byte scantokey[128] =
|
||||
{
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0 , 27, '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
|
||||
'o', 'p', '[', ']', 13, K_CTRL, 'a', 's', // 1
|
||||
'o', 'p', '[', ']', 13 , K_CTRL,'a', 's', // 1
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
'\'', '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', '/', K_SHIFT,KP_MULTIPLY,
|
||||
K_ALT, ' ', K_CAPSLOCK,K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE,K_SCRLCK,KP_HOME,
|
||||
KP_UPARROW,KP_PGUP,KP_MINUS,KP_LEFTARROW,KP_5,KP_RIGHTARROW,KP_PLUS,KP_END, // 4
|
||||
KP_DOWNARROW,KP_PGDN,KP_INS,KP_DEL,0, 0, 0, K_F11,
|
||||
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
'\'' , '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', '/', K_SHIFT,'*',
|
||||
K_ALT,' ', 0 , K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE , 0 , K_HOME,
|
||||
K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+',K_END, //4
|
||||
K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11,
|
||||
K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
|
||||
};
|
||||
|
||||
byte extscantokey[128] =
|
||||
{
|
||||
byte shiftscantokey[128] =
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0 , 27, '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
|
||||
'o', 'p', '[', ']', KP_ENTER,K_CTRL,'a', 's', // 1
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
'\'', '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', KP_DIVIDE,K_SHIFT,'*',
|
||||
K_ALT, ' ', K_CAPSLOCK,K_F1,K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, KP_NUMLCK,0, K_HOME,
|
||||
K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+', K_END, // 4
|
||||
K_DOWNARROW,K_PGDN,K_INS,K_DEL, 0, 0, 0, K_F11,
|
||||
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
0 , 27, '!', '@', '#', '$', '%', '^',
|
||||
'&', '*', '(', ')', '_', '+', K_BACKSPACE, 9, // 0
|
||||
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
|
||||
'O', 'P', '{', '}', 13 , K_CTRL,'A', 'S', // 1
|
||||
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
|
||||
'"' , '~', K_SHIFT,'|', 'Z', 'X', 'C', 'V', // 2
|
||||
'B', 'N', 'M', '<', '>', '?', K_SHIFT,'*',
|
||||
K_ALT,' ', 0 , K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE , 0 , K_HOME,
|
||||
K_UPARROW,K_PGUP,'_',K_LEFTARROW,'%',K_RIGHTARROW,'+',K_END, //4
|
||||
K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11,
|
||||
K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
@ -935,21 +958,14 @@ Map from windows to quake keynums
|
|||
*/
|
||||
int MapKey (int key)
|
||||
{
|
||||
int extended;
|
||||
|
||||
extended = (key >> 24) & 1;
|
||||
|
||||
key = (key>>16)&255;
|
||||
if (key > 127)
|
||||
return 0;
|
||||
|
||||
if (extended)
|
||||
return extscantokey[key];
|
||||
else
|
||||
if (scantokey[key] == 0)
|
||||
Con_DPrintf("key 0x%02x has no translation\n", key);
|
||||
return scantokey[key];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===================================================================
|
||||
|
||||
|
@ -958,7 +974,7 @@ MAIN WINDOW
|
|||
===================================================================
|
||||
*/
|
||||
|
||||
extern void CL_ClearStates ();
|
||||
extern qboolean keydown[256];
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -967,7 +983,15 @@ ClearAllStates
|
|||
*/
|
||||
void ClearAllStates (void)
|
||||
{
|
||||
CL_ClearStates ();
|
||||
int i;
|
||||
|
||||
// send an up event for each key, to make sure the server clears them all
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
if (keydown[i])
|
||||
Key_Event (i, false);
|
||||
}
|
||||
|
||||
Key_ClearStates ();
|
||||
IN_ClearStates ();
|
||||
}
|
||||
|
@ -1016,6 +1040,8 @@ void AppActivate(BOOL fActive, BOOL minimize)
|
|||
ShowWindow(mainwindow, SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
/* else if ((modestate == MS_WINDOWED) && _windowed_mouse.value && key_dest == key_game)
|
||||
CVAR_FIXME */
|
||||
else if ((modestate == MS_WINDOWED) && _windowed_mouse->value && key_dest == key_game)
|
||||
{
|
||||
IN_ActivateMouse ();
|
||||
|
@ -1034,6 +1060,8 @@ void AppActivate(BOOL fActive, BOOL minimize)
|
|||
vid_wassuspended = true;
|
||||
}
|
||||
}
|
||||
/* else if ((modestate == MS_WINDOWED) && _windowed_mouse.value)
|
||||
CVAR_FIXME */
|
||||
else if ((modestate == MS_WINDOWED) && _windowed_mouse->value)
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
|
@ -1612,19 +1640,38 @@ void VID_Init (unsigned char *palette)
|
|||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
|
||||
// Note that 0 is MODE_WINDOWED
|
||||
/* Cvar_RegisterVariable (&vid_mode);
|
||||
CVAR_FIXME */
|
||||
vid_mode = Cvar_Get("vid_mode", "0", CVAR_NONE, "None");
|
||||
_vid_default_mode = Cvar_Get("_vid_default_mode", "0", CVAR_ARCHIVE, "None");
|
||||
// Note that 3 is MODE_FULLSCREEN_DEFAULT
|
||||
_vid_default_mode_win = Cvar_Get("_vid_default_mode_win", "3", CVAR_ARCHIVE, "None");
|
||||
|
||||
/* Cvar_RegisterVariable (&vid_wait);
|
||||
CVAR_FIXME */
|
||||
vid_wait = Cvar_Get("vid_wait", "0", CVAR_NONE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_nopageflip);
|
||||
CVAR_FIXME */
|
||||
vid_nopageflip = Cvar_Get("vid_nopageflip", "0", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&_vid_wait_override);
|
||||
CVAR_FIXME */
|
||||
_vid_wait_override = Cvar_Get("_vid_wait_override", "0", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&_vid_default_mode);
|
||||
CVAR_FIXME */
|
||||
_vid_default_mode = Cvar_Get("_vid_default_mode", "0", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&_vid_default_mode_win);
|
||||
CVAR_FIXME */
|
||||
_vid_default_mode_win = Cvar_Get("_vid_default_mode_win", "3", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_config_x);
|
||||
CVAR_FIXME */
|
||||
vid_config_x = Cvar_Get("vid_config_x", "800", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_config_y);
|
||||
CVAR_FIXME */
|
||||
vid_config_y = Cvar_Get("vid_config_y", "600", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&vid_stretch_by_2);
|
||||
CVAR_FIXME */
|
||||
vid_stretch_by_2 = Cvar_Get("vid_stretch_by_2", "1", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&_windowed_mouse);
|
||||
CVAR_FIXME */
|
||||
_windowed_mouse = Cvar_Get("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
|
||||
/* Cvar_RegisterVariable (&gl_ztrick);
|
||||
CVAR_FIXME */
|
||||
gl_ztrick = Cvar_Get("gl_ztrick", "1", CVAR_NONE, "None");
|
||||
|
||||
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
|
||||
|
|
1111
source/vid_x11.c
1111
source/vid_x11.c
File diff suppressed because it is too large
Load diff
|
@ -30,14 +30,7 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "qtypes.h"
|
||||
#include "zone.h"
|
||||
#include "console.h"
|
||||
#include "cmd.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
#define DYNAMIC_SIZE 0x20000
|
||||
|
||||
|
|
Loading…
Reference in a new issue