nuq-glx almost builds. just some last problems with gl_part.c and gl_view.c

This commit is contained in:
Bill Currie 2000-08-25 06:42:29 +00:00
parent d6d6aff0aa
commit e2efff9dde
45 changed files with 3318 additions and 5321 deletions

View file

@ -962,7 +962,7 @@ if test "x$HAVE_X" = xyes; then
TARGETS="$TARGETS $PACKAGE-x11\$(EXEEXT)" TARGETS="$TARGETS $PACKAGE-x11\$(EXEEXT)"
CL_TARGETS="$CL_TARGETS X11" CL_TARGETS="$CL_TARGETS X11"
if test "x$HAVE_GLX" = xyes; then if test "x$HAVE_GLX" = xyes; then
# TARGETS="$TARGETS $PACKAGE-glx\$(EXEEXT)" TARGETS="$TARGETS $PACKAGE-glx\$(EXEEXT)"
CL_TARGETS="$CL_TARGETS GLX" CL_TARGETS="$CL_TARGETS GLX"
fi fi
fi fi

52
include/context_x11.h Normal file
View file

@ -0,0 +1,52 @@
/*
context_x11.h
(description)
Copyright (C) 1996-1997 Id Software, Inc.
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
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$
*/
#ifndef __CONTEXT_X11_H__
#define __CONTEXT_X11_H__
#include <qtypes.h>
#include <X11/Xlib.h>
void GetEvent( void );
extern Display *x_disp;
extern Window x_win;
extern qboolean doShm;
extern int x_shmeventtype;
extern qboolean oktodraw;
qboolean x11_add_event( int event, void (*event_handler)(XEvent *));
qboolean x11_del_event( int event, void (*event_handler)(XEvent *));
void x11_process_event( void );
void x11_process_events( void );
void x11_open_display( void );
void x11_close_display( void );
#endif // __CONTEXT_X11_H__

View file

@ -1,438 +0,0 @@
/*
gl_model.h
@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$
*/
#ifndef __MODEL__
#define __MODEL__
#include "modelgen.h"
#include "spritegn.h"
/*
d*_t structures are on-disk representations
m*_t structures are in-memory
*/
// entity effects
#define EF_BRIGHTFIELD 1
#define EF_MUZZLEFLASH 2
#define EF_BRIGHTLIGHT 4
#define EF_DIMLIGHT 8
/*
==============================================================================
BRUSH MODELS
==============================================================================
*/
//
// in memory representation
//
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct
{
vec3_t position;
} mvertex_t;
#define SIDE_FRONT 0
#define SIDE_BACK 1
#define SIDE_ON 2
// plane_t structure
// !!! if this is changed, it must be changed in asm_ia32.h too !!!
typedef struct mplane_s
{
vec3_t normal;
float dist;
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
byte pad[2];
} mplane_t;
typedef struct texture_s
{
char name[16];
unsigned width, height;
int gl_texturenum;
struct msurface_s *texturechain; // for gl_texsort drawing
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored
} texture_t;
#define SURF_PLANEBACK 2
#define SURF_DRAWSKY 4
#define SURF_DRAWSPRITE 8
#define SURF_DRAWTURB 0x10
#define SURF_DRAWTILED 0x20
#define SURF_DRAWBACKGROUND 0x40
#define SURF_UNDERWATER 0x80
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct
{
unsigned short v[2];
unsigned int cachededgeoffset;
} medge_t;
typedef struct
{
float vecs[2][4];
float mipadjust;
texture_t *texture;
int flags;
} mtexinfo_t;
#define VERTEXSIZE 7
typedef struct glpoly_s
{
struct glpoly_s *next;
struct glpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;
typedef struct msurface_s
{
int visframe; // should be drawn when node is crossed
mplane_t *plane;
int flags;
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
short texturemins[2];
short extents[2];
int light_s, light_t; // gl lightmap coordinates
glpoly_t *polys; // multiple if warped
struct msurface_s *texturechain;
mtexinfo_t *texinfo;
// lighting info
int dlightframe;
int dlightbits;
int lightmaptexturenum;
byte styles[MAXLIGHTMAPS];
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
qboolean cached_dlight; // true if dynamic light in cache
byte *samples; // [numstyles*surfsize]
} msurface_t;
typedef struct mnode_s
{
// common with leaf
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// node specific
mplane_t *plane;
struct mnode_s *children[2];
unsigned short firstsurface;
unsigned short numsurfaces;
} mnode_t;
typedef struct mleaf_s
{
// common with node
int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// leaf specific
byte *compressed_vis;
efrag_t *efrags;
msurface_t **firstmarksurface;
int nummarksurfaces;
int key; // BSP sequence number for leaf's contents
byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t;
// !!! if this is changed, it must be changed in asm_ia32.h too !!!
typedef struct
{
dclipnode_t *clipnodes;
mplane_t *planes;
int firstclipnode;
int lastclipnode;
vec3_t clip_mins;
vec3_t clip_maxs;
} hull_t;
/*
==============================================================================
SPRITE MODELS
==============================================================================
*/
// FIXME: shorten these?
typedef struct mspriteframe_s
{
int width;
int height;
float up, down, left, right;
int gl_texturenum;
} mspriteframe_t;
typedef struct
{
int numframes;
float *intervals;
mspriteframe_t *frames[1];
} mspritegroup_t;
typedef struct
{
spriteframetype_t type;
mspriteframe_t *frameptr;
} mspriteframedesc_t;
typedef struct
{
int type;
int maxwidth;
int maxheight;
int numframes;
float beamlength; // remove?
void *cachespot; // remove?
mspriteframedesc_t frames[1];
} msprite_t;
/*
==============================================================================
ALIAS MODELS
Alias models are position independent, so the cache manager can move them.
==============================================================================
*/
typedef struct
{
int firstpose;
int numposes;
float interval;
trivertx_t bboxmin;
trivertx_t bboxmax;
int frame;
char name[16];
} maliasframedesc_t;
typedef struct
{
trivertx_t bboxmin;
trivertx_t bboxmax;
int frame;
} maliasgroupframedesc_t;
typedef struct
{
int numframes;
int intervals;
maliasgroupframedesc_t frames[1];
} maliasgroup_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct mtriangle_s {
int facesfront;
int vertindex[3];
} mtriangle_t;
#define MAX_SKINS 32
typedef struct {
int ident;
int version;
vec3_t scale;
vec3_t scale_origin;
float boundingradius;
vec3_t eyeposition;
int numskins;
int skinwidth;
int skinheight;
int numverts;
int numtris;
int numframes;
synctype_t synctype;
int flags;
float size;
int numposes;
int poseverts;
int posedata; // numposes*poseverts trivert_t
int commands; // gl command list with embedded s/t
int gl_texturenum[MAX_SKINS][4];
int texels[MAX_SKINS]; // only for player skins
maliasframedesc_t frames[1]; // variable sized
} aliashdr_t;
#define MAXALIASVERTS 1024
#define MAXALIASFRAMES 256
#define MAXALIASTRIS 2048
extern aliashdr_t *pheader;
extern stvert_t stverts[MAXALIASVERTS];
extern mtriangle_t triangles[MAXALIASTRIS];
extern trivertx_t *poseverts[MAXALIASFRAMES];
//===================================================================
//
// Whole model
//
typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t;
#define EF_ROCKET 1 // leave a trail
#define EF_GRENADE 2 // leave a trail
#define EF_GIB 4 // leave a trail
#define EF_ROTATE 8 // rotate (bonus items)
#define EF_TRACER 16 // green split trail
#define EF_ZOMGIB 32 // small blood trail
#define EF_TRACER2 64 // orange split trail + rotate
#define EF_TRACER3 128 // purple trail
typedef struct model_s
{
char name[MAX_QPATH];
qboolean needload; // bmodels and sprites don't cache normally
modtype_t type;
int numframes;
synctype_t synctype;
int flags;
//
// volume occupied by the model graphics
//
vec3_t mins, maxs;
float radius;
//
// solid volume for clipping
//
qboolean clipbox;
vec3_t clipmins, clipmaxs;
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels;
int numplanes;
mplane_t *planes;
int numleafs; // number of visible leafs, not counting 0
mleaf_t *leafs;
int numvertexes;
mvertex_t *vertexes;
int numedges;
medge_t *edges;
int numnodes;
mnode_t *nodes;
int numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
int numclipnodes;
dclipnode_t *clipnodes;
int nummarksurfaces;
msurface_t **marksurfaces;
hull_t hulls[MAX_MAP_HULLS];
int numtextures;
texture_t **textures;
byte *visdata;
byte *lightdata;
char *entities;
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
} model_t;
//============================================================================
void Mod_Init (void);
void Mod_ClearAll (void);
model_t *Mod_ForName (char *name, qboolean crash);
void *Mod_Extradata (model_t *mod); // handles caching
void Mod_TouchModel (char *name);
mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
#endif // __MODEL__

View file

@ -26,11 +26,15 @@
$Id$ $Id$
*/ */
// disable data conversion warnings #ifndef __glquake_h
#define __glquake_h
#ifndef __GNUC__
// disable data conversion warnings
#pragma warning(disable : 4244) // MIPS #pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4136) // X86 #pragma warning(disable : 4136) // X86
#pragma warning(disable : 4051) // ALPHA #pragma warning(disable : 4051) // ALPHA
#endif
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
@ -39,6 +43,10 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#include "qtypes.h"
#include "model.h"
#include "d_iface.h"
void GL_BeginRendering (int *x, int *y, int *width, int *height); void GL_BeginRendering (int *x, int *y, int *width, int *height);
void GL_EndRendering (void); void GL_EndRendering (void);
@ -122,40 +130,6 @@ typedef struct surfcache_s
byte data[4]; // width*height elements byte data[4]; // width*height elements
} surfcache_t; } surfcache_t;
typedef struct
{
pixel_t *surfdat; // destination for generated surface
int rowbytes; // destination logical width in bytes
msurface_t *surf; // description for surface to generate
fixed8_t lightadj[MAXLIGHTMAPS];
// adjust for lightmap levels for dynamic lighting
texture_t *texture; // corrected for animating textures
int surfmip; // mipmapped ratio of surface texels / world pixels
int surfwidth; // in mipmapped texels
int surfheight; // in mipmapped texels
} drawsurf_t;
typedef enum {
pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2
} ptype_t;
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
typedef struct particle_s
{
// driver-usable fields
vec3_t org;
float color;
// drivers never touch the following fields
struct particle_s *next;
vec3_t vel;
float ramp;
float die;
ptype_t type;
} particle_t;
//==================================================== //====================================================
@ -258,8 +232,23 @@ typedef void (APIENTRY *lpMTexFUNC) (GLenum, GLfloat, GLfloat);
typedef void (APIENTRY *lpSelTexFUNC) (GLenum); typedef void (APIENTRY *lpSelTexFUNC) (GLenum);
extern lpMTexFUNC qglMTexCoord2fSGIS; extern lpMTexFUNC qglMTexCoord2fSGIS;
extern lpSelTexFUNC qglSelectTextureSGIS; extern lpSelTexFUNC qglSelectTextureSGIS;
extern lpMTexFUNC qglMTexCoord2f;
extern lpSelTexFUNC qglSelectTexture;
extern qboolean gl_mtexable; extern qboolean gl_mtexable;
void GL_DisableMultitexture(void); void GL_DisableMultitexture(void);
void GL_EnableMultitexture(void); void GL_EnableMultitexture(void);
void GL_BuildLightmaps (void);
void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha) ;
void GL_Set2D (void);
void GL_CheckGamma (unsigned char *pal);
void EmitWaterPolys (msurface_t *fa);
void EmitSkyPolys (msurface_t *fa);
void EmitBothSkyLayers (msurface_t *fa);
void R_DrawSkyChain (msurface_t *s);
qboolean R_CullBox (vec3_t mins, vec3_t maxs);
void R_RotateForEntity (entity_t *e);
#endif // __glquake_h

View file

@ -26,6 +26,11 @@
$Id$ $Id$
*/ */
#ifndef __input_h
#define __input_h
#include "client.h"
#include "cvar.h"
void IN_Init (void); void IN_Init (void);
@ -40,3 +45,9 @@ void IN_Move (usercmd_t *cmd);
void IN_ClearStates (void); void IN_ClearStates (void);
// restores all button and position states to defaults // restores all button and position states to defaults
void IN_SendKeyEvents (void);
extern cvar_t *_windowed_mouse;
#endif // __input_h

View file

