// start position 12 units behind head
}
-extern qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
-
void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
{
trace_t trace;
CL_Fog_f
======================
*/
-extern float fog_density, fog_red, fog_green, fog_blue;
void CL_Fog_f (void)
{
if (Cmd_Argc () == 1)
extern qboolean isworldmodel;
extern char skyname[];
-extern float fog_density;
-extern float fog_red;
-extern float fog_green;
-extern float fog_blue;
extern void R_SetSkyBox (char *sky);
extern void FOG_clear();
extern cvar_t r_farclip;
extern void SHOWLMP_decodeshow();
extern void R_SetSkyBox(char* sky);
-extern float fog_density;
-extern float fog_red;
-extern float fog_green;
-extern float fog_blue;
-
/*
=====================
CL_ParseServerMessage
void V_StopPitchDrift (void);
void V_RenderView (void);
-void V_UpdatePalette (void);
+void V_UpdateBlends (void);
void V_Register (void);
void V_ParseDamage (void);
void V_SetContentsColor (int contents);
#define GL_COLOR_INDEX8_EXT 0x80E5
-extern unsigned char d_15to8table[65536];
-
cvar_t qsg_version = {"qsg_version", "1"};
cvar_t scr_conalpha = {"scr_conalpha", "1"};
extern void LoadSky_f(void);
-extern char *QSG_EXTENSIONS;
-
/*
===============
Draw_Init
Cmd_AddCommand ("loadsky", &LoadSky_f);
-#ifdef NEHAHRA
-#if defined(__linux__)
- sprintf (engineversion, "DPNehahra Linux GL %.2f build %3i", (float) VERSION, buildnumber);
-#elif defined(WIN32)
- sprintf (engineversion, "DPNehahra Windows GL %.2f build %3i", (float) VERSION, buildnumber);
-#else
- sprintf (engineversion, "DPNehahra Unknown GL %.2f build %3i", (float) VERSION, buildnumber);
-#endif
-#else
#if defined(__linux__)
sprintf (engineversion, "DarkPlaces Linux GL %.2f build %3i", (float) VERSION, buildnumber);
#elif defined(WIN32)
sprintf (engineversion, "DarkPlaces Windows GL %.2f build %3i", (float) VERSION, buildnumber);
#else
sprintf (engineversion, "DarkPlaces Unknown GL %.2f build %3i", (float) VERSION, buildnumber);
-#endif
#endif
for (i = 0;i < 40 && engineversion[i];i++)
engineversion[i] += 0x80; // shift to orange
if (lerp != 0)
{
float ilerp, ilerp127, lerp127, scalex1, scalex2, translatex, scaley1, scaley2, translatey, scalez1, scalez2, translatez;
- if (lerp < 0) lerp = 0;
- if (lerp > 1) lerp = 1;
ilerp = 1 - lerp;
ilerp127 = ilerp * (1.0 / 127.0);
lerp127 = lerp * (1.0 / 127.0);
}
}
-extern cvar_t gl_vertexarrays;
-extern qboolean lighthalf;
void GL_DrawModelMesh(int skin, byte *colors, maliashdr_t *maliashdr)
{
int i;
int modeldlightbits[8];
extern int r_dlightframecount;
-extern void R_LightPoint (vec3_t color, vec3_t p);
/*
=================
}
int transpolyindices;
-extern qboolean isG200;
/*
void transpolyrenderminmax()
glDisable(GL_ALPHA_TEST);
}
-extern qboolean isG200;
-
void wallpolyclear()
{
currentwallpoly = currentwallvert = 0;
}
-extern qboolean lighthalf;
void wallpolyrender()
{
int i, j, texnum, lighttexnum;
currentskypoly = currentskyvert = 0;
}
-extern qboolean isATI;
-
extern char skyname[];
extern int solidskytexture, alphaskytexture;
void skypolyrender()
glDepthMask(1);
if (!fogenabled && !skyname[0]) // normal quake sky
{
- glColor3f(0.5f, 0.5f, 0.5f);
+ if(lighthalf)
+ glColor3f(0.5f, 0.5f, 0.5f);
+ else
+ glColor3f(1.0f,1.0f,1.0f);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
+extern float fog_density, fog_red, fog_green, fog_blue;
+
#define TPOLYTYPE_ALPHA 0
#define TPOLYTYPE_ADD 1
//int particletexture; // little dot for particles
//int playertextures; // up to 16 color translated skins
-extern qboolean isG200, isRagePro; // LordHavoc: special card hacks
-
//
// view origin
//
cvar_t gl_fogend = {"gl_fogend","0"};
cvar_t glfog = {"glfog", "0"};
-extern qboolean isRagePro;
-
qboolean lighthalf;
vec3_t fogcolor;
fog_blue = 0;
}
}
+ if (fog_density)
+ {
+ fogcolor[0] = fog_red = bound(0.0f, fog_red , 1.0f);
+ fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
+ fogcolor[2] = fog_blue = bound(0.0f, fog_blue , 1.0f);
+ if (lighthalf)
+ {
+ fogcolor[0] *= 0.5f;
+ fogcolor[1] *= 0.5f;
+ fogcolor[2] *= 0.5f;
+ }
+ }
if (glfog.value)
{
if (!r_render.value)
{
fogenabled = true;
fogdensity = -4000.0f / (fog_density * fog_density);
- fogcolor[0] = fog_red = bound(0.0f, fog_red , 1.0f);
- fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
- fogcolor[2] = fog_blue = bound(0.0f, fog_blue , 1.0f);
- if (lighthalf)
- {
- fogcolor[0] *= 0.5f;
- fogcolor[1] *= 0.5f;
- fogcolor[2] *= 0.5f;
- }
+ // fog color was already set
}
else
fogenabled = false;
R_StartModules();
}
+/*
+===============
+GL_Init
+===============
+*/
+extern char *QSG_EXTENSIONS;
+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);
+
+ VID_CheckMultiTexture();
+ VID_CheckVertexArrays();
+
+ // LordHavoc: report supported extensions
+ Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
+
+ glCullFace(GL_FRONT);
+ glEnable(GL_TEXTURE_2D);
+// glDisable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.5);
+
+// glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+
+ Palette_Init();
+}
+
+
/*
void R_RotateForEntity (entity_t *e)
{
#include "anorms.h"
};
-// LordHavoc: moved this shading stuff up because the sprites need shading stuff
+// LordHavoc: shading stuff
vec3_t shadevector;
vec3_t shadecolor;
float modelalpha;
-extern void R_LightPoint (vec3_t color, vec3_t p);
-extern void R_DynamicLightPoint(vec3_t color, vec3_t org, int *dlightbits);
-extern void R_DynamicLightPointNoMask(vec3_t color, vec3_t org);
-
-/*
-=============================================================
-
- SPRITE MODELS
-
-=============================================================
-*/
-
-/*
-================
-R_GetSpriteFrame
-================
-*/
-void R_GetSpriteFrame (entity_t *currententity, mspriteframe_t **oldframe, mspriteframe_t **newframe, float *framelerp)
-{
- msprite_t *psprite;
- mspritegroup_t *pspritegroup;
- int i, j, numframes, frame;
- float *pintervals, fullinterval, targettime, time, jtime, jinterval;
-
- psprite = currententity->model->cache.data;
- frame = currententity->frame;
-
- if ((frame >= psprite->numframes) || (frame < 0))
- {
- Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
- frame = 0;
- }
-
- if (psprite->frames[frame].type == SPR_SINGLE)
- {
- if (currententity->draw_lastmodel == currententity->model && currententity->draw_lerpstart < cl.time)
- {
- if (frame != currententity->draw_pose)
- {
- currententity->draw_lastpose = currententity->draw_pose;
- currententity->draw_pose = frame;
- currententity->draw_lerpstart = cl.time;
- *framelerp = 0;
- }
- else
- *framelerp = (cl.time - currententity->draw_lerpstart) * 10.0;
- }
- else // uninitialized
- {
- currententity->draw_lastmodel = currententity->model;
- currententity->draw_lastpose = currententity->draw_pose = frame;
- currententity->draw_lerpstart = cl.time;
- *framelerp = 0;
- }
- *oldframe = psprite->frames[currententity->draw_lastpose].frameptr;
- *newframe = psprite->frames[frame].frameptr;
- }
- else
- {
- pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
- pintervals = pspritegroup->intervals;
- numframes = pspritegroup->numframes;
- fullinterval = pintervals[numframes-1];
-
- time = cl.time + currententity->syncbase;
-
- // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
- // are positive, so we don't have to worry about division by 0
- targettime = time - ((int)(time / fullinterval)) * fullinterval;
-
- // LordHavoc: since I can't measure the time properly when it loops from numframes-1 to 0,
- // I instead measure the time of the first frame, hoping it is consistent
- j = numframes-1;jtime = 0;jinterval = pintervals[1] - pintervals[0];
- for (i=0 ; i<(numframes-1) ; i++)
- {
- if (pintervals[i] > targettime)
- break;
- j = i;jinterval = pintervals[i] - jtime;jtime = pintervals[i];
- }
- *framelerp = (targettime - jtime) / jinterval;
-
- *oldframe = pspritegroup->frames[j];
- *newframe = pspritegroup->frames[i];
- }
-}
-
-void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t right, int red, int green, int blue, int alpha)
-{
- // LordHavoc: rewrote this to use the transparent poly system
- transpolybegin(frame->gl_texturenum, 0, frame->gl_fogtexturenum, currententity->effects & EF_ADDITIVE ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
- transpolyvert(origin[0] + frame->down * up[0] + frame->left * right[0], origin[1] + frame->down * up[1] + frame->left * right[1], origin[2] + frame->down * up[2] + frame->left * right[2], 0, 1, red, green, blue, alpha);
- transpolyvert(origin[0] + frame->up * up[0] + frame->left * right[0], origin[1] + frame->up * up[1] + frame->left * right[1], origin[2] + frame->up * up[2] + frame->left * right[2], 0, 0, red, green, blue, alpha);
- transpolyvert(origin[0] + frame->up * up[0] + frame->right * right[0], origin[1] + frame->up * up[1] + frame->right * right[1], origin[2] + frame->up * up[2] + frame->right * right[2], 1, 0, red, green, blue, alpha);
- transpolyvert(origin[0] + frame->down * up[0] + frame->right * right[0], origin[1] + frame->down * up[1] + frame->right * right[1], origin[2] + frame->down * up[2] + frame->right * right[2], 1, 1, red, green, blue, alpha);
- transpolyend();
-}
-
-extern qboolean isG200, isRagePro, lighthalf;
-
-/*
-=================
-R_DrawSpriteModel
-
-=================
-*/
-void R_DrawSpriteModel (entity_t *e)
-{
- mspriteframe_t *oldframe, *newframe;
- float lerp, ilerp;
- vec3_t forward, right, up, org;
- msprite_t *psprite;
-
- // don't even bother culling, because it's just a single
- // polygon without a surface cache
- R_GetSpriteFrame (e, &oldframe, &newframe, &lerp);
- if (lerp < 0) lerp = 0;
- if (lerp > 1) lerp = 1;
- if (isRagePro) // LordHavoc: no alpha scaling supported on per pixel alpha images on ATI Rage Pro... ACK!
- lerp = 1;
- ilerp = 1.0 - lerp;
- psprite = e->model->cache.data;
-
- if (psprite->type == SPR_ORIENTED)
- { // bullet marks on walls
- AngleVectors (e->angles, forward, right, up);
- VectorSubtract(e->origin, vpn, org);
- }
- else
- { // normal sprite
- VectorCopy(vup, up);
- VectorCopy(vright, right);
- VectorCopy(e->origin, org);
- }
- if (e->scale != 1)
- {
- VectorScale(up, e->scale, up);
- VectorScale(right, e->scale, right);
- }
-
- if (e->model->flags & EF_FULLBRIGHT || e->effects & EF_FULLBRIGHT)
- {
- shadecolor[0] = e->colormod[0] * 255;
- shadecolor[1] = e->colormod[1] * 255;
- shadecolor[2] = e->colormod[2] * 255;
- }
- else
- {
- R_LightPoint (shadecolor, e->origin);
- R_DynamicLightPointNoMask(shadecolor, e->origin);
- }
-
- // LordHavoc: interpolated sprite rendering
- if (ilerp != 0)
- GL_DrawSpriteImage(oldframe, org, up, right, shadecolor[0],shadecolor[1],shadecolor[2],e->alpha*255*ilerp);
- if (lerp != 0)
- GL_DrawSpriteImage(newframe, org, up, right, shadecolor[0],shadecolor[1],shadecolor[2],e->alpha*255*lerp);
-}
-
//==================================================================================
void R_DrawBrushModel (entity_t *e);
+void R_DrawSpriteModel (entity_t *e);
/*
=============
R_RegisterModule("GL_Misc", gl_misc_start, gl_misc_shutdown);
}
-//qboolean VID_Is8bit(void);
-//void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
-
void R_ClearParticles (void);
void GL_BuildLightmaps (void);
#include "quakedef.h"
-extern int skytexturenum;
-
int lightmap_textures;
signed blocklights[18*18*3]; // LordHavoc: *3 for colored lighting
R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown);
}
-extern qboolean lighthalf;
/*
===============
R_BuildLightMap
===============
SCR_BringDownConsole
-Brings the console down and fades the palettes back to normal
+Brings the console down and fades the blends back to normal
================
*/
void SCR_BringDownConsole (void)
for (i=0 ; i<20 && scr_conlines != scr_con_current ; i++)
SCR_UpdateScreen ();
- cl.cshifts[0].percent = 0; // no area contents palette on next frame
+ cl.cshifts[0].percent = 0; // no area contents blend on next frame
}
void DrawCrosshair(int num);
else
{
if (crosshair.value)
- DrawCrosshair(crosshair.value);
+ DrawCrosshair(crosshair.value - 1);
SCR_DrawRam ();
SCR_DrawNet ();
Draw_String(vid.width - (12*8), 0, temp, 9999);
}
- V_UpdatePalette ();
+ V_UpdateBlends ();
GL_BrightenScreen();
typedef struct
{
int texnum;
+ int totaltexels;
byte *texels[MAXMIPS];
unsigned short texelsize[MAXMIPS][2];
char identifier[64];
}
}
+void GL_TextureStats_Print(char *name, int total, int crc, int mip, int alpha)
+{
+ char n[64];
+ int c = 0;
+ if (!name[0])
+ name = "<unnamed>";
+ while (name[c] && c < 28)
+ n[c++] = name[c];
+ while (c < 28)
+ n[c++] = ' ';
+ n[c] = 0;
+ Con_Printf("%s %5i %04X %s %s\n", n, total, crc, mip ? "yes" : "no ", alpha ? "yes " : "no ");
+}
+
+void GL_TextureStats_f(void)
+{
+ int i, t = 0;
+ gltexture_t *glt;
+ Con_Printf("name kbytes crc mip alpha\n");
+ for (i = 0, glt = gltextures;i < numgltextures;i++, glt++)
+ {
+ GL_TextureStats_Print(glt->identifier, ((glt->totaltexels * 4) + 512) >> 10, glt->crc, glt->mipmap, glt->alpha);
+ t += glt->totaltexels;
+ }
+ Con_Printf("%i textures, totalling %.3f mbytes\n", numgltextures, t / 1024.0 / 1024.0);
+}
+
extern int buildnumber;
char engineversion[40];
void GL_Textures_Init (void)
{
+ Cmd_AddCommand("r_texturestats", GL_TextureStats_f);
Cvar_RegisterVariable (&gl_max_size);
Cvar_RegisterVariable (&gl_picmip);
Cvar_RegisterVariable (&gl_lerpimages);
return -1;
}
-extern byte qgamma[];
-
-// LordHavoc: gamma correction and improved resampling
void GL_ResampleTextureLerpLine (byte *in, byte *out, int inwidth, int outwidth)
{
int j, xi, oldx = 0, f, fstep, l1, l2, endx;
*out++ = (byte) ((in[1] * l1 + in[5] * l2) >> 16);
*out++ = (byte) ((in[2] * l1 + in[6] * l2) >> 16);
*out++ = (byte) ((in[3] * l1 + in[7] * l2) >> 16);
-// *out++ = qgamma[(byte) ((in[0] * l1 + in[4] * l2) >> 16)];
-// *out++ = qgamma[(byte) ((in[1] * l1 + in[5] * l2) >> 16)];
-// *out++ = qgamma[(byte) ((in[2] * l1 + in[6] * l2) >> 16)];
-// *out++ = (byte) ((in[3] * l1 + in[7] * l2) >> 16) ;
}
else // last pixel of the line has no pixel to lerp to
{
*out++ = in[1];
*out++ = in[2];
*out++ = in[3];
-// *out++ = qgamma[in[0]];
-// *out++ = qgamma[in[1]];
-// *out++ = qgamma[in[2]];
-// *out++ = in[3] ;
}
}
}
*/
void GL_ResampleTexture (void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
{
- // LordHavoc: gamma correction and greatly improved resampling
if (gl_lerpimages.value)
{
int i, j, yi, oldy, f, fstep, l1, l2, endy = (inheight-1);
}
}
-/*
-================
-GL_Resample8BitTexture -- JACK
-================
-*/
-/*
-void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight)
-{
- int i, j;
- unsigned char *inrow;
- unsigned frac, fracstep;
-
- fracstep = inwidth*0x10000/outwidth;
- for (i=0 ; i<outheight ; i++, out += outwidth)
- {
- inrow = in + inwidth*(i*inheight/outheight);
- frac = fracstep >> 1;
- for (j=0 ; j<outwidth ; j+=4)
- {
- out[j ] = inrow[frac>>16];frac += fracstep;
- out[j+1] = inrow[frac>>16];frac += fracstep;
- out[j+2] = inrow[frac>>16];frac += fracstep;
- out[j+3] = inrow[frac>>16];frac += fracstep;
- }
- }
-}
-*/
-
-
-/*
-================
-GL_MipMap
-
-Operates in place, quartering the size of the texture
-================
-*/
-/*
-void GL_MipMap (byte *in, int width, int height)
-{
- int i, j;
- byte *out;
-
- width <<=2;
- height >>= 1;
- out = in;
- for (i=0 ; i<height ; i++, in+=width)
- {
- for (j=0 ; j<width ; j+=8, out+=4, in+=8)
- {
- out[0] = (in[0] + in[4] + in[width+0] + in[width+4])>>2;
- out[1] = (in[1] + in[5] + in[width+1] + in[width+5])>>2;
- out[2] = (in[2] + in[6] + in[width+2] + in[width+6])>>2;
- out[3] = (in[3] + in[7] + in[width+3] + in[width+7])>>2;
- }
- }
-}
-*/
-
-/*
-================
-GL_MipMap8Bit
-
-Mipping for 8 bit textures
-================
-*/
-/*
-void GL_MipMap8Bit (byte *in, int width, int height)
-{
- int i, j;
- unsigned short r,g,b;
- byte *out, *at1, *at2, *at3, *at4;
-
- height >>= 1;
- out = in;
- for (i=0 ; i<height ; i++, in+=width)
- {
- for (j=0 ; j<width ; j+=2, out+=1, in+=2)
- {
- at1 = (byte *) (d_8to24table + in[0]);
- at2 = (byte *) (d_8to24table + in[1]);
- at3 = (byte *) (d_8to24table + in[width+0]);
- at4 = (byte *) (d_8to24table + in[width+1]);
-
- r = (at1[0]+at2[0]+at3[0]+at4[0]); r>>=5;
- g = (at1[1]+at2[1]+at3[1]+at4[1]); g>>=5;
- b = (at1[2]+at2[2]+at3[2]+at4[2]); b>>=5;
-
- out[0] = d_15to8table[(r<<0) + (g<<5) + (b<<10)];
- }
- }
-}
-*/
-
-/*
-===============
-GL_Upload32
-===============
-*/
-/*
-void GL_Upload32 (void *data, int width, int height, qboolean mipmap, qboolean alpha)
-{
- int samples, scaled_width, scaled_height, i;
- byte *in, *out, *scaled;
-
- for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
- ;
- for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
- ;
-
- scaled_width >>= (int)gl_picmip.value;
- scaled_height >>= (int)gl_picmip.value;
-
- if (scaled_width > gl_max_size.value)
- scaled_width = gl_max_size.value;
- if (scaled_height > gl_max_size.value)
- scaled_height = gl_max_size.value;
-
- if (alpha)
- {
- alpha = false;
- in = data;
- for (i = 3;i < width*height*4;i += 4)
- if (in[i] != 255)
- {
- alpha = true;
- break;
- }
- }
-
- samples = alpha ? gl_alpha_format : gl_solid_format;
-
- texels += scaled_width * scaled_height;
-
- scaled = malloc(scaled_width*scaled_height*4);
- if (scaled_width == width && scaled_height == height)
- {
- // LordHavoc: gamma correct while copying
- in = (byte *)data;
- out = (byte *)scaled;
- for (i = 0;i < width*height;i++)
- {
- *out++ = qgamma[*in++];
- *out++ = qgamma[*in++];
- *out++ = qgamma[*in++];
- *out++ = *in++;
- }
- }
- else
- GL_ResampleTexture (data, width, height, scaled, scaled_width, scaled_height);
-
- glTexImage2D (GL_TEXTURE_2D, 0, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
- if (mipmap)
- {
- int miplevel;
-
- miplevel = 0;
- while (scaled_width > 1 || scaled_height > 1)
- {
- GL_MipMap ((byte *)scaled, scaled_width, scaled_height);
- scaled_width >>= 1;
- scaled_height >>= 1;
- if (scaled_width < 1)
- scaled_width = 1;
- if (scaled_height < 1)
- scaled_height = 1;
- miplevel++;
- glTexImage2D (GL_TEXTURE_2D, miplevel, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
- }
- }
-
- if (mipmap)
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
- else
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
- free(scaled);
-}
-
-void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap)
+void GL_FreeTexels(gltexture_t *glt)
{
- int scaled_width, scaled_height;
- byte *scaled = NULL;
-
- for (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)
- ;
- for (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)
- ;
-
- scaled_width >>= (int)gl_picmip.value;
- scaled_height >>= (int)gl_picmip.value;
-
- if (scaled_width > gl_max_size.value)
- scaled_width = gl_max_size.value;
- if (scaled_height > gl_max_size.value)
- scaled_height = gl_max_size.value;
-
- texels += scaled_width * scaled_height;
-
- if (scaled_width == width && scaled_height == height)
- {
- if (!mipmap)
- {
- glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX , GL_UNSIGNED_BYTE, data);
- goto done;
- }
- scaled = malloc(scaled_width*scaled_height*4);
- memcpy (scaled, data, width*height);
- }
- else
- {
- scaled = malloc(scaled_width*scaled_height*4);
- GL_Resample8BitTexture (data, width, height, (void*) scaled, scaled_width, scaled_height);
- }
-
- glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
- if (mipmap)
- {
- int miplevel;
-
- miplevel = 0;
- while (scaled_width > 1 || scaled_height > 1)
- {
- GL_MipMap8Bit ((byte *)scaled, scaled_width, scaled_height);
- scaled_width >>= 1;
- scaled_height >>= 1;
- if (scaled_width < 1)
- scaled_width = 1;
- if (scaled_height < 1)
- scaled_height = 1;
- miplevel++;
- glTexImage2D (GL_TEXTURE_2D, miplevel, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
- }
- }
-done: ;
-
-
- if (mipmap)
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
- else
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
- free(scaled);
-}
-*/
-
-extern qboolean VID_Is8bit();
-
-/*
-===============
-GL_Upload8
-===============
-*/
-/*
-void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha)
-{
- static unsigned *trans;
- int i, s;
- qboolean noalpha;
- int p;
- byte *indata;
- int *outdata;
-
- s = width*height;
- trans = malloc(s*4);
- // if there are no transparent pixels, make it a 3 component
- // texture even if it was specified as otherwise
- if (alpha)
- {
- noalpha = true;
- for (i=0 ; i<s ; i++)
- {
- p = data[i];
- if (p != 255)
- trans[i] = d_8to24table[p];
- else
- {
- trans[i] = 0; // force to black
- noalpha = false;
- }
- }
-
- if (noalpha)
- {
- if (VID_Is8bit() && (data!=scrap_texels[0]))
- {
- GL_Upload8_EXT (data, width, height, mipmap);
- free(trans);
- return;
- }
- alpha = false;
- }
- }
- else
- {
- // LordHavoc: dodge the copy if it will be uploaded as 8bit
- if (VID_Is8bit() && (data!=scrap_texels[0]))
- {
- GL_Upload8_EXT (data, width, height, mipmap);
- free(trans);
- return;
- }
- //if (s&3)
- // Sys_Error ("GL_Upload8: s&3");
- indata = data;
- outdata = trans;
- if (s&1)
- *outdata++ = d_8to24table[*indata++];
- if (s&2)
- {
- *outdata++ = d_8to24table[*indata++];
- *outdata++ = d_8to24table[*indata++];
- }
- for (i = 0;i < s;i+=4)
- {
- *outdata++ = d_8to24table[*indata++];
- *outdata++ = d_8to24table[*indata++];
- *outdata++ = d_8to24table[*indata++];
- *outdata++ = d_8to24table[*indata++];
- }
- }
-
- GL_Upload32 (trans, width, height, mipmap, alpha);
- free(trans);
+ if (glt->texels[0])
+ free(glt->texels[0]);
+ glt->texels[0] = 0;
}
-*/
void GL_AllocTexels(gltexture_t *glt, int width, int height, int mipmapped)
{
int i, w, h, size, done;
if (glt->texels[0])
- free(glt->texels[0]);
+ GL_FreeTexels(glt);
glt->texelsize[0][0] = width;
glt->texelsize[0][1] = height;
if (mipmapped)
break;
}
}
+ glt->totaltexels = size;
while (i < MAXMIPS)
glt->texels[i++] = NULL;
glt->texels[0] = malloc(size);
}
else
{
- glt->texels[0] = malloc(width*height*4);
+ size = width*height*4;
+ glt->totaltexels = size;
+ glt->texels[0] = malloc(size);
for (i = 1;i < MAXMIPS;i++)
glt->texels[i] = NULL;
}
for (mip = 1;mip < MAXMIPS && glt->texels[mip];mip++)
GL_MipReduce(glt->texels[mip-1], glt->texels[mip], glt->texelsize[mip-1][0], glt->texelsize[mip-1][1], 1, 1);
GL_UploadTexture(glt);
+ GL_FreeTexels(glt);
// if (bytesperpixel == 1) // 8bit
// GL_Upload8 (data, width, height, mipmap, alpha);
-extern qboolean lighthalf;
-
int skyboxside[6];
char skyname[256];
// LordHavoc: moved LoadTGA and LoadPCX to gl_draw.c
-extern int image_width, image_height;
-
-byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight);
/*
==================
R_LoadSkyBox
// LordHavoc: ARB multitexure support
extern int gl_mtex_enum;
+
+// for platforms (wgl) that do not use GLAPIENTRY
+#ifndef GLAPIENTRY
+#define GLAPIENTRY APIENTRY
+#endif
+
// Micro$oft dropped GL support beyond 1.1, so...
#ifdef WIN32
// LordHavoc: vertex array defines
#define GL_VERTEX_ARRAY 0x8074
-//#define GL_NORMAL_ARRAY 0x8075
+#define GL_NORMAL_ARRAY 0x8075
#define GL_COLOR_ARRAY 0x8076
-//#define GL_INDEX_ARRAY 0x8077
#define GL_TEXTURE_COORD_ARRAY 0x8078
-//#define GL_EDGE_FLAG_ARRAY 0x8079
-/*
-#define GL_V2F 0x2A20
-#define GL_V3F 0x2A21
-#define GL_C4UB_V2F 0x2A22
-#define GL_C4UB_V3F 0x2A23
-#define GL_C3F_V3F 0x2A24
-#define GL_N3F_V3F 0x2A25
-#define GL_C4F_N3F_V3F 0x2A26
-#define GL_T2F_V3F 0x2A27
-#define GL_T4F_V4F 0x2A28
-#define GL_T2F_C4UB_V3F 0x2A29
-#define GL_T2F_C3F_V3F 0x2A2A
-#define GL_T2F_N3F_V3F 0x2A2B
-#define GL_T2F_C4F_N3F_V3F 0x2A2C
-#define GL_T4F_C4F_N3F_V4F 0x2A2D
-*/
-//extern void (APIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
-extern void (APIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
-extern void (APIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglIndexPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
-extern void (APIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglEdgeFlagPointer)(GLsizei stride, const GLvoid *ptr);
-//extern void (APIENTRY *qglGetPointerv)(GLenum pname, void **params);
-extern void (APIENTRY *qglArrayElement)(GLint i);
-//extern void (APIENTRY *qglDrawArrays)(GLenum mode, GLint first, GLsizei count);
-extern void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
-//extern void (APIENTRY *qglInterleavedArrays)(GLenum format, GLsizei stride, const GLvoid *pointer);
-
-extern void (APIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-extern void (APIENTRY *qglSelectTexture) (GLenum);
-extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+//extern void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
+extern void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+//extern void (GLAPIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglArrayElement)(GLint i);
+//extern void (GLAPIENTRY *qglDrawArrays)(GLenum mode, GLint first, GLsizei count);
+extern void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+
+extern void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (GLAPIENTRY *qglSelectTexture) (GLenum);
+//extern void (GLAPIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
#else
#define qglVertexPointer glVertexPointer
//#define qglNormalPointer glNormalPointer
#define qglColorPointer glColorPointer
-//#define qglIndexPointer glIndexPointer
#define qglTexCoordPointer glTexCoordPointer
-//#define qglEdgeFlagPointer glEdgeFlagPointer
-//#define qglGetPointerv glGetPointerv
#define qglArrayElement glArrayElement
//#define qglDrawArrays glDrawArrays
#define qglDrawElements glDrawElements
-//#define qglInterleavedArrays glInterleavedArrays
-extern void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
-extern void (*qglSelectTexture) (GLenum);
-#ifndef MESA
-extern void (*glColorTableEXT)(int, int, int, int, int, const void*);
-#endif
+extern void (GLAPIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (GLAPIENTRY *qglSelectTexture) (GLenum);
+//#ifndef MESA
+//extern void (GLAPIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+//#endif
#endif
#include "r_modules.h"
+extern cvar_t gl_vertexarrays;
+extern qboolean lighthalf;
+
extern void R_DrawAliasModel (entity_t *ent, int cull, float alpha, model_t *clmodel, int frame, int skin, vec3_t org, int effects, int flags, int colormap);
extern cvar_t r_render;
jmp_buf host_abortserver;
-byte *host_basepal;
-
cvar_t host_framerate = {"host_framerate","0"}; // set for slow motion
cvar_t host_speeds = {"host_speeds","0"}; // set for running times
cvar_t slowmo = {"slowmo", "1.0"}; // LordHavoc: framerate independent slowmo
#define VCR_SIGNATURE 0x56435231
// "VCR1"
-void Host_InitVCR (quakeparms_t *parms)
+void Host_InitVCR ()
{
int i, len, n;
char *p;
Sys_FileRead (vcrFile, &com_argc, sizeof(int));
com_argv = malloc(com_argc * sizeof(char *));
- com_argv[0] = parms->argv[0];
+ com_argv[0] = host_parms.argv[0];
for (i = 0; i < com_argc; i++)
{
Sys_FileRead (vcrFile, &len, sizeof(int));
com_argv[i+1] = p;
}
com_argc++; /* add one for arg[0] */
- parms->argc = com_argc;
- parms->argv = com_argv;
+ host_parms.argc = com_argc;
+ host_parms.argv = com_argv;
}
if ( (n = COM_CheckParm("-record")) != 0)
Host_Init
====================
*/
-void Host_Init (quakeparms_t *parms)
+void Host_Init ()
{
if (standard_quake)
minimum_memory = MINIMUM_MEMORY_LEVELPAK;
if (COM_CheckParm ("-minmemory"))
- parms->memsize = minimum_memory;
-
- host_parms = *parms;
+ host_parms.memsize = minimum_memory;
- if (parms->memsize < minimum_memory)
- Sys_Error ("Only %4.1f megs of memory available, can't execute game", parms->memsize / (float)0x100000);
+ if (host_parms.memsize < minimum_memory)
+ Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms.memsize / (float)0x100000);
- com_argc = parms->argc;
- com_argv = parms->argv;
+ com_argc = host_parms.argc;
+ com_argv = host_parms.argv;
- Memory_Init (parms->membase, parms->memsize);
+ Memory_Init (host_parms.membase, host_parms.memsize);
Cbuf_Init ();
Cmd_Init ();
V_Init ();
Chase_Init ();
- Host_InitVCR (parms);
- COM_Init (parms->basedir);
+ Host_InitVCR ();
+ COM_Init (host_parms.basedir);
Host_InitLocal ();
W_LoadWadFile ("gfx.wad");
Key_Init ();
SV_Init ();
Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
- Con_Printf ("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0));
+ Con_Printf ("%4.1f megabyte heap\n",host_parms.memsize/(1024*1024.0));
R_InitTextures (); // needed even for dedicated servers
if (cls.state != ca_dedicated)
{
- host_basepal = (byte *)COM_LoadHunkFile ("gfx/palette.lmp", false);
- if (!host_basepal)
- Sys_Error ("Couldn't load gfx/palette.lmp");
- host_basepal[765] = host_basepal[766] = host_basepal[767] = 0; // LordHavoc: force the transparent color to black
+ Palette_Init("gfx/palette.lmp");
#ifndef _WIN32 // on non win32, mouse comes before video for security reasons
IN_Init ();
#endif
- VID_Init (host_basepal);
+ VID_Init ();
Render_Init();
S_Init ();
iout[0] = pal[in[0]];
}
-extern byte qgamma[];
void Image_CopyRGBAGamma(byte *in, byte *out, int pixels)
{
while (pixels--)
pcx = &pcxbuf;
- if (pcx->manufacturer != 0x0a
- || pcx->version != 5
- || pcx->encoding != 1
- || pcx->bits_per_pixel != 8
- || pcx->xmax > 320
- || pcx->ymax > 256)
+ // LordHavoc: big-endian support ported from QF newtree
+ pcx->xmax = LittleShort (pcx->xmax);
+ pcx->xmin = LittleShort (pcx->xmin);
+ pcx->ymax = LittleShort (pcx->ymax);
+ pcx->ymin = LittleShort (pcx->ymin);
+ pcx->hres = LittleShort (pcx->hres);
+ pcx->vres = LittleShort (pcx->vres);
+ pcx->bytes_per_line = LittleShort (pcx->bytes_per_line);
+ pcx->palette_type = LittleShort (pcx->palette_type);
+
+ if (pcx->manufacturer != 0x0a || pcx->version != 5 || pcx->encoding != 1 || pcx->bits_per_pixel != 8 || pcx->xmax > 320 || pcx->ymax > 256)
{
Con_Printf ("Bad pcx file\n");
return NULL;
{
runLength = dataByte & 0x3F;
dataByte = fgetc(f);
+ if (runLength)
+ {
+ x += runLength;
+ while(runLength--)
+ {
+ pix[0] = palette[dataByte*3];
+ pix[1] = palette[dataByte*3+1];
+ pix[2] = palette[dataByte*3+2];
+ pix[3] = 255;
+ pix += 4;
+ }
+ }
}
else
- runLength = 1;
-
- while(runLength-- > 0)
{
+ x++;
pix[0] = palette[dataByte*3];
pix[1] = palette[dataByte*3+1];
pix[2] = palette[dataByte*3+2];
pix[3] = 255;
pix += 4;
- x++;
}
+
}
}
fclose(f);
char basename[128], name[128];
byte *image_rgba, *c;
COM_StripExtension(filename, basename); // strip the extension to allow TGA skins on Q2 models despite the .pcx in the skin name
- // replace *'s with +, so commandline utils don't get confused when dealing with the external files
- c = basename;
- while (*c)
- {
+ // replace *'s with #, so commandline utils don't get confused when dealing with the external files
+ for (c = basename;*c;c++)
if (*c == '*')
- *c = '+';
- c++;
- }
+ *c = '#';
sprintf (name, "textures/%s.tga", basename);
COM_FOpenFile (name, &f, true);
if (f)
case JOY_AXIS_V:
return &ji.dwVpos;
}
+ return NULL; // LordHavoc: hush compiler warning
}
{
}
-//aliashdr_t *pheader;
-
-//typedef struct
-//{
-// int v[3];
-// vec3_t normal;
-//} temptris_t;
-//temptris_t *temptris;
-//stvert_t stverts[MAXALIASVERTS];
-//mtriangle_t triangles[MAXALIASTRIS];
-
-// a pose is a single set of vertexes. a frame may be
-// an animating sequence of poses
-//trivertx_t *poseverts[MAXALIASFRAMES];
int posenum;
-byte **player_8bit_texels_tbl;
-byte *player_8bit_texels;
-
float aliasbboxmin[3], aliasbboxmax[3]; // LordHavoc: proper bounding box considerations
#define MAXVERTS 8192
short x, y;
} floodfill_t;
-extern unsigned d_8to24table[];
-
// must be a power of 2
#define FLOODFILL_FIFO_SIZE 0x1000
#define FLOODFILL_FIFO_MASK (FLOODFILL_FIFO_SIZE - 1)
texture_t *anims[10];
texture_t *altanims[10];
dmiptexlump_t *m;
- byte *data;
+ byte *data;
if (!l->filelen)
{
tx = Hunk_AllocName (sizeof(texture_t), loadname );
loadmodel->textures[i] = tx;
- memcpy (tx->name, mt->name, sizeof(tx->name));
+ // LordHavoc: force all names to lowercase and make sure they are terminated while copying
+ for (j = 0;mt->name[j] && j < 15;j++)
+ {
+ if (mt->name[j] >= 'A' && mt->name[j] <= 'Z')
+ tx->name[j] = mt->name[j] + ('a' - 'A');
+ else
+ tx->name[j] = mt->name[j];
+ }
+ for (;j < 16;j++)
+ tx->name[j] = 0;
+
tx->width = mt->width;
tx->height = mt->height;
for (j=0 ; j<MIPLEVELS ; j++)
bytesperpixel = 4;
fullbrights = FALSE;
transparent = TRUE;
- data = loadimagepixels(mt->name, FALSE, 0, 0); //tx->width, tx->height);
+ data = loadimagepixels(tx->name, FALSE, 0, 0); //tx->width, tx->height);
if (!data) // no external texture found
{
freeimage = FALSE;
if (!hlbsp && mt->offsets[0]) // texture included
{
data = (byte *)((int) mt + mt->offsets[0]);
- if (r_fullbrights.value && mt->name[0] != '*')
+ if (r_fullbrights.value && tx->name[0] != '*')
{
for (j = 0;j < tx->width*tx->height;j++)
if (data[j] >= 224) // fullbright
tx->width = image_width;
tx->height = image_height;
}
- if (!hlbsp && !strncmp(mt->name,"sky",3) && tx->width == 256 && tx->height == 128) // LordHavoc: HL sky textures are entirely unrelated
+ if (!hlbsp && !strncmp(tx->name,"sky",3) && tx->width == 256 && tx->height == 128) // LordHavoc: HL sky textures are entirely unrelated
{
tx->transparent = FALSE;
R_InitSky (data, bytesperpixel);
}
if (freeimage)
free(data);
-
- /*
- pixels = mt->width*mt->height/64*85;
- tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname );
- loadmodel->textures[i] = tx;
-
- memcpy (tx->name, mt->name, sizeof(tx->name));
- tx->width = mt->width;
- tx->height = mt->height;
- for (j=0 ; j<MIPLEVELS ; j++)
- tx->offsets[j] = mt->offsets[j] + sizeof(texture_t) - sizeof(miptex_t);
- // the pixels immediately follow the structures
- memcpy ( tx+1, mt+1, pixels);
-
-
- if (!strncmp(mt->name,"sky",3))
- R_InitSky (tx);
- else
- tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false, 1);
- */
}
//
psprite->frames[i].type = frametype;
if (frametype == SPR_SINGLE)
- {
- pframetype = (dspriteframetype_t *)
- Mod_LoadSpriteFrame (pframetype + 1,
- &psprite->frames[i].frameptr, i, bytesperpixel);
- }
+ pframetype = (dspriteframetype_t *) Mod_LoadSpriteFrame (pframetype + 1, &psprite->frames[i].frameptr, i, bytesperpixel);
else
- {
- pframetype = (dspriteframetype_t *)
- Mod_LoadSpriteGroup (pframetype + 1,
- &psprite->frames[i].frameptr, i, bytesperpixel);
- }
+ pframetype = (dspriteframetype_t *) Mod_LoadSpriteGroup (pframetype + 1, &psprite->frames[i].frameptr, i, bytesperpixel);
}
mod->type = mod_sprite;
--- /dev/null
+
+#include "quakedef.h"
+
+unsigned int d_8to24table[256];
+//byte d_15to8table[32768];
+byte host_basepal[768];
+byte qgamma[256];
+static float vid_gamma = 1.0;
+
+void Palette_Setup8to24()
+{
+ byte *in, *out;
+ unsigned short i;
+
+ in = host_basepal;
+ out = (byte *) d_8to24table; // d_8to24table is accessed as 32bit for speed reasons, but is created as 8bit bytes
+ for (i=0 ; i<255 ; i++)
+ {
+ *out++ = *in++;
+ *out++ = *in++;
+ *out++ = *in++;
+ *out++ = 255;
+ }
+ d_8to24table[255] = 0; // completely transparent black
+}
+
+/*
+void Palette_Setup15to8()
+{
+ byte *pal;
+ unsigned r,g,b;
+ unsigned v;
+ int r1,g1,b1;
+ int j,k,l;
+ unsigned short i;
+
+ for (i = 0;i < 32768;i++)
+ {
+ r = ((i & 0x001F) << 3)+4;
+ g = ((i & 0x03E0) >> 2)+4;
+ b = ((i & 0x7C00) >> 7)+4;
+ pal = (unsigned char *)d_8to24table;
+ for (v = 0, k = 0, l = 1000000000;v < 256;v++, pal += 4)
+ {
+ r1 = r - pal[0];
+ g1 = g - pal[1];
+ b1 = b - pal[2];
+ j = r1*r1+g1*g1+b1*b1;
+ if (j < l)
+ {
+ k = v;
+ l = j;
+ }
+ }
+ d_15to8table[i] = k;
+ }
+}
+*/
+
+void Palette_Gamma ()
+{
+ float inf;
+ int i;
+
+ vid_gamma = 1;
+ if ((i = COM_CheckParm("-gamma")))
+ vid_gamma = atof(com_argv[i+1]);
+
+ if (vid_gamma == 1) // LordHavoc: dodge the math
+ {
+ for (i = 0;i < 256;i++)
+ qgamma[i] = i;
+ }
+ else
+ {
+ for (i = 0;i < 256;i++)
+ {
+ inf = pow((i+1)/256.0, vid_gamma)*255 + 0.5;
+ if (inf < 0) inf = 0;
+ if (inf > 255) inf = 255;
+ qgamma[i] = inf;
+ }
+ }
+}
+
+void Palette_Init()
+{
+ byte *pal;
+ pal = (byte *)COM_LoadMallocFile ("gfx/palette.lmp", false);
+ if (!pal)
+ Sys_Error ("Couldn't load gfx/palette.lmp");
+ memcpy(host_basepal, pal, 765);
+ free(pal);
+ host_basepal[765] = host_basepal[766] = host_basepal[767] = 0; // LordHavoc: force the transparent color to black
+ Palette_Setup8to24();
+// Palette_Setup15to8();
+ Palette_Gamma();
+}
--- /dev/null
+
+extern unsigned int d_8to24table[256];
+//extern byte d_15to8table[32768];
+extern byte host_basepal[768];
+extern byte qgamma[256];
+extern float vid_gamma;
+
+void Palette_Init();
extern qboolean host_initialized; // true if into command execution
extern double host_frametime;
-extern byte *host_basepal;
extern int host_framecount; // incremented every frame, never reset
extern double realtime; // not bounded in any way, changed at
// start of every frame, never reset
void Host_ClearMemory (void);
void Host_ServerFrame (void);
void Host_InitCommands (void);
-void Host_Init (quakeparms_t *parms);
+void Host_Init ();
void Host_Shutdown(void);
void Host_Error (char *error, ...);
void Host_EndGame (char *message, ...);
void fractalnoise(unsigned char *noise, int size, int startgrid);
+#include "palette.h"
#include "image.h"
cvar_t crosshair_flashspeed = {"crosshair_flashspeed", "2", true};
cvar_t crosshair_flashrange = {"crosshair_flashrange", "0.1", true};
-#define NUMCROSSHAIRS 1
+#define NUMCROSSHAIRS 5
int crosshairtex[NUMCROSSHAIRS];
-char crosshairtex1[16*16] =
+byte *crosshairtexdata[NUMCROSSHAIRS] =
+{
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0003300000033000"
+ "0003550000553000"
+ "0000577007750000"
+ "0000077007700000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000077007700000"
+ "0000577007750000"
+ "0003550000553000"
+ "0003300000033000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ ,
"0000000000000000"
"0000000000000000"
"0000000000000000"
"0000000000000000"
"0000000000000000"
"0000000000000000"
-;
+ ,
+ "0000000000000000"
+ "0000000770000000"
+ "0000000770000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000440000000"
+ "0000000440000000"
+ "0770044004400770"
+ "0770044004400770"
+ "0000000440000000"
+ "0000000440000000"
+ "0000000000000000"
+ "0000000770000000"
+ "0000000770000000"
+ "0000000000000000"
+ "0000000000000000"
+ ,
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000077777770"
+ "0000000075200000"
+ "0000000072000000"
+ "0000000070000000"
+ "0000000070000000"
+ "0000000070000000"
+ "0000000000000000"
+ "0000000000000000"
+ ,
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000070000000"
+ "0000000000000000"
+ "0000000040000000"
+ "0000070404070000"
+ "0000000040000000"
+ "0000000000000000"
+ "0000000070000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+ "0000000000000000"
+};
-void r_crosshairs_start()
+void crosshairload(int num, byte *in)
{
int i;
- byte data[64*64][4];
+ byte data[16*16][4];
for (i = 0;i < 16*16;i++)
{
data[i][0] = data[i][1] = data[i][2] = 255;
- data[i][3] = (crosshairtex1[i] - '0') * 255 / 7;
+ data[i][3] = (in[i] - '0') * 255 / 7;
}
- crosshairtex[0] = GL_LoadTexture("crosshair0", 16, 16, &data[0][0], false, true, 4);
+ crosshairtex[num] = GL_LoadTexture(va("crosshair%02d", num), 16, 16, &data[0][0], false, true, 4);
+}
+
+void r_crosshairs_start()
+{
+ int i;
+ for (i = 0;i < NUMCROSSHAIRS;i++)
+ crosshairload(i, crosshairtexdata[i]);
+// crosshairtex[1] = crosshairload(crosshairtex2);
}
void r_crosshairs_shutdown()
extern float *aliasvertnorm;
extern byte *aliasvertcolor;
extern float modelalpha;
-extern qboolean lighthalf;
extern int modeldlightbits[8];
void R_LightModel(int numverts, vec3_t center, vec3_t basecolor)
{
}
-extern qboolean lighthalf;
-
/*
===============
R_DrawParticles
--- /dev/null
+#include "quakedef.h"
+
+/*
+================
+R_GetSpriteFrame
+================
+*/
+void R_GetSpriteFrame (entity_t *currententity, mspriteframe_t **oldframe, mspriteframe_t **newframe, float *framelerp)
+{
+ msprite_t *psprite;
+ mspritegroup_t *pspritegroup;
+ int i, j, numframes, frame;
+ float *pintervals, fullinterval, targettime, time, jtime, jinterval;
+
+ psprite = currententity->model->cache.data;
+ frame = currententity->frame;
+
+ if ((frame >= psprite->numframes) || (frame < 0))
+ {
+ Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
+ frame = 0;
+ }
+
+ if (psprite->frames[frame].type == SPR_SINGLE)
+ {
+ if (currententity->draw_lastmodel == currententity->model && currententity->draw_lerpstart < cl.time)
+ {
+ if (frame != currententity->draw_pose)
+ {
+ currententity->draw_lastpose = currententity->draw_pose;
+ currententity->draw_pose = frame;
+ currententity->draw_lerpstart = cl.time;
+ *framelerp = 0;
+ }
+ else
+ *framelerp = (cl.time - currententity->draw_lerpstart) * 10.0;
+ }
+ else // uninitialized
+ {
+ currententity->draw_lastmodel = currententity->model;
+ currententity->draw_lastpose = currententity->draw_pose = frame;
+ currententity->draw_lerpstart = cl.time;
+ *framelerp = 0;
+ }
+ *oldframe = psprite->frames[currententity->draw_lastpose].frameptr;
+ *newframe = psprite->frames[frame].frameptr;
+ }
+ else
+ {
+ pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
+ pintervals = pspritegroup->intervals;
+ numframes = pspritegroup->numframes;
+ fullinterval = pintervals[numframes-1];
+
+ time = cl.time + currententity->syncbase;
+
+ // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
+ // are positive, so we don't have to worry about division by 0
+ targettime = time - ((int)(time / fullinterval)) * fullinterval;
+
+ // LordHavoc: since I can't measure the time properly when it loops from numframes-1 to 0,
+ // I instead measure the time of the first frame, hoping it is consistent
+ j = numframes-1;jtime = 0;jinterval = pintervals[1] - pintervals[0];
+ for (i=0 ; i<(numframes-1) ; i++)
+ {
+ if (pintervals[i] > targettime)
+ break;
+ j = i;jinterval = pintervals[i] - jtime;jtime = pintervals[i];
+ }
+ *framelerp = (targettime - jtime) / jinterval;
+
+ *oldframe = pspritegroup->frames[j];
+ *newframe = pspritegroup->frames[i];
+ }
+}
+
+void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t right, int red, int green, int blue, int alpha)
+{
+ // LordHavoc: rewrote this to use the transparent poly system
+ transpolybegin(frame->gl_texturenum, 0, frame->gl_fogtexturenum, currententity->effects & EF_ADDITIVE ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
+ transpolyvert(origin[0] + frame->down * up[0] + frame->left * right[0], origin[1] + frame->down * up[1] + frame->left * right[1], origin[2] + frame->down * up[2] + frame->left * right[2], 0, 1, red, green, blue, alpha);
+ transpolyvert(origin[0] + frame->up * up[0] + frame->left * right[0], origin[1] + frame->up * up[1] + frame->left * right[1], origin[2] + frame->up * up[2] + frame->left * right[2], 0, 0, red, green, blue, alpha);
+ transpolyvert(origin[0] + frame->up * up[0] + frame->right * right[0], origin[1] + frame->up * up[1] + frame->right * right[1], origin[2] + frame->up * up[2] + frame->right * right[2], 1, 0, red, green, blue, alpha);
+ transpolyvert(origin[0] + frame->down * up[0] + frame->right * right[0], origin[1] + frame->down * up[1] + frame->right * right[1], origin[2] + frame->down * up[2] + frame->right * right[2], 1, 1, red, green, blue, alpha);
+ transpolyend();
+}
+
+/*
+=================
+R_DrawSpriteModel
+
+=================
+*/
+void R_DrawSpriteModel (entity_t *e)
+{
+ mspriteframe_t *oldframe, *newframe;
+ float lerp, ilerp;
+ vec3_t forward, right, up, org, color;
+ msprite_t *psprite;
+
+ // don't even bother culling, because it's just a single
+ // polygon without a surface cache
+ R_GetSpriteFrame (e, &oldframe, &newframe, &lerp);
+ if (lerp < 0) lerp = 0;
+ if (lerp > 1) lerp = 1;
+ if (isRagePro) // LordHavoc: no alpha scaling supported on per pixel alpha images on ATI Rage Pro... ACK!
+ lerp = 1;
+ ilerp = 1.0 - lerp;
+ psprite = e->model->cache.data;
+
+ if (psprite->type == SPR_ORIENTED)
+ { // bullet marks on walls
+ AngleVectors (e->angles, forward, right, up);
+ VectorSubtract(e->origin, vpn, org);
+ }
+ else
+ { // normal sprite
+ VectorCopy(vup, up);
+ VectorCopy(vright, right);
+ VectorCopy(e->origin, org);
+ }
+ if (e->scale != 1)
+ {
+ VectorScale(up, e->scale, up);
+ VectorScale(right, e->scale, right);
+ }
+
+ if (e->model->flags & EF_FULLBRIGHT || e->effects & EF_FULLBRIGHT)
+ {
+ color[0] = e->colormod[0] * 255;
+ color[1] = e->colormod[1] * 255;
+ color[2] = e->colormod[2] * 255;
+ }
+ else
+ {
+ R_LightPoint (color, e->origin);
+ R_DynamicLightPointNoMask(color, e->origin);
+ }
+
+ // LordHavoc: interpolated sprite rendering
+ if (ilerp != 0)
+ GL_DrawSpriteImage(oldframe, org, up, right, color[0],color[1],color[2],e->alpha*255*ilerp);
+ if (lerp != 0)
+ GL_DrawSpriteImage(newframe, org, up, right, color[0],color[1],color[2],e->alpha*255*lerp);
+}
+
extern struct texture_s *r_notexture_mip;
-void R_Init (void);
-void R_InitTextures (void);
-void R_InitEfrags (void);
-void R_RenderView (void); // must set r_refdef first
-void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
+extern void R_Init (void);
+extern void R_InitTextures (void);
+extern void R_InitEfrags (void);
+extern void R_RenderView (void); // must set r_refdef first
+extern void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
// called whenever r_refdef or vid change
// LordHavoc: changed this for sake of GLQuake
-void R_InitSky (byte *src, int bytesperpixel); // called at level load
-//void R_InitSky (struct texture_s *mt); // called at level load
+extern void R_InitSky (byte *src, int bytesperpixel); // called at level load
+//extern void R_InitSky (struct texture_s *mt); // called at level load
-void R_AddEfrags (entity_t *ent);
-void R_RemoveEfrags (entity_t *ent);
+extern void R_AddEfrags (entity_t *ent);
+extern void R_RemoveEfrags (entity_t *ent);
-void R_NewMap (void);
+extern void R_NewMap (void);
-void R_ParseParticleEffect (void);
-void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
-void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
-void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
-void R_SparkShower (vec3_t org, vec3_t dir, int count);
-void R_BloodPuff (vec3_t org);
+extern void R_ParseParticleEffect (void);
+extern void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
+extern void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
+extern void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
+extern void R_SparkShower (vec3_t org, vec3_t dir, int count);
+extern void R_BloodPuff (vec3_t org);
-void R_EntityParticles (entity_t *ent);
-void R_BlobExplosion (vec3_t org);
-void R_ParticleExplosion (vec3_t org, int smoke);
-void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
-void R_LavaSplash (vec3_t org);
-void R_TeleportSplash (vec3_t org);
+extern void R_EntityParticles (entity_t *ent);
+extern void R_BlobExplosion (vec3_t org);
+extern void R_ParticleExplosion (vec3_t org, int smoke);
+extern void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
+extern void R_LavaSplash (vec3_t org);
+extern void R_TeleportSplash (vec3_t org);
-void R_PushDlights (void);
+extern void R_PushDlights (void);
+
+extern void R_DynamicLightPoint(vec3_t color, vec3_t org, int *dlightbits);
+extern void R_DynamicLightPointNoMask(vec3_t color, vec3_t org);
+extern void R_LightPoint (vec3_t color, vec3_t p);
char message[2048];
MSG_WriteByte (&client->message, svc_print);
-#ifdef NEHAHRA
- sprintf (message, "%c\nDPNEHAHRA VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
-#else
sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
-#endif
MSG_WriteString (&client->message,message);
MSG_WriteByte (&client->message, svc_serverinfo);
vec3_t moved_from[MAX_EDICTS];
float savesolid;
+ switch ((int) pusher->v.solid)
+ {
+ // LordHavoc: valid pusher types
+ case SOLID_BSP:
+ case SOLID_BBOX:
+ case SOLID_SLIDEBOX:
+ case SOLID_CORPSE: // LordHavoc: this would be weird...
+ break;
+ // LordHavoc: no collisions
+ case SOLID_NOT:
+ case SOLID_TRIGGER:
+ VectorMA (pusher->v.origin, movetime, pusher->v.velocity, pusher->v.origin);
+ pusher->v.ltime += movetime;
+ SV_LinkEdict (pusher, false);
+ return;
+ default:
+ Host_Error("SV_PushMove: unrecognized solid type %f\n", pusher->v.solid);
+ }
if (!pusher->v.velocity[0] && !pusher->v.velocity[1] && !pusher->v.velocity[2])
{
pusher->v.ltime += movetime;
SV_LinkEdict (pusher, false);
pusher->v.ltime -= movetime;
- // if the pusher has a "blocked" function, call it
- // otherwise, just stay in place until the obstacle is gone
+ // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
if (pusher->v.blocked)
{
pr_global_struct->self = EDICT_TO_PROG(pusher);
}
// move back any entities we already moved
+ num_moved--; // LordHavoc: pop off check, because it was already restored
for (i=0 ; i<num_moved ; i++)
{
VectorCopy (moved_from[i], moved_edict[i]->v.origin);
int i, e;
edict_t *check;
vec3_t move, a, amove;
- vec3_t entorig, pushorig;
+ vec3_t entorigin, entangles, pushorigin, pushangles;
int num_moved;
edict_t *moved_edict[MAX_EDICTS];
vec3_t moved_from[MAX_EDICTS];
+ vec3_t angled_from[MAX_EDICTS];
vec3_t org, org2;
vec3_t forward, right, up;
float savesolid;
VectorSubtract (vec3_origin, amove, a);
AngleVectors (a, forward, right, up);
- VectorCopy (pusher->v.angles, pushorig);
+ VectorCopy (pusher->v.origin, pushorigin);
+ VectorCopy (pusher->v.angles, pushangles);
// move the pusher to it's final position
if (check->free)
continue;
if (check->v.movetype == MOVETYPE_PUSH
- || check->v.movetype == MOVETYPE_NONE
- || check->v.movetype == MOVETYPE_FOLLOW
- || check->v.movetype == MOVETYPE_NOCLIP)
+ || check->v.movetype == MOVETYPE_NONE
+ || check->v.movetype == MOVETYPE_FOLLOW
+ || check->v.movetype == MOVETYPE_NOCLIP)
continue;
// if the entity is standing on the pusher, it will definately be moved
- if ( ! ( ((int)check->v.flags & FL_ONGROUND)
- && PROG_TO_EDICT(check->v.groundentity) == pusher) )
+ if (!(((int)check->v.flags & FL_ONGROUND) && PROG_TO_EDICT(check->v.groundentity) == pusher))
{
- if ( check->v.absmin[0] >= pusher->v.absmax[0]
- || check->v.absmin[1] >= pusher->v.absmax[1]
- || check->v.absmin[2] >= pusher->v.absmax[2]
- || check->v.absmax[0] <= pusher->v.absmin[0]
- || check->v.absmax[1] <= pusher->v.absmin[1]
- || check->v.absmax[2] <= pusher->v.absmin[2] )
+ if (check->v.absmin[0] >= pusher->v.absmax[0]
+ || check->v.absmin[1] >= pusher->v.absmax[1]
+ || check->v.absmin[2] >= pusher->v.absmax[2]
+ || check->v.absmax[0] <= pusher->v.absmin[0]
+ || check->v.absmax[1] <= pusher->v.absmin[1]
+ || check->v.absmax[2] <= pusher->v.absmin[2])
continue;
// see if the ent's bbox is inside the pusher's final position
if (check->v.movetype != MOVETYPE_WALK)
check->v.flags = (int)check->v.flags & ~FL_ONGROUND;
- VectorCopy (check->v.origin, entorig);
+ VectorCopy (check->v.origin, entorigin);
VectorCopy (check->v.origin, moved_from[num_moved]);
+ VectorCopy (check->v.angles, entangles);
+ VectorCopy (check->v.angles, angled_from[num_moved]);
moved_edict[num_moved] = check;
num_moved++;
SV_PushEntity (check, move);
pusher->v.solid = savesolid; // LordHavoc: restore to correct solid type
+ VectorAdd (check->v.angles, amove, check->v.angles);
+
// if it is still inside the pusher, block
if (SV_TestEntityPosition (check))
{ // fail the move
continue;
}
- VectorCopy (entorig, check->v.origin);
+ VectorCopy (entorigin, check->v.origin);
+ VectorCopy (entangles, check->v.angles);
SV_LinkEdict (check, true);
- VectorCopy (pushorig, pusher->v.angles);
+ VectorCopy (pushorigin, pusher->v.origin);
+ VectorCopy (pushangles, pusher->v.angles);
SV_LinkEdict (pusher, false);
pusher->v.ltime -= movetime;
- // if the pusher has a "blocked" function, call it
- // otherwise, just stay in place until the obstacle is gone
+ // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
if (pusher->v.blocked)
{
pr_global_struct->self = EDICT_TO_PROG(pusher);
}
// move back any entities we already moved
+ num_moved--; // LordHavoc: pop off check, because it was already restored
for (i=0 ; i<num_moved ; i++)
{
VectorCopy (moved_from[i], moved_edict[i]->v.origin);
- VectorSubtract (moved_edict[i]->v.angles, amove, moved_edict[i]->v.angles);
+ VectorCopy (angled_from[i], moved_edict[i]->v.angles);
SV_LinkEdict (moved_edict[i], false);
}
return;
}
- else
- {
- VectorAdd (check->v.angles, amove, check->v.angles);
- }
}
-
-
}
-//#endif
/*
================
oldltime = ent->v.ltime;
+ /*
thinktime = ent->v.nextthink;
if (thinktime < ent->v.ltime + host_frametime)
{
else
SV_PushMove (ent, movetime); // advances ent->v.ltime if not blocked
}
+ */
+ if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2])
+ SV_PushRotate (ent, host_frametime);
+ else
+ {
+ thinktime = ent->v.nextthink;
+ if (thinktime < ent->v.ltime + host_frametime)
+ {
+ movetime = thinktime - ent->v.ltime;
+ if (movetime < 0)
+ movetime = 0;
+ }
+ else
+ movetime = host_frametime;
+ if (movetime)
+ SV_PushMove (ent, movetime); // advances ent->v.ltime if not blocked
+ }
if (thinktime > oldltime && thinktime <= ent->v.ltime)
{
continue;
if (pr_global_struct->force_retouch)
- {
SV_LinkEdict (ent, true); // force retouch even for stationary
- }
if (i > 0 && i <= svs.maxclients)
+ {
SV_Physics_Client (ent, i);
- else if (ent->v.movetype == MOVETYPE_PUSH)
+ continue;
+ }
+
+ switch ((int) ent->v.movetype)
+ {
+ case MOVETYPE_PUSH:
SV_Physics_Pusher (ent);
- else if (ent->v.movetype == MOVETYPE_NONE)
+ break;
+ case MOVETYPE_NONE:
SV_Physics_None (ent);
- else if (ent->v.movetype == MOVETYPE_FOLLOW)
+ break;
+ case MOVETYPE_FOLLOW:
SV_Physics_Follow (ent);
- else if (ent->v.movetype == MOVETYPE_NOCLIP)
+ break;
+ case MOVETYPE_NOCLIP:
SV_Physics_Noclip (ent);
- else if (ent->v.movetype == MOVETYPE_STEP)
+ break;
+ case MOVETYPE_STEP:
SV_Physics_Step (ent);
+ break;
// LordHavoc: added support for MOVETYPE_WALK on normal entities! :)
- else if (ent->v.movetype == MOVETYPE_WALK)
- {
+ case MOVETYPE_WALK:
if (SV_RunThink (ent))
{
if (!SV_CheckWater (ent) && ! ((int)ent->v.flags & FL_WATERJUMP) )
SV_CheckStuck (ent);
SV_WalkMove (ent);
}
- }
- else if (ent->v.movetype == MOVETYPE_TOSS
- || ent->v.movetype == MOVETYPE_BOUNCE
- || ent->v.movetype == MOVETYPE_BOUNCEMISSILE
- || ent->v.movetype == MOVETYPE_FLY
- || ent->v.movetype == MOVETYPE_FLYMISSILE)
+ break;
+ case MOVETYPE_TOSS:
+ case MOVETYPE_BOUNCE:
+ case MOVETYPE_BOUNCEMISSILE:
+ case MOVETYPE_FLY:
+ case MOVETYPE_FLYMISSILE:
SV_Physics_Toss (ent);
- else
- Host_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);
+ break;
+ default:
+ Host_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);
+ break;
+ }
}
if (pr_global_struct->force_retouch)
{
double time, oldtime, newtime;
- quakeparms_t parms;
extern int vcrFile;
extern int recording;
int j;
// signal(SIGFPE, floating_point_exception_handler);
signal(SIGFPE, SIG_IGN);
- memset(&parms, 0, sizeof(parms));
+ memset(&host_parms, 0, sizeof(host_parms));
COM_InitArgv(c, v);
- parms.argc = com_argc;
- parms.argv = com_argv;
+ host_parms.argc = com_argc;
+ host_parms.argv = com_argv;
- parms.memsize = 24*1024*1024;
+ host_parms.memsize = 24*1024*1024;
j = COM_CheckParm("-mem");
if (j)
- parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
- parms.membase = malloc (parms.memsize);
- if (!parms.membase)
+ host_parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
+ host_parms.membase = malloc (host_parms.memsize);
+ if (!host_parms.membase)
{
printf("Unable to allocate heap memory\n");
return 1;
}
- parms.basedir = basedir;
+ host_parms.basedir = basedir;
// caching is disabled by default, use -cachedir to enable
-// parms.cachedir = cachedir;
+// host_parms.cachedir = cachedir;
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
- Host_Init(&parms);
+ Host_Init();
Sys_Init();
Sys_PageIn
================
*/
+/*
void Sys_PageIn (void *ptr, int size)
{
byte *x;
}
}
}
+*/
/*
int global_nCmdShow;
char *argv[MAX_NUM_ARGVS];
static char *empty_string = "";
-HWND hwnd_dialog;
-
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
- quakeparms_t parms;
double time, oldtime, newtime/*, timediff*/;
MEMORYSTATUS lpBuffer;
static char cwd[1024];
int t;
- RECT rect;
/* previous instances do not exist in Win32 */
if (hPrevInstance)
if (cwd[strlen(cwd)-1] == '/')
cwd[strlen(cwd)-1] = 0;
- parms.basedir = cwd;
- parms.cachedir = NULL;
+ host_parms.basedir = cwd;
+ host_parms.cachedir = NULL;
- parms.argc = 1;
+ host_parms.argc = 1;
argv[0] = empty_string;
- while (*lpCmdLine && (parms.argc < MAX_NUM_ARGVS))
+ while (*lpCmdLine && (host_parms.argc < MAX_NUM_ARGVS))
{
while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
lpCmdLine++;
if (*lpCmdLine)
{
- argv[parms.argc] = lpCmdLine;
- parms.argc++;
+ argv[host_parms.argc] = lpCmdLine;
+ host_parms.argc++;
while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
lpCmdLine++;
}
}
- parms.argv = argv;
+ host_parms.argv = argv;
- COM_InitArgv (parms.argc, parms.argv);
+ COM_InitArgv (host_parms.argc, host_parms.argv);
- parms.argc = com_argc;
- parms.argv = com_argv;
+ host_parms.argc = com_argc;
+ host_parms.argv = com_argv;
isDedicated = (COM_CheckParm ("-dedicated") != 0);
- if (!isDedicated)
- {
- hwnd_dialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NULL);
-
- if (hwnd_dialog)
- {
- if (GetWindowRect (hwnd_dialog, &rect))
- {
- if (rect.left > (rect.top * 2))
- {
- SetWindowPos (hwnd_dialog, 0,
- (rect.left / 2) - ((rect.right - rect.left) / 2),
- rect.top, 0, 0,
- SWP_NOZORDER | SWP_NOSIZE);
- }
- }
-
- ShowWindow (hwnd_dialog, SW_SHOWDEFAULT);
- UpdateWindow (hwnd_dialog);
- SetForegroundWindow (hwnd_dialog);
- }
- }
-
// take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise
- parms.memsize = lpBuffer.dwAvailPhys;
+ host_parms.memsize = lpBuffer.dwAvailPhys;
- if (parms.memsize < MINIMUM_WIN_MEMORY)
- parms.memsize = MINIMUM_WIN_MEMORY;
+ if (host_parms.memsize < MINIMUM_WIN_MEMORY)
+ host_parms.memsize = MINIMUM_WIN_MEMORY;
- if (parms.memsize < (lpBuffer.dwTotalPhys >> 1))
- parms.memsize = lpBuffer.dwTotalPhys >> 1;
+ if (host_parms.memsize < (lpBuffer.dwTotalPhys >> 1))
+ host_parms.memsize = lpBuffer.dwTotalPhys >> 1;
- if (parms.memsize > MAXIMUM_WIN_MEMORY)
- parms.memsize = MAXIMUM_WIN_MEMORY;
+ if (host_parms.memsize > MAXIMUM_WIN_MEMORY)
+ host_parms.memsize = MAXIMUM_WIN_MEMORY;
- if (COM_CheckParm ("-heapsize"))
+ if ((t = COM_CheckParm("-heapsize")))
{
- t = COM_CheckParm("-heapsize") + 1;
-
+ t++;
if (t < com_argc)
- parms.memsize = atoi (com_argv[t]) * 1024;
+ host_parms.memsize = atoi (com_argv[t]) * 1024;
}
-
- if (COM_CheckParm ("-mem"))
+ else if ((t = COM_CheckParm("-mem")) || (t = COM_CheckParm("-winmem")))
{
- t = COM_CheckParm("-mem") + 1;
-
- if (t < com_argc)
- parms.memsize = atoi (com_argv[t]) * 1048576;
- }
-
- if (COM_CheckParm ("-winmem"))
- {
- t = COM_CheckParm("-winmem") + 1;
-
+ t++;
if (t < com_argc)
- parms.memsize = atoi (com_argv[t]) * 1048576;
+ host_parms.memsize = atoi (com_argv[t]) * 1048576;
}
- parms.membase = malloc (parms.memsize);
+ host_parms.membase = malloc (host_parms.memsize);
- if (!parms.membase)
+ if (!host_parms.membase)
Sys_Error ("Not enough memory free; check disk space\n");
// Sys_PageIn (parms.membase, parms.memsize);
S_BlockSound ();
Sys_Printf ("Host_Init\n");
- Host_Init (&parms);
+ Host_Init ();
oldtime = Sys_FloatTime ();
int main (int argc, char **argv)
{
MSG msg;
- quakeparms_t parms;
double time, oldtime;
static char cwd[1024];
- memset (&parms, 0, sizeof(parms));
+ memset (&host_parms, 0, sizeof(host_parms));
- parms.memsize = 16384*1024;
- parms.membase = malloc (parms.memsize);
+ host_parms.memsize = 16384*1024;
+ host_parms.membase = malloc (parms.memsize);
_getcwd (cwd, sizeof(cwd));
if (cwd[strlen(cwd)-1] == '\\')
cwd[strlen(cwd)-1] = 0;
- parms.basedir = cwd; //"f:/quake";
-// parms.basedir = "f:\\quake";
+ host_parms.basedir = cwd;
COM_InitArgv (argc, argv);
COM_InitArgv (argc, argv);
}
- parms.argc = argc;
- parms.argv = argv;
+ host_parms.argc = argc;
+ host_parms.argv = argv;
printf ("Host_Init\n");
- Host_Init (&parms);
+ Host_Init ();
oldtime = Sys_FloatTime ();
} viddef_t;
extern viddef_t vid; // global video state
-extern unsigned short d_8to16table[256];
-extern unsigned d_8to24table[256];
extern void (*vid_menudrawfn)(void);
extern void (*vid_menukeyfn)(int key);
-void VID_SetPalette (unsigned char *palette);
-// called at startup
+extern qboolean isG200;
+extern qboolean isRagePro;
+extern qboolean gl_mtexable;
+extern qboolean gl_arrays;
-void VID_Init (unsigned char *palette);
-// Called at startup to set up translation tables, takes 256 8 bit RGB values
-// the palette data will go away after the call, so it must be copied off if
-// the video driver will need it again
+void GL_Init (void);
+
+void VID_CheckMultiTexture();
+void VID_CheckVertexArrays();
+
+void VID_Init ();
+// Called at startup
void VID_Shutdown (void);
// Called at shutdown
-int VID_SetMode (int modenum, unsigned char *palette);
+int VID_SetMode (int modenum);
// sets the mode; only used by the Quake engine for resetting to mode 0 (the
// base mode) on memory allocation failures
#include <GL/fxmesa.h>
#include <glide/sst1vid.h>
-#define WARP_WIDTH 320
-#define WARP_HEIGHT 200
-
-//unsigned short d_8to16table[256];
unsigned d_8to24table[256];
unsigned char d_15to8table[65536];
const char *gl_version;
const char *gl_extensions;
-void (*qglColorTableEXT) (int, int, int, int, int, const void*);
-void (*qgl3DfxSetPaletteEXT) (GLuint *);
void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
void (*qglSelectTexture) (GLenum);
int gl_mtex_enum = 0;
// LordHavoc: in GLX these are never set, simply provided to make the rest of the code work
-qboolean is8bit = false;
-qboolean isPermedia = false;
-qboolean isATI = false;
qboolean isG200 = false;
qboolean isRagePro = false;
qboolean gl_mtexable = false;
signal(SIGTERM, signal_handler);
}
+// LordHavoc: FIXME or something?
+void VID_CheckVertexArrays()
+{
+}
+
/*
- CheckMultiTextureExtensions
+ VID_CheckMultitexture
Check for ARB, SGIS, or EXT multitexture support
*/
-void
-CheckMultiTextureExtensions ( void )
+void VID_CheckMultitexture()
{
Con_Printf ("Checking for multitexture... ");
if (COM_CheckParm ("-nomtex"))
qglSelectTexture = (void *)dlsym(dlhand, "glActiveTextureARB");
gl_mtex_enum = GL_TEXTURE0_ARB;
gl_mtexable = true;
- } else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
+ }
+ 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;
- } else {
- Con_Printf ("none found\n");
}
+ else
+ Con_Printf ("none found\n");
dlclose(dlhand);
dlhand = NULL;
}
typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
-/*
-===============
-GL_Init
-===============
-*/
-void GL_Init (void)
+void VID_SetupDithering()
{
- gl_vendor = glGetString (GL_VENDOR);
- Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
- gl_renderer = glGetString (GL_RENDERER);
- Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
-
- gl_version = glGetString (GL_VERSION);
- Con_Printf ("GL_VERSION: %s\n", gl_version);
- gl_extensions = glGetString (GL_EXTENSIONS);
- Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
-
- CheckMultiTextureExtensions ();
-
- 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);
-
Con_Printf ("Dithering: ");
dlhand = dlopen (NULL, RTLD_LAZY);
return GR_RESOLUTION_640x480;
}
-qboolean VID_Is8bit(void)
-{
- return is8bit;
-}
-
-typedef void (GLAPIENTRY *glColorTableEXT_FUNC) (GLenum, GLenum, GLsizei,
- GLenum, GLenum, const GLvoid *);
-typedef void (GLAPIENTRY *gl3DfxSetPaletteEXT_FUNC) (GLuint *pal);
-
-void VID_Init8bitPalette()
-{
- // Check for 8bit Extensions and initialize them.
- int i;
-
- dlhand = dlopen (NULL, RTLD_LAZY);
-
- Con_SafePrintf ("8-bit GL extensions: ");
-
- if (dlhand == NULL) {
- Con_SafePrintf ("unable to check.\n");
- return;
- }
-
- if (COM_CheckParm("-no8bit")) {
- Con_SafePrintf("disabled.\n");
- return;
- }
-
- if (strstr(gl_extensions, "3DFX_set_global_palette") && (qgl3DfxSetPaletteEXT = dlsym(dlhand, "gl3DfxSetPaletteEXT")) != NULL)
- {
- GLubyte table[256][4];
- char *oldpal;
-
- Con_SafePrintf("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")) {
- char thePalette[256*3];
- char *oldPalette, *newPalette;
- glColorTableEXT_FUNC load_texture = NULL;
-
- Con_SafePrintf("GL_EXT_shared.\n");
- load_texture = (void *) dlsym(dlhand, "glColorTableEXT");
-
- glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
- oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
- newPalette = thePalette;
- for (i=0;i<256;i++) {
- *newPalette++ = *oldPalette++;
- *newPalette++ = *oldPalette++;
- *newPalette++ = *oldPalette++;
- oldPalette++;
- }
- load_texture(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
- is8bit = true;
- } else {
- Con_SafePrintf ("not found.\n");
- }
-
- dlclose(dlhand);
- dlhand = NULL;
-}
-
-extern void Check_Gamma (unsigned char *pal);
-void VID_Setup15to8Palette ();
-
-void VID_Init(unsigned char *palette)
+void VID_Init()
{
int i;
GLint attribs[32];
GL_Init();
- snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
- Sys_mkdir (gldir);
-
- VID_SetPalette(palette);
-
- Check_Gamma(palette);
-
- // Check for 3DFX Extensions and initialize them.
- VID_Init8bitPalette();
-
- if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
- VID_Setup15to8Palette ();
+ VID_SetupDithering(); // 3DFX specific
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
#include <X11/extensions/xf86dga.h>
#include <X11/extensions/xf86vmode.h>
-#define WARP_WIDTH 320
-#define WARP_HEIGHT 200
-
static Display *dpy = NULL;
static int scrnum;
static Window win;
#define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )
-unsigned short d_8to16table[256];
unsigned d_8to24table[256];
unsigned char d_15to8table[65536];
viddef_t vid; // global video state
-static qboolean mouse_avail;
-static qboolean mouse_active;
-static int mx, my;
-static int old_mouse_x, old_mouse_y;
+static qboolean mouse_avail = true;
+static qboolean mouse_active = false;
+static float mouse_x, mouse_y;
+static float old_mouse_x, old_mouse_y;
+static int p_mouse_x, p_mouse_y;
static cvar_t in_mouse = {"in_mouse", "1", false};
static cvar_t in_dgamouse = {"in_dgamouse", "1", false};
const char *gl_version;
const char *gl_extensions;
-void (*qglColorTableEXT) (int, int, int, int, int, const void*);
-void (*qgl3DfxSetPaletteEXT) (GLuint *);
void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
void (*qglSelectTexture) (GLenum);
int gl_mtex_enum = 0;
// LordHavoc: in GLX these are never set, simply provided to make the rest of the code work
-qboolean is8bit = false;
-qboolean isPermedia = false;
-qboolean isATI = false;
qboolean isG200 = false;
qboolean isRagePro = false;
qboolean gl_mtexable = false;
qboolean gl_arrays = false;
/*-----------------------------------------------------------------------*/
-void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
-{
-}
-
-void D_EndDirectRect (int x, int y, int width, int height)
+static int
+XLateKey(XKeyEvent *ev/*, qboolean modified*/)
{
-}
-
-static int XLateKey(XKeyEvent *ev)
-{
-
- int key;
- char buf[64];
+ char tmp[2];
+ int key = 0;
KeySym keysym;
- key = 0;
-
- XLookupString(ev, buf, sizeof buf, &keysym, 0);
-
- switch(keysym)
- {
- case XK_KP_Page_Up:
- case XK_Page_Up: key = K_PGUP; break;
-
- case XK_KP_Page_Down:
- case XK_Page_Down: key = K_PGDN; break;
-
- case XK_KP_Home:
- case XK_Home: key = K_HOME; break;
-
- case XK_KP_End:
- case XK_End: key = K_END; break;
+/* if (!modified) {*/
+ keysym = XLookupKeysym(ev, 0);
+/* } else {
+ XLookupString(ev, tmp, 1, &keysym, NULL);
+ }*/
- case XK_KP_Left:
- case XK_Left: key = K_LEFTARROW; break;
+ switch(keysym) {
+ case XK_KP_Page_Up: key = KP_PGUP; break;
+ case XK_Page_Up: key = K_PGUP; break;
- case XK_KP_Right:
- case XK_Right: key = K_RIGHTARROW; break;
+ case XK_KP_Page_Down: key = KP_PGDN; break;
+ case XK_Page_Down: key = K_PGDN; break;
- case XK_KP_Down:
- case XK_Down: key = K_DOWNARROW; break;
+ case XK_KP_Home: key = KP_HOME; break;
+ case XK_Home: key = K_HOME; break;
- case XK_KP_Up:
- case XK_Up: key = K_UPARROW; break;
+ case XK_KP_End: key = KP_END; break;
+ case XK_End: key = K_END; break;
- case XK_Escape: key = K_ESCAPE; break;
+ case XK_KP_Left: key = KP_LEFTARROW; break;
+ case XK_Left: key = K_LEFTARROW; break;
- case XK_KP_Enter:
- case XK_Return: key = K_ENTER; break;
+ case XK_KP_Right: key = KP_RIGHTARROW; break;
+ case XK_Right: key = K_RIGHTARROW; break;
- case XK_Tab: key = K_TAB; break;
+ case XK_KP_Down: key = KP_DOWNARROW; break;
+ case XK_Down: key = K_DOWNARROW; break;
- case XK_F1: key = K_F1; break;
+ case XK_KP_Up: key = KP_UPARROW; break;
+ case XK_Up: key = K_UPARROW; break;
- case XK_F2: key = K_F2; break;
+ case XK_Escape: key = K_ESCAPE; break;
- case XK_F3: key = K_F3; break;
+ case XK_KP_Enter: key = KP_ENTER; break;
+ case XK_Return: key = K_ENTER; break;
- case XK_F4: key = K_F4; break;
+ case XK_Tab: key = K_TAB; break;
- case XK_F5: key = K_F5; 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_F6: key = K_F6; break;
+ case XK_BackSpace: key = K_BACKSPACE; break;
- case XK_F7: key = K_F7; break;
+ case XK_KP_Delete: key = KP_DEL; break;
+ case XK_Delete: key = K_DEL; break;
- case XK_F8: key = K_F8; break;
+ case XK_Pause: key = K_PAUSE; break;
- case XK_F9: key = K_F9; break;
-
- case XK_F10: key = K_F10; break;
+ case XK_Shift_L:
+ case XK_Shift_R: key = K_SHIFT; break;
- case XK_F11: key = K_F11; break;
+ case XK_Execute:
+ case XK_Control_L:
+ case XK_Control_R: key = K_CTRL; break;
- case XK_F12: key = K_F12; 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_BackSpace: key = K_BACKSPACE; break;
+ case XK_Caps_Lock: key = K_CAPSLOCK; break;
+ case XK_KP_Begin: key = KP_5; break;
- case XK_KP_Delete:
- case XK_Delete: key = K_DEL; break;
+ case XK_Insert: key = K_INS; break;
+ case XK_KP_Insert: key = KP_INS; break;
- case XK_Pause: key = K_PAUSE; 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;
- case XK_Shift_L:
- case XK_Shift_R: key = K_SHIFT; break;
-
- case XK_Execute:
- case XK_Control_L:
- case XK_Control_R: key = K_CTRL; break;
-
- case XK_Alt_L:
- case XK_Meta_L:
- case XK_Alt_R:
- case XK_Meta_R: key = K_ALT; break;
-
- case XK_KP_Begin: key = '5'; break;
-
- case XK_KP_Insert:
- case XK_Insert:key = K_INS; break;
-
- case XK_KP_Multiply: key = '*'; break;
- case XK_KP_Add: key = '+'; break;
- case XK_KP_Subtract: key = '-'; break;
- case XK_KP_Divide: key = '/'; break;
-
-#if 0
- case 0x021: key = '1';break;/* [!] */
- case 0x040: key = '2';break;/* [@] */
- case 0x023: key = '3';break;/* [#] */
- case 0x024: key = '4';break;/* [$] */
- case 0x025: key = '5';break;/* [%] */
- case 0x05e: key = '6';break;/* [^] */
- case 0x026: key = '7';break;/* [&] */
- case 0x02a: key = '8';break;/* [*] */
- case 0x028: key = '9';;break;/* [(] */
- case 0x029: key = '0';break;/* [)] */
- case 0x05f: key = '-';break;/* [_] */
- case 0x02b: key = '=';break;/* [+] */
- case 0x07c: key = '\'';break;/* [|] */
- case 0x07d: key = '[';break;/* [}] */
- case 0x07b: key = ']';break;/* [{] */
- case 0x022: key = '\'';break;/* ["] */
- case 0x03a: key = ';';break;/* [:] */
- case 0x03f: key = '/';break;/* [?] */
- case 0x03e: key = '.';break;/* [>] */
- case 0x03c: key = ',';break;/* [<] */
-#endif
+ /* 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;
default:
- key = *(unsigned char*)buf;
- if (key >= 'A' && key <= 'Z')
- key = key - 'A' + 'a';
+ if (keysym < 128) {
+ /* ASCII keys */
+ key = keysym;
+ if (/*!modified && */((key >= 'A') && (key <= 'Z'))) {
+ key = key + ('a' - 'A');
+ }
+ }
break;
- }
+ }
return key;
}
static void install_grabs(void)
{
+ XWindowAttributes attribs_1;
+ XSetWindowAttributes attribs_2;
+
+ XGetWindowAttributes(dpy, win, &attribs_1);
+ attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
+ XChangeWindowAttributes(dpy, win, CWEventMask, &attribs_2);
// inviso cursor
XDefineCursor(dpy, win, CreateNullCursor(dpy, win));
- XGrabPointer(dpy, win,
- True,
- 0,
- GrabModeAsync, GrabModeAsync,
- win,
- None,
- CurrentTime);
+ XGrabPointer(dpy, win, True, 0, GrabModeAsync, GrabModeAsync,
+ win, None, CurrentTime);
- if (in_dgamouse.value) {
+/* if (in_dgamouse.value) {
int MajorVersion, MinorVersion;
if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
}
- } else {
+ } else {*/
XWarpPointer(dpy, None, win,
0, 0, 0, 0,
vid.width / 2, vid.height / 2);
- }
+/* }*/
- XGrabKeyboard(dpy, win,
- False,
- GrabModeAsync, GrabModeAsync,
- CurrentTime);
+ XGrabKeyboard(dpy, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
mouse_active = true;
+ mouse_x = mouse_y = 0;
// XSync(dpy, True);
}
if (!dpy || !win)
return;
- if (dgamouse) {
+/* if (dgamouse) {
dgamouse = false;
XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
- }
+ }*/
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
// KeySym ks;
int b;
qboolean dowarp = false;
- int mwx = vid.width/2;
- int mwy = vid.height/2;
if (!dpy)
return;
break;
case MotionNotify:
- if (mouse_active) {
+ if (dgamouse) {
+ mouse_x += event.xmotion.x_root/* * in_dga_mouseaccel.value*/;
+ mouse_y += event.xmotion.y_root/* * in_dga_mouseaccel.value*/;
+ } else {
+ if (!p_mouse_x && !p_mouse_y) {
+ Con_Printf("event->xmotion.x: %d\n", event.xmotion.x);
+ Con_Printf("event->xmotion.y: %d\n", event.xmotion.y);
+ }
+/* if (vid_fullscreen.value || _windowed_mouse.value) {*/
+ if (!event.xmotion.send_event) {
+ mouse_x += (event.xmotion.x - p_mouse_x);
+ mouse_y += (event.xmotion.y - p_mouse_y);
+ if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4
+ || abs(vid.height/2 - event.xmotion.y) > vid.height / 4) {
+ dowarp = true;
+ }
+ }
+/* } 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;
+ }
+
+/* if (mouse_active) {
if (dgamouse) {
- mx += (event.xmotion.x + win_x) * 2;
- my += (event.xmotion.y + win_y) * 2;
+ mouse_x += (event.xmotion.x + win_x) * 2;
+ mouse_y += (event.xmotion.y + win_y) * 2;
}
- else
+ else
{
- mx += ((int)event.xmotion.x - mwx) * 2;
- my += ((int)event.xmotion.y - mwy) * 2;
+ mouse_x += ((int)event.xmotion.x - mwx) * 2;
+ mouse_y += ((int)event.xmotion.y - mwy) * 2;
mwx = event.xmotion.x;
mwy = event.xmotion.y;
- if (mx || my)
+ if (mouse_x || mouse_y)
dowarp = true;
}
- }
- break;
-
+ }*/
break;
case ButtonPress:
if (dowarp) {
/* move the mouse to the window center again */
- XWarpPointer(dpy, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
+ p_mouse_x = vid.width / 2;
+ p_mouse_y = vid.height / 2;
+ XWarpPointer(dpy, None, win, 0, 0, 0, 0, p_mouse_x, p_mouse_y);
}
}
return;
if (!mouse_active) {
- mx = my = 0; // don't spazz
+ mouse_x = mouse_y = 0; // don't spazz
install_grabs();
mouse_active = true;
}
{
if (!ctx || !dpy)
return;
- IN_DeactivateMouse();
+
if (dpy) {
+ uninstall_grabs();
+
if (ctx)
glXDestroyContext(dpy, ctx);
if (win)
signal(SIGTERM, signal_handler);
}
-/*
void (*qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
void (*qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
void (*qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
void (*qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void (*qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
void (*qglSelectTexture)(GLenum);
-void (*glColorTableEXT)(int, int, int, int, int, const void*);
-void CheckVertexArrays (void)
+void VID_CheckVertexArrays (void)
{
void *prjobj;
if (COM_CheckParm("-novertex"))
Con_Printf("...vertex array support disabled (not detected - get a better driver)\n");
dlclose(prjobj);
}
-*/
-void CheckMultiTexture(void)
+void VID_CheckMultiTexture(void)
{
void *prjobj;
qglMTexCoord2f = NULL;
dlclose(prjobj);
}
-/*
-===============
-GL_Init
-===============
-*/
-extern char *QSG_EXTENSIONS;
-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);
-
- CheckMultiTexture();
-// CheckVertexArrays();
-
- // LordHavoc: report supported extensions
- Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
-
- glCullFace(GL_FRONT);
- glAlphaFunc(GL_GREATER, 0.5);
-}
-
/*
=================
GL_BeginRendering
*width = scr_width;
*height = scr_height;
-// if (!wglMakeCurrent( maindc, baseRC ))
-// Sys_Error ("wglMakeCurrent failed");
-
// glViewport (*x, *y, *width, *height);
}
glXSwapBuffers(dpy, win);
}
-qboolean VID_Is8bit(void)
-{
- return is8bit;
-}
-
-void VID_Init8bitPalette(void)
-{
- // Check for 8bit Extensions and initialize them.
- int i;
- void *prjobj;
-
- if (!COM_CheckParm("-8bit"))
- 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("8-bit GL extensions enabled.\n");
- glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
- oldpal = (char *) d_8to24table; //d_8to24table3dfx;
- for (i=0;i<256;i++)
- {
- table[i][2] = *oldpal++;
- table[i][1] = *oldpal++;
- table[i][0] = *oldpal++;
- table[i][3] = 255;
- oldpal++;
- }
- 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("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++;
- }
- qglColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
- is8bit = true;
- }
-
- dlclose(prjobj);
-}
-
-extern void Check_Gamma (unsigned char *pal);
-void VID_Setup15to8Palette ();
-
-void VID_Init(unsigned char *palette)
+void VID_Init()
{
int i;
int attrib[] = {
GL_Init();
-// sprintf (gldir, "%s/glquake", com_gamedir);
-// Sys_mkdir (gldir);
-
- VID_SetPalette(palette);
-
- Check_Gamma(palette);
-
- VID_Init8bitPalette();
-
- if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
- VID_Setup15to8Palette ();
-
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
vid.recalc_refdef = 1; // force a surface cache flush
+
+ install_grabs();
}
void Sys_SendKeyEvents(void)
{
if (!mouse_avail)
return;
-
- if (m_filter.value)
- {
- mx = (mx + old_mouse_x) * 0.5;
- my = (my + old_mouse_y) * 0.5;
- }
- old_mouse_x = mx;
- old_mouse_y = my;
-
- mx *= sensitivity.value;
- my *= 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 * mx;
- else
- cl.viewangles[YAW] -= m_yaw.value * mx;
-
- if (in_mlook.state & 1)
- V_StopPitchDrift ();
-
- if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
- {
- cl.viewangles[PITCH] += m_pitch.value * my;
- 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 * my;
- else
- cmd->forwardmove -= m_forward.value * my;
- }
- mx = my = 0;
+ 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)
+ cmd->sidemove += m_side.value * mouse_x;
+ else
+ cl.viewangles[YAW] -= m_yaw.value * mouse_x;
+
+/* if (freelook)*/
+ V_StopPitchDrift ();
+
+ if (/*freelook && */!(in_strafe.state & 1)) {
+ cl.viewangles[PITCH] += m_pitch.value * mouse_y;
+ cl.viewangles[PITCH] = bound (-70, cl.viewangles[PITCH], 80);
+ } else {
+ if ((in_strafe.state & 1) && noclip_anglehack)
+ cmd->upmove -= m_forward.value * mouse_y;
+ else
+ cmd->forwardmove -= m_forward.value * mouse_y;
+ }
+ mouse_x = mouse_y = 0.0;
}
void IN_Move (usercmd_t *cmd)
#include "quakedef.h"
-unsigned d_8to24table[256];
-unsigned char d_15to8table[32768]; // LordHavoc: was 64k elements, now 32k like it should be
-
-void VID_SetPalette (unsigned char *palette)
-{
- byte *out;
- unsigned short i;
-
- out = (byte *) d_8to24table; // d_8to24table is accessed as 32bit for speed reasons, but is created as 8bit bytes
- for (i=0 ; i<255 ; i++)
- {
- *out++ = *palette++;
- *out++ = *palette++;
- *out++ = *palette++;
- *out++ = 255;
- }
- d_8to24table[255] = 0;
-}
-
-void VID_Setup15to8Palette ()
-{
- byte *pal;
- unsigned r,g,b;
- unsigned v;
- int r1,g1,b1;
- int j,k,l;
- unsigned short i;
-
- // JACK: 3D distance calcs - k is last closest, l is the distance.
- // FIXME: Precalculate this and cache to disk.
- for (i = 0;i < 32768;i++)
- {
- /* Maps
- 000000000000000
- 000000000011111 = Red = 0x001F
- 000001111100000 = Blue = 0x03E0
- 111110000000000 = Grn = 0x7C00
- */
- r = ((i & 0x001F) << 3)+4;
- g = ((i & 0x03E0) >> 2)+4;
- b = ((i & 0x7C00) >> 7)+4;
- pal = (unsigned char *)d_8to24table;
- for (v = 0, k = 0, l = 1000000000;v < 256;v++, pal += 4)
- {
- r1 = r - pal[0];
- g1 = g - pal[1];
- b1 = b - pal[2];
- j = (r1*r1*2)+(g1*g1*3)+(b1*b1); // LordHavoc: weighting to tune for human eye (added *2 and *3)
- if (j < l)
- {
- k = v;
- l = j;
- }
- }
- d_15to8table[i] = k;
- }
-}
-
-// LordHavoc: gamma correction does not belong in gl_vidnt.c
-byte qgamma[256];
-static float vid_gamma = 1.0;
-
-void Check_Gamma (unsigned char *pal)
-{
- float inf;
- int i;
-
- if ((i = COM_CheckParm("-gamma")))
- vid_gamma = atof(com_argv[i+1]);
- else
- {
-// if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
-// (gl_vendor && strstr(gl_vendor, "3Dfx")))
- vid_gamma = 1;
-// else if (gl_vendor && strstr(gl_vendor, "ATI"))
-// vid_gamma = 1;
-// else
-// vid_gamma = 0.7;
- }
-
- if (vid_gamma == 1) // LordHavoc: dodge the math
- {
- for (i = 0;i < 256;i++)
- qgamma[i] = i;
- }
- else
- {
- for (i = 0;i < 256;i++)
- {
- inf = pow((i+1)/256.0, vid_gamma)*255 + 0.5;
- if (inf < 0) inf = 0;
- if (inf > 255) inf = 255;
- qgamma[i] = inf;
- }
- }
-
- // gamma correct the palette
- //for (i=0 ; i<768 ; i++)
- // pal[i] = qgamma[pal[i]];
- // note: 32bit uploads are corrected by the upload functions
-}
#define MAX_MODE_LIST 30
#define VID_ROW_SIZE 3
-#define WARP_WIDTH 320
-#define WARP_HEIGHT 200
#define MAXWIDTH 10000
#define MAXHEIGHT 10000
-#define BASEWIDTH 320
-#define BASEHEIGHT 200
#define MODE_WINDOWED 0
#define NO_MODE (MODE_WINDOWED - 1)
RECT WindowRect;
DWORD WindowStyle, ExWindowStyle;
-HWND mainwindow, dibwindow;
+HWND mainwindow;
int vid_modenum = NO_MODE;
int vid_realmode;
char *VID_GetModeDescription (int mode);
void ClearAllStates (void);
void VID_UpdateWindowStatus (void);
-void GL_Init (void);
// LordHavoc: ARB multitexture support
int gl_mtex_enum = 0;
-qboolean is8bit = false;
-qboolean isPermedia = false;
-qboolean isATI = false; // LordHavoc: special differences for ATI's broken drivers
qboolean isG200 = false; // LordHavoc: the Matrox G200 can't do per pixel alpha, and it uses a D3D driver for GL... ugh...
qboolean isRagePro = false; // LordHavoc: the ATI Rage Pro has limitations with per pixel alpha (the color scaler does not apply to per pixel alpha images...), although not as bad as a G200.
qboolean gl_mtexable = false;
DIBWidth = modelist[modenum].width;
DIBHeight = modelist[modenum].height;
- WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU |
- WS_MINIMIZEBOX;
+ WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
ExWindowStyle = 0;
rect = WindowRect;
height = rect.bottom - rect.top;
// Create the DIB window
- dibwindow = CreateWindowEx (
- ExWindowStyle,
-#ifdef NEHAHRA
- "DPNehahraQuake",
- "DPNehahraGLQuake",
-#else
- "DarkPlacesQuake",
- "DarkPlacesGLQuake",
-#endif
- WindowStyle,
- rect.left, rect.top,
- width,
- height,
- NULL,
- NULL,
- global_hInstance,
- NULL);
-
- if (!dibwindow)
+ mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlaces", "DarkPlacesGL", WindowStyle, rect.left, rect.top, width, height, NULL, NULL, global_hInstance, NULL);
+
+ if (!mainwindow)
Sys_Error ("Couldn't create DIB window");
// Center and show the DIB window
- CenterWindow(dibwindow, WindowRect.right - WindowRect.left,
- WindowRect.bottom - WindowRect.top, false);
+ CenterWindow(mainwindow, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, false);
- ShowWindow (dibwindow, SW_SHOWDEFAULT);
- UpdateWindow (dibwindow);
+ ShowWindow (mainwindow, SW_SHOWDEFAULT);
+ UpdateWindow (mainwindow);
modestate = MS_WINDOWED;
- // LordHavoc: using GDI functions on an OpenGL window? bad idea
- /*
-// because we have set the background brush for the window to NULL
-// (to avoid flickering when re-sizing the window on the desktop),
-// we clear the window to black when created, otherwise it will be
-// empty while Quake starts up.
- hdc = GetDC(dibwindow);
- PatBlt(hdc,0,0,WindowRect.right,WindowRect.bottom,BLACKNESS);
- ReleaseDC(dibwindow, hdc);
- */
-
if (vid.conheight > modelist[modenum].height)
vid.conheight = modelist[modenum].height;
if (vid.conwidth > modelist[modenum].width)
vid.width = vid.conwidth;
vid.height = vid.conheight;
- mainwindow = dibwindow;
-
SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon);
SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon);
height = rect.bottom - rect.top;
// Create the DIB window
- dibwindow = CreateWindowEx (
- ExWindowStyle,
-#ifdef NEHAHRA
- "DPNehahraQuake",
- "DPNehahraGLQuake",
-#else
- "DarkPlacesQuake",
- "DarkPlacesGLQuake",
-#endif
- WindowStyle,
- rect.left, rect.top,
- width,
- height,
- NULL,
- NULL,
- global_hInstance,
- NULL);
-
- if (!dibwindow)
- Sys_Error ("Couldn't create DIB window");
+ mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlaces", "DarkPlacesGL", WindowStyle, rect.left, rect.top, width, height, NULL, NULL, global_hInstance, NULL);
- ShowWindow (dibwindow, SW_SHOWDEFAULT);
- UpdateWindow (dibwindow);
+ if (!mainwindow)
+ Sys_Error ("Couldn't create DIB window");
- // LordHavoc: using GDI functions on an OpenGL window? bad idea
- /*
- // Because we have set the background brush for the window to NULL
- // (to avoid flickering when re-sizing the window on the desktop), we
- // clear the window to black when created, otherwise it will be
- // empty while Quake starts up.
- hdc = GetDC(dibwindow);
- PatBlt(hdc,0,0,WindowRect.right,WindowRect.bottom,BLACKNESS);
- ReleaseDC(dibwindow, hdc);
- */
+ ShowWindow (mainwindow, SW_SHOWDEFAULT);
+ UpdateWindow (mainwindow);
if (vid.conheight > modelist[modenum].height)
vid.conheight = modelist[modenum].height;
window_x = 0;
window_y = 0;
- mainwindow = dibwindow;
-
SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon);
SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon);
}
-int VID_SetMode (int modenum, unsigned char *palette)
+int VID_SetMode (int modenum)
{
int original_mode, temp;
qboolean stat;
MSG msg;
- if ((windowed && (modenum != 0)) ||
- (!windowed && (modenum < 1)) ||
- (!windowed && (modenum >= nummodes)))
- {
+ if ((windowed && (modenum != 0)) || (!windowed && (modenum < 1)) || (!windowed && (modenum >= nummodes)))
Sys_Error ("Bad video mode\n");
- }
// so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading;
IN_HideMouse ();
}
else
- {
Sys_Error ("VID_SetMode: Bad mode type in modelist");
- }
window_width = DIBWidth;
window_height = DIBHeight;
scr_disabled_for_loading = temp;
if (!stat)
- {
Sys_Error ("Couldn't set video mode");
- }
// now we try to make sure we get the focus on the mode switch, because
// sometimes in some systems we don't. We grab the foreground, then
// ourselves at the top of the z order, then grab the foreground again,
// Who knows if it helps, but it probably doesn't hurt
SetForegroundWindow (mainwindow);
- VID_SetPalette (palette);
vid_modenum = modenum;
Cvar_SetValue ("vid_mode", (float)vid_modenum);
Sleep (100);
- SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0,
- SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW |
- SWP_NOCOPYBITS);
+ SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOCOPYBITS);
SetForegroundWindow (mainwindow);
if (!msg_suppress_1)
Con_SafePrintf ("Video mode %s initialized.\n", VID_GetModeDescription (vid_modenum));
- VID_SetPalette (palette);
-
vid.recalc_refdef = 1;
return true;
//====================================
-void (APIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void (APIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void (APIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void (APIENTRY *qglArrayElement)(GLint i);
-void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
-void (APIENTRY *qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
-void (APIENTRY *qglSelectTexture)(GLenum);
-void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
+void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglArrayElement)(GLint i);
+void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+void (GLAPIENTRY *qglMTexCoord2f)(GLenum, GLfloat, GLfloat);
+void (GLAPIENTRY *qglSelectTexture)(GLenum);
-void CheckVertexArrays (void)
+void VID_CheckVertexArrays (void)
{
if (COM_CheckParm("-novertex"))
{
int texture_extension_number = 1;
-void CheckMultiTexture(void)
+void VID_CheckMultiTexture(void)
{
qglMTexCoord2f = NULL;
qglSelectTexture = NULL;
Con_Printf("...multitexture disabled (not detected)\n");
}
-/*
-===============
-GL_Init
-===============
-*/
-extern char *QSG_EXTENSIONS;
-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);
-
- if (strncasecmp(gl_renderer,"Permedia",8)==0)
- isPermedia = true;
-
- // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
- if (strncasecmp(gl_vendor,"ATI",3)==0)
- {
- isATI = true;
- if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
- isRagePro = true;
- }
- if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
- isG200 = true;
-
- CheckMultiTexture ();
- CheckVertexArrays ();
-
- // LordHavoc: report supported extensions
- Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
- // LordHavoc: set up state
- glAlphaFunc(GL_GREATER, 0.5);
- glCullFace(GL_FRONT);
-}
-
/*
=================
GL_BeginRendering
*/
void GL_BeginRendering (int *x, int *y, int *width, int *height)
{
-// extern cvar_t gl_clear;
-
*x = *y = 0;
*width = WindowRect.right - WindowRect.left;
*height = WindowRect.bottom - WindowRect.top;
wglMakeCurrent(NULL, NULL);
// LordHavoc: free textures before closing (may help NVIDIA)
- for (i = 0;i < 8192;i++) temp[i] = i;
+ for (i = 0;i < 8192;i++) temp[i] = i+1;
glDeleteTextures(8192, temp);
if (hRC)
wglDeleteContext(hRC);
- if (hDC && dibwindow)
- ReleaseDC(dibwindow, hDC);
+ if (hDC && mainwindow)
+ ReleaseDC(mainwindow, hDC);
if (modestate == MS_FULLDIB)
ChangeDisplaySettings (NULL, 0);
- if (maindc && dibwindow)
- ReleaseDC (dibwindow, maindc);
+ if (maindc && mainwindow)
+ ReleaseDC (mainwindow, maindc);
AppActivate(false, false);
}
-byte scantokey[128] =
- {
-// 0 1 2 3 4 5 6 7
-// 8 9 A B C D E F
- 0 , 27, '1', '2', '3', '4', '5', '6',
- '7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0
- 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
- 'o', 'p', '[', ']', 13 , K_CTRL,'a', 's', // 1
- 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
- '\'' , '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
- 'b', 'n', 'm', ',', '.', '/', K_SHIFT,'*',
- K_ALT,' ', 0 , K_F1, K_F2, K_F3, K_F4, K_F5, // 3
- K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE , 0 , K_HOME,
- K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+',K_END, //4
- K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11,
- K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
- };
-
-byte shiftscantokey[128] =
- {
-// 0 1 2 3 4 5 6 7
-// 8 9 A B C D E F
- 0 , 27, '!', '@', '#', '$', '%', '^',
- '&', '*', '(', ')', '_', '+', K_BACKSPACE, 9, // 0
- 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
- 'O', 'P', '{', '}', 13 , K_CTRL,'A', 'S', // 1
- 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
- '"' , '~', K_SHIFT,'|', 'Z', 'X', 'C', 'V', // 2
- 'B', 'N', 'M', '<', '>', '?', K_SHIFT,'*',
- K_ALT,' ', 0 , K_F1, K_F2, K_F3, K_F4, K_F5, // 3
- K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE , 0 , K_HOME,
- K_UPARROW,K_PGUP,'_',K_LEFTARROW,'%',K_RIGHTARROW,'+',K_END, //4
- K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11,
- K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
- };
+byte scantokey[128] =
+{
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0 ,27 ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,K_BACKSPACE,9 , // 0
+ 'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,'o' ,'p' ,'[' ,']' ,13 ,K_CTRL ,'a' ,'s' , // 1
+ 'd' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,'\'' ,'`' ,K_SHIFT,'\\' ,'z' ,'x' ,'c' ,'v' , // 2
+ 'b' ,'n' ,'m' ,',' ,'.' ,'/' ,K_SHIFT,'*' ,K_ALT ,' ' ,0 ,K_F1 ,K_F2 ,K_F3 ,K_F4 ,K_F5 , // 3
+ K_F6 ,K_F7 ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0 ,K_HOME,K_UPARROW,K_PGUP,'-' ,K_LEFTARROW,'5' ,K_RIGHTARROW,'+' ,K_END , // 4
+ K_DOWNARROW,K_PGDN,K_INS,K_DEL,0 ,0 ,0 ,K_F11 ,K_F12 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
+ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
+ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
+};
+/*
+byte shiftscantokey[128] =
+{
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0 ,27 ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'_' ,'+' ,K_BACKSPACE,9 , // 0
+ 'Q' ,'W' ,'E' ,'R' ,'T' ,'Y' ,'U' ,'I' ,'O' ,'P' ,'{' ,'}' ,13 ,K_CTRL ,'A' ,'S' , // 1
+ 'D' ,'F' ,'G' ,'H' ,'J' ,'K' ,'L' ,':' ,'"' ,'~' ,K_SHIFT,'|' ,'Z' ,'X' ,'C' ,'V' , // 2
+ 'B' ,'N' ,'M' ,'<' ,'>' ,'?' ,K_SHIFT,'*' ,K_ALT ,' ' ,0 ,K_F1 ,K_F2,K_F3 ,K_F4 ,K_F5 , // 3
+ K_F6 ,K_F7 ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0 ,K_HOME,K_UPARROW,K_PGUP,'_' ,K_LEFTARROW,'%' ,K_RIGHTARROW,'+' ,K_END, // 4
+ K_DOWNARROW,K_PGDN,K_INS,K_DEL,0 ,0 ,0 ,K_F11 ,K_F12 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
+ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
+ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
+};
+*/
/*
=======
Map from windows to quake keynums
=======
*/
-int MapKey (int key)
+int MapKey (int key, int virtualkey)
{
key = (key>>16)&255;
if (key > 127)
return 0;
if (scantokey[key] == 0)
Con_DPrintf("key 0x%02x has no translation\n", key);
+// if (scantokey[key] >= 0x20 && scantokey[key] < 0x7F)
+// return realchar;
return scantokey[key];
}
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
- Key_Event (MapKey(lParam), true);
+ Key_Event (MapKey(lParam, wParam), true);
break;
case WM_KEYUP:
case WM_SYSKEYUP:
- Key_Event (MapKey(lParam), false);
+ Key_Event (MapKey(lParam, wParam), false);
break;
case WM_SYSCHAR:
break;
case WM_CLOSE:
- if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit",
- MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
- {
+ if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
Sys_Quit ();
- }
break;
case WM_DESTROY:
{
- if (dibwindow)
- DestroyWindow (dibwindow);
+ if (mainwindow)
+ DestroyWindow (mainwindow);
PostQuitMessage (0);
}
}
else
{
- sprintf (temp, "Desktop resolution (%dx%d)",
- modelist[MODE_FULLSCREEN_DEFAULT].width,
- modelist[MODE_FULLSCREEN_DEFAULT].height);
+ sprintf (temp, "Desktop resolution (%dx%d)", modelist[MODE_FULLSCREEN_DEFAULT].width, modelist[MODE_FULLSCREEN_DEFAULT].height);
pinfo = temp;
}
if (modelist[mode].type == MS_FULLDIB)
{
if (!leavecurrentmode)
- {
sprintf(pinfo,"%s fullscreen", pv->modedesc);
- }
else
- {
- sprintf (pinfo, "Desktop resolution (%dx%d)",
- modelist[MODE_FULLSCREEN_DEFAULT].width,
- modelist[MODE_FULLSCREEN_DEFAULT].height);
- }
+ sprintf (pinfo, "Desktop resolution (%dx%d)", modelist[MODE_FULLSCREEN_DEFAULT].width, modelist[MODE_FULLSCREEN_DEFAULT].height);
}
else
{
leavecurrentmode = t;
}
+void VID_AddMode(int type, int width, int height, int modenum, int halfscreen, int dib, int fullscreen, int bpp)
+{
+ int i;
+ if (nummodes >= MAX_MODE_LIST)
+ return;
+ modelist[nummodes].type = type;
+ modelist[nummodes].width = width;
+ modelist[nummodes].height = height;
+ modelist[nummodes].modenum = modenum;
+ modelist[nummodes].halfscreen = halfscreen;
+ modelist[nummodes].dib = dib;
+ modelist[nummodes].fullscreen = fullscreen;
+ modelist[nummodes].bpp = bpp;
+ if (bpp == 0)
+ sprintf (modelist[nummodes].modedesc, "%dx%d", width, height);
+ else
+ sprintf (modelist[nummodes].modedesc, "%dx%dx%d", width, height, bpp);
+ for (i = 0;i < nummodes;i++)
+ {
+ if (!memcmp(&modelist[i], &modelist[nummodes], sizeof(vmode_t)))
+ return;
+ }
+ nummodes++;
+}
void VID_InitDIB (HINSTANCE hInstance)
{
+ int w, h;
WNDCLASS wc;
- /* Register the frame class */
+ // Register the frame class
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
-#ifdef NEHAHRA
- wc.lpszClassName = "DPNehahraQuake";
-#else
- wc.lpszClassName = "DarkPlacesQuake";
-#endif
+ wc.lpszClassName = "DarkPlaces";
if (!RegisterClass (&wc) )
Sys_Error ("Couldn't register window class");
+ /*
modelist[0].type = MS_WINDOWED;
if (COM_CheckParm("-width"))
if (modelist[0].height < 240)
modelist[0].height = 240;
- sprintf (modelist[0].modedesc, "%dx%d",
- modelist[0].width, modelist[0].height);
+ sprintf (modelist[0].modedesc, "%dx%d", modelist[0].width, modelist[0].height);
modelist[0].modenum = MODE_WINDOWED;
modelist[0].dib = 1;
modelist[0].bpp = 0;
nummodes = 1;
+ */
+ if (COM_CheckParm("-width"))
+ w = atoi(com_argv[COM_CheckParm("-width")+1]);
+ else
+ w = 640;
+
+ if (w < 320)
+ w = 320;
+
+ if (COM_CheckParm("-height"))
+ h = atoi(com_argv[COM_CheckParm("-height")+1]);
+ else
+ h = w * 240/320;
+
+ if (h < 240)
+ h = 240;
+
+ VID_AddMode(MS_WINDOWED, w, h, 0, 0, 1, 0, 0);
}
void VID_InitFullDIB (HINSTANCE hInstance)
{
DEVMODE devmode;
- int i, modenum, originalnummodes, existingmode, numlowresmodes;
- int j, bpp, done;
+// int i;
+ int modenum;
+ int originalnummodes;
+// int existingmode;
+ int numlowresmodes;
+ int j;
+ int bpp;
+ int done;
BOOL stat;
// enumerate >8 bpp modes
{
stat = EnumDisplaySettings (NULL, modenum, &devmode);
- if ((devmode.dmBitsPerPel >= 15) &&
- (devmode.dmPelsWidth <= MAXWIDTH) &&
- (devmode.dmPelsHeight <= MAXHEIGHT) &&
- (nummodes < MAX_MODE_LIST))
+ if ((devmode.dmBitsPerPel >= 15) && (devmode.dmPelsWidth <= MAXWIDTH) && (devmode.dmPelsHeight <= MAXHEIGHT) && (nummodes < MAX_MODE_LIST))
{
- devmode.dmFields = DM_BITSPERPEL |
- DM_PELSWIDTH |
- DM_PELSHEIGHT;
+ devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) ==
- DISP_CHANGE_SUCCESSFUL)
+ if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
{
+ // if the width is more than twice the height, reduce it by half because this
+ // is probably a dual-screen monitor
+ if ((!COM_CheckParm("-noadjustaspect")) && (devmode.dmPelsWidth > (devmode.dmPelsHeight << 1)))
+ VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth >> 1, devmode.dmPelsHeight, 0, 1, 1, 1, devmode.dmBitsPerPel);
+ else
+ VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 0, 1, 1, devmode.dmBitsPerPel);
+ /*
modelist[nummodes].type = MS_FULLDIB;
modelist[nummodes].width = devmode.dmPelsWidth;
modelist[nummodes].height = devmode.dmPelsHeight;
modelist[nummodes].dib = 1;
modelist[nummodes].fullscreen = 1;
modelist[nummodes].bpp = devmode.dmBitsPerPel;
- sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
- devmode.dmPelsWidth, devmode.dmPelsHeight,
- devmode.dmBitsPerPel);
+ sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
// if the width is more than twice the height, reduce it by half because this
// is probably a dual-screen monitor
{
modelist[nummodes].width >>= 1;
modelist[nummodes].halfscreen = 1;
- sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
- modelist[nummodes].width,
- modelist[nummodes].height,
- modelist[nummodes].bpp);
+ sprintf (modelist[nummodes].modedesc, "%dx%dx%d", modelist[nummodes].width, modelist[nummodes].height, modelist[nummodes].bpp);
}
}
for (i=originalnummodes, existingmode = 0 ; i<nummodes ; i++)
{
- if ((modelist[nummodes].width == modelist[i].width) &&
- (modelist[nummodes].height == modelist[i].height) &&
- (modelist[nummodes].bpp == modelist[i].bpp))
+ if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
{
existingmode = 1;
break;
}
if (!existingmode)
- {
nummodes++;
- }
+ */
}
}
modenum++;
- } while (stat);
+ }
+ while (stat);
// see if there are any low-res modes that aren't being reported
numlowresmodes = sizeof(lowresmodes) / sizeof(lowresmodes[0]);
devmode.dmPelsHeight = lowresmodes[j].height;
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) ==
- DISP_CHANGE_SUCCESSFUL)
+ if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
+ VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 0, 1, 1, devmode.dmBitsPerPel);
+ /*
{
modelist[nummodes].type = MS_FULLDIB;
modelist[nummodes].width = devmode.dmPelsWidth;
modelist[nummodes].dib = 1;
modelist[nummodes].fullscreen = 1;
modelist[nummodes].bpp = devmode.dmBitsPerPel;
- sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
- devmode.dmPelsWidth, devmode.dmPelsHeight,
- devmode.dmBitsPerPel);
+ sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
for (i=originalnummodes, existingmode = 0 ; i<nummodes ; i++)
{
- if ((modelist[nummodes].width == modelist[i].width) &&
- (modelist[nummodes].height == modelist[i].height) &&
- (modelist[nummodes].bpp == modelist[i].bpp))
+ if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
{
existingmode = 1;
break;
}
if (!existingmode)
- {
nummodes++;
- }
}
+ */
}
switch (bpp)
{
done = 1;
break;
}
- } while (!done);
+ }
+ while (!done);
if (nummodes == originalnummodes)
Con_SafePrintf ("No fullscreen DIB modes found\n");
}
-qboolean VID_Is8bit()
-{
- return is8bit;
-}
-
-#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
-
-void VID_Init8bitPalette()
-{
- // Check for 8bit Extensions and initialize them.
- int i;
- char thePalette[256*3];
- char *oldPalette, *newPalette;
- // LordHavoc: 8bit texture support broke many things... it now must be specifically stated on the commandline (-no8bit became -8bit)
- if (!COM_CheckParm("-8bit"))
- return;
- if (strstr(gl_extensions, "GL_EXT_shared_texture_palette"))
- return;
- if (!(glColorTableEXT = (void *)wglGetProcAddress("glColorTableEXT")))
- return;
-
- Con_SafePrintf("8-bit GL extensions enabled.\n");
- glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
- oldPalette = (char *) d_8to24table;
- 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;
-}
-
-extern void Check_Gamma (unsigned char *pal);
-void VID_Setup15to8Palette ();
-
/*
===================
VID_Init
===================
*/
-void VID_Init (unsigned char *palette)
+void VID_Init ()
{
- int i, existingmode;
+ int i;
+// int existingmode;
int basenummodes, width, height, bpp, findbpp, done;
-// char gldir[MAX_OSPATH];
HDC hdc;
DEVMODE devmode;
hdc = GetDC (NULL);
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
- {
Sys_Error ("Can't run in non-RGB mode");
- }
ReleaseDC (NULL, hdc);
windowed = false;
if (COM_CheckParm("-mode"))
- {
vid_default = atoi(com_argv[COM_CheckParm("-mode")+1]);
- }
else
{
if (COM_CheckParm("-current"))
{
- modelist[MODE_FULLSCREEN_DEFAULT].width =
- GetSystemMetrics (SM_CXSCREEN);
- modelist[MODE_FULLSCREEN_DEFAULT].height =
- GetSystemMetrics (SM_CYSCREEN);
+ modelist[MODE_FULLSCREEN_DEFAULT].width = GetSystemMetrics (SM_CXSCREEN);
+ modelist[MODE_FULLSCREEN_DEFAULT].height = GetSystemMetrics (SM_CYSCREEN);
vid_default = MODE_FULLSCREEN_DEFAULT;
leavecurrentmode = 1;
}
else
{
if (COM_CheckParm("-width"))
- {
width = atoi(com_argv[COM_CheckParm("-width")+1]);
- }
else
- {
width = 640;
- }
if (COM_CheckParm("-bpp"))
{
// if they want to force it, add the specified mode to the list
if (COM_CheckParm("-force") && (nummodes < MAX_MODE_LIST))
+ VID_AddMode(MS_FULLDIB, width, height, 0, 0, 1, 1, bpp);
+ /*
{
modelist[nummodes].type = MS_FULLDIB;
modelist[nummodes].width = width;
modelist[nummodes].dib = 1;
modelist[nummodes].fullscreen = 1;
modelist[nummodes].bpp = bpp;
- sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
- devmode.dmPelsWidth, devmode.dmPelsHeight,
- devmode.dmBitsPerPel);
+ sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
for (i=nummodes, existingmode = 0 ; i<nummodes ; i++)
{
- if ((modelist[nummodes].width == modelist[i].width) &&
- (modelist[nummodes].height == modelist[i].height) &&
- (modelist[nummodes].bpp == modelist[i].bpp))
+ if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
{
existingmode = 1;
break;
}
if (!existingmode)
- {
nummodes++;
- }
}
+ */
done = 0;
for (i=1, vid_default=0 ; i<nummodes ; i++)
{
- if ((modelist[i].width == width) &&
- (modelist[i].height == height) &&
- (modelist[i].bpp == bpp))
+ if ((modelist[i].width == width) && (modelist[i].height == height) && (modelist[i].bpp == bpp))
{
vid_default = i;
done = 1;
{
switch (bpp)
{
- case 15:
- bpp = 16;
- break;
- case 16:
- bpp = 32;
- break;
- case 32:
- bpp = 24;
- break;
- case 24:
- done = 1;
- break;
+ case 15: bpp = 16;break;
+ case 16: bpp = 32;break;
+ case 32: bpp = 24;break;
+ case 24: done = 1;break;
}
}
else
- {
done = 1;
- }
}
}
while (!done);
if (!vid_default)
- {
Sys_Error ("Specified video mode not available");
- }
}
}
}
if (vid.conheight < 200)
vid.conheight = 200;
- DestroyWindow (hwnd_dialog);
-
- VID_SetPalette (palette);
-
- Check_Gamma(palette);
-
- VID_SetMode (vid_default, palette);
+ VID_SetMode (vid_default);
maindc = GetDC(mainwindow);
bSetupPixelFormat(maindc);
GL_Init ();
+ // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
+ if (strncasecmp(gl_vendor,"ATI",3)==0)
+ {
+ if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
+ isRagePro = true;
+ }
+ if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
+ isG200 = true;
+
// sprintf (gldir, "%s/glquake", com_gamedir);
// Sys_mkdir (gldir);
vid_realmode = vid_modenum;
- VID_Init8bitPalette();
-
- if (is8bit) // LordHavoc: avoid calculating 15to8 table if it won't be used
- VID_Setup15to8Palette ();
-
vid_menudrawfn = VID_MenuDraw;
vid_menukeyfn = VID_MenuKey;
/*
==============================================================================
- PALETTE FLASHES
+ SCREEN FLASHES
==============================================================================
*/
/*
=============
-V_UpdatePalette
+V_UpdateBlends
=============
*/
-void V_UpdatePalette (void)
+void V_UpdateBlends (void)
{
int i, j;
qboolean new;
void V_Init (void);
void V_RenderView (void);
float V_CalcRoll (vec3_t angles, vec3_t velocity);
-void V_UpdatePalette (void);
+void V_UpdateBlends (void);
extern RECT window_rect;
extern qboolean mouseinitialized;
-extern HWND hwnd_dialog;
extern HANDLE hinput, houtput;
// set the abs box
// LordHavoc: enabling rotating bmodels
- if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+ if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
{ // expand for rotation
float max, v;
int i;
+ max = DotProduct(ent->v.mins, ent->v.mins);
+ v = DotProduct(ent->v.maxs, ent->v.maxs);
+ if (max < v)
+ max = v;
+ max = sqrt(max);
+ /*
max = 0;
for (i=0 ; i<3 ; i++)
{
- v =fabs( ent->v.mins[i]);
- if (v > max)
+ v = fabs(ent->v.mins[i]);
+ if (max < v)
max = v;
- v =fabs( ent->v.maxs[i]);
- if (v > max)
+ v = fabs(ent->v.maxs[i]);
+ if (max < v)
max = v;
}
+ */
for (i=0 ; i<3 ; i++)
{
ent->v.absmin[i] = ent->v.origin[i] - max;
ent->v.absmax[1] += 1;
ent->v.absmax[2] += 1;
}
-
+
// link to PVS leafs
ent->num_leafs = 0;
if (ent->v.modelindex)
else
break; // crosses the node
}
-
+
// link it in
if (ent->v.solid == SOLID_TRIGGER)
// LordHavoc: enabling rotating bmodels
// rotate start and end into the models frame of reference
- if (ent->v.solid == SOLID_BSP &&
- (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+ if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
{
vec3_t forward, right, up;
vec3_t temp;
// LordHavoc: enabling rotating bmodels
// rotate endpos back to world frame of reference
- if (ent->v.solid == SOLID_BSP &&
- (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+ if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
{
vec3_t a;
vec3_t forward, right, up;
// shouldn't be considered solid objects
// passedict is explicitly excluded from clipping checks (normally NULL)
+
+extern qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
\ No newline at end of file