@ -1,7 +1,7 @@
/* /*
keys.h keys.h
@description@ Key definitions and prototypes
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -26,109 +26,140 @@
$Id$ $Id$
*/ */
#ifndef __keys_h
#define __keys_h #ifndef _KEYS_H
#define _KEYS_H
#include "quakeio.h" #include "quakeio.h"
#include "qtypes.h" #include "qtypes.h"
//
// these are the key numbers that should be passed to Key_Event // these are the key numbers that should be passed to Key_Event
//
#define K_TAB 9 typedef enum {
#define K_ENTER 13 K_TAB = 9,
#define K_ESCAPE 27 K_ENTER = 13,
#define K_SPACE 32 K_ESCAPE = 27,
K_SPACE = 32,
// normal keys should be passed as lowercased ascii // normal keys should be passed as lowercased ascii
#define K_BACKSPACE 127 K_BACKSPACE = 127,
#define K_UPARROW 128
#define K_DOWNARROW 129
#define K_LEFTARROW 130
#define K_RIGHTARROW 131
#define K_ALT 132 K_CAPSLOCK,
#define K_CTRL 133 K_PRNTSCR,
#define K_SHIFT 134 K_SCRLCK,
#define K_F1 135 K_PAUSE,
#define K_F2 136
#define K_F3 137
#define K_F4 138
#define K_F5 139
#define K_F6 140
#define K_F7 141
#define K_F8 142
#define K_F9 143
#define K_F10 144
#define K_F11 145
#define K_F12 146
#define K_INS 147
#define K_DEL 148
#define K_PGDN 149
#define K_PGUP 150
#define K_HOME 151
#define K_END 152
#define K_PAUSE 255 K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_ALT,
K_CTRL,
K_SHIFT,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
//
// Keypad stuff..
//
KP_NUMLCK,
KP_DIVIDE,
KP_MULTIPLY,
KP_HOME,
KP_UPARROW,
KP_PGUP,
KP_MINUS,
KP_LEFTARROW,
KP_5,
KP_RIGHTARROW,
KP_PLUS,
KP_END,
KP_DOWNARROW,
KP_PGDN,
KP_INS,
KP_DEL,
KP_ENTER,
// //
// mouse buttons generate virtual keys // mouse buttons generate virtual keys
// //
#define K_MOUSE1 200 K_MOUSE1 = 200,
#define K_MOUSE2 201 K_MOUSE2,
#define K_MOUSE3 202 K_MOUSE3,
// //
// joystick buttons // joystick buttons
// //
#define K_JOY1 203 K_JOY1,
#define K_JOY2 204 K_JOY2,
#define K_JOY3 205 K_JOY3,
#define K_JOY4 206 K_JOY4,
// //
// aux keys are for multi-buttoned joysticks to generate so they can use // aux keys are for multi-buttoned joysticks to generate so they can use
// the normal binding process // the normal binding process
// //
#define K_AUX1 207 K_AUX1,
#define K_AUX2 208 K_AUX2,
#define K_AUX3 209 K_AUX3,
#define K_AUX4 210 K_AUX4,
#define K_AUX5 211 K_AUX5,
#define K_AUX6 212 K_AUX6,
#define K_AUX7 213 K_AUX7,
#define K_AUX8 214 K_AUX8,
#define K_AUX9 215 K_AUX9,
#define K_AUX10 216 K_AUX10,
#define K_AUX11 217 K_AUX11,
#define K_AUX12 218 K_AUX12,
#define K_AUX13 219 K_AUX13,
#define K_AUX14 220 K_AUX14,
#define K_AUX15 221 K_AUX15,
#define K_AUX16 222 K_AUX16,
#define K_AUX17 223 K_AUX17,
#define K_AUX18 224 K_AUX18,
#define K_AUX19 225 K_AUX19,
#define K_AUX20 226 K_AUX20,
#define K_AUX21 227 K_AUX21,
#define K_AUX22 228 K_AUX22,
#define K_AUX23 229 K_AUX23,
#define K_AUX24 230 K_AUX24,
#define K_AUX25 231 K_AUX25,
#define K_AUX26 232 K_AUX26,
#define K_AUX27 233 K_AUX27,
#define K_AUX28 234 K_AUX28,
#define K_AUX29 235 K_AUX29,
#define K_AUX30 236 K_AUX30,
#define K_AUX31 237 K_AUX31,
#define K_AUX32 238 K_AUX32,
// JACK: Intellimouse(c) Mouse Wheel Support // JACK: Intellimouse(c) Mouse Wheel Support
#define K_MWHEELUP 239 K_MWHEELUP,
#define K_MWHEELDOWN 240 K_MWHEELDOWN
} keynum_t;
typedef enum {key_game, key_console, key_message, key_menu} keydest_t; typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
@ -139,10 +170,14 @@ extern int key_repeats[256];
extern int key_count; // incremented every key event extern int key_count; // incremented every key event
extern int key_lastpress; extern int key_lastpress;
extern char chat_buffer[];
extern int chat_bufferlen;
extern qboolean chat_team;
void Key_Event (int key, qboolean down); void Key_Event (int key, qboolean down);
void Key_Init (void); void Key_Init (void);
void Key_WriteBindings (FILE *f); void Key_WriteBindings (FILE *f);
void Key_SetBinding (int keynum, char *binding); void Key_SetBinding (int keynum, char *binding);
void Key_ClearStates (void); void Key_ClearStates (void);
#endif // __keys_h #endif // _KEYS_H

View file

@ -72,6 +72,7 @@ int Q_log2(int val);
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
void FloorDivMod (double numer, double denom, int *quotient, void FloorDivMod (double numer, double denom, int *quotient,
int *rem); int *rem);

View file

@ -1,7 +1,7 @@
/* /*
model.h model.h
@description@ (description)
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -26,9 +26,8 @@
$Id$ $Id$
*/ */
#ifndef _MODEL_H
#ifndef __model_h #define _MODEL_H
#define __model_h
#include "qtypes.h" #include "qtypes.h"
#include "render.h" #include "render.h"
@ -44,6 +43,17 @@ m*_t structures are in-memory
*/ */
// entity effects
#define EF_BRIGHTFIELD 1
#define EF_MUZZLEFLASH 2
#define EF_BRIGHTLIGHT 4
#define EF_DIMLIGHT 8
#define EF_FLAG1 16
#define EF_FLAG2 32
#define EF_BLUE 64
#define EF_RED 128
/* /*
============================================================================== ==============================================================================
@ -66,9 +76,8 @@ typedef struct
#define SIDE_BACK 1 #define SIDE_BACK 1
#define SIDE_ON 2 #define SIDE_ON 2
// plane_t structure // plane_t structure
// !!! if this is changed, it must be changed in asm_ia32.h too !!! // !!! if this is changed, it must be changed in asm_i386.h too !!!
typedef struct mplane_s typedef struct mplane_s
{ {
vec3_t normal; vec3_t normal;
@ -82,6 +91,8 @@ typedef struct texture_s
{ {
char name[16]; char name[16];
unsigned width, height; unsigned width, height;
int gl_texturenum;
struct msurface_s *texturechain; // for gl_texsort drawing
int anim_total; // total tenths in sequence ( 0 = no) int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence struct texture_s *anim_next; // in the animation sequence
@ -96,6 +107,8 @@ typedef struct texture_s
#define SURF_DRAWTURB 0x10 #define SURF_DRAWTURB 0x10
#define SURF_DRAWTILED 0x20 #define SURF_DRAWTILED 0x20
#define SURF_DRAWBACKGROUND 0x40 #define SURF_DRAWBACKGROUND 0x40
#define SURF_UNDERWATER 0x80
#define SURF_DONTWARP 0x100
// !!! if this is changed, it must be changed in asm_draw.h too !!! // !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct typedef struct
@ -112,29 +125,47 @@ typedef struct
int flags; int flags;
} mtexinfo_t; } mtexinfo_t;
#define VERTEXSIZE 7
typedef struct glpoly_s
{
struct glpoly_s *next;
struct glpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;
typedef struct msurface_s typedef struct msurface_s
{ {
int visframe; // should be drawn when node is crossed int visframe; // should be drawn when node is crossed
int dlightframe;
int dlightbits;
mplane_t *plane; mplane_t *plane;
int flags; int flags;
int firstedge; // look up in model->surfedges[], negative numbers int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges int numedges; // are backwards edges
// surface generation data
struct surfcache_s *cachespots[MIPLEVELS]; struct surfcache_s *cachespots[MIPLEVELS];
short texturemins[2]; short texturemins[2];
short extents[2]; short extents[2];
int light_s, light_t; // gl lightmap coordinates
glpoly_t *polys; // multiple if warped
struct msurface_s *texturechain;
mtexinfo_t *texinfo; mtexinfo_t *texinfo;
// lighting info // lighting info
int dlightframe;
int dlightbits;
int lightmaptexturenum;
byte styles[MAXLIGHTMAPS]; byte styles[MAXLIGHTMAPS];
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
qboolean cached_dlight; // true if dynamic light in cache
byte *samples; // [numstyles*surfsize] byte *samples; // [numstyles*surfsize]
} msurface_t; } msurface_t;
@ -144,7 +175,7 @@ typedef struct mnode_s
int contents; // 0, to differentiate from leafs int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling float minmaxs[6]; // for bounding box culling
struct mnode_s *parent; struct mnode_s *parent;
@ -156,15 +187,13 @@ typedef struct mnode_s
unsigned short numsurfaces; unsigned short numsurfaces;
} mnode_t; } mnode_t;
typedef struct mleaf_s typedef struct mleaf_s
{ {
// common with node // common with node
int contents; // wil be a negative contents number int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling float minmaxs[6]; // for bounding box culling
struct mnode_s *parent; struct mnode_s *parent;
@ -178,7 +207,7 @@ typedef struct mleaf_s
byte ambient_sound_level[NUM_AMBIENTS]; byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t; } mleaf_t;
// !!! if this is changed, it must be changed in asm_ia32.h too !!! // !!! if this is changed, it must be changed in asm_i386.h too !!!
typedef struct typedef struct
{ {
dclipnode_t *clipnodes; dclipnode_t *clipnodes;
@ -197,15 +226,14 @@ SPRITE MODELS
============================================================================== ==============================================================================
*/ */
// FIXME: shorten these? // FIXME: shorten these?
typedef struct mspriteframe_s typedef struct mspriteframe_s
{ {
int width; int width;
int height; int height;
void *pcachespot; // remove?
float up, down, left, right; float up, down, left, right;
byte pixels[4]; byte pixels[4];
int gl_texturenum;
} mspriteframe_t; } mspriteframe_t;
typedef struct typedef struct
@ -245,6 +273,9 @@ Alias models are position independent, so the cache manager can move them.
typedef struct typedef struct
{ {
aliasframetype_t type; aliasframetype_t type;
int firstpose;
int numposes;
float interval;
trivertx_t bboxmin; trivertx_t bboxmin;
trivertx_t bboxmax; trivertx_t bboxmax;
int frame; int frame;
@ -254,7 +285,6 @@ typedef struct
typedef struct typedef struct
{ {
aliasskintype_t type; aliasskintype_t type;
void *pcachespot;
int skin; int skin;
} maliasskindesc_t; } maliasskindesc_t;
@ -285,14 +315,47 @@ typedef struct mtriangle_s {
int vertindex[3]; int vertindex[3];
} mtriangle_t; } mtriangle_t;
#define MAX_SKINS 32
typedef struct { typedef struct {
int model; int ident;
int stverts; int version;
int skindesc; vec3_t scale;
int triangles; vec3_t scale_origin;
float boundingradius;
vec3_t eyeposition;
int numskins;
int skinwidth;
int skinheight;
int numverts;
int numtris;
int numframes;
synctype_t synctype;
int flags;
float size;
int numposes;
int poseverts;
int posedata; // numposes*poseverts trivert_t
int commands; // gl command list with embedded s/t
int gl_texturenum[MAX_SKINS][4];
int gl_fb_texturenum[MAX_SKINS][4];
int model;
int stverts;
int skindesc;
int triangles;
int texels[MAX_SKINS]; // only for player skins
maliasframedesc_t frames[1]; maliasframedesc_t frames[1];
} aliashdr_t; } aliashdr_t;
#define MAXALIASVERTS 1024
#define MAXALIASFRAMES 256
#define MAXALIASTRIS 2048
extern aliashdr_t *pheader;
extern stvert_t stverts[MAXALIASVERTS];
extern mtriangle_t triangles[MAXALIASTRIS];
extern trivertx_t *poseverts[MAXALIASFRAMES];
//=================================================================== //===================================================================
// //
@ -314,6 +377,7 @@ typedef struct model_s
{ {
char name[MAX_QPATH]; char name[MAX_QPATH];
qboolean needload; // bmodels and sprites don't cache normally qboolean needload; // bmodels and sprites don't cache normally
qboolean hasfullbrights;
modtype_t type; modtype_t type;
int numframes; int numframes;
@ -322,11 +386,17 @@ typedef struct model_s
int flags; int flags;
// //
// volume occupied by the model // volume occupied by the model graphics
// //
vec3_t mins, maxs; vec3_t mins, maxs;
float radius; float radius;
//
// solid volume for clipping
//
qboolean clipbox;
vec3_t clipmins, clipmaxs;
// //
// brush model // brush model
// //
@ -374,6 +444,9 @@ typedef struct model_s
byte *lightdata; byte *lightdata;
char *entities; char *entities;
unsigned checksum;
unsigned checksum2;
// //
// additional model data // additional model data
// //
@ -392,4 +465,4 @@ void Mod_TouchModel (char *name);
mleaf_t *Mod_PointInLeaf (float *p, model_t *model); mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model); byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
#endif // __model_h #endif // _MODEL_H

View file

@ -233,7 +233,7 @@ void R_ZDrawSubmodelPolys (model_t *clmodel);
// Alias models // Alias models
//========================================================= //=========================================================
#define MAXALIASVERTS 2000 // TODO: tune this #define MAXALIASVERTS 1024 // was 2000, but gl has 1024
#define ALIAS_Z_CLIP_PLANE 5 #define ALIAS_Z_CLIP_PLANE 5
extern int numverts; extern int numverts;

View file

@ -32,14 +32,12 @@
#include "d_iface.h" #include "d_iface.h"
#ifndef GLQUAKE #ifndef GLQUAKE
// r_shared.h: general refresh-related stuff shared between the refresh and the // r_shared.h: general refresh-related stuff shared between the refresh and the
// driver // driver
// FIXME: clean up and move into d_iface.h // FIXME: clean up and move into d_iface.h
#ifndef _R_SHARED_H_
#define _R_SHARED_H_
#define MAXVERTS 16 // max points in a surface polygon #define MAXVERTS 16 // max points in a surface polygon
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
// polygon (while processing) // polygon (while processing)
@ -166,8 +164,6 @@ typedef struct edge_s
medge_t *owner; medge_t *owner;
} edge_t; } edge_t;
#endif // _R_SHARED_H_
#endif // GLQUAKE #endif // GLQUAKE
#endif // __r_shared_h #endif // __r_shared_h

View file

@ -170,4 +170,11 @@ void D_DeleteSurfaceCache (void);
void D_InitCaches (void *buffer, int size); void D_InitCaches (void *buffer, int size);
void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj); void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
void R_DrawBrushModel (entity_t *e);
void R_DrawWorld (void);
void R_RenderDlights (void);
void R_DrawWaterSurfaces (void);
struct msurface_s;
void R_RenderBrushPoly (struct msurface_s *fa);
#endif // __render_h #endif // __render_h

View file

@ -54,7 +54,7 @@ void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
// //
void Sys_DebugLog(char *file, char *fmt, ...); void Sys_DebugLog(char *file, char *fmt, ...);
void Sys_Error (char *error, ...); void __attribute__((noreturn)) Sys_Error (char *error, ...);
// an error will cause the entire program to exit // an error will cause the entire program to exit
void Sys_Printf (char *fmt, ...); void Sys_Printf (char *fmt, ...);
@ -70,9 +70,6 @@ void Sys_Sleep (void);
// called to yield for a little bit so as // called to yield for a little bit so as
// not to hog cpu when paused or debugging // not to hog cpu when paused or debugging
void Sys_SendKeyEvents (void);
// Perform Key_Event () callbacks until the input que is empty
void Sys_LowFPPrecision (void); void Sys_LowFPPrecision (void);
void Sys_HighFPPrecision (void); void Sys_HighFPPrecision (void);
void Sys_SetFPCW (void); void Sys_SetFPCW (void);

View file

@ -68,6 +68,8 @@ extern unsigned d_8to24table[256];
extern void (*vid_menudrawfn)(void); extern void (*vid_menudrawfn)(void);
extern void (*vid_menukeyfn)(int key); extern void (*vid_menukeyfn)(int key);
qboolean VID_Is8bit(void);
void VID_SetPalette (unsigned char *palette); void VID_SetPalette (unsigned char *palette);
// called at startup and after any gamma correction // called at startup and after any gamma correction

View file

@ -44,5 +44,6 @@ void V_Init (void);
void V_RenderView (void); void V_RenderView (void);
float V_CalcRoll (vec3_t angles, vec3_t velocity); float V_CalcRoll (vec3_t angles, vec3_t velocity);
void V_UpdatePalette (void); void V_UpdatePalette (void);
void V_CalcBlend (void);
#endif // __cvar_h #endif // __cvar_h

View file

@ -173,9 +173,9 @@ nuq_svga_DEPENDENCIES=libqfsys.a libqfsnd.a libqfcd.a libqfnet.a
# #
# ... X11 # ... X11
# #
x11_SOURCES= vid_x11.c dga_check.c x11_SOURCES= in_x11.c context_x11.c dga_check.c
nuq_x11_SOURCES= $(combined_SOURCES) $(soft_SOURCES) $(x11_SOURCES) nuq_x11_SOURCES= $(combined_SOURCES) $(soft_SOURCES) $(x11_SOURCES) vid_x11.c
nuq_x11_LDADD= $(client_LIBS) $(X_PRE_LIBS) $(VIDMODE_LIBS) $(DGA_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) $(X_SHM_LIB) nuq_x11_LDADD= $(client_LIBS) $(X_PRE_LIBS) $(VIDMODE_LIBS) $(DGA_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) $(X_SHM_LIB)
nuq_x11_DEPENDENCIES=libqfsys.a libqfsnd.a libqfcd.a libqfnet.a nuq_x11_DEPENDENCIES=libqfsys.a libqfsnd.a libqfcd.a libqfnet.a
@ -200,7 +200,7 @@ nuq_3dfx_DEPENDENCIES=libqfsys.a libqfsnd.a libqfcd.a libqfnet.a
# #
# ... OpenGL in X Window # ... OpenGL in X Window
# #
glx_SOURCES= vid_glx.c in_x11.c context_x11.c dga_check.c glx_SOURCES= vid_glx.c $(x11_SOURCES)
nuq_glx_SOURCES= $(combined_SOURCES) $(ogl_SOURCES) $(glx_SOURCES) nuq_glx_SOURCES= $(combined_SOURCES) $(ogl_SOURCES) $(glx_SOURCES)
nuq_glx_LDADD= $(client_LIBS) $(GLX_LIBS) $(X_PRE_LIBS) $(VIDMODE_LIBS) $(DGA_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) $(DL_LIBS) nuq_glx_LDADD= $(client_LIBS) $(GLX_LIBS) $(X_PRE_LIBS) $(VIDMODE_LIBS) $(DGA_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS) $(DL_LIBS)

View file

@ -45,6 +45,7 @@
#include "qargs.h" #include "qargs.h"
#include "client.h" #include "client.h"
#include "console.h" #include "console.h"
#include "input.h"
#include "screen.h" #include "screen.h"
#include "keys.h" #include "keys.h"
@ -657,7 +658,7 @@ void Con_NotifyBox (char *text)
{ {
t1 = Sys_DoubleTime (); t1 = Sys_DoubleTime ();
SCR_UpdateScreen (); SCR_UpdateScreen ();
Sys_SendKeyEvents (); IN_SendKeyEvents ();
t2 = Sys_DoubleTime (); t2 = Sys_DoubleTime ();
realtime += t2-t1; // make the cursor blink realtime += t2-t1; // make the cursor blink
} while (key_count < 0); } while (key_count < 0);

169
source/context_x11.c Normal file
View file

@ -0,0 +1,169 @@
/*
context_x11.c
general x11 context layer
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 2000 Zephaniah E. Hull <warp@whitestar.soark.net>
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
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$
*/
#include <config.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/extensions/XShm.h>
#include <errno.h>
#include <context_x11.h>
#include <qtypes.h>
#include <vid.h>
#include <sys.h>
static void (*event_handlers[LASTEvent]) (XEvent *);
qboolean oktodraw = false;
int x_shmeventtype;
static int x_disp_ref_count = 0;
Display *x_disp = NULL;
qboolean
x11_add_event(int event, void (*event_handler)(XEvent *))
{
if (event >= LASTEvent) {
printf("event: %d, LASTEvent: %d\n", event, LASTEvent);
return false;
}
if (event_handlers[event] != NULL)
return false;
event_handlers[event] = event_handler;
return true;
}
qboolean
x11_del_event(int event, void (*event_handler)(XEvent *))
{
if (event >= LASTEvent)
return false;
if (event_handlers[event] != event_handler)
return false;
event_handlers[event] = NULL;
return true;
}
void
x11_process_event( void )
{
XEvent x_event;
XNextEvent(x_disp, &x_event);
if ( x_event.type >= LASTEvent ) {
// FIXME: KLUGE!!!!!!
if (x_event.type == x_shmeventtype)
oktodraw = 1;
return;
}
if (event_handlers[x_event.type])
event_handlers[x_event.type](&x_event);
}
void
x11_process_events(void)
{
/* Get events from X server. */
while ( XPending( x_disp )) {
x11_process_event();
}
}
// ========================================================================
// Tragic death handler
// ========================================================================
static void
TragicDeath(int sig)
{
printf("Received signal %d, exiting...\n", sig);
Sys_Quit();
exit(sig);
//XCloseDisplay(x_disp);
//VID_Shutdown();
//Sys_Error("This death brought to you by the number %d\n", signal_num);
}
void
x11_open_display( void )
{
if ( !x_disp ) {
x_disp = XOpenDisplay( NULL );
if ( !x_disp ) {
Sys_Error("x11_open_display: Could not open display [%s]\n", XDisplayName( NULL ));
}
// catch signals
signal(SIGHUP, TragicDeath);
signal(SIGINT, TragicDeath);
signal(SIGQUIT, TragicDeath);
signal(SIGILL, TragicDeath);
signal(SIGTRAP, TragicDeath);
signal(SIGIOT, TragicDeath);
signal(SIGBUS, TragicDeath);
/* signal(SIGFPE, TragicDeath); */
signal(SIGSEGV, TragicDeath);
signal(SIGTERM, TragicDeath);
// for debugging only
XSynchronize( x_disp, True );
x_disp_ref_count=1;
} else {
x_disp_ref_count++;
}
}
void
x11_close_display( void )
{
if (!--x_disp_ref_count) {
XCloseDisplay( x_disp );
x_disp = NULL;
}
}

View file

@ -30,6 +30,17 @@
# include "config.h" # include "config.h"
#endif #endif
#include <string.h>
#include <sys/utsname.h>
#include "host.h"
#include "glquake.h"
#include "sbar.h"
#include "vid.h"
#include "quakefs.h"
#include "wad.h"
#include "sys.h"
#include "console.h"
#define GL_COLOR_INDEX8_EXT 0x80E5 #define GL_COLOR_INDEX8_EXT 0x80E5
@ -39,6 +50,8 @@ cvar_t *gl_nobind;
cvar_t *gl_max_size; cvar_t *gl_max_size;
cvar_t *gl_picmip; cvar_t *gl_picmip;
int GL_LoadPicTexture (qpic_t *pic);
byte *draw_chars; // 8*8 graphic characters byte *draw_chars; // 8*8 graphic characters
qpic_t *draw_disc; qpic_t *draw_disc;
qpic_t *draw_backtile; qpic_t *draw_backtile;
@ -118,7 +131,6 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y)
{ {
int i, j; int i, j;
int best, best2; int best, best2;
int bestx;
int texnum; int texnum;
for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++) for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++)
@ -344,7 +356,7 @@ void Draw_TextureMode_f (void)
for (i=0 ; i< 6 ; i++) for (i=0 ; i< 6 ; i++)
{ {
if (!Q_strcasecmp (modes[i].name, Cmd_Argv(1) ) ) if (!strcasecmp (modes[i].name, Cmd_Argv(1) ) )
break; break;
} }
if (i == 6) if (i == 6)
@ -377,13 +389,13 @@ void Draw_Init (void)
{ {
int i; int i;
qpic_t *cb; qpic_t *cb;
byte *dest, *src; byte *dest;
int x, y; int x, y;
char ver[40]; char ver[40];
glpic_t *gl; glpic_t *gl;
int start; int start;
byte *ncdata; byte *ncdata;
int f, fstep; struct utsname utsname;
gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_NONE, "None"); gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_NONE, "None");
@ -391,7 +403,7 @@ void Draw_Init (void)
gl_picmip = Cvar_Get("gl_picmip", "0", CVAR_NONE, "None"); gl_picmip = Cvar_Get("gl_picmip", "0", CVAR_NONE, "None");
// 3dfx can only handle 256 wide textures // 3dfx can only handle 256 wide textures
if (!Q_strncasecmp ((char *)gl_renderer, "3dfx",4) || if (!strncasecmp ((char *)gl_renderer, "3dfx",4) ||
strstr((char *)gl_renderer, "Glide")) strstr((char *)gl_renderer, "Glide"))
Cvar_Set(gl_max_size, "256"); Cvar_Set(gl_max_size, "256");
@ -417,12 +429,10 @@ void Draw_Init (void)
SwapPic (cb); SwapPic (cb);
// hack the version number directly into the pic // hack the version number directly into the pic
#if defined(__linux__) uname(&utsname);
sprintf (ver, "(Linux %2.2f, gl %4.2f) %4.2f", (float)LINUX_VERSION, (float)GLQUAKE_VERSION, (float)VERSION); sprintf (ver, "(%s %s, gl %x) %s", utsname.sysname, utsname.release, GL_VERSION, VERSION);
#else
sprintf (ver, "(gl %4.2f) %4.2f", (float)GLQUAKE_VERSION, (float)VERSION);
#endif
dest = cb->data + 320*186 + 320 - 11 - 8*strlen(ver); dest = cb->data + 320*186 + 320 - 11 - 8*strlen(ver);
y = strlen(ver); y = strlen(ver);
for (x=0 ; x<y ; x++) for (x=0 ; x<y ; x++)
Draw_CharToConback (ver[x], dest+(x<<3)); Draw_CharToConback (ver[x], dest+(x<<3));
@ -504,10 +514,6 @@ smoothly scrolled off.
*/ */
void Draw_Character (int x, int y, int num) void Draw_Character (int x, int y, int num)
{ {
byte *dest;
byte *source;
unsigned short *pusdest;
int drawline;
int row, col; int row, col;
float frow, fcol, size; float frow, fcol, size;
@ -575,9 +581,6 @@ Draw_AlphaPic
*/ */
void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha) void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
{ {
byte *dest, *source;
unsigned short *pusdest;
int v, u;
glpic_t *gl; glpic_t *gl;
if (scrap_dirty) if (scrap_dirty)
@ -612,9 +615,6 @@ Draw_Pic
*/ */
void Draw_Pic (int x, int y, qpic_t *pic) void Draw_Pic (int x, int y, qpic_t *pic)
{ {
byte *dest, *source;
unsigned short *pusdest;
int v, u;
glpic_t *gl; glpic_t *gl;
if (scrap_dirty) if (scrap_dirty)
@ -642,10 +642,6 @@ Draw_TransPic
*/ */
void Draw_TransPic (int x, int y, qpic_t *pic) void Draw_TransPic (int x, int y, qpic_t *pic)
{ {
byte *dest, *source, tbyte;
unsigned short *pusdest;
int v, u;
if (x < 0 || (unsigned)(x + pic->width) > vid.width || y < 0 || if (x < 0 || (unsigned)(x + pic->width) > vid.width || y < 0 ||
(unsigned)(y + pic->height) > vid.height) (unsigned)(y + pic->height) > vid.height)
{ {
@ -1098,8 +1094,6 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
{ {
int i, s; int i, s;
qboolean noalpha; qboolean noalpha;
int p;
static unsigned j;
int samples; int samples;
static unsigned char scaled[1024*512]; // [512*256]; static unsigned char scaled[1024*512]; // [512*256];
int scaled_width, scaled_height; int scaled_width, scaled_height;
@ -1241,8 +1235,7 @@ GL_LoadTexture
*/ */
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha) int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha)
{ {
qboolean noalpha; int i;
int i, p, s;
gltexture_t *glt; gltexture_t *glt;
// see if the texture is allready present // see if the texture is allready present

View file

@ -30,6 +30,11 @@
# include "config.h" # include "config.h"
#endif #endif
#include <string.h>
#include "quakefs.h"
#include "console.h"
#include "model.h"
/* /*
================================================================= =================================================================
@ -209,14 +214,8 @@ void BuildTris (void)
{ {
int i, j, k; int i, j, k;
int startv; int startv;
mtriangle_t *last, *check;
int m1, m2;
int striplength;
trivertx_t *v;
mtriangle_t *tv;
float s, t; float s, t;
int index; int len, bestlen, besttype=-1;
int len, bestlen, besttype;
int bestverts[1024]; int bestverts[1024];
int besttris[1024]; int besttris[1024];
int type; int type;
@ -300,13 +299,10 @@ GL_MakeAliasModelDisplayLists
void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr) void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
{ {
int i, j; int i, j;
maliasgroup_t *paliasgroup;
int *cmds; int *cmds;
trivertx_t *verts; trivertx_t *verts;
char cache[MAX_QPATH], fullpath[MAX_OSPATH], *c; char cache[MAX_QPATH], fullpath[MAX_OSPATH];
FILE *f; FILE *f;
int len;
byte *data;
aliasmodel = m; aliasmodel = m;
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m); paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);

854
source/gl_part.c Normal file
View file

@ -0,0 +1,854 @@
/*
r_part.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 "qargs.h"
#include "d_iface.h"
#include "bspfile.h" // needed by: glquake.h
#include "vid.h"
#include "sys.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 <stdlib.h>
#define MAX_PARTICLES 2048 // default max # of particles at one
// time
#define MAX_FIRES 128 // rocket flames
#define ABSOLUTE_MIN_PARTICLES 512 // no fewer than this no matter what's
// on the command line
int ramp1[8] = {0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61};
int ramp2[8] = {0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66};
int ramp3[8] = {0x6d, 0x6b, 6, 5, 4, 3};
particle_t *active_particles, *free_particles;
particle_t *particles;
int r_numparticles;
vec3_t r_pright, r_pup, r_ppn;
fire_t r_fires[MAX_FIRES];
extern cvar_t *gl_fires;
extern qboolean lighthalf;
/*
===============
R_InitParticles
===============
*/
void R_InitParticles (void)
{
int i;
i = COM_CheckParm ("-particles");
if (i)
{
r_numparticles = (int)(atoi(com_argv[i+1]));
if (r_numparticles < ABSOLUTE_MIN_PARTICLES)
r_numparticles = ABSOLUTE_MIN_PARTICLES;
}
else
{
r_numparticles = MAX_PARTICLES;
}
particles = (particle_t *)
Hunk_AllocName (r_numparticles * sizeof(particle_t), "particles");
}
/*
===============
R_ClearParticles
===============
*/
void R_ClearParticles (void)
{
int i;
free_particles = &particles[0];
active_particles = NULL;
for (i=0 ;i<r_numparticles ; i++)
particles[i].next = &particles[i+1];
particles[r_numparticles-1].next = NULL;
}
void R_ReadPointFile_f (void)
{
FILE *f;
vec3_t org;
int r;
int c;
particle_t *p;
char name[MAX_OSPATH];
// FIXME sprintf (name,"maps/%s.pts", sv.name);
COM_FOpenFile (name, &f);
if (!f)
{
Con_Printf ("couldn't open %s\n", name);
return;
}
Con_Printf ("Reading %s...\n", name);
c = 0;
for ( ;; )
{
r = fscanf (f,"%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3)
break;
c++;
if (!free_particles)
{
Con_Printf ("Not enough free particles\n");
break;
}
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = 99999;
p->color = (-c)&15;
p->type = pt_static;
VectorCopy (vec3_origin, p->vel);
VectorCopy (org, p->org);
}
fclose (f);
Con_Printf ("%i points read\n", c);
}
/*
===============
R_ParticleExplosion
===============
*/
void R_ParticleExplosion (vec3_t org)
{
int i, j;
particle_t *p;
if (!gl_particles->value)
return;
for (i=0 ; i<1024 ; i++)
{
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 5;
p->color = ramp1[0];
p->ramp = rand()&3;
if (i & 1)
{
p->type = pt_explode;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%32)-16);
p->vel[j] = (rand()%512)-256;
}
}
else
{
p->type = pt_explode2;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%32)-16);
p->vel[j] = (rand()%512)-256;
}
}
}
}
/*
===============
R_BlobExplosion
===============
*/
void R_BlobExplosion (vec3_t org)
{
int i, j;
particle_t *p;
if (!gl_particles->value)
return;
for (i=0 ; i<1024 ; i++)
{
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 1 + (rand()&8)*0.05;
if (i & 1)
{
p->type = pt_blob;
p->color = 66 + rand()%6;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%32)-16);
p->vel[j] = (rand()%512)-256;
}
}
else
{
p->type = pt_blob2;
p->color = 150 + rand()%6;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%32)-16);
p->vel[j] = (rand()%512)-256;
}
}
}
}
/*
===============
R_RunParticleEffect
===============
*/
void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count)
{
int i, j;
particle_t *p;
int scale;
if (!gl_particles->value)
return;
if (count > 130)
scale = 3;
else if (count > 20)
scale = 2;
else
scale = 1;
for (i=0 ; i<count ; i++)
{
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 0.1*(rand()%5);
p->color = (color&~7) + (rand()&7);
p->type = pt_grav;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + scale*((rand()&15)-8);
p->vel[j] = dir[j]*15;// + (rand()%300)-150;
}
}
}
/*
===============
R_LavaSplash
===============
*/
void R_LavaSplash (vec3_t org)
{
int i, j, k;
particle_t *p;
float vel;
vec3_t dir;
if (!gl_particles->value)
return;
for (i=-16 ; i<16 ; i++)
for (j=-16 ; j<16 ; j++)
for (k=0 ; k<1 ; k++)
{
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 2 + (rand()&31) * 0.02;
p->color = 224 + (rand()&7);
p->type = pt_grav;
dir[0] = j*8 + (rand()&7);
dir[1] = i*8 + (rand()&7);
dir[2] = 256;
p->org[0] = org[0] + dir[0];
p->org[1] = org[1] + dir[1];
p->org[2] = org[2] + (rand()&63);
VectorNormalize (dir);
vel = 50 + (rand()&63);
VectorScale (dir, vel, p->vel);
}
}
/*
===============
R_TeleportSplash
===============
*/
void R_TeleportSplash (vec3_t org)
{
int i, j, k;
particle_t *p;
float vel;
vec3_t dir;
if (!gl_particles->value)
return;
for (i=-16 ; i<16 ; i+=4)
for (j=-16 ; j<16 ; j+=4)
for (k=-24 ; k<32 ; k+=4)
{
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 0.2 + (rand()&7) * 0.02;
p->color = 7 + (rand()&7);
p->type = pt_grav;
dir[0] = j*8;
dir[1] = i*8;
dir[2] = k*8;
p->org[0] = org[0] + i + (rand()&3);
p->org[1] = org[1] + j + (rand()&3);
p->org[2] = org[2] + k + (rand()&3);
VectorNormalize (dir);
vel = 50 + (rand()&63);
VectorScale (dir, vel, p->vel);
}
}
void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent)
{
vec3_t vec;
float len;
int j;
particle_t *p;
if (type == 0)
R_AddFire (start, end, ent);
if (!gl_particles->value)
return;
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
while (len > 0)
{
len -= 3;
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
VectorCopy (vec3_origin, p->vel);
p->die = cl.time + 2;
if (type == 4)
{ // slight blood
p->type = pt_slowgrav;
p->color = 67 + (rand()&3);
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
len -= 3;
}
else if (type == 2)
{ // blood
p->type = pt_slowgrav;
p->color = 67 + (rand()&3);
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
}
else if (type == 6)
{ // voor trail
p->color = 9*16 + 8 + (rand()&3);
p->type = pt_static;
p->die = cl.time + 0.3;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()&15)-8);
}
else if (type == 1)
{ // smoke smoke
p->ramp = (rand()&3) + 2;
p->color = ramp3[(int)p->ramp];
p->type = pt_fire;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
}
else if (type == 0)
{ // rocket trail
p->ramp = (rand()&3);
p->color = ramp3[(int)p->ramp];
p->type = pt_fire;
for (j=0 ; j<3 ; j++)
p->org[j] = start[j] + ((rand()%6)-3);
}
else if (type == 3 || type == 5)
{ // tracer
static int tracercount;
p->die = cl.time + 0.5;
p->type = pt_static;
if (type == 3)
p->color = 52 + ((tracercount&4)<<1);
else
p->color = 230 + ((tracercount&4)<<1);
tracercount++;
VectorCopy (start, p->org);
if (tracercount & 1)
{
p->vel[0] = 30*vec[1];
p->vel[1] = 30*-vec[0];
}
else
{
p->vel[0] = 30*-vec[1];
p->vel[1] = 30*vec[0];
}
}
VectorAdd (start, vec, start);
}
}
/*
===============
R_DrawParticles
===============
*/
void R_DrawParticles (void)
{
particle_t *p, *kill;
float grav;
int i;
float time2, time3;
float time1;
float dvel;
float frametime;
unsigned char *at;
unsigned char theAlpha;
vec3_t up, right;
float scale;
qboolean alphaTestEnabled;
glBindTexture (GL_TEXTURE_2D, particletexture);
// LordHavoc: particles should not affect zbuffer
glDepthMask(0);
alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
if (alphaTestEnabled)
glDisable(GL_ALPHA_TEST);
glBegin (GL_TRIANGLES);
VectorScale (vup, 1.5, up);
VectorScale (vright, 1.5, right);
frametime = host_frametime;
time3 = frametime * 15;
time2 = frametime * 10; // 15;
time1 = frametime * 5;
grav = frametime * 800 * 0.05;
dvel = 4*frametime;
for ( ;; )
{
kill = active_particles;
if (kill && kill->die < cl.time)
{
active_particles = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
for (p=active_particles ; p ; p=p->next)
{
for ( ;; )
{
kill = p->next;
if (kill && kill->die < cl.time)
{
p->next = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
// hack a scale up to keep particles from disapearing
scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1]
+ (p->org[2] - r_origin[2])*vpn[2];
if (scale < 20)
scale = 1;
else
scale = 1 + scale * 0.004;
at = (byte *)&d_8to24table[(int)p->color];
if (p->type==pt_fire)
theAlpha = 255*(6-p->ramp)/6;
// theAlpha = 192;
// else if (p->type==pt_explode || p->type==pt_explode2)
// theAlpha = 255*(8-p->ramp)/8;
else
theAlpha = 255;
if (lighthalf)
glColor4ub((byte) ((int) at[0] >> 1), (byte) ((int) at[1] >> 1), (byte) ((int) at[2] >> 1), theAlpha);
else
glColor4ub(at[0], at[1], at[2], theAlpha);
// glColor3ubv (at);
// glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
glTexCoord2f (0,0);
glVertex3fv (p->org);
glTexCoord2f (1,0);
glVertex3f (p->org[0] + up[0]*scale, p->org[1] + up[1]*scale, p->org[2] + up[2]*scale);
glTexCoord2f (0,1);
glVertex3f (p->org[0] + right[0]*scale, p->org[1] + right[1]*scale, p->org[2] + right[2]*scale);
p->org[0] += p->vel[0]*frametime;
p->org[1] += p->vel[1]*frametime;
p->org[2] += p->vel[2]*frametime;
switch (p->type)
{
case pt_static:
break;
case pt_fire:
p->ramp += time1;
if (p->ramp >= 6)
p->die = -1;
else
p->color = ramp3[(int)p->ramp];
p->vel[2] += grav;
break;
case pt_explode:
p->ramp += time2;
if (p->ramp >=8)
p->die = -1;
else
p->color = ramp1[(int)p->ramp];
for (i=0 ; i<3 ; i++)
p->vel[i] += p->vel[i]*dvel;
p->vel[2] -= grav;
break;
case pt_explode2:
p->ramp += time3;
if (p->ramp >=8)
p->die = -1;
else
p->color = ramp2[(int)p->ramp];
for (i=0 ; i<3 ; i++)
p->vel[i] -= p->vel[i]*frametime;
p->vel[2] -= grav;
break;
case pt_blob:
for (i=0 ; i<3 ; i++)
p->vel[i] += p->vel[i]*dvel;
p->vel[2] -= grav;
break;
case pt_blob2:
for (i=0 ; i<2 ; i++)
p->vel[i] -= p->vel[i]*dvel;
p->vel[2] -= grav;
break;
case pt_slowgrav:
case pt_grav:
p->vel[2] -= grav;
break;
}
}
glEnd ();
if (alphaTestEnabled)
glEnable(GL_ALPHA_TEST);
glDepthMask(1);
}
/*
R_AddFire
Nifty ball of fire GL effect. Kinda a meshing of the dlight and
particle engine code.
*/
float r_firecolor_flame[3]={0.9,0.7,0.3};
float r_firecolor_light[3]={0.9,0.7,0.3};
void
R_AddFire (vec3_t start, vec3_t end, entity_t *ent)
{
float len;
fire_t *f;
dlight_t *dl;
vec3_t vec;
int key;
if (!gl_fires->value)
return;
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
key = ent-cl_visedicts+1;
if (len)
{
f = R_AllocFire (key);
VectorCopy (end, f->origin);
VectorCopy (start, f->owner);
f->size = 20;
f->die = cl.time + 0.5;
f->decay = -1;
f->color=r_firecolor_flame;
dl = CL_AllocDlight (key);
VectorCopy (end, dl->origin);
dl->radius = 200;
dl->die = cl.time + 0.5;
dl->color=r_firecolor_light;
}
}
/*
R_AllocFire
Clears out and returns a new fireball
*/
fire_t *
R_AllocFire (int key)
{
int i;
fire_t *f;
if (key) // first try to find/reuse a keyed spot
{
f = r_fires;
for (i = 0; i < MAX_FIRES; i++, f++)
if (f->key == key)
{
memset (f, 0, sizeof(*f));
f->key = key;
f->color = f->_color;
return f;
}
}
f = r_fires; // no match, look for a free spot
for (i = 0; i < MAX_FIRES; i++, f++)
{
if (f->die < cl.time)
{
memset (f, 0, sizeof(*f));
f->key = key;
f->color = f->_color;
return f;
}
}
f = &r_fires[0];
memset (f, 0, sizeof(*f));
f->key = key;
f->color = f->_color;
return f;
}
/*
R_DrawFire
draws one fireball - probably never need to call this directly
*/
void
R_DrawFire (fire_t *f)
{
int i, j;
vec3_t vec,vec2;
float radius;
float *b_sin, *b_cos;
b_sin = bubble_sintable;
b_cos = bubble_costable;
radius = f->size + 0.35;
// figure out if we're inside the area of effect
VectorSubtract (f->origin, r_origin, vec);
if (Length (vec) < radius)
{
AddLightBlend (1, 0.5, 0, f->size * 0.0003); // we are
return;
}
// we're not - draw it
glBegin (GL_TRIANGLE_FAN);
if (lighthalf)
glColor3f(f->color[0]*0.5,f->color[1]*0.5,f->color[2]*0.5);
else
glColor3fv(f->color);
for (i=0 ; i<3 ; i++)
vec[i] = f->origin[i] - vpn[i] * radius;
glVertex3fv (vec);
glColor3f (0.0, 0.0, 0.0);
// don't panic, this just draws a bubble...
for (i=16 ; i>=0 ; i--)
{
for (j=0 ; j<3 ; j++) {
vec[j] = f->origin[j] + (*b_cos * vright[j]
+ vup[j]*(*b_sin)) * radius;
vec2[j] = f->owner[j] + (*b_cos * vright[j]
+ vup[j]*(*b_sin)) * radius;
}
glVertex3fv (vec);
glVertex3fv (vec2);
b_sin+=2;
b_cos+=2;
}
glEnd ();
}
/*
R_UpdateFires
Draws each fireball in sequence
*/
void
R_UpdateFires (void)
{
int i;
fire_t *f;
if (!gl_fires->value)
return;
glDepthMask (0);
glDisable (GL_TEXTURE_2D);
glShadeModel (GL_SMOOTH);
glBlendFunc (GL_ONE, GL_ONE);
f = r_fires;
for (i = 0; i < MAX_FIRES; i++, f++)
{
if (f->die < cl.time || !f->size)
continue;
f->size += f->decay;
R_DrawFire (f);
}
glColor3f (1.0, 1.0, 1.0);
glEnable (GL_TEXTURE_2D);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask (1);
}
void
R_FireColor_f (void)
{
int i;
if (Cmd_Argc() == 1) {
Con_Printf ("r_firecolor %f %f %f\n",
r_firecolor_flame[0],
r_firecolor_flame[1],
r_firecolor_flame[2]);
return;
}
if (Cmd_Argc() == 5 || Cmd_Argc() == 6) {
Con_Printf ("Warning: obsolete 4th and 5th parameters to r_firecolor ignored\n");
} else if (Cmd_Argc() !=4) {
Con_Printf ("Usage r_firecolor R G B\n");
return;
}
for (i=0; i<4; i++) {
r_firecolor_flame[i]=atof(Cmd_Argv(i+1));
r_firecolor_light[i]=r_firecolor_flame[i];
}
}

View file

@ -30,6 +30,12 @@
# include "config.h" # include "config.h"
#endif #endif
#include "render.h"
#include "model.h"
#include "client.h"
#include "sys.h"
#include "console.h"
#include "glquake.h"
mnode_t *r_pefragtopnode; mnode_t *r_pefragtopnode;

View file

@ -30,6 +30,9 @@
# include "config.h" # include "config.h"
#endif #endif
#include "client.h"
#include "glquake.h"
#include "view.h"
int r_dlightframecount; int r_dlightframecount;

View file

@ -30,6 +30,13 @@
# include "config.h" # include "config.h"
#endif #endif
#include "glquake.h"
#include "client.h"
#include "sys.h"
#include "console.h"
#include "chase.h"
#include "view.h"
#include "r_local.h"
entity_t r_worldentity; entity_t r_worldentity;
@ -296,15 +303,9 @@ GL_DrawAliasFrame
*/ */
void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum) void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
{ {
float s, t;
float l; float l;
int i, j; trivertx_t *verts;
int index;
trivertx_t *v, *verts;
int list;
int *order; int *order;
vec3_t point;
float *normal;
int count; int count;
lastposenum = posenum; lastposenum = posenum;
@ -354,14 +355,9 @@ extern vec3_t lightspot;
void GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum) void GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
{ {
float s, t, l; trivertx_t *verts;
int i, j;
int index;
trivertx_t *v, *verts;
int list;
int *order; int *order;
vec3_t point; vec3_t point;
float *normal;
float height, lheight; float height, lheight;
int count; int count;
@ -453,16 +449,14 @@ R_DrawAliasModel
*/ */
void R_DrawAliasModel (entity_t *e) void R_DrawAliasModel (entity_t *e)
{ {
int i, j; int i;
int lnum; int lnum;
vec3_t dist; vec3_t dist;
float add; float add;
model_t *clmodel; model_t *clmodel;
vec3_t mins, maxs; vec3_t mins, maxs;
aliashdr_t *paliashdr; aliashdr_t *paliashdr;
trivertx_t *verts, *v; float an;
int index;
float s, t, an;
int anim; int anim;
clmodel = currententity->model; clmodel = currententity->model;
@ -643,6 +637,9 @@ void R_DrawEntitiesOnList (void)
case mod_sprite: case mod_sprite:
R_DrawSpriteModel (currententity); R_DrawSpriteModel (currententity);
break; break;
case mod_brush:
case mod_alias:
break;
} }
} }
} }
@ -817,10 +814,6 @@ R_SetupFrame
*/ */
void R_SetupFrame (void) void R_SetupFrame (void)
{ {
int edgecount;
vrect_t vrect;
float w, h;
// don't allow cheats in multiplayer // don't allow cheats in multiplayer
if (cl.maxclients > 1) if (cl.maxclients > 1)
Cvar_Set(r_fullbright, "0"); Cvar_Set(r_fullbright, "0");
@ -872,8 +865,6 @@ R_SetupGL
void R_SetupGL (void) void R_SetupGL (void)
{ {
float screenaspect; float screenaspect;
float yfov;
int i;
extern int glwidth, glheight; extern int glwidth, glheight;
int x, x2, y2, y, w, h; int x, x2, y2, y, w, h;
@ -1111,8 +1102,7 @@ r_refdef must be set before the first call
*/ */
void R_RenderView (void) void R_RenderView (void)
{ {
double time1, time2; double time1=0, time2;
GLfloat colors[4] = {(GLfloat) 0.0, (GLfloat) 0.0, (GLfloat) 1, (GLfloat) 0.20};
if (r_norefresh->value) if (r_norefresh->value)
return; return;

View file

@ -30,8 +30,11 @@
# include "config.h" # include "config.h"
#endif #endif
#include "glquake.h"
#include "client.h"
#include "r_local.h"
#include "sys.h"
#include "console.h"
/* /*
================== ==================
@ -116,7 +119,6 @@ Grab six views for environment mapping tests
void R_Envmap_f (void) void R_Envmap_f (void)
{ {
byte buffer[256*256*4]; byte buffer[256*256*4];
char name[1024];
glDrawBuffer (GL_FRONT); glDrawBuffer (GL_FRONT);
glReadBuffer (GL_FRONT); glReadBuffer (GL_FRONT);
@ -180,8 +182,6 @@ R_Init
*/ */
void R_Init (void) void R_Init (void)
{ {
extern byte *hunk_base;
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f); Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
Cmd_AddCommand ("envmap", R_Envmap_f); Cmd_AddCommand ("envmap", R_Envmap_f);
Cmd_AddCommand ("pointfile", R_ReadPointFile_f); Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
@ -250,7 +250,6 @@ void R_TranslatePlayerSkin (int playernum)
int inwidth, inheight; int inwidth, inheight;
byte *inrow; byte *inrow;
unsigned frac, fracstep; unsigned frac, fracstep;
extern byte **player_8bit_texels_tbl;
GL_DisableMultitexture(); GL_DisableMultitexture();
@ -412,9 +411,9 @@ void R_NewMap (void)
{ {
if (!cl.worldmodel->textures[i]) if (!cl.worldmodel->textures[i])
continue; continue;
if (!Q_strncmp(cl.worldmodel->textures[i]->name,"sky",3) ) if (!strncmp(cl.worldmodel->textures[i]->name,"sky",3) )
skytexturenum = i; skytexturenum = i;
if (!Q_strncmp(cl.worldmodel->textures[i]->name,"window02_1",10) ) if (!strncmp(cl.worldmodel->textures[i]->name,"window02_1",10) )
mirrortexturenum = i; mirrortexturenum = i;
cl.worldmodel->textures[i]->texturechain = NULL; cl.worldmodel->textures[i]->texturechain = NULL;
} }
@ -435,8 +434,6 @@ void R_TimeRefresh_f (void)
{ {
int i; int i;
float start, stop, time; float start, stop, time;
int startangle;
vrect_t vr;
glDrawBuffer (GL_FRONT); glDrawBuffer (GL_FRONT);
glFinish (); glFinish ();

View file

@ -30,6 +30,13 @@
# include "config.h" # include "config.h"
#endif #endif
#include "glquake.h"
#include "qargs.h"
#include "qdefs.h"
#include "host.h"
#include "r_local.h"
#include "client.h"
#include "sys.h"
int skytexturenum; int skytexturenum;
@ -68,6 +75,8 @@ byte lightmaps[4*MAX_LIGHTMAPS*BLOCK_WIDTH*BLOCK_HEIGHT];
msurface_t *skychain = NULL; msurface_t *skychain = NULL;
msurface_t *waterchain = NULL; msurface_t *waterchain = NULL;
lpMTexFUNC qglMTexCoord2f = NULL;
void R_RenderDynamicLightmaps (msurface_t *fa); void R_RenderDynamicLightmaps (msurface_t *fa);
/* /*
@ -153,7 +162,6 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
byte *lightmap; byte *lightmap;
unsigned scale; unsigned scale;
int maps; int maps;
int lightadj[4];
unsigned *bl; unsigned *bl;
surf->cached_dlight = (surf->dlightframe == r_framecount); surf->cached_dlight = (surf->dlightframe == r_framecount);
@ -423,9 +431,7 @@ void R_DrawSequentialPoly (msurface_t *s)
float *v; float *v;
int i; int i;
texture_t *t; texture_t *t;
vec3_t nv, dir; vec3_t nv;
float ss, ss2, length;
float s1, t1;
glRect_t *theRect; glRect_t *theRect;
// //
@ -604,7 +610,6 @@ void DrawGLWaterPoly (glpoly_t *p)
{ {
int i; int i;
float *v; float *v;
float s, t, os, ot;
vec3_t nv; vec3_t nv;
GL_DisableMultitexture(); GL_DisableMultitexture();
@ -628,7 +633,6 @@ void DrawGLWaterPolyLightmap (glpoly_t *p)
{ {
int i; int i;
float *v; float *v;
float s, t, os, ot;
vec3_t nv; vec3_t nv;
GL_DisableMultitexture(); GL_DisableMultitexture();
@ -841,7 +845,6 @@ Multitexture
*/ */
void R_RenderDynamicLightmaps (msurface_t *fa) void R_RenderDynamicLightmaps (msurface_t *fa)
{ {
texture_t *t;
byte *base; byte *base;
int maps; int maps;
glRect_t *theRect; glRect_t *theRect;
@ -1084,9 +1087,9 @@ R_DrawBrushModel
*/ */
void R_DrawBrushModel (entity_t *e) void R_DrawBrushModel (entity_t *e)
{ {
int j, k; int k;
vec3_t mins, maxs; vec3_t mins, maxs;
int i, numsurfaces; int i;
msurface_t *psurf; msurface_t *psurf;
float dot; float dot;
mplane_t *pplane; mplane_t *pplane;
@ -1196,13 +1199,11 @@ R_RecursiveWorldNode
*/ */
void R_RecursiveWorldNode (mnode_t *node) void R_RecursiveWorldNode (mnode_t *node)
{ {
int i, c, side, *pindex; int c, side;
vec3_t acceptpt, rejectpt;
mplane_t *plane; mplane_t *plane;
msurface_t *surf, **mark; msurface_t *surf, **mark;
mleaf_t *pleaf; mleaf_t *pleaf;
double d, dot; double dot;
vec3_t mins, maxs;
if (node->contents == CONTENTS_SOLID) if (node->contents == CONTENTS_SOLID)
return; // solid return; // solid
@ -1323,7 +1324,6 @@ R_DrawWorld
void R_DrawWorld (void) void R_DrawWorld (void)
{ {
entity_t ent; entity_t ent;
int i;
memset (&ent, 0, sizeof(ent)); memset (&ent, 0, sizeof(ent));
ent.model = cl.worldmodel; ent.model = cl.worldmodel;
@ -1411,7 +1411,6 @@ int AllocBlock (int w, int h, int *x, int *y)
{ {
int i, j; int i, j;
int best, best2; int best, best2;
int bestx;
int texnum; int texnum;
for (texnum=0 ; texnum<MAX_LIGHTMAPS ; texnum++) for (texnum=0 ; texnum<MAX_LIGHTMAPS ; texnum++)
@ -1461,14 +1460,9 @@ BuildSurfaceDisplayList
*/ */
void BuildSurfaceDisplayList (msurface_t *fa) void BuildSurfaceDisplayList (msurface_t *fa)
{ {
int i, lindex, lnumverts, s_axis, t_axis; int i, lindex, lnumverts;
float dist, lastdist, lzi, scale, u, v, frac;
unsigned mask;
vec3_t local, transformed;
medge_t *pedges, *r_pedge; medge_t *pedges, *r_pedge;
mplane_t *pplane; int vertpage;
int vertpage, newverts, newpage, lastvert;
qboolean visible;
float *vec; float *vec;
float s, t; float s, t;
glpoly_t *poly; glpoly_t *poly;
@ -1539,7 +1533,6 @@ void BuildSurfaceDisplayList (msurface_t *fa)
{ {
vec3_t v1, v2; vec3_t v1, v2;
float *prev, *this, *next; float *prev, *this, *next;
float f;
prev = poly->verts[(i + lnumverts - 1) % lnumverts]; prev = poly->verts[(i + lnumverts - 1) % lnumverts];
this = poly->verts[i]; this = poly->verts[i];
@ -1581,7 +1574,7 @@ GL_CreateSurfaceLightmap
*/ */
void GL_CreateSurfaceLightmap (msurface_t *surf) void GL_CreateSurfaceLightmap (msurface_t *surf)
{ {
int smax, tmax, s, t, l, i; int smax, tmax;
byte *base; byte *base;
if (surf->flags & (SURF_DRAWSKY|SURF_DRAWTURB)) if (surf->flags & (SURF_DRAWSKY|SURF_DRAWTURB))

View file

@ -30,6 +30,19 @@
# include "config.h" # include "config.h"
#endif #endif
#include "glquake.h"
#include "menu.h"
#include "view.h"
#include "input.h"
#include "cvar.h"
#include "console.h"
#include "draw.h"
#include "screen.h"
#include "host.h"
#include "sys.h"
#include "client.h"
#include "keys.h"
#include "sbar.h"
/* /*
@ -261,7 +274,6 @@ Internal use only
*/ */
static void SCR_CalcRefdef (void) static void SCR_CalcRefdef (void)
{ {
vrect_t vrect;
float size; float size;
int h; int h;
qboolean full = false; qboolean full = false;
@ -277,15 +289,15 @@ static void SCR_CalcRefdef (void)
// bound viewsize // bound viewsize
if (scr_viewsize->value < 30) if (scr_viewsize->value < 30)
Cvar_Set ("viewsize","30"); Cvar_Set (scr_viewsize,"30");
if (scr_viewsize->value > 120) if (scr_viewsize->value > 120)
Cvar_Set ("viewsize","120"); Cvar_Set (scr_viewsize,"120");
// bound field of view // bound field of view
if (scr_fov->value < 10) if (scr_fov->value < 10)
Cvar_Set ("fov","10"); Cvar_Set (scr_fov,"10");
if (scr_fov->value > 170) if (scr_fov->value > 170)
Cvar_Set ("fov","170"); Cvar_Set (scr_fov,"170");
// intermission is always full screen // intermission is always full screen
if (cl.intermission) if (cl.intermission)
@ -349,7 +361,7 @@ Keybinding command
*/ */
void SCR_SizeUp_f (void) void SCR_SizeUp_f (void)
{ {
Cvar_SetValue ("viewsize",scr_viewsize->value+10); Cvar_SetValue (scr_viewsize,scr_viewsize->value+10);
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
} }
@ -363,7 +375,7 @@ Keybinding command
*/ */
void SCR_SizeDown_f (void) void SCR_SizeDown_f (void)
{ {
Cvar_SetValue ("viewsize",scr_viewsize->value-10); Cvar_SetValue (scr_viewsize,scr_viewsize->value-10);
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
} }
@ -758,7 +770,7 @@ int SCR_ModalMessage (char *text)
do do
{ {
key_count = -1; // wait for a key down and up key_count = -1; // wait for a key down and up
Sys_SendKeyEvents (); IN_SendKeyEvents ();
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE); } while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);
scr_fullupdate = 0; scr_fullupdate = 0;
@ -827,9 +839,6 @@ needs almost the entire 256k of stack space!
*/ */
void SCR_UpdateScreen (void) void SCR_UpdateScreen (void)
{ {
static float oldscr_viewsize;
vrect_t vrect;
if (block_drawing) if (block_drawing)
return; return;

View file

@ -1,881 +0,0 @@
/*
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 <dlfcn.h>
/*#include "vga.h" */
#include "vgakeyboard.h"
#include "vgamouse.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;
cvar_t *vid_redrawfull;
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;
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;
const char *gl_vendor;
const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;
void (*qgl3DfxSetPaletteEXT) (GLuint *);
void (*qglColorTableEXT) (int, int, int, int, int, const void *);
static float vid_gamma = 1.0;
qboolean is8bit = false;
qboolean isPermedia = false;
qboolean gl_mtexable = false;
void
VID_InitCvars(void)
{
}
/*-----------------------------------------------------------------------*/
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
{
}
void D_EndDirectRect (int x, int y, int width, int height)
{
}
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 j,k,l,m;
unsigned short i;
unsigned *table;
FILE *f;
char s[255];
int 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<<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.
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*10000; v<256; v++,pal+=4) {
r1 = (int)r - (int)pal[0];
g1 = (int)g - (int)pal[1];
b1 = (int)b - (int)pal[2];
dist = (r1*r1)+(g1*g1)+(b1*b1);
if (dist < bestdist) {
k=v;
bestdist = dist;
}
}
d_15to8table[i]=k;
}
}
void CheckMultiTextureExtensions(void)
{
void *prjobj;
if (strstr(gl_extensions, "GL_SGIS_multitexture ") && !COM_CheckParm("-nomtex")) {
Con_Printf("Found GL_SGIS_multitexture...\n");
if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL) {
Con_Printf("Unable to open symbol list for main program.\n");
return;
}
qglMTexCoord2fSGIS = (void *) dlsym(prjobj, "glMTexCoord2fSGIS");
qglSelectTextureSGIS = (void *) dlsym(prjobj, "glSelectTextureSGIS");
if (qglMTexCoord2fSGIS && qglSelectTextureSGIS) {
Con_Printf("Multitexture extensions found.\n");
gl_mtexable = true;
} else
Con_Printf("Symbol not found, disabled.\n");
dlclose(prjobj);
}
}
/*
===============
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);
CheckMultiTextureExtensions ();
glClearColor (1,0,0,0);
glCullFace(GL_FRONT);
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.666);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glShadeModel (GL_FLAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
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)
{
*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 16
static int resolutions[NUM_RESOLUTIONS][3]={
320,200, GR_RESOLUTION_320x200,
320,240, GR_RESOLUTION_320x240,
400,256, GR_RESOLUTION_400x256,
400,300, GR_RESOLUTION_400x300,
512,384, GR_RESOLUTION_512x384,
640,200, GR_RESOLUTION_640x200,
640,350, GR_RESOLUTION_640x350,
640,400, GR_RESOLUTION_640x400,
640,480, GR_RESOLUTION_640x480,
800,600, GR_RESOLUTION_800x600,
960,720, GR_RESOLUTION_960x720,
856,480, GR_RESOLUTION_856x480,
512,256, GR_RESOLUTION_512x256,
1024,768, GR_RESOLUTION_1024x768,
1280,1024,GR_RESOLUTION_1280x1024,
1600,1200,GR_RESOLUTION_1600x1200
};
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;
}
void VID_Init8bitPalette(void)
{
// Check for 8bit Extensions and initialize them.
int i;
void *prjobj;
if (COM_CheckParm("-no8bit"))
return;
if ((prjobj = dlopen(NULL, RTLD_LAZY)) == NULL) {
Con_Printf("Unable to open symbol list for main program.\n");
return;
}
if (strstr(gl_extensions, "3DFX_set_global_palette") &&
(qgl3DfxSetPaletteEXT = dlsym(prjobj, "gl3DfxSetPaletteEXT")) != NULL) {
GLubyte table[256][4];
char *oldpal;
Con_SafePrintf("... Using 3DFX_set_global_palette\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++;
}
qgl3DfxSetPaletteEXT((GLuint *)table);
is8bit = true;
} else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette") &&
(qglColorTableEXT = dlsym(prjobj, "glColorTableEXT")) != NULL) {
char thePalette[256*3];
char *oldPalette, *newPalette;
Con_SafePrintf("... Using GL_EXT_shared_texture_palette\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++;
}
qglColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
is8bit = true;
}
dlclose(prjobj);
}
static void Check_Gamma (unsigned char *pal)
{
float f, inf;
unsigned char palette[768];
int i;
if ((i = COM_CheckParm("-gamma")) == 0) {
if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
(gl_vendor && strstr(gl_vendor, "3Dfx")))
vid_gamma = 1;
else
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
} else
vid_gamma = Q_atof(com_argv[i+1]);
for (i=0 ; i<768 ; i++)
{
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
inf = f*255 + 0.5;
if (inf < 0)
inf = 0;
if (inf > 255)
inf = 255;
palette[i] = inf;
}
memcpy (pal, palette, sizeof(palette));
}
void VID_Init(unsigned char *palette)
{
int i;
GLint attribs[32];
char gldir[MAX_OSPATH];
int width = 640, height = 480;
Init_KBD();
vid_mode = Cvar_Get("vid_mode", "0", CVAR_NONE, "None");
vid_redrawfull = Cvar_Get("vid_redrawfull", "0", CVAR_NONE, "None");
vid_waitforrefresh = Cvar_Get("vid_waitforrefresh", "0", CVAR_ARCHIVE, "None");
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 = Q_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 = Q_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");
InitSig(); // trap evil signals
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;
GL_Init();
sprintf (gldir, "%s/glquake", com_gamedir);
Sys_mkdir (gldir);
Check_Gamma(palette);
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 && cls.state != ca_dedicated)
{
// 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)
{
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;
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;
}
}
void IN_Move (usercmd_t *cmd)
{
IN_MouseMove(cmd);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

209
source/gl_view.c Normal file
View file

@ -0,0 +1,209 @@
/*
gl_view.c
player eye positioning
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 <string.h>
#include <stdio.h>
#include "bothdefs.h" // needed by: common.h, net.h, client.h
#include "bspfile.h" // needed by: glquake.h
#include "vid.h"
#include "sys.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 "sbar.h"
#include "render.h" // needed by: client.h, 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"
extern byte *host_basepal;
extern double host_frametime;
extern int onground;
extern byte gammatable[256];
extern cvar_t *gl_cshiftpercent;
byte ramps[3][256];
float v_blend[4];
void V_CalcPowerupCshift (void);
qboolean V_CheckGamma (void);
/*
V_CalcBlend
LordHavoc made this a real, (messy,) true alpha blend. Cleaned it up
a bit, but otherwise this is his code. --KB
*/
void
V_CalcBlend (void)
{
float r, g, b, a, a2, a3;
int j;
r = 0;
g = 0;
b = 0;
a = 0;
for (j=0 ; j<NUM_CSHIFTS ; j++)
{
if (!gl_cshiftpercent->value)
continue;
a2 = ((cl.cshifts[j].percent * gl_cshiftpercent->value) / 100.0) / 255.0;
if (!a2)
continue;
a2 = min(a2, 1.0);
r += (cl.cshifts[j].destcolor[0]-r) * a2;
g += (cl.cshifts[j].destcolor[1]-g) * a2;
b += (cl.cshifts[j].destcolor[2]-b) * a2;
a3 = (1.0 - a) * (1.0 - a2);
a = 1.0 - a3;
}
// LordHavoc: saturate color
if (a)
{
a2 = 1.0 / a;
r *= a2;
g *= a2;
b *= a2;
if (a > 1) // clamp alpha blend too
a = 1;
}
v_blend[0] = min(r, 255.0)/255.0;
v_blend[1] = min(g, 255.0)/255.0;
v_blend[2] = min(b, 255.0)/255.0;
v_blend[3] = bound (0.0, a, 1.0);
}
/*
=============
V_UpdatePalette
=============
*/
void V_UpdatePalette (void)
{
int i, j;
qboolean new;
byte *basepal, *newpal;
byte pal[768];
float r,g,b,a;
int ir, ig, ib;
qboolean force;
V_CalcPowerupCshift ();
new = false;
for (i=0 ; i<NUM_CSHIFTS ; i++)
{
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
{
new = true;
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
}
for (j=0 ; j<3 ; j++)
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j])
{
new = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
}
}
// drop the damage value
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150;
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
// drop the bonus value
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100;
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
cl.cshifts[CSHIFT_BONUS].percent = 0;
force = V_CheckGamma ();
if (!new && !force)
return;
V_CalcBlend ();
//Con_Printf("b: %4.2f %4.2f %4.2f %4.6f\n", v_blend[0], v_blend[1], v_blend[2], v_blend[3]);
a = v_blend[3];
r = 255*v_blend[0]*a;
g = 255*v_blend[1]*a;
b = 255*v_blend[2]*a;
a = 1-a;
for (i=0 ; i<256 ; i++)
{
ir = min(i*a + r, 255);
ig = min(i*a + g, 255);
ib = min(i*a + b, 255);
ramps[0][i] = gammatable[ir];
ramps[1][i] = gammatable[ig];
ramps[2][i] = gammatable[ib];
}
basepal = host_basepal;
newpal = pal;
for (i=0 ; i<256 ; i++)
{
ir = basepal[0];
ig = basepal[1];
ib = basepal[2];
basepal += 3;
newpal[0] = ramps[0][ir];
newpal[1] = ramps[1][ig];
newpal[2] = ramps[2][ib];
newpal += 3;
}
VID_ShiftPalette (pal);
}

View file

@ -30,6 +30,9 @@
# include "config.h" # include "config.h"
#endif #endif
#include "glquake.h"
#include "sys.h"
#include "host.h"
extern model_t *loadmodel; extern model_t *loadmodel;
@ -158,7 +161,6 @@ void GL_SubdivideSurface (msurface_t *fa)
int i; int i;
int lindex; int lindex;
float *vec; float *vec;
texture_t *t;
warpface = fa; warpface = fa;
@ -281,10 +283,6 @@ will have them chained together.
*/ */
void EmitBothSkyLayers (msurface_t *fa) void EmitBothSkyLayers (msurface_t *fa)
{ {
int i;
int lindex;
float *vec;
GL_DisableMultitexture(); GL_DisableMultitexture();
GL_Bind (solidskytexture); GL_Bind (solidskytexture);
@ -1047,7 +1045,6 @@ void R_InitSky (texture_t *mt)
unsigned transpix; unsigned transpix;
int r, g, b; int r, g, b;
unsigned *rgba; unsigned *rgba;
extern int skytexturenum;
src = (byte *)mt + mt->offsets[0]; src = (byte *)mt + mt->offsets[0];

View file

@ -678,7 +678,7 @@ void _Host_Frame (float time)
return; // don't run too fast, or packets will flood out return; // don't run too fast, or packets will flood out
// get new key events // get new key events
Sys_SendKeyEvents (); IN_SendKeyEvents ();
// allow mice or other external controllers to add commands // allow mice or other external controllers to add commands
IN_Commands (); IN_Commands ();

View file

@ -459,7 +459,7 @@ qboolean WaitJoyButton (void)
do do
{ {
key_count = -1; key_count = -1;
Sys_SendKeyEvents (); IN_SendKeyEvents ();
key_count = 0; key_count = 0;
if (key_lastpress == K_ESCAPE) if (key_lastpress == K_ESCAPE)
{ {
@ -479,7 +479,7 @@ qboolean WaitJoyButton (void)
do do
{ {
key_count = -1; key_count = -1;
Sys_SendKeyEvents (); IN_SendKeyEvents ();
key_count = 0; key_count = 0;
if (key_lastpress == K_ESCAPE) if (key_lastpress == K_ESCAPE)
{ {

461
source/in_x11.c Normal file
View file

@ -0,0 +1,461 @@
/*
in_x11.c
general x11 input driver
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 2000 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
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$
*/
#define _BSD
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <X11/Xlib.h>
#include <X11/keysym.h>
#ifdef HAVE_DGA
#include <X11/extensions/XShm.h>
#include <X11/extensions/xf86dga.h>
#endif
#include "d_local.h"
#include "sound.h"
#include "keys.h"
#include "cvar.h"
#include "sys.h"
#include "cmd.h"
#include "draw.h"
#include "console.h"
#include "client.h"
#include "context_x11.h"
#include "qargs.h"
#include "host.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
cvar_t *_windowed_mouse;
cvar_t *m_filter;
cvar_t *in_dgamouse;
#ifdef HAVE_DGA
cvar_t *in_dga_mouseaccel;
#endif
static qboolean mouse_avail;
static float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
static int p_mouse_x, p_mouse_y;
static float old__windowed_mouse;
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
#define INPUT_MASK (KEY_MASK | MOUSE_MASK)
static int
XLateKey(XKeyEvent *ev)
{
int key = 0;
KeySym keysym;
keysym = XLookupKeysym(ev, 0);
switch(keysym) {
case XK_KP_Page_Up: key = KP_PGUP; break;
case XK_Page_Up: key = K_PGUP; break;
case XK_KP_Page_Down: key = KP_PGDN; break;
case XK_Page_Down: key = K_PGDN; break;
case XK_KP_Home: key = KP_HOME; break;
case XK_Home: key = K_HOME; break;
case XK_KP_End: key = KP_END; break;
case XK_End: key = K_END; break;
case XK_KP_Left: key = KP_LEFTARROW; break;
case XK_Left: key = K_LEFTARROW; break;
case XK_KP_Right: key = KP_RIGHTARROW; break;
case XK_Right: key = K_RIGHTARROW; break;
case XK_KP_Down: key = KP_DOWNARROW; break;
case XK_Down: key = K_DOWNARROW; break;
case XK_KP_Up: key = KP_UPARROW; break;
case XK_Up: key = K_UPARROW; break;
case XK_Escape: key = K_ESCAPE; break;
case XK_KP_Enter: key = KP_ENTER; break;
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: key = KP_DEL; break;
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_Mode_switch:
case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R: key = K_ALT; break;
case XK_Caps_Lock: key = K_CAPSLOCK; break;
case XK_KP_Begin: key = K_AUX30; break;
case XK_Insert: key = K_INS; break;
case XK_KP_Insert: key = KP_INS; break;
case XK_KP_Multiply: key = KP_MULTIPLY; break;
case XK_KP_Add: key = KP_PLUS; break;
case XK_KP_Subtract: key = KP_MINUS; break;
case XK_KP_Divide: key = KP_DIVIDE; break;
/* For Sun keyboards */
case XK_F27: key = K_HOME; break;
case XK_F29: key = K_PGUP; break;
case XK_F33: key = K_END; break;
case XK_F35: key = K_PGDN; 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:
if (keysym < 128) {
/* ASCII keys */
key = keysym;
if (key >= 'A' && key <= 'Z') {
key = key + ('a' - 'A');
}
}
break;
}
return key;
}
static void
event_key(XEvent *event)
{
Key_Event(XLateKey(&event->xkey), event->type == KeyPress);
}
static void
event_button(XEvent *event)
{
int but;
but = event->xbutton.button;
if (but == 2) but = 3;
else if (but == 3) but = 2;
switch(but) {
case 1:
case 2:
case 3:
Key_Event(K_MOUSE1 + but - 1, event->type == ButtonPress);
break;
case 4:
Key_Event(K_MWHEELUP, 1);
Key_Event(K_MWHEELUP, 0);
break;
case 5:
Key_Event(K_MWHEELDOWN, 1);
Key_Event(K_MWHEELDOWN, 0);
break;
}
}
static void
center_pointer(void)
{
XEvent event;
event.type = MotionNotify;
event.xmotion.display = x_disp;
event.xmotion.window = x_win;
event.xmotion.x = vid.width / 2;
event.xmotion.y = vid.height / 2;
XSendEvent(x_disp, x_win, False, PointerMotionMask, &event);
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
vid.width / 2, vid.height / 2);
}
static void
event_motion(XEvent *event)
{
#ifdef HAVE_DGA
if (in_dgamouse->value) {
mouse_x += event->xmotion.x_root * in_dga_mouseaccel->value;
mouse_y += event->xmotion.y_root * in_dga_mouseaccel->value;
} else
#endif
{
//printf("_windowed_mouse: %f\n", _windowed_mouse->value);
//printf("CurrentTime: %ld\n", CurrentTime);
if (_windowed_mouse->value) {
if (!event->xmotion.send_event) {
mouse_x += (event->xmotion.x - p_mouse_x);
mouse_y += (event->xmotion.y - p_mouse_y);
#undef ABS
#define ABS(a) (((int)(a) < 0) ? -(a) : (a))
if (ABS(vid.width/2 - event->xmotion.x)
> vid.width / 4
|| ABS(vid.height/2 - event->xmotion.y)
> vid.height / 4) {
#undef ABS
center_pointer();
}
}
} else {
mouse_x += (event->xmotion.x - p_mouse_x);
mouse_y += (event->xmotion.y - p_mouse_y);
}
p_mouse_x = event->xmotion.x;
p_mouse_y = event->xmotion.y;
}
}
void
IN_Commands(void)
{
if (old__windowed_mouse != _windowed_mouse->value) {
old__windowed_mouse = _windowed_mouse->value;
if (!_windowed_mouse->value) {
/* ungrab the pointer */
XUngrabPointer(x_disp,CurrentTime);
} else {
/* grab the pointer */
XGrabPointer(x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime);
//XGrabPointer(x_disp,x_win,True,0,GrabModeAsync,
// GrabModeAsync,x_win,None,CurrentTime);
}
}
}
void
IN_SendKeyEvents(void)
{
/* Get events from X server. */
x11_process_events();
}
void
IN_Move(usercmd_t *cmd)
{
if (!mouse_avail)
return;
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;
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;
}
/*
static void IN_ExtraOptionDraw(unsigned int options_draw_cursor)
{
// Windowed Mouse
M_Print(16, options_draw_cursor+=8, " Use Mouse");
M_DrawCheckbox(220, options_draw_cursor, _windowed_mouse->value);
}
static void IN_ExtraOptionCmd(int option_cursor)
{
switch (option_cursor) {
case 1: // _windowed_mouse
_windowed_mouse->value = !_windowed_mouse->value;
break;
}
}
*/
/*
Called at shutdown
*/
void
IN_Shutdown(void)
{
Con_Printf("IN_Shutdown\n");
mouse_avail = 0;
if (x_disp) {
XAutoRepeatOn(x_disp);
#ifdef HAVE_DGA
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), 0);
#endif
}
x11_close_display();
}
extern int scr_width, scr_height;
int
IN_Init(void)
{
// open the display
if (!x_disp)
Sys_Error("IN: No display!!\n");
if (!x_win)
Sys_Error("IN: No window!!\n");
x11_open_display(); // call to increment the reference counter
{
int attribmask = CWEventMask;
XWindowAttributes attribs_1;
XSetWindowAttributes attribs_2;
XGetWindowAttributes(x_disp, x_win, &attribs_1);
attribs_2.event_mask = attribs_1.your_event_mask | INPUT_MASK;
XChangeWindowAttributes(x_disp, x_win, attribmask, &attribs_2);
}
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
m_filter = Cvar_Get ("m_filter","0",CVAR_ARCHIVE,"None");
if (COM_CheckParm("-nomouse")) return 1;
#ifdef HAVE_DGA
in_dgamouse = Cvar_Get ("in_dgamouse", "0", CVAR_ROM,
"1 if you have DGA mouse support");
in_dga_mouseaccel = Cvar_Get ("in_dga_mouseaccel", "1", CVAR_ARCHIVE,
"None");
if (!COM_CheckParm("-nodga"))
{
XGrabKeyboard (x_disp, x_win, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp),
XF86DGADirectMouse|XF86DGADirectKeyb);
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime);
Cvar_SetROM (in_dgamouse, "1");
}
#endif
mouse_x = mouse_y = 0.0;
mouse_avail = 1;
x11_add_event(KeyPress, &event_key);
x11_add_event(KeyRelease, &event_key);
x11_add_event(ButtonPress, &event_button);
x11_add_event(ButtonRelease, &event_button);
x11_add_event(MotionNotify, &event_motion);
return 1;
}

View file

@ -794,7 +794,7 @@ int TTY_Connect(int handle, char *host)
break; break;
} }
Sys_SendKeyEvents (); IN_SendKeyEvents ();
if (key_count == 0) if (key_count == 0)
{ {
if (key_lastpress != K_ESCAPE) if (key_lastpress != K_ESCAPE)

View file

@ -33,6 +33,7 @@
#include "r_local.h" #include "r_local.h"
#include "screen.h" #include "screen.h"
#include "sbar.h" #include "sbar.h"
#include "input.h"
#include "view.h" #include "view.h"
#include "menu.h" #include "menu.h"
#include "host.h" #include "host.h"
@ -786,7 +787,7 @@ int SCR_ModalMessage (char *text)
do do
{ {
key_count = -1; // wait for a key down and up key_count = -1; // wait for a key down and up
Sys_SendKeyEvents (); IN_SendKeyEvents ();
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE); } while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);
scr_fullupdate = 0; scr_fullupdate = 0;

View file

@ -493,7 +493,7 @@ void Sys_Shutdown(void)
#define SC_RSHIFT 0x36 #define SC_RSHIFT 0x36
#define SC_LSHIFT 0x2a #define SC_LSHIFT 0x2a
void Sys_SendKeyEvents (void) void IN_SendKeyEvents (void)
{ {
int k, next; int k, next;
int outkey; int outkey;

View file

@ -204,7 +204,7 @@ void Sys_Sleep (void)
{ {
} }
void Sys_SendKeyEvents (void) void IN_SendKeyEvents (void)
{ {
} }

View file

@ -648,7 +648,7 @@ void Sys_Sleep (void)
} }
void Sys_SendKeyEvents (void) void IN_SendKeyEvents (void)
{ {
MSG msg; MSG msg;

View file

@ -216,7 +216,7 @@ void Sys_Sleep (void)
} }
void Sys_SendKeyEvents (void) void IN_SendKeyEvents (void)
{ {
} }

729
source/vid_glx.c Normal file
View file

@ -0,0 +1,729 @@
/*
vid_glx.c
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
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 <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <values.h>
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif
#ifndef RTLD_LAZY
# ifdef DL_LAZY
# define RTLD_LAZY DL_LAZY
# else
# define RTLD_LAZY 0
# endif
#endif
#include <GL/glx.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#ifdef HAVE_DGA
# include <X11/extensions/xf86dga.h>
#endif
#ifdef HAVE_VIDMODE
# include <X11/extensions/xf86vmode.h>
#endif
#ifdef XMESA
# include <GL/xmesa.h>
#endif
#include "qtypes.h"
#include "qendian.h"
#include "glquake.h"
#include "host.h"
#include "cvar.h"
#include "qargs.h"
#include "console.h"
#include "keys.h"
#include "menu.h"
#include "sys.h"
#include "quakefs.h"
#include "draw.h"
#include "input.h"
#include "sbar.h"
#include "context_x11.h"
#include "dga_check.h"
#define WARP_WIDTH 320
#define WARP_HEIGHT 200
static qboolean vid_initialized = false;
static int screen;
Window x_win;
static GLXContext ctx = NULL;
static Cursor nullcursor = None;
#define X_MASK (VisibilityChangeMask | StructureNotifyMask)
unsigned short d_8to16table[256];
unsigned d_8to24table[256];
unsigned char d_15to8table[65536];
cvar_t *vid_mode;
cvar_t *vid_fullscreen;
extern cvar_t *gl_triplebuffer;
extern cvar_t *in_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
#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
/*-----------------------------------------------------------------------*/
//int texture_mode = GL_NEAREST;
//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
int texture_mode = GL_LINEAR;
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
int texture_extension_number = 1;
float gldepthmin, gldepthmax;
const char *gl_vendor;
const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;
qboolean is8bit = false;
// ARB Multitexture
int gl_mtex_enum = TEXTURE0_SGIS;
qboolean gl_arb_mtex = false;
qboolean gl_mtexable = false;
/*
======================
Create an empty cursor
======================
*/
static void
CreateNullCursor(Display *display, Window root)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
if (nullcursor != None) return;
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);
}
/*-----------------------------------------------------------------------*/
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
{
}
void D_EndDirectRect (int x, int y, int width, int height)
{
}
void
VID_Shutdown(void)
{
if (!vid_initialized)
return;
Con_Printf("VID_Shutdown\n");
XDestroyWindow(x_disp, x_win);
glXDestroyContext(x_disp, ctx);
#ifdef HAVE_VIDMODE
if (hasvidmode) {
int i;
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[0]);
for (i = 0; i < nummodes; i++) {
// if (vidmodes[i]->privsize) XFree(vidmodes[i]->private);
}
XFree(vidmodes);
}
#endif
#ifdef HAVE_DLOPEN
if (dlhand) {
dlclose(dlhand);
dlhand = NULL;
}
#endif
if (nullcursor != None) {
XFreeCursor(x_disp, nullcursor);
nullcursor = None;
}
x11_close_display();
}
#if 0
static void
signal_handler(int sig)
{
printf("Received signal %d, exiting...\n", sig);
Sys_Quit();
exit(sig);
}
static 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);
}
#endif
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] &= 0; // 255 is transparent
// JACK: 3D distance calcs - k is last closest, l is the distance.
// FIXME: Precalculate this and cache to disk.
if (palflag)
return;
palflag = true;
COM_FOpenFile("glquake/15to8.pal", &f);
if (f) {
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);
}
}
}
/*
CheckMultiTextureExtensions
Check for ARB, SGIS, or EXT multitexture support
*/
void
CheckMultiTextureExtensions ( void )
{
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex"))
{
Con_Printf ("disabled\n");
return;
}
#ifdef HAVE_DLOPEN
dlhand = dlopen (NULL, RTLD_LAZY);
if (dlhand == NULL)
{
Con_Printf ("unable to check\n");
return;
}
if (strstr(gl_extensions, "GL_ARB_multitexture "))
{
Con_Printf ("GL_ARB_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
qglSelectTexture = (void *)dlsym(dlhand, "glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
gl_arb_mtex = true;
} else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
{
Con_Printf ("GL_SGIS_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fSGIS");
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureSGIS");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
{
Con_Printf ("GL_EXT_multitexture\n");
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fEXT");
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
gl_mtex_enum = TEXTURE0_SGIS;
gl_mtexable = true;
gl_arb_mtex = false;
} else {
Con_Printf ("none found\n");
}
dlclose(dlhand);
dlhand = NULL;
#else
gl_mtexable = false;
#endif
}
/*
===============
GL_Init
===============
*/
void GL_Init (void)
{
gl_vendor = glGetString (GL_VENDOR);
Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
gl_renderer = glGetString (GL_RENDERER);
Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
gl_version = glGetString (GL_VERSION);
Con_Printf ("GL_VERSION: %s\n", gl_version);
gl_extensions = glGetString (GL_EXTENSIONS);
Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
CheckMultiTextureExtensions ();
glClearColor (0,0,0,0);
glCullFace(GL_FRONT);
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.666);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
/* glShadeMode(GL_SMOOTH) should look better then GL_FLAT but
I don't know if it looks any better, sure is slower
glShadeModel (GL_SMOOTH);
*/
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);
}
/*
=================
GL_BeginRendering
=================
*/
void GL_BeginRendering (int *x, int *y, int *width, int *height)
{
*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(x_disp, x_win);
Sbar_Changed ();
}
qboolean VID_Is8bit(void)
{
return is8bit;
}
#ifdef GL_EXT_SHARED
void VID_Init8bitPalette()
{
// Check for 8bit Extensions and initialize them.
int i;
char thePalette[256*3];
char *oldPalette, *newPalette;
if (strstr(gl_extensions, "GL_EXT_shared_texture_palette") == NULL)
return;
Con_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
void VID_Init8bitPalette(void)
{
}
#endif
void VID_Init(unsigned char *palette)
{
int i;
int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
None
};
char gldir[MAX_OSPATH];
int width = 640, height = 480;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
XVisualInfo *visinfo;
vid_mode = Cvar_Get ("vid_mode","0",0,"None");
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"None");
#ifdef HAVE_DGA
in_dga_mouseaccel = Cvar_Get("vid_dga_mouseaccel","1",CVAR_ARCHIVE,
"None");
#endif
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 = width;
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;
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;
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");
exit(1);
}
#ifdef HAVE_DGA
{
int maj_ver;
hasdga = VID_CheckDGA(x_disp, &maj_ver, NULL, &hasdgavideo);
if (!hasdga || maj_ver < 1) {
hasdga = hasdgavideo = 0;
}
}
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;
attr.colormap = XCreateColormap(x_disp, root, visinfo->visual, AllocNone);
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);
XRaiseWindow(x_disp, x_win);
/* Invisible cursor */
CreateNullCursor(x_disp, x_win);
XDefineCursor(x_disp, x_win, nullcursor);
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
vid.width+2, vid.height+2);
#ifdef HAVE_VIDMODE
if (hasvidmode && vid_fullscreen->value) {
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
CurrentTime);
}
#endif
XSync(x_disp, 0);
ctx = glXCreateContext(x_disp, visinfo, NULL, True);
glXMakeCurrent(x_disp, x_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);
GL_CheckGamma (palette);
VID_SetPalette (palette);
// Check for 3DFX Extensions and initialize them.
VID_Init8bitPalette();
Con_SafePrintf ("Video mode %dx%d initialized.\n",
width, height);
vid_initialized = true;
vid.recalc_refdef = 1; // force a surface cache flush
}
void VID_InitCvars()
{
gl_triplebuffer = Cvar_Get("gl_triplebuffer","1",CVAR_ARCHIVE,"None");
}
void VID_SetCaption (char *text)
{
}

View file

@ -1156,7 +1156,7 @@ void I_DisplayWindow(int window)
{ {
} }
void Sys_SendKeyEvents(void) void IN_SendKeyEvents(void)
{ {
// get events from x server // get events from x server
if (x_disp) if (x_disp)

View file

@ -1213,7 +1213,7 @@ void I_DisplayWindow(int window)
{ {
} }
void Sys_SendKeyEvents(void) void IN_SendKeyEvents(void)
{ {
// get events from x server // get events from x server
if (x_disp) { if (x_disp) {

View file

@ -824,7 +824,7 @@ void VID_DitherOff(void)
} }
} }
void Sys_SendKeyEvents(void) void IN_SendKeyEvents(void)
{ {
if (!svgalib_inited) if (!svgalib_inited)
return; return;

File diff suppressed because it is too large Load diff