Oh noes! Everything is broken!

Rewrote much of the console code. Should be no obvious differences.
Nearly all conchar parsing goes via a single function. Still some left in the dedicated server code.
Added the ability to parse utf-8 text, disabled by default.
Added the ability to input unicode chars using whatever keymap the user has set up in windows (not enabled by default).
Reworked vbo stuff to be a little more versatile.
Added toggle console command.
Added freetype2 support (not compiled by default).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3234 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-07-05 18:45:53 +00:00
parent 5206c1a0c8
commit a80214290d
59 changed files with 2668 additions and 1094 deletions

View file

@ -79,6 +79,19 @@ qboolean CL_FilterModelindex(int modelindex, int frame)
//============================================================ //============================================================
static void CL_ClearDlight(dlight_t *dl, int key)
{
int st;
st = dl->stexture;
memset (dl, 0, sizeof(*dl));
dl->stexture = st;
dl->axis[0][0] = 1;
dl->axis[1][1] = 1;
dl->axis[2][2] = 1;
dl->key = key;
dl->flags = LFLAG_DYNAMIC;
}
/* /*
=============== ===============
CL_AllocDlight CL_AllocDlight
@ -98,8 +111,7 @@ dlight_t *CL_AllocDlight (int key)
{ {
if (dl->key == key) if (dl->key == key)
{ {
memset (dl, 0, sizeof(*dl)); CL_ClearDlight(dl, key);
dl->key = key;
return dl; return dl;
} }
} }
@ -109,8 +121,7 @@ dlight_t *CL_AllocDlight (int key)
if (dlights_running < MAX_DLIGHTS) if (dlights_running < MAX_DLIGHTS)
{ {
dl = &cl_dlights[dlights_running]; dl = &cl_dlights[dlights_running];
memset (dl, 0, sizeof(*dl)); CL_ClearDlight(dl, key);
dl->key = key;
dlights_running++; dlights_running++;
if (dlights_software < MAX_SWLIGHTS) if (dlights_software < MAX_SWLIGHTS)
dlights_software++; dlights_software++;
@ -118,8 +129,7 @@ dlight_t *CL_AllocDlight (int key)
} }
dl = &cl_dlights[0]; dl = &cl_dlights[0];
memset (dl, 0, sizeof(*dl)); CL_ClearDlight(dl, key);
dl->key = key;
return dl; return dl;
} }
@ -199,6 +209,12 @@ void CL_DecayLights (void)
if (!dl->radius) if (!dl->radius)
continue; continue;
if (!dl->die)
{
lastrunning = i;
continue;
}
if (dl->die < (float)cl.time) if (dl->die < (float)cl.time)
{ {
dl->radius = 0; dl->radius = 0;
@ -1476,6 +1492,9 @@ void CL_TransitionPacketEntities(packet_entities_t *newpack, packet_entities_t *
le->oldframechange = le->framechange; le->oldframechange = le->framechange;
le->framechange = newpack->servertime; le->framechange = newpack->servertime;
if (le->framechange > le->oldframechange + 0.2)
le->oldframechange = le->framechange - 0.2;
le->frame = sold->frame; le->frame = sold->frame;
} }
} }
@ -1745,7 +1764,7 @@ void CL_LinkPacketEntities (void)
ent->shaderRGBAf[3] = state->trans/255.0f; ent->shaderRGBAf[3] = state->trans/255.0f;
#ifdef PEXT_FATNESS #ifdef PEXT_FATNESS
//set trans //set trans
ent->fatness = state->fatness/2.0; ent->fatness = state->fatness/16.0;
#endif #endif
// rotate binary objects locally // rotate binary objects locally
@ -1867,6 +1886,7 @@ void CL_LinkPacketEntities (void)
if (rad) if (rad)
{ {
dl = CL_AllocDlight (state->number); dl = CL_AllocDlight (state->number);
memcpy(dl->axis, ent->axis, sizeof(dl->axis));
VectorCopy (ent->origin, dl->origin); VectorCopy (ent->origin, dl->origin);
dl->die = (float)cl.time; dl->die = (float)cl.time;
if (model->flags & EF_ROCKET) if (model->flags & EF_ROCKET)
@ -2045,7 +2065,7 @@ void CL_LinkPacketEntities (void)
#endif #endif
#ifdef PEXT_FATNESS #ifdef PEXT_FATNESS
//set trans //set trans
ent->fatness = s1->fatness/2.0; ent->fatness = s1->fatness/16.0;
#endif #endif
// rotate binary objects locally // rotate binary objects locally
@ -2558,7 +2578,7 @@ void CL_ParsePlayerinfo (void)
#endif #endif
#ifdef PEXT_FATNESS #ifdef PEXT_FATNESS
if (flags & PF_FATNESS_Z && cls.fteprotocolextensions & PEXT_FATNESS) if (flags & PF_FATNESS_Z && cls.fteprotocolextensions & PEXT_FATNESS)
state->fatness = (float)MSG_ReadChar() / 2; state->fatness = (float)MSG_ReadChar() / 16;
#endif #endif
#ifdef PEXT_HULLSIZE #ifdef PEXT_HULLSIZE
if (cls.fteprotocolextensions & PEXT_HULLSIZE) if (cls.fteprotocolextensions & PEXT_HULLSIZE)
@ -2793,20 +2813,51 @@ void CL_LinkPlayers (void)
#endif #endif
// spawn light flashes, even ones coming from invisible objects // spawn light flashes, even ones coming from invisible objects
if (r_powerupglow.value && !(r_powerupglow.value == 2 && j == cl.playernum[0])) if (r_powerupglow.value && !(r_powerupglow.value == 2 && j == cl.playernum[0])
&& (state->effects & (EF_BLUE|EF_RED|EF_BRIGHTLIGHT|EF_DIMLIGHT)))
{ {
vec3_t colour;
float radius;
org = (j == cl.playernum[0]) ? cl.simorg[0] : state->origin; org = (j == cl.playernum[0]) ? cl.simorg[0] : state->origin;
colour[0] = 0;
colour[1] = 0;
colour[2] = 0;
radius = 0;
if ((state->effects & (EF_BLUE | EF_RED)) == (EF_BLUE | EF_RED)) if (state->effects & EF_BRIGHTLIGHT)
CL_NewDlight (j+1, org[0], org[1], org[2], 200 + (r_lightflicker.value?(rand()&31):0), 0.1, 3)->noppl = (j != cl.playernum[0]); {
else if (state->effects & EF_BLUE) radius = max(radius,400);
CL_NewDlight (j+1, org[0], org[1], org[2], 200 + (r_lightflicker.value?(rand()&31):0), 0.1, 1)->noppl = (j != cl.playernum[0]); colour[0] += 0.2;
else if (state->effects & EF_RED) colour[1] += 0.1;
CL_NewDlight (j+1, org[0], org[1], org[2], 200 + (r_lightflicker.value?(rand()&31):0), 0.1, 2)->noppl = (j != cl.playernum[0]); colour[2] += 0.05;
else if (state->effects & EF_BRIGHTLIGHT) }
CL_NewDlight (j+1, org[0], org[1], org[2] + 16, 400 + (r_lightflicker.value?(rand()&31):0), 0.1, 0)->noppl = (j != cl.playernum[0]); if (state->effects & EF_DIMLIGHT)
else if (state->effects & EF_DIMLIGHT) {
CL_NewDlight (j+1, org[0], org[1], org[2], 200 + (r_lightflicker.value?(rand()&31):0), 0.1, 0)->noppl = (j != cl.playernum[0]); radius = max(radius,200);
colour[0] += 0.2;
colour[1] += 0.1;
colour[2] += 0.05;
}
if (state->effects & EF_BLUE)
{
radius = max(radius,200);
colour[0] += 0.05;
colour[1] += 0.05;
colour[2] += 0.3;
}
if (state->effects & EF_RED)
{
radius = max(radius,200);
colour[0] += 0.5;
colour[1] += 0.05;
colour[2] += 0.05;
}
if (radius)
{
radius += r_lightflicker.value?(rand()&31):0;
CL_NewDlightRGB(j+1, org[0], org[1], org[2], radius, 0.1, colour[0], colour[1], colour[2])->flags &= ~LFLAG_ALLOW_FLASH;
}
} }
if (state->modelindex < 1) if (state->modelindex < 1)
@ -2867,7 +2918,7 @@ void CL_LinkPlayers (void)
ent->shaderRGBAf[2] = state->colourmod[2]/32; ent->shaderRGBAf[2] = state->colourmod[2]/32;
ent->shaderRGBAf[3] = state->alpha/255; ent->shaderRGBAf[3] = state->alpha/255;
ent->fatness = state->fatness/2; ent->fatness = state->fatness/16;
// //
// angles // angles
// //

View file

@ -725,7 +725,7 @@ void CL_UpdatePrydonCursor(usercmd_t *from, float cursor_screen[2], vec3_t curso
temp[1] = (-cursor_screen[1]+1)/2; temp[1] = (-cursor_screen[1]+1)/2;
temp[2] = 1; temp[2] = 1;
Matrix4_UnProject(temp, cursor_end, cl.viewangles[0], vec3_origin, (float)vid.width/vid.height, scr_fov.value ); Matrix4_UnProject(temp, cursor_end, cl.viewangles[0], vec3_origin, scr_fov.value*(float)vid.width/vid.height, scr_fov.value );
VectorScale(cursor_end, 100000, cursor_end); VectorScale(cursor_end, 100000, cursor_end);
VectorAdd(cursor_start, cl.simorg[0], cursor_start); VectorAdd(cursor_start, cl.simorg[0], cursor_start);

View file

@ -679,7 +679,7 @@ void CL_CheckForResend (void)
#endif #endif
if (connect_tries == 0) if (connect_tries == 0)
NET_EnsureRoute(cls.sockets, "conn", cls.servername); NET_EnsureRoute(cls.sockets, "conn", cls.servername, false);
#ifdef NQPROT #ifdef NQPROT
if (connect_type || ((connect_tries&3)==3)) if (connect_type || ((connect_tries&3)==3))
@ -844,7 +844,7 @@ void CL_IRCConnect_f (void)
{ {
CL_Disconnect_f (); CL_Disconnect_f ();
if (FTENET_AddToCollection(cls.sockets, "TCP", Cmd_Argv(2), FTENET_IRCConnect_EstablishConnection)) if (FTENET_AddToCollection(cls.sockets, "TCP", Cmd_Argv(2), FTENET_IRCConnect_EstablishConnection, false))
{ {
char *server; char *server;
server = Cmd_Argv (1); server = Cmd_Argv (1);
@ -3530,13 +3530,10 @@ void Host_Init (quakeparms_t *parms)
Con_Init (); Con_Init ();
M_Init (); M_Init ();
//fixme: this difference needs to go.
#ifndef _WIN32 #ifndef _WIN32
IN_Init (); IN_Init ();
CDAudio_Init (); CDAudio_Init ();
// VID_Init (host_basepal);
// Draw_Init ();
// SCR_Init ();
// R_Init ();
S_Init (); S_Init ();
@ -3552,6 +3549,7 @@ void Host_Init (quakeparms_t *parms)
CL_Init (); CL_Init ();
IN_Init (); IN_Init ();
#endif #endif
TranslateInit(); TranslateInit();
#ifndef CLIENTONLY #ifndef CLIENTONLY
SV_Init(parms); SV_Init(parms);

View file

@ -456,11 +456,23 @@ void CL_DownloadFinished(void)
{ {
if (strncmp(tempname,"skins/",6)) if (strncmp(tempname,"skins/",6))
{ {
FS_Rename(tempname, filename, FS_GAME); if (!FS_Rename(tempname, filename, FS_GAME))
{
char nativetmp[MAX_OSPATH], nativefinal[MAX_OSPATH];;
FS_NativePath(tempname, FS_GAME, nativetmp, sizeof(nativetmp));
FS_NativePath(filename, FS_GAME, nativefinal, sizeof(nativefinal));
Con_Printf("Couldn't rename %s to %s\n", nativetmp, nativefinal);
}
} }
else else
{ {
FS_Rename(tempname+6, filename+6, FS_SKINS); if (!FS_Rename(tempname+6, filename+6, FS_SKINS))
{
char nativetmp[MAX_OSPATH], nativefinal[MAX_OSPATH];;
FS_NativePath(tempname+6, FS_SKINS, nativetmp, sizeof(nativetmp));
FS_NativePath(filename+6, FS_SKINS, nativefinal, sizeof(nativefinal));
Con_Printf("Couldn't rename %s to %s\n", nativetmp, nativefinal);
}
} }
} }
} }
@ -2104,8 +2116,21 @@ void CL_ParseServerData (void)
} }
// seperate the printfs so the server message can have a color // seperate the printfs so the server message can have a color
#if 1
{
int i;
Con_Printf ("\n\n");
Con_Printf ("^Ue01d");
for (i = 34; i-->0; i--)
Con_Printf ("^Ue01e");
Con_Printf ("^Ue01f");
Con_Printf ("\n\n");
}
Con_Printf ("\1%s\n", str);
#else
Con_TPrintf (TLC_LINEBREAK_NEWLEVEL); Con_TPrintf (TLC_LINEBREAK_NEWLEVEL);
Con_TPrintf (TLC_PC_PS_NL, 2, str); Con_TPrintf (TLC_PC_PS_NL, 2, str);
#endif
if (CL_RemoveClientCommands("new")) //mvdsv is really appaling some times. if (CL_RemoveClientCommands("new")) //mvdsv is really appaling some times.
{ {
@ -3067,7 +3092,7 @@ void CL_ParseStatic (int version)
ent->shaderRGBAf[2] = (8.0f/255.0f)*es.colormod[2]; ent->shaderRGBAf[2] = (8.0f/255.0f)*es.colormod[2];
ent->shaderRGBAf[3] = es.trans/255; ent->shaderRGBAf[3] = es.trans/255;
ent->fatness = es.fatness/2.0; ent->fatness = es.fatness/16.0;
ent->abslight = es.abslight; ent->abslight = es.abslight;
VectorCopy (es.origin, ent->origin); VectorCopy (es.origin, ent->origin);
@ -3711,6 +3736,7 @@ void CL_MuzzleFlash (int destsplit)
{ {
dl = CL_AllocDlight (-i); dl = CL_AllocDlight (-i);
VectorCopy (s1->origin, dl->origin); VectorCopy (s1->origin, dl->origin);
AngleVectors(s1->angles, dl->axis[0], dl->axis[1], dl->axis[2]);
break; break;
} }
} }
@ -3722,9 +3748,10 @@ void CL_MuzzleFlash (int destsplit)
dl = CL_AllocDlight (-i); dl = CL_AllocDlight (-i);
VectorCopy (pl->origin, dl->origin); //set it's origin VectorCopy (pl->origin, dl->origin); //set it's origin
AngleVectors(pl->viewangles, dl->axis[0], dl->axis[1], dl->axis[2]);
AngleVectors (pl->viewangles, fv, rv, uv); //shift it up a little AngleVectors (pl->viewangles, fv, rv, uv); //shift it up a little
VectorMA (dl->origin, 18, fv, dl->origin); VectorMA (dl->origin, 15, fv, dl->origin);
} }
else else
return; return;

View file

@ -358,7 +358,7 @@ void SCR_CenterPrint (int pnum, char *str, qboolean skipgamecode)
Cbuf_AddText("f_centerprint\n", RESTRICT_LOCAL); Cbuf_AddText("f_centerprint\n", RESTRICT_LOCAL);
} }
COM_ParseFunString(CON_WHITEMASK, str, scr_centerstring[pnum], sizeof(scr_centerstring[pnum])); COM_ParseFunString(CON_WHITEMASK, str, scr_centerstring[pnum], sizeof(scr_centerstring[pnum]), false);
scr_centertime_off[pnum] = scr_centertime.value; scr_centertime_off[pnum] = scr_centertime.value;
scr_centertime_start[pnum] = cl.time; scr_centertime_start[pnum] = cl.time;
@ -412,11 +412,11 @@ void SCR_CenterPrintBreaks(conchar_t *start, int *lines, int *maxlength)
{ {
// scan the width of the line // scan the width of the line
for (l=0 ; l<40 ; l++) for (l=0 ; l<40 ; l++)
if ((start[l]&255) == '\n' || !(start[l]&255)) if ((start[l]&CON_CHARMASK) == '\n' || !(start[l]&CON_CHARMASK))
break; break;
if (l == 40) if (l == 40)
{ {
while(l > 0 && (start[l-1]&255)>' ') while(l > 0 && (start[l-1]&CON_CHARMASK)>' ')
{ {
l--; l--;
} }
@ -430,9 +430,9 @@ void SCR_CenterPrintBreaks(conchar_t *start, int *lines, int *maxlength)
// for (l=0 ; l<40 && *start && *start != '\n'; l++) // for (l=0 ; l<40 && *start && *start != '\n'; l++)
// start++; // start++;
if (!(*start&255)) if (!(*start&CON_CHARMASK))
break; break;
else if ((*start&255) == '\n'||!l) else if ((*start&CON_CHARMASK) == '\n'||!l)
start++; // skip the \n start++; // skip the \n
} while (1); } while (1);
} }
@ -474,14 +474,14 @@ void SCR_DrawCenterString (int pnum)
screenwidth = 40;//vid.width/8; screenwidth = 40;//vid.width/8;
if ((start[0]&255) == '/') if ((start[0]&CON_CHARMASK) == '/')
{ {
if ((start[1]&255) == 'O') if ((start[1]&CON_CHARMASK) == 'O')
{ {
telejanostyle = (start[1]&255); telejanostyle = (start[1]&CON_CHARMASK);
start+=2; start+=2;
} }
else if ((start[1]&255) == 'P') else if ((start[1]&CON_CHARMASK) == 'P')
{ //hexen2 style plaque. { //hexen2 style plaque.
int lines, len; int lines, len;
start+=2; start+=2;
@ -495,11 +495,11 @@ void SCR_DrawCenterString (int pnum)
{ {
// scan the width of the line // scan the width of the line
for (l=0 ; l<=screenwidth ; l++) for (l=0 ; l<=screenwidth ; l++)
if ((start[l]&255) == '\n' || !(start[l]&255)) if ((start[l]&CON_CHARMASK) == '\n' || !(start[l]&CON_CHARMASK))
break; break;
if (l == screenwidth+1) if (l == screenwidth+1)
{ {
while(l > 0 && (start[l-1]&255)>' ' && (start[l-1]&255) != ' '+128) while(l > 0 && (start[l-1]&CON_CHARMASK)>' ' && (start[l-1]&CON_CHARMASK) != ' '+128)
{ {
l--; l--;
} }
@ -525,9 +525,9 @@ void SCR_DrawCenterString (int pnum)
// for (l=0 ; l<40 && *start && *start != '\n'; l++) // for (l=0 ; l<40 && *start && *start != '\n'; l++)
// start++; // start++;
if (!(*start&255)) if (!(*start&CON_CHARMASK))
break; break;
else if ((*start&255) == '\n'||!l) else if ((*start&CON_CHARMASK) == '\n'||!l)
start++; // skip the \n start++; // skip the \n
} while (1); } while (1);
} }
@ -1038,7 +1038,7 @@ void SCR_CrosshairPosition(int pnum, int *x, int *y)
adj+=v_viewheight.value; adj+=v_viewheight.value;
start[2]+=adj; start[2]+=adj;
Matrix4_Project(tr.endpos, end, cl.simangles[pnum], start, (float)rect.width/rect.height, r_refdef.fov_y); Matrix4_Project(tr.endpos, end, cl.simangles[pnum], start, r_refdef.fov_x, r_refdef.fov_y);
*x = rect.x+rect.width*end[0]; *x = rect.x+rect.width*end[0];
*y = rect.y+rect.height*(1-end[1]); *y = rect.y+rect.height*(1-end[1]);
return; return;

View file

@ -244,11 +244,20 @@ typedef struct
#define MAX_DLIGHTS MAX_RTLIGHTS #define MAX_DLIGHTS MAX_RTLIGHTS
#endif #endif
#define LFLAG_NORMALMODE (1<<0)
#define LFLAG_REALTIMEMODE (1<<1)
#define LFLAG_NOSHADOWS (1<<15)
#define LFLAG_ALLOW_LMHACK (1<<16)
#define LFLAG_ALLOW_FLASH (1<<17)
#define LFLAG_ALLOW_PPL (1<<18)
#define LFLAG_ALLOW_PPL (1<<18)
#define LFLAG_DYNAMIC (LFLAG_ALLOW_PPL | LFLAG_ALLOW_LMHACK | LFLAG_ALLOW_FLASH | LFLAG_NORMALMODE | LFLAG_REALTIMEMODE)
typedef struct dlight_s typedef struct dlight_s
{ {
int key; // so entities can reuse same entry int key; // so entities can reuse same entry
qboolean noppl, nodynamic, noflash, isstatic;
vec3_t origin; vec3_t origin;
vec3_t axis[3]; vec3_t axis[3];
float radius; float radius;
@ -258,6 +267,8 @@ typedef struct dlight_s
float color[3]; float color[3];
float channelfade[3]; float channelfade[3];
unsigned int flags;
//the following are used for rendering (client code should clear on create) //the following are used for rendering (client code should clear on create)
struct shadowmesh_s *worldshadowmesh; struct shadowmesh_s *worldshadowmesh;
int stexture; int stexture;

File diff suppressed because it is too large Load diff

View file

@ -58,6 +58,7 @@ cvar_t m_forcewheel = SCVAR("m_forcewheel", "1");
cvar_t m_forcewheel_threshold = SCVAR("m_forcewheel_threshold", "32"); cvar_t m_forcewheel_threshold = SCVAR("m_forcewheel_threshold", "32");
cvar_t in_mwhook = SCVARF("in_mwhook","0", CVAR_ARCHIVE); cvar_t in_mwhook = SCVARF("in_mwhook","0", CVAR_ARCHIVE);
cvar_t in_dinput = SCVARF("in_dinput","0", CVAR_ARCHIVE); cvar_t in_dinput = SCVARF("in_dinput","0", CVAR_ARCHIVE);
cvar_t in_builtinkeymap = SCVARF("in_builtinkeymap", "1", CVAR_ARCHIVE);
cvar_t m_accel_noforce = SCVAR("m_accel_noforce", "0"); cvar_t m_accel_noforce = SCVAR("m_accel_noforce", "0");
cvar_t m_threshold_noforce = SCVAR("m_threshold_noforce", "0"); cvar_t m_threshold_noforce = SCVAR("m_threshold_noforce", "0");
@ -370,11 +371,11 @@ void MW_Hook_Message (long buttons)
buttons &= 0xFFFF; buttons &= 0xFFFF;
switch (buttons ^ old_buttons) switch (buttons ^ old_buttons)
{ {
case 8: Key_Event(K_MOUSE4, buttons > old_buttons ? true : false); break; case 8: Key_Event(K_MOUSE4, 0, buttons > old_buttons ? true : false); break;
case 16: Key_Event(K_MOUSE5, buttons > old_buttons ? true : false); break; case 16: Key_Event(K_MOUSE5, 0, buttons > old_buttons ? true : false); break;
case 32: Key_Event(K_MOUSE6, buttons > old_buttons ? true : false); break; case 32: Key_Event(K_MOUSE6, 0, buttons > old_buttons ? true : false); break;
case 64: Key_Event(K_MOUSE7, buttons > old_buttons ? true : false); break; case 64: Key_Event(K_MOUSE7, 0, buttons > old_buttons ? true : false); break;
case 128: Key_Event(K_MOUSE8, buttons > old_buttons ? true : false); break; case 128: Key_Event(K_MOUSE8, 0, buttons > old_buttons ? true : false); break;
default: break; default: break;
} }
@ -1276,6 +1277,7 @@ void IN_Init (void)
Cvar_Register (&in_mwhook, "Input Controls"); Cvar_Register (&in_mwhook, "Input Controls");
Cvar_Register (&in_dinput, "Input Controls"); Cvar_Register (&in_dinput, "Input Controls");
Cvar_Register (&in_builtinkeymap, "Input Controls");
Cvar_Register (&m_accel_noforce, "Input Controls"); Cvar_Register (&m_accel_noforce, "Input Controls");
Cvar_Register (&m_threshold_noforce, "Input Controls"); Cvar_Register (&m_threshold_noforce, "Input Controls");
@ -1383,13 +1385,13 @@ void IN_MouseEvent (int mstate)
if ( (mstate & (1<<i)) && if ( (mstate & (1<<i)) &&
!(sysmouse.oldbuttons & (1<<i)) ) !(sysmouse.oldbuttons & (1<<i)) )
{ {
Key_Event (K_MOUSE1 + i, true); Key_Event (K_MOUSE1 + i, 0, true);
} }
if ( !(mstate & (1<<i)) && if ( !(mstate & (1<<i)) &&
(sysmouse.oldbuttons & (1<<i)) ) (sysmouse.oldbuttons & (1<<i)) )
{ {
Key_Event (K_MOUSE1 + i, false); Key_Event (K_MOUSE1 + i, 0, false);
} }
} }
@ -1414,13 +1416,13 @@ static void ProcessMouse(mouse_t *mouse, float *movements, int pnum)
if ( (mouse->buttons & (1<<i)) && if ( (mouse->buttons & (1<<i)) &&
!(mouse->oldbuttons & (1<<i)) ) !(mouse->oldbuttons & (1<<i)) )
{ {
Key_Event (K_MOUSE1 + i, true); Key_Event (K_MOUSE1 + i, 0, true);
} }
if ( !(mouse->buttons & (1<<i)) && if ( !(mouse->buttons & (1<<i)) &&
(mouse->oldbuttons & (1<<i)) ) (mouse->oldbuttons & (1<<i)) )
{ {
Key_Event (K_MOUSE1 + i, false); Key_Event (K_MOUSE1 + i, 0, false);
} }
} }
mouse->oldbuttons = mouse->buttons; mouse->oldbuttons = mouse->buttons;
@ -1432,15 +1434,15 @@ static void ProcessMouse(mouse_t *mouse, float *movements, int pnum)
{ {
while(mouse->wheeldelta <= -mfwt) while(mouse->wheeldelta <= -mfwt)
{ {
Key_Event (K_MWHEELUP, true); Key_Event (K_MWHEELUP, 0, true);
Key_Event (K_MWHEELUP, false); Key_Event (K_MWHEELUP, 0, false);
mouse->wheeldelta += mfwt; mouse->wheeldelta += mfwt;
} }
while(mouse->wheeldelta >= mfwt) while(mouse->wheeldelta >= mfwt)
{ {
Key_Event (K_MWHEELDOWN, true); Key_Event (K_MWHEELDOWN, 0, true);
Key_Event (K_MWHEELDOWN, false); Key_Event (K_MWHEELDOWN, 0, false);
mouse->wheeldelta -= mfwt; mouse->wheeldelta -= mfwt;
} }
} }
@ -1864,38 +1866,38 @@ void IN_RawInput_MouseRead(HANDLE in_device_handle)
// buttons // buttons
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_DOWN) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_DOWN)
Key_Event(K_MOUSE1, true); Key_Event(K_MOUSE1, 0, true);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_UP) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_UP)
Key_Event(K_MOUSE1, false); Key_Event(K_MOUSE1, 0, false);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_2_DOWN) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_2_DOWN)
Key_Event(K_MOUSE2, true); Key_Event(K_MOUSE2, 0, true);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_2_UP) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_2_UP)
Key_Event(K_MOUSE2, false); Key_Event(K_MOUSE2, 0, false);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_DOWN) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_DOWN)
Key_Event(K_MOUSE3, true); Key_Event(K_MOUSE3, 0, true);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_UP) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_UP)
Key_Event(K_MOUSE3, false); Key_Event(K_MOUSE3, 0, false);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN)
Key_Event(K_MOUSE4, true); Key_Event(K_MOUSE4, 0, true);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_UP) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_UP)
Key_Event(K_MOUSE4, false); Key_Event(K_MOUSE4, 0, false);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN)
Key_Event(K_MOUSE5, true); Key_Event(K_MOUSE5, 0, true);
if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_UP) if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_UP)
Key_Event(K_MOUSE5, false); Key_Event(K_MOUSE5, 0, false);
// mouse wheel // mouse wheel
if (raw->data.mouse.usButtonFlags & RI_MOUSE_WHEEL) if (raw->data.mouse.usButtonFlags & RI_MOUSE_WHEEL)
{ // If the current message has a mouse_wheel message { // If the current message has a mouse_wheel message
if ((SHORT)raw->data.mouse.usButtonData > 0) if ((SHORT)raw->data.mouse.usButtonData > 0)
{ {
Key_Event(K_MWHEELUP, true); Key_Event(K_MWHEELUP, 0, true);
Key_Event(K_MWHEELUP, false); Key_Event(K_MWHEELUP, 0, false);
} }
if ((SHORT)raw->data.mouse.usButtonData < 0) if ((SHORT)raw->data.mouse.usButtonData < 0)
{ {
Key_Event(K_MWHEELDOWN, true); Key_Event(K_MWHEELDOWN, 0, true);
Key_Event(K_MWHEELDOWN, false); Key_Event(K_MWHEELDOWN, 0, false);
} }
} }
@ -1905,12 +1907,12 @@ void IN_RawInput_MouseRead(HANDLE in_device_handle)
{ {
if ( (tbuttons & (1<<j)) && !(rawmice[i].buttons & (1<<j)) ) if ( (tbuttons & (1<<j)) && !(rawmice[i].buttons & (1<<j)) )
{ {
Key_Event (K_MOUSE1 + j, true); Key_Event (K_MOUSE1 + j, 0, true);
} }
if ( !(tbuttons & (1<<j)) && (rawmice[i].buttons & (1<<j)) ) if ( !(tbuttons & (1<<j)) && (rawmice[i].buttons & (1<<j)) )
{ {
Key_Event (K_MOUSE1 + j, false); Key_Event (K_MOUSE1 + j, 0, false);
} }
} }
@ -1961,7 +1963,7 @@ void IN_StartupJoystick (void)
// verify joystick driver is present // verify joystick driver is present
if ((numdevs = joyGetNumDevs ()) == 0) if ((numdevs = joyGetNumDevs ()) == 0)
{ {
Con_Printf ("\njoystick not found -- driver not present\n\n"); Con_Printf ("joystick not found -- driver not present\n");
return; return;
} }
@ -1981,7 +1983,7 @@ void IN_StartupJoystick (void)
// abort startup if we didn't find a valid joystick // abort startup if we didn't find a valid joystick
if (mmr != JOYERR_NOERROR) if (mmr != JOYERR_NOERROR)
{ {
Con_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr); Con_Printf ("joystick not found -- no valid joysticks (%x)\n", mmr);
return; return;
} }
@ -1990,7 +1992,7 @@ void IN_StartupJoystick (void)
memset (&jc, 0, sizeof(jc)); memset (&jc, 0, sizeof(jc));
if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR) if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
{ {
Con_Printf ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr); Con_Printf ("joystick not found -- invalid joystick capabilities (%x)\n", mmr);
return; return;
} }
@ -2007,7 +2009,7 @@ void IN_StartupJoystick (void)
joy_avail = true; joy_avail = true;
joy_advancedinit = false; joy_advancedinit = false;
Con_Printf ("\njoystick detected\n\n"); Con_Printf ("joystick detected\n");
} }
@ -2133,13 +2135,13 @@ void IN_Commands (void)
if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) ) if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) )
{ {
key_index = (i < 4) ? K_JOY1 : K_AUX1; key_index = (i < 4) ? K_JOY1 : K_AUX1;
Key_Event (key_index + i, true); Key_Event (key_index + i, 0, true);
} }
if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) ) if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) )
{ {
key_index = (i < 4) ? K_JOY1 : K_AUX1; key_index = (i < 4) ? K_JOY1 : K_AUX1;
Key_Event (key_index + i, false); Key_Event (key_index + i, 0, false);
} }
} }
joy_oldbuttonstate = buttonstate; joy_oldbuttonstate = buttonstate;
@ -2166,12 +2168,12 @@ void IN_Commands (void)
{ {
if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) ) if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) )
{ {
Key_Event (K_AUX29 + i, true); Key_Event (K_AUX29 + i, 0, true);
} }
if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) ) if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) )
{ {
Key_Event (K_AUX29 + i, false); Key_Event (K_AUX29 + i, 0, false);
} }
} }
joy_oldpovstate = povstate; joy_oldpovstate = povstate;
@ -2388,11 +2390,7 @@ void IN_JoyMove (float *movements, int pnum)
CL_ClampPitch(pnum); CL_ClampPitch(pnum);
} }
static qbyte scantokey[128] =
qbyte scantokey[128] =
{ {
// 0 1 2 3 4 5 6 7 // 0 1 2 3 4 5 6 7
// 8 9 A B C D E F // 8 9 A B C D E F
@ -2413,8 +2411,8 @@ qbyte scantokey[128] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 // 7 0, 0, 0, 0, 0, 0, 0, 0 // 7
}; };
/*
qbyte shiftscantokey[128] = static qbyte shiftscantokey[128] =
{ {
// 0 1 2 3 4 5 6 7 // 0 1 2 3 4 5 6 7
// 8 9 A B C D E F // 8 9 A B C D E F
@ -2435,7 +2433,7 @@ qbyte shiftscantokey[128] =
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
}; };
*/
/* /*
======= =======
@ -2444,7 +2442,7 @@ MapKey
Map from windows to quake keynums Map from windows to quake keynums
======= =======
*/ */
int MapKey (int vkey) static int MapKey (int vkey)
{ {
int key; int key;
key = (vkey>>16)&255; key = (vkey>>16)&255;
@ -2523,3 +2521,28 @@ int MapKey (int vkey)
Con_DPrintf("key 0x%02x has no translation\n", key); Con_DPrintf("key 0x%02x has no translation\n", key);
return scantokey[key]; return scantokey[key];
} }
void IN_TranslateKeyEvent(WPARAM wParam, LPARAM lParam, qboolean down)
{
extern cvar_t in_builtinkeymap;
int qcode;
int unicode;
qcode = MapKey(lParam);
unicode = (qcode < 128)?qcode:0;
if (WinNT && !in_builtinkeymap.value)
{
BYTE keystate[256];
WCHAR wchars[2];
GetKeyboardState(keystate);
if (ToUnicode(wParam, HIWORD(lParam), keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) > 0)
{
//ignore if more, its probably a compose and > 65535 anyway. we can't represent that.
// if (!wchars[1])
unicode = wchars[0];
}
}
Key_Event (qcode, unicode, down);
}

View file

@ -253,7 +253,7 @@ int PaddedPrint (char *s, int x)
{ {
int nextcolx = 0; int nextcolx = 0;
if (x) /* if (x)
nextcolx = (int)((x + COLUMNWIDTH)/COLUMNWIDTH)*COLUMNWIDTH; nextcolx = (int)((x + COLUMNWIDTH)/COLUMNWIDTH)*COLUMNWIDTH;
if (nextcolx > con_main.linewidth - MINCOLUMNWIDTH if (nextcolx > con_main.linewidth - MINCOLUMNWIDTH
@ -262,7 +262,7 @@ int PaddedPrint (char *s, int x)
Con_Printf ("\n"); Con_Printf ("\n");
x=0; x=0;
} }
*/
if (x) if (x)
{ {
Con_Printf (" "); Con_Printf (" ");
@ -434,49 +434,19 @@ void GetSelectionCoords(int *selectcoords)
} }
*/ */
void Key_ConsoleDrawSelectionBox(void) qboolean Key_GetConsoleSelectionBox(int *sx, int *sy, int *ex, int *ey)
{ {
extern cvar_t vid_conwidth, vid_conheight;
extern int mousecursor_x, mousecursor_y; extern int mousecursor_x, mousecursor_y;
int xpos, ypos, temp;
int xpos2, ypos2;
int yadj;
if (!con_mousedown[2]) if (!con_mousedown[2])
return;
xpos2 = con_mousedown[0];
ypos2 = con_mousedown[1];
xpos = (int)((mousecursor_x*vid_conwidth.value)/(vid.width*8));
ypos = (int)((mousecursor_y*vid_conheight.value)/(vid.height*8));
if (xpos2 < 1)
xpos2 = 1;
if (xpos < 1)
xpos = 1;
if (xpos2 > con_current->linewidth)
xpos2 = con_current->linewidth;
if (xpos > con_current->linewidth)
xpos = con_current->linewidth;
if (xpos2 > xpos)
{ {
temp = xpos; *sx = *sy = *ex = *ey = 0;
xpos = xpos2; return false;
xpos2 = temp;
} }
xpos++; *sx = con_mousedown[0];
if (ypos2 > ypos) *sy = con_mousedown[1];
{ *ex = mousecursor_x;
temp = ypos; *ey = mousecursor_y;
ypos = ypos2;
ypos2 = temp;
}
ypos++;
yadj = (con_current->vislines-22) % 8;
Draw_FillRGB(xpos2*8, yadj+ypos2*8, (xpos - xpos2)*8, (ypos - ypos2)*8, sccolor[0], sccolor[1], sccolor[2]);
} }
void Key_ConsoleRelease(int key) void Key_ConsoleRelease(int key)
@ -485,6 +455,7 @@ void Key_ConsoleRelease(int key)
con_mousedown[2] = false; con_mousedown[2] = false;
if (key == K_MOUSE2 && con_mousedown[2]) if (key == K_MOUSE2 && con_mousedown[2])
{ {
#if 0
extern cvar_t vid_conwidth, vid_conheight; extern cvar_t vid_conwidth, vid_conheight;
extern int mousecursor_x, mousecursor_y; extern int mousecursor_x, mousecursor_y;
int xpos, ypos, temp; int xpos, ypos, temp;
@ -552,6 +523,7 @@ void Key_ConsoleRelease(int key)
Sys_SaveClipboard(bufhead); Sys_SaveClipboard(bufhead);
Z_Free(bufhead); Z_Free(bufhead);
#endif
} }
} }
@ -562,7 +534,7 @@ Key_Console
Interactive line editing and console scrollback Interactive line editing and console scrollback
==================== ====================
*/ */
void Key_Console (int key) void Key_Console (unsigned int unicode, int key)
{ {
char *clipText; char *clipText;
int upperconbound; int upperconbound;
@ -588,8 +560,8 @@ void Key_Console (int key)
int xpos, ypos; int xpos, ypos;
xpos = (int)((mousecursor_x*vid_conwidth.value)/(vid.width*8)); xpos = (int)((mousecursor_x*vid_conwidth.value)/(vid.width*8));
ypos = (int)((mousecursor_y*vid_conheight.value)/(vid.height*8)); ypos = (int)((mousecursor_y*vid_conheight.value)/(vid.height*8));
con_mousedown[0] = xpos; con_mousedown[0] = mousecursor_x;
con_mousedown[1] = ypos; con_mousedown[1] = mousecursor_y;
if (ypos == 0 && con_main.next) if (ypos == 0 && con_main.next)
{ {
console_t *con; console_t *con;
@ -740,61 +712,41 @@ void Key_Console (int key)
return; return;
} }
upperconbound = con_current->current - con_current->totallines + 1;
if (key == K_PGUP || key==K_MWHEELUP) if (key == K_PGUP || key==K_MWHEELUP)
{ {
// con_current->vislines actually contains the height of the console in int i = 2;
// pixels (and not the number of lines). It's 22 pixels larger
// than the text area to include borders I guess... weird shit.
// - Molgrum
if (keydown[K_CTRL]) if (keydown[K_CTRL])
{ i = 8;
if (con_current->display == con_current->current) if (con_current->display == con_current->current)
i+=2; //skip over the blank input line, and extra so we actually move despite the addition of the ^^^^^ line
while (i-->0)
{ {
con_current->display -= ( ( con_current->vislines - 22 ) / 8 ); if (con_current->display->older == NULL)
break;
con_current->display = con_current->display->older;
} }
else
{
con_current->display -= ( ( con_current->vislines - 30 ) / 8 );
}
}
else
con_current->display -= 2;
if (con_current->display < upperconbound)
con_current->display = upperconbound;
return; return;
} }
if (key == K_PGDN || key==K_MWHEELDOWN) if (key == K_PGDN || key==K_MWHEELDOWN)
{ {
// con_current->vislines actually contains the height of the console in int i = 2;
// pixels (and not the number of lines). It's 22 pixels larger
// than the text area to include borders I guess... weird shit.
// - Molgrum
if (keydown[K_CTRL]) if (keydown[K_CTRL])
con_current->display += ( ( con_current->vislines - 30 ) / 8 ); i = 8;
else while (i-->0)
con_current->display += 2; {
if (con_current->display->newer == NULL)
if (con_current->display < upperconbound) break;
con_current->display = upperconbound; con_current->display = con_current->display->newer;
}
// Changed this to prevent the following scenario: PGUP, ENTER, PGDN ,(you'll if (con_current->display->newer && con_current->display->newer == con_current->current)
// see the ^^^^ indicator), PGDN, (the indicator disappears but the console position
// is still the same).
// - Molgrum
if (con_current->display >= ( con_current->current - 1 ))
con_current->display = con_current->current; con_current->display = con_current->current;
return; return;
} }
if (key == K_HOME) if (key == K_HOME)
{ {
if (keydown[K_CTRL]) if (keydown[K_CTRL])
con_current->display = upperconbound; con_current->display = con_current->oldest;
else else
key_linepos = 1; key_linepos = 1;
return; return;
@ -844,8 +796,35 @@ void Key_Console (int key)
return; return;
} }
if (key < 32 || key > 127) key = unicode;
return; // non printable if (!key)
return;
{
unsigned char c1;
unsigned char c2;
if (unicode > 127)
{
extern cvar_t com_parseutf8;
if (com_parseutf8.value)
{
c1 = 0xc0 | ((unicode>>6)&0x1f);
c2 = 0x80 | (unicode&0x3f);
if (key_linepos < MAXCMDLINE-2)
{
memmove(key_lines[edit_line]+key_linepos+2, key_lines[edit_line]+key_linepos, strlen(key_lines[edit_line]+key_linepos)+1);
key_lines[edit_line][key_linepos] = c1;
key_linepos++;
key_lines[edit_line][key_linepos] = c2;
key_linepos++;
// key_lines[edit_line][key_linepos] = 0;
}
return;
}
unicode = '?'; //sorry
}
}
if (keydown[K_CTRL]) { if (keydown[K_CTRL]) {
if (key >= '0' && key <= '9') if (key >= '0' && key <= '9')
@ -877,7 +856,7 @@ void Key_Console (int key)
if (key_linepos < MAXCMDLINE-1) if (strlen(key_lines[edit_line])+1 < MAXCMDLINE-1)
{ {
memmove(key_lines[edit_line]+key_linepos+1, key_lines[edit_line]+key_linepos, strlen(key_lines[edit_line]+key_linepos)+1); memmove(key_lines[edit_line]+key_linepos+1, key_lines[edit_line]+key_linepos, strlen(key_lines[edit_line]+key_linepos)+1);
key_lines[edit_line][key_linepos] = key; key_lines[edit_line][key_linepos] = key;
@ -988,7 +967,13 @@ int Key_StringToKeynum (char *str, int *modifier)
if (!str || !str[0]) if (!str || !str[0])
return -1; return -1;
if (!str[1]) //single char. if (!str[1]) //single char.
{
#if 0//def _WIN32
return VkKeyScan(str[0]);
#else
return str[0]; return str[0];
#endif
}
if (!strncmp(str, "K_", 2)) if (!strncmp(str, "K_", 2))
str+=2; str+=2;
@ -999,7 +984,9 @@ int Key_StringToKeynum (char *str, int *modifier)
return kn->keynum; return kn->keynum;
} }
if (atoi(str)) //assume ascii code. (prepend with a 0 if needed) if (atoi(str)) //assume ascii code. (prepend with a 0 if needed)
{
return atoi(str); return atoi(str);
}
return -1; return -1;
} }
@ -1400,13 +1387,13 @@ Called by the system between frames for both key up and key down events
Should NOT be called during an interrupt! Should NOT be called during an interrupt!
=================== ===================
*/ */
void Key_Event (int key, qboolean down) void Key_Event (int key, unsigned int unicode, qboolean down)
{ {
char *kb; char *kb;
char cmd[1024]; char cmd[1024];
int keystate, oldstate; int keystate, oldstate;
// Con_Printf ("%i : %i\n", key, down); //@@@ // Con_Printf ("%i : %i : %i\n", key, unicode, down); //@@@
oldstate = KeyModifier(keydown[K_SHIFT], keydown[K_ALT], keydown[K_CTRL]); oldstate = KeyModifier(keydown[K_SHIFT], keydown[K_ALT], keydown[K_CTRL]);
@ -1515,7 +1502,9 @@ void Key_Event (int key, qboolean down)
} }
if (key == K_SHIFT) if (key == K_SHIFT)
{
shift_down = down; shift_down = down;
}
if (key == K_ESCAPE) if (key == K_ESCAPE)
if (shift_down) if (shift_down)
@ -1687,7 +1676,7 @@ void Key_Event (int key, qboolean down)
} }
if (shift_down) if (shift_down)
key = keyshift[key]; unicode = keyshift[unicode];
if (!down) if (!down)
{ {
@ -1719,7 +1708,7 @@ void Key_Event (int key, qboolean down)
case key_console: case key_console:
if ((key >= ' ' && key <= 127) || key == K_ENTER || key == K_TAB) if ((key >= ' ' && key <= 127) || key == K_ENTER || key == K_TAB)
key_dest = key_console; key_dest = key_console;
Key_Console (key); Key_Console (unicode, key);
break; break;
default: default:
Sys_Error ("Bad key_dest"); Sys_Error ("Bad key_dest");

View file

@ -176,7 +176,7 @@ extern char chat_buffer[];
extern int chat_bufferlen; extern int chat_bufferlen;
extern qboolean chat_team; extern qboolean chat_team;
void Key_Event (int key, qboolean down); void Key_Event (int key, unsigned int unicode, qboolean down);
void Key_Init (void); void Key_Init (void);
void Key_WriteBindings (vfsfile_t *f); void Key_WriteBindings (vfsfile_t *f);
void Key_SetBinding (int keynum, int modifier, char *binding, int cmdlevel); void Key_SetBinding (int keynum, int modifier, char *binding, int cmdlevel);

View file

@ -428,13 +428,18 @@ void PF_CL_stringwidth(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
char *text = PR_GetStringOfs(prinst, OFS_PARM0); char *text = PR_GetStringOfs(prinst, OFS_PARM0);
qboolean usecolours = G_FLOAT(OFS_PARM1); qboolean usecolours = G_FLOAT(OFS_PARM1);
float fontsize;
if (*prinst->callargc > 2)
fontsize = G_FLOAT(OFS_PARM2);
else
fontsize = 8;
if (usecolours) if (usecolours)
{ {
G_FLOAT(OFS_RETURN) = COM_FunStringLength(text)*8; G_FLOAT(OFS_RETURN) = COM_FunStringLength(text)*fontsize;
} }
else else
{ {
G_FLOAT(OFS_RETURN) = strlen(text)*8; G_FLOAT(OFS_RETURN) = strlen(text)*fontsize;
} }
} }

View file

@ -2294,6 +2294,8 @@ float r_view_matrix[16];
void MYgluPerspective(double fovx, double fovy, double zNear, double zFar) void MYgluPerspective(double fovx, double fovy, double zNear, double zFar)
{ {
Matrix4_Projection_Far(r_projection_matrix, fovx, fovy, zNear, zFar);
/*
double xmin, xmax, ymin, ymax; double xmin, xmax, ymin, ymax;
ymax = zNear * tan( fovy * M_PI / 360.0 ); ymax = zNear * tan( fovy * M_PI / 360.0 );
@ -2321,6 +2323,7 @@ void MYgluPerspective(double fovx, double fovy, double zNear, double zFar)
r_projection_matrix[7] = 0; r_projection_matrix[7] = 0;
r_projection_matrix[11] = -1; r_projection_matrix[11] = -1;
r_projection_matrix[15] = 0; r_projection_matrix[15] = 0;
*/
} }
void GL_InfinatePerspective(double fovx, double fovy, void GL_InfinatePerspective(double fovx, double fovy,

View file

@ -158,7 +158,7 @@ void Draw_ExpandedString(int x, int y, conchar_t *str)
void Draw_FunString(int x, int y, unsigned char *str) void Draw_FunString(int x, int y, unsigned char *str)
{ {
conchar_t buffer[2048]; conchar_t buffer[2048];
COM_ParseFunString(CON_WHITEMASK, str, buffer, sizeof(buffer)); COM_ParseFunString(CON_WHITEMASK, str, buffer, sizeof(buffer), false);
Draw_ExpandedString(x, y, buffer); Draw_ExpandedString(x, y, buffer);
} }
@ -167,9 +167,11 @@ void Draw_FunStringLen(int x, int y, unsigned char *str, int numchars)
{ {
conchar_t buffer[2048]; conchar_t buffer[2048];
if (numchars > sizeof(buffer)-1) numchars *= sizeof(conchar_t); //numchars should now be the size of the chars.
numchars = sizeof(buffer)-1;
COM_ParseFunString(CON_WHITEMASK, str, buffer, numchars+1); if (numchars > sizeof(buffer))
numchars = sizeof(buffer);
COM_ParseFunString(CON_WHITEMASK, str, buffer, numchars, false);
Draw_ExpandedString(x, y, buffer); Draw_ExpandedString(x, y, buffer);
} }

View file

@ -350,19 +350,19 @@ LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
//Trap the Left Windowskey //Trap the Left Windowskey
if (pkbhs->vkCode == VK_LWIN) if (pkbhs->vkCode == VK_LWIN)
{ {
Key_Event (K_LWIN, !(pkbhs->flags & LLKHF_UP)); Key_Event (K_LWIN, 0, !(pkbhs->flags & LLKHF_UP));
return 1; return 1;
} }
//Trap the Right Windowskey //Trap the Right Windowskey
if (pkbhs->vkCode == VK_RWIN) if (pkbhs->vkCode == VK_RWIN)
{ {
Key_Event (K_RWIN, !(pkbhs->flags & LLKHF_UP)); Key_Event (K_RWIN, 0, !(pkbhs->flags & LLKHF_UP));
return 1; return 1;
} }
//Trap the Application Key (what a pointless key) //Trap the Application Key (what a pointless key)
if (pkbhs->vkCode == VK_APPS) if (pkbhs->vkCode == VK_APPS)
{ {
Key_Event (K_APP, !(pkbhs->flags & LLKHF_UP)); Key_Event (K_APP, 0, !(pkbhs->flags & LLKHF_UP));
return 1; return 1;
} }
@ -1114,7 +1114,8 @@ void Sys_SendKeyEvents (void)
if (!GetMessage (&msg, NULL, 0, 0)) if (!GetMessage (&msg, NULL, 0, 0))
break; break;
// Sys_Quit (); // Sys_Quit ();
TranslateMessage (&msg); // if (TranslateMessage (&msg))
// continue;
DispatchMessage (&msg); DispatchMessage (&msg);
} }
#endif #endif

View file

@ -1383,7 +1383,7 @@ void R_DrawNameTags(void)
{ {
VectorCopy(state->origin, tagcenter); VectorCopy(state->origin, tagcenter);
tagcenter[2] += 32; tagcenter[2] += 32;
Matrix4_Project(tagcenter, center, r_refdef.viewangles, r_refdef.vieworg, (float)r_refdef.vrect.width/r_refdef.vrect.height, r_refdef.fov_y); Matrix4_Project(tagcenter, center, r_refdef.viewangles, r_refdef.vieworg, r_refdef.fov_x, r_refdef.fov_y);
if (center[2] > 1) if (center[2] > 1)
continue; continue;
Draw_FunString(center[0]*r_refdef.vrect.width+r_refdef.vrect.x, (1-center[1])*r_refdef.vrect.height+r_refdef.vrect.y, cl.players[i].name); Draw_FunString(center[0]*r_refdef.vrect.width+r_refdef.vrect.x, (1-center[1])*r_refdef.vrect.height+r_refdef.vrect.y, cl.players[i].name);

View file

@ -173,7 +173,7 @@ extern HWND hwnd_dialog;
void IN_UpdateClipCursor (void); void IN_UpdateClipCursor (void);
void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify); void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify);
int MapKey (int key); void IN_TranslateKeyEvent(WPARAM wParam, LPARAM lParam, qboolean down);
void MW_Hook_Message (long buttons); void MW_Hook_Message (long buttons);
void S_BlockSound (void); void S_BlockSound (void);

View file

@ -83,6 +83,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef AVAIL_MASM #undef AVAIL_MASM
#endif #endif
//#define AVAIL_FREETYPE
//#define NEWBACKEND
//set any additional defines or libs in win32 //set any additional defines or libs in win32
#ifndef AVAIL_MASM #ifndef AVAIL_MASM

View file

@ -2567,6 +2567,24 @@ void Cmd_Vstr_f( void )
Cbuf_InsertText(v, Cmd_ExecLevel, true); Cbuf_InsertText(v, Cmd_ExecLevel, true);
} }
void Cmd_toggle_f(void)
{
cvar_t *v;
if (Cmd_Argc()<2)
{
Con_Printf("missing cvar name\n");
return;
}
v = Cvar_Get(Cmd_Argv(1), "0", 0, "Custom variables");
if (!v)
return;
if (v->value)
Cvar_Set(v, "0");
else
Cvar_Set(v, "1");
}
void Cmd_set_f(void) void Cmd_set_f(void)
{ {
void *mark; void *mark;
@ -2798,30 +2816,19 @@ void Cmd_Condump_f(void)
// print out current contents of console // print out current contents of console
// stripping out starting blank lines and blank spaces // stripping out starting blank lines and blank spaces
{ {
conchar_t *text;
int row, line, x, spc, content;
console_t *curcon = &con_main; console_t *curcon = &con_main;
conline_t *l;
content = 0; int i;
row = curcon->current - curcon->totallines+1; conchar_t *t;
for (line = 0; line < curcon->totallines-1; line++, row++) for (l = curcon->oldest; l; l = l->newer)
{ {
text = curcon->text + (row % curcon->totallines)*curcon->linewidth; t = (conchar_t*)(l+1);
spc = 0; //FIXME: utf8?
for (x = 0; x < curcon->linewidth; x++) for (i = 0; i < l->length; i++)
{ {
if (((qbyte)text[x]&255) == ' ') c = (qbyte)t[i]&0xff;
spc++;
else
{
content = 1;
for (; spc > 0; spc--)
VFS_WRITE(f, " ", 1);
c = (qbyte)text[x]&255;
VFS_WRITE(f, &c, 1); VFS_WRITE(f, &c, 1);
} }
}
if (content)
VFS_WRITE(f, "\n", 1); VFS_WRITE(f, "\n", 1);
} }
} }
@ -2875,6 +2882,7 @@ void Cmd_Init (void)
// Cmd_AddCommand ("msg_trigger", Cmd_Msg_Trigger_f); // Cmd_AddCommand ("msg_trigger", Cmd_Msg_Trigger_f);
// Cmd_AddCommand ("filter", Cmd_Msg_Filter_f); // Cmd_AddCommand ("filter", Cmd_Msg_Filter_f);
Cmd_AddCommand ("toggle", Cmd_toggle_f);
Cmd_AddCommand ("set", Cmd_set_f); Cmd_AddCommand ("set", Cmd_set_f);
Cmd_AddCommand ("set_calc", Cmd_set_f); Cmd_AddCommand ("set_calc", Cmd_set_f);
Cmd_AddCommand ("seta", Cmd_set_f); Cmd_AddCommand ("seta", Cmd_set_f);

View file

@ -1746,8 +1746,19 @@ void COM_DeFunString(conchar_t *str, char *out, int outsize, qboolean ignoreflag
} }
} }
//Takes a q3-style fun string, and returns an expanded string-with-flags static int dehex(int i)
void COM_ParseFunString(conchar_t defaultflags, char *str, conchar_t *out, int outsize) {
if (i >= '0' && i <= '9')
return (i-'0');
else if (i >= 'A' && i <= 'F')
return (i-'A'+10);
else
return (i-'a'+10);
}
//Takes a q3-style fun string, and returns an expanded string-with-flags (actual return value is the null terminator)
//outsize parameter is in _BYTES_ (so sizeof is safe).
conchar_t *COM_ParseFunString(conchar_t defaultflags, char *str, conchar_t *out, int outsize, qboolean keepmarkup)
{ {
conchar_t extstack[4]; conchar_t extstack[4];
int extstackdepth = 0; int extstackdepth = 0;
@ -1756,17 +1767,25 @@ void COM_ParseFunString(conchar_t defaultflags, char *str, conchar_t *out, int o
conchar_t ext; conchar_t ext;
outsize /= sizeof(conchar_t);
if (!outsize)
return out;
//then outsize is decremented then checked before each write, so the trailing null has space
#if 0 #if 0
while(*str) while(*str)
{ {
*out++ = CON_WHITEMASK|(unsigned char)*str++; *out++ = CON_WHITEMASK|(unsigned char)*str++;
} }
*out = 0; *out = 0;
return; return out;
#endif #endif
if (*str == 1 || *str == 2) if (*str == 1 || *str == 2)
{ {
if (com_parseutf8.value)
defaultflags = (defaultflags&~CON_FGMASK) | (COLOR_MAGENTA<<CON_FGSHIFT);
else
defaultflags |= CON_HIGHCHARSMASK; defaultflags |= CON_HIGHCHARSMASK;
str++; str++;
} }
@ -1870,104 +1889,128 @@ void COM_ParseFunString(conchar_t defaultflags, char *str, conchar_t *out, int o
} }
if (*str == '^') if (*str == '^')
{ {
str++; if (str[1] >= '0' && str[1] <= '9')
if (*str >= '0' && *str <= '9')
{ {
ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only. ext = q3codemasks[str[1]-'0'] | (ext&~CON_Q3MASK); //change colour only.
}
else if (str[1] == '&') // extended code
{
if (isextendedcode(str[2]) && isextendedcode(str[3]))
{
// foreground char
if (str[2] == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (str[2] >= 'A')
ext = ((str[2] - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((str[2] - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
// background char
if (str[3] == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (str[3] >= 'A')
ext = ((str[3] - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((str[3] - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
if (!keepmarkup)
{
str += 4;
continue; continue;
} }
else if (*str == '&') // extended code
{
if (isextendedcode(str[1]) && isextendedcode(str[2]))
{
str++;// foreground char
if (*str == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((*str - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
str++; // background char
if (*str == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((*str - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
str++;
continue;
} }
// else invalid code // else invalid code
goto messedup; goto messedup;
} }
else if (*str == 'a') else if (str[1] == 'a')
{ {
str++;
ext ^= CON_2NDCHARSETTEXT; ext ^= CON_2NDCHARSETTEXT;
continue;
} }
else if (*str == 'b') else if (str[1] == 'b')
{ {
str++;
ext ^= CON_BLINKTEXT; ext ^= CON_BLINKTEXT;
continue;
} }
else if (*str == 'd') else if (str[1] == 'd')
{ {
str++;
ext = defaultflags; ext = defaultflags;
continue;
} }
else if (*str == 'm') else if (str[1] == 'm')
{ {
str++; if (com_parseutf8.value)
{
if ((ext & CON_FGMASK) != (COLOR_MAGENTA<<CON_FGSHIFT))
ext = (ext&~CON_FGMASK) | (COLOR_MAGENTA<<CON_FGSHIFT);
else
ext = (ext&~CON_FGMASK) | (CON_WHITEMASK);
}
else
ext ^= CON_HIGHCHARSMASK; ext ^= CON_HIGHCHARSMASK;
continue;
} }
else if (*str == 'h') else if (str[1] == 'h')
{ {
str++;
ext ^= CON_HALFALPHA; ext ^= CON_HALFALPHA;
continue;
} }
else if (*str == 's') //store on stack (it's great for names) else if (str[1] == 's') //store on stack (it's great for names)
{ {
str++;
if (extstackdepth < sizeof(extstack)/sizeof(extstack[0])) if (extstackdepth < sizeof(extstack)/sizeof(extstack[0]))
{ {
extstack[extstackdepth] = ext; extstack[extstackdepth] = ext;
extstackdepth++; extstackdepth++;
} }
continue;
} }
else if (*str == 'r') //restore from stack (it's great for names) else if (str[1] == 'r') //restore from stack (it's great for names)
{ {
str++;
if (extstackdepth) if (extstackdepth)
{ {
extstackdepth--; extstackdepth--;
ext = extstack[extstackdepth]; ext = extstack[extstackdepth];
} }
}
else if (str[1] == 'U') //restore from stack (it's great for names)
{
if (!keepmarkup)
{
uc = 0;
uc |= dehex(str[2])<<12;
uc |= dehex(str[3])<<8;
uc |= dehex(str[4])<<4;
uc |= dehex(str[5])<<0;
if (!--outsize)
break;
*out++ = uc | (ext&~CON_HIGHCHARSMASK);
str += 6;
continue; continue;
} }
else if (*str == '^') }
else if (str[1] == '^')
{
if (keepmarkup)
{ {
if (!--outsize) if (!--outsize)
break; break;
*out++ = '^' | ext; if (com_parseutf8.value)
*out++ = (unsigned char)(*str) | ext;
else
*out++ = (unsigned char)(*str) | ext | 0xe000;
}
str++; str++;
if (*str)
goto messedup;
continue;
} }
else else
{ {
if (!--outsize) goto messedup;
break;
*out++ = '^' | ext;
if (!--outsize)
break;
*out++ = (unsigned char)(*str++) | ext;
} }
if (!keepmarkup)
{
str+=2;
continue; continue;
} }
}
if (*str == '&' && str[1] == 'c') if (*str == '&' && str[1] == 'c')
{ {
// ezQuake color codes // ezQuake color codes
@ -2012,16 +2055,28 @@ void COM_ParseFunString(conchar_t defaultflags, char *str, conchar_t *out, int o
} }
ext = (best << CON_FGSHIFT) | (ext&~CON_FGMASK); ext = (best << CON_FGSHIFT) | (ext&~CON_FGMASK);
if (!keepmarkup)
{
str += 5; str += 5;
continue; continue;
} }
} }
}
messedup: messedup:
if (!--outsize) if (!--outsize)
break; break;
if (utf8)
*out++ = (unsigned char)(*str++) | ext; *out++ = (unsigned char)(*str++) | ext;
else
{
if (strchr("\n\r ", *str))
*out++ = (unsigned char)(*str++) | (ext&~CON_HIGHCHARSMASK);
else
*out++ = (unsigned char)(*str++) | ext | 0xe000;
}
} }
*out = 0; *out = 0;
return out;
} }
int COM_FunStringLength(unsigned char *str) int COM_FunStringLength(unsigned char *str)

View file

@ -258,7 +258,7 @@ void COM_ParsePlusSets (void);
typedef unsigned int conchar_t; typedef unsigned int conchar_t;
void COM_DeFunString(conchar_t *str, char *out, int outsize, qboolean ignoreflags); void COM_DeFunString(conchar_t *str, char *out, int outsize, qboolean ignoreflags);
void COM_ParseFunString(conchar_t ext, char *str, conchar_t *out, int outsize); //ext is usually CON_WHITEMASK conchar_t *COM_ParseFunString(conchar_t defaultflags, char *str, conchar_t *out, int outsize, qboolean keepmarkup); //ext is usually CON_WHITEMASK, returns its null terminator
int COM_FunStringLength(unsigned char *str); int COM_FunStringLength(unsigned char *str);
char *COM_SkipPath (const char *pathname); char *COM_SkipPath (const char *pathname);

View file

@ -87,16 +87,22 @@ extern conchar_t q3codemasks[MAXQ3COLOURS];
#define isextendedcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || x == '-') #define isextendedcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || x == '-')
#define ishexcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || (x >= 'a' && x <= 'f')) #define ishexcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || (x >= 'a' && x <= 'f'))
typedef struct conline_s {
struct conline_s *older;
unsigned int length;
struct conline_s *newer;
} conline_t;
typedef struct console_s typedef struct console_s
{ {
char name[64]; char name[64];
conchar_t text[CON_TEXTSIZE]; int linecount;
int current; // line where next message will be printed conline_t *oldest;
conline_t *current; // line where next message will be printed
int x; // offset in current line for next print int x; // offset in current line for next print
int display; // bottom of console displays this line conline_t *display; // bottom of console displays this line
int linewidth; int vislines; // pixel lines
int totallines; int linesprinted; // for notify times
int vislines;
qboolean unseentext; qboolean unseentext;
int commandcompletion; //allows tab completion of quake console commands int commandcompletion; //allows tab completion of quake console commands
void (*linebuffered) (struct console_s *con, char *line); //if present, called on enter, causes the standard console input to appear. void (*linebuffered) (struct console_s *con, char *line); //if present, called on enter, causes the standard console input to appear.

View file

@ -2768,6 +2768,11 @@ qboolean CModQ3_LoadRFaces (lump_t *l, qboolean useshaders)
out->mesh = Hunk_Alloc(sizeof(mesh_t) + (sizeof(vec3_t)) * numverts); out->mesh = Hunk_Alloc(sizeof(mesh_t) + (sizeof(vec3_t)) * numverts);
out->mesh->normals_array= map_normals_array + LittleLong(in->firstvertex); out->mesh->normals_array= map_normals_array + LittleLong(in->firstvertex);
#pragma message("s/t vectors not calculated for q3bsp")
out->mesh->snormals_array = out->mesh->normals_array;
out->mesh->tnormals_array = out->mesh->normals_array;
out->mesh->colors_array = map_colors_array + LittleLong(in->firstvertex); out->mesh->colors_array = map_colors_array + LittleLong(in->firstvertex);
out->mesh->indexes = map_surfindexes + LittleLong(in->firstindex); out->mesh->indexes = map_surfindexes + LittleLong(in->firstindex);
out->mesh->xyz_array = map_verts + LittleLong(in->firstvertex); out->mesh->xyz_array = map_verts + LittleLong(in->firstvertex);

View file

@ -373,7 +373,7 @@ void VectorAngles(float *forward, float *up, float *result) //up may be NULL
result[2] = roll; result[2] = roll;
} }
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{ {
float angle; float angle;
float sr, sp, sy, cr, cp, cy; float sr, sp, sy, cr, cp, cy;
@ -419,7 +419,7 @@ int VectorCompare (vec3_t v1, vec3_t v2)
return 1; return 1;
} }
void VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc) void _VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc)
{ {
vecc[0] = veca[0] + scale*vecb[0]; vecc[0] = veca[0] + scale*vecb[0];
vecc[1] = veca[1] + scale*vecb[1]; vecc[1] = veca[1] + scale*vecb[1];
@ -1027,7 +1027,47 @@ void Matrix4_Identity(float *outm)
outm[15] = 1; outm[15] = 1;
} }
void Matrix4_Projection(float *proj, float wdivh, float fovy, float neard) void Matrix4_Projection_Far(float *proj, float fovx, float fovy, float neard, float fard)
{
double xmin, xmax, ymin, ymax;
//proj
ymax = neard * tan( fovy * M_PI / 360.0 );
ymin = -ymax;
if (fovx == fovy)
{
xmax = ymax;
xmin = ymin;
}
else
{
xmax = neard * tan( fovx * M_PI / 360.0 );
xmin = -xmax;
}
proj[0] = (2*neard) / (xmax - xmin);
proj[4] = 0;
proj[8] = (xmax + xmin) / (xmax - xmin);
proj[12] = 0;
proj[1] = 0;
proj[5] = (2*neard) / (ymax - ymin);
proj[9] = (ymax + ymin) / (ymax - ymin);
proj[13] = 0;
proj[2] = 0;
proj[6] = 0;
proj[10] = (fard+neard)/(neard-fard);
proj[14] = (2*fard*neard)/(neard-fard);
proj[3] = 0;
proj[7] = 0;
proj[11] = -1;
proj[15] = 0;
}
void Matrix4_Projection_Inf(float *proj, float fovx, float fovy, float neard)
{ {
float xmin, xmax, ymin, ymax; float xmin, xmax, ymin, ymax;
float nudge = 1; float nudge = 1;
@ -1036,8 +1076,16 @@ void Matrix4_Projection(float *proj, float wdivh, float fovy, float neard)
ymax = neard * tan( fovy * M_PI / 360.0 ); ymax = neard * tan( fovy * M_PI / 360.0 );
ymin = -ymax; ymin = -ymax;
xmin = ymin * wdivh; if (fovx == fovy)
xmax = ymax * wdivh; {
xmax = ymax;
xmin = ymin;
}
else
{
xmax = neard * tan( fovx * M_PI / 360.0 );
xmin = -xmax;
}
proj[0] = (2*neard) / (xmax - xmin); proj[0] = (2*neard) / (xmax - xmin);
proj[4] = 0; proj[4] = 0;
@ -1297,6 +1345,18 @@ qboolean Matrix4_Invert(const float *m, float *out)
void Matrix3x4_InvertTo3x3(float *in, float *result) void Matrix3x4_InvertTo3x3(float *in, float *result)
{ {
float t1[16], tr[16];
memcpy(t1, in, sizeof(float)*12);
t1[12] = 0;
t1[13] = 0;
t1[14] = 0;
t1[15] = 1;
Matrix4_Invert(t1, tr);
VectorCopy(tr+0, result+0);
VectorCopy(tr+4, result+3);
VectorCopy(tr+8, result+6);
return;
/*
#define A(x,y) in[x+y*4] #define A(x,y) in[x+y*4]
#define result(x,y) result[x+y*3] #define result(x,y) result[x+y*3]
double determinant = +A(0,0)*(A(1,1)*A(2,2)-A(2,1)*A(1,2)) double determinant = +A(0,0)*(A(1,1)*A(2,2)-A(2,1)*A(1,2))
@ -1312,18 +1372,19 @@ void Matrix3x4_InvertTo3x3(float *in, float *result)
result(0,2) = (A(1,0)*A(2,1)-A(2,0)*A(1,1))*invdet; result(0,2) = (A(1,0)*A(2,1)-A(2,0)*A(1,1))*invdet;
result(1,2) = -(A(0,0)*A(2,1)-A(2,0)*A(0,1))*invdet; result(1,2) = -(A(0,0)*A(2,1)-A(2,0)*A(0,1))*invdet;
result(2,2) = (A(0,0)*A(1,1)-A(1,0)*A(0,1))*invdet; result(2,2) = (A(0,0)*A(1,1)-A(1,0)*A(0,1))*invdet;
*/
} }
//screen->3d //screen->3d
void Matrix4_UnProject(vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float wdivh, float fovy) void Matrix4_UnProject(vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float fovx, float fovy)
{ {
float modelview[16]; float modelview[16];
float proj[16]; float proj[16];
float tempm[16]; float tempm[16];
Matrix4_ModelViewMatrix(modelview, viewangles, vieworg); Matrix4_ModelViewMatrix(modelview, viewangles, vieworg);
Matrix4_Projection(proj, wdivh, fovy, 4); Matrix4_Projection_Inf(proj, fovx, fovy, 4);
Matrix4_Multiply(proj, modelview, tempm); Matrix4_Multiply(proj, modelview, tempm);
Matrix4_Invert(tempm, proj); Matrix4_Invert(tempm, proj);
@ -1346,13 +1407,13 @@ void Matrix4_UnProject(vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg,
//returns fractions of screen. //returns fractions of screen.
//uses GL style rotations and translations and stuff. //uses GL style rotations and translations and stuff.
//3d -> screen (fixme: offscreen return values needed) //3d -> screen (fixme: offscreen return values needed)
void Matrix4_Project (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float wdivh, float fovy) void Matrix4_Project (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float fovx, float fovy)
{ {
float modelview[16]; float modelview[16];
float proj[16]; float proj[16];
Matrix4_ModelViewMatrix(modelview, viewangles, vieworg); Matrix4_ModelViewMatrix(modelview, viewangles, vieworg);
Matrix4_Projection(proj, wdivh, fovy, 4); Matrix4_Projection_Inf(proj, fovx, fovy, 4);
{ {
float v[4], tempv[4]; float v[4], tempv[4];

View file

@ -51,6 +51,7 @@ extern int nanmask;
#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) #define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) #define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
#define VectorLength(a) Length(a) #define VectorLength(a) Length(a)
#define VectorMA(a,s,b,c) do{c[0] = a[0] + s*b[0];c[1] = a[1] + s*b[1];c[2] = a[2] + s*b[2];}while(0)
@ -86,7 +87,7 @@ void _VectorCopy (vec3_t in, vec3_t out);
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs); void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
float anglemod (float a); float anglemod (float a);
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void VectorAngles (float *forward, float *up, float *angles); //up may be NULL void VectorAngles (float *forward, float *up, float *angles); //up may be NULL
void VARGS BOPS_Error (void); void VARGS BOPS_Error (void);
int VARGS BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); int VARGS BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
@ -109,12 +110,19 @@ void Matrix4_ModelMatrixFromAxis (float *modelview, vec3_t pn, vec3_t right, ve
void Matrix4_ModelViewMatrix (float *modelview, vec3_t viewangles, vec3_t vieworg); void Matrix4_ModelViewMatrix (float *modelview, vec3_t viewangles, vec3_t vieworg);
void Matrix4_ModelViewMatrixFromAxis (float *modelview, vec3_t pn, vec3_t right, vec3_t up, vec3_t vieworg); void Matrix4_ModelViewMatrixFromAxis (float *modelview, vec3_t pn, vec3_t right, vec3_t up, vec3_t vieworg);
void Matrix4_Multiply (float *a, float *b, float *out); void Matrix4_Multiply (float *a, float *b, float *out);
void Matrix4_Orthographic (float *proj, float xmin, float xmax, float ymax, float ymin, float znear, float zfar); void Matrix4_Project (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float fovx, float fovy);
void Matrix4_Project (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float wdivh, float fovy);
void Matrix4_Projection2 (float *proj, float fovx, float fovy, float neard);
void Matrix4_Transform3 (float *matrix, float *vector, float *product); void Matrix4_Transform3 (float *matrix, float *vector, float *product);
void Matrix4_Transform4 (float *matrix, float *vector, float *product); void Matrix4_Transform4 (float *matrix, float *vector, float *product);
void Matrix4_UnProject (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float wdivh, float fovy); void Matrix4_UnProject (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float fovx, float fovy);
//projection matricies of different types... gesh
void Matrix4_Orthographic (float *proj, float xmin, float xmax, float ymax, float ymin, float znear, float zfar);
void Matrix4_Projection_Far(float *proj, float fovx, float fovy, float neard, float fard);
void Matrix4_Projection2 (float *proj, float fovx, float fovy, float neard);
void Matrix4_Projection_Inf(float *proj, float fovx, float fovy, float neard);
fixed16_t Mul16_30 (fixed16_t multiplier, fixed16_t multiplicand);
int Q_log2 (int val);
void Matrix3x4_InvertTo3x3(float *in, float *result); void Matrix3x4_InvertTo3x3(float *in, float *result);
@ -126,7 +134,7 @@ void R_ConcatTransforms (matrix3x4 in1, matrix3x4 in2, matrix3x4 out);
void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees); void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees);
int VectorCompare (vec3_t v1, vec3_t v2); int VectorCompare (vec3_t v1, vec3_t v2);
void VectorInverse (vec3_t v); void VectorInverse (vec3_t v);
void VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc); void _VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc);
float VectorNormalize (vec3_t v); // returns vector length float VectorNormalize (vec3_t v); // returns vector length
vec_t VectorNormalize2 (vec3_t v, vec3_t out); vec_t VectorNormalize2 (vec3_t v, vec3_t out);
void VectorNormalizeFast(vec3_t v); void VectorNormalizeFast(vec3_t v);

View file

@ -83,7 +83,7 @@ void NET_SendPacket (netsrc_t socket, int length, void *data, netadr_t to);
int NET_LocalAddressForRemote(struct ftenet_connections_s *collection, netadr_t *remote, netadr_t *local, int idx); int NET_LocalAddressForRemote(struct ftenet_connections_s *collection, netadr_t *remote, netadr_t *local, int idx);
void NET_PrintAddresses(struct ftenet_connections_s *collection); void NET_PrintAddresses(struct ftenet_connections_s *collection);
qboolean NET_AddressSmellsFunny(netadr_t a); qboolean NET_AddressSmellsFunny(netadr_t a);
void NET_EnsureRoute(struct ftenet_connections_s *collection, char *routename, char *host); void NET_EnsureRoute(struct ftenet_connections_s *collection, char *routename, char *host, qboolean islisten);
qboolean NET_CompareAdr (netadr_t a, netadr_t b); qboolean NET_CompareAdr (netadr_t a, netadr_t b);
qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b); qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);

View file

@ -1333,7 +1333,7 @@ ftenet_connections_t *FTENET_CreateCollection(qboolean listen)
return col; return col;
} }
qboolean FTENET_AddToCollection(ftenet_connections_t *col, const char *name, const char *address, ftenet_generic_connection_t *(*establish)(qboolean isserver, const char *address)) qboolean FTENET_AddToCollection(ftenet_connections_t *col, const char *name, const char *address, ftenet_generic_connection_t *(*establish)(qboolean isserver, const char *address), qboolean islisten)
{ {
int i; int i;
if (!col) if (!col)
@ -1369,7 +1369,7 @@ qboolean FTENET_AddToCollection(ftenet_connections_t *col, const char *name, con
{ {
if (!col->conn[i]) if (!col->conn[i])
{ {
col->conn[i] = establish(col->islisten, address); col->conn[i] = establish(islisten, address);
if (!col->conn[i]) if (!col->conn[i])
return false; return false;
col->conn[i]->name = name; col->conn[i]->name = name;
@ -1994,27 +1994,18 @@ ftenet_generic_connection_t *FTENET_TCPConnect_EstablishConnection(int affamily,
closesocket(newsocket); closesocket(newsocket);
return NULL; return NULL;
} }
}
else
{
if (!NET_StringToAdr(address, &adr))
return NULL; //couldn't resolve the name
temp = NetadrToSockadr(&adr, &qs);
family = ((struct sockaddr_in*)&qs)->sin_family;
if ((newsocket = socket (family, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)
return NULL;
if (connect(newsocket, (struct sockaddr *)&qs, temp) == INVALID_SOCKET)
{
closesocket(newsocket);
return NULL;
}
}
if (ioctlsocket (newsocket, FIONBIO, &_true) == -1) if (ioctlsocket (newsocket, FIONBIO, &_true) == -1)
Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror(qerrno)); Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror(qerrno));
}
else
{
if (!NET_PortToAdr(affamily, address, &adr))
return NULL; //couldn't resolve the name
newsocket = TCP_OpenStream(adr);
if (newsocket == INVALID_SOCKET)
return NULL;
}
//this isn't fatal //this isn't fatal
setsockopt(newsocket, IPPROTO_TCP, TCP_NODELAY, (char *)&_true, sizeof(_true)); setsockopt(newsocket, IPPROTO_TCP, TCP_NODELAY, (char *)&_true, sizeof(_true));
@ -2639,7 +2630,7 @@ ftenet_generic_connection_t *FTENET_IRCConnect_EstablishConnection(qboolean isse
newcon->generic.SendPacket = FTENET_IRCConnect_SendPacket; newcon->generic.SendPacket = FTENET_IRCConnect_SendPacket;
newcon->generic.Close = FTENET_IRCConnect_Close; newcon->generic.Close = FTENET_IRCConnect_Close;
newcon->generic.islisten = true; newcon->generic.islisten = isserver;
newcon->generic.addrtype[0] = NA_IRC; newcon->generic.addrtype[0] = NA_IRC;
newcon->generic.addrtype[1] = NA_INVALID; newcon->generic.addrtype[1] = NA_INVALID;
@ -2758,7 +2749,7 @@ void NET_SendPacket (netsrc_t netsrc, int length, void *data, netadr_t to)
Con_Printf("No route - open some ports\n"); Con_Printf("No route - open some ports\n");
} }
void NET_EnsureRoute(ftenet_connections_t *collection, char *routename, char *host) void NET_EnsureRoute(ftenet_connections_t *collection, char *routename, char *host, qboolean islisten)
{ {
netadr_t adr; netadr_t adr;
NET_StringToAdr(host, &adr); NET_StringToAdr(host, &adr);
@ -2767,17 +2758,17 @@ void NET_EnsureRoute(ftenet_connections_t *collection, char *routename, char *ho
{ {
#ifdef TCPCONNECT #ifdef TCPCONNECT
case NA_TCP: case NA_TCP:
FTENET_AddToCollection(collection, routename, host, FTENET_TCP4Connect_EstablishConnection); FTENET_AddToCollection(collection, routename, host, FTENET_TCP4Connect_EstablishConnection, islisten);
break; break;
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
case NA_TCPV6: case NA_TCPV6:
FTENET_AddToCollection(collection, routename, host, FTENET_TCP6Connect_EstablishConnection); FTENET_AddToCollection(collection, routename, host, FTENET_TCP6Connect_EstablishConnection, islisten);
break; break;
#endif #endif
#endif #endif
#ifdef IRCCONNECT #ifdef IRCCONNECT
case NA_IRC: case NA_IRC:
FTENET_AddToCollection(collection, routename, host, FTENET_IRCConnect_EstablishConnection); FTENET_AddToCollection(collection, routename, host, FTENET_IRCConnect_EstablishConnection, islisten);
break; break;
#endif #endif
default: default:
@ -3185,7 +3176,7 @@ void SVNET_AddPort(void)
{ {
svs.sockets = FTENET_CreateCollection(true); svs.sockets = FTENET_CreateCollection(true);
#ifndef SERVERONLY #ifndef SERVERONLY
FTENET_AddToCollection(svs.sockets, "SVLoopback", "27500", FTENET_Loop_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVLoopback", "27500", FTENET_Loop_EstablishConnection, true);
#endif #endif
} }
@ -3194,30 +3185,30 @@ void SVNET_AddPort(void)
switch(adr.type) switch(adr.type)
{ {
case NA_IP: case NA_IP:
FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_UDP4_EstablishConnection); FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_UDP4_EstablishConnection, true);
break; break;
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
case NA_IPV6: case NA_IPV6:
FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_UDP6_EstablishConnection); FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_UDP6_EstablishConnection, true);
break; break;
#endif #endif
#ifdef USEIPX #ifdef USEIPX
case NA_IPX: case NA_IPX:
FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_IPX_EstablishConnection); FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_IPX_EstablishConnection, true);
break; break;
#endif #endif
#ifdef IRCCONNECT #ifdef IRCCONNECT
case NA_IRC: case NA_IRC:
FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_IRCConnect_EstablishConnection); FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_IRCConnect_EstablishConnection, true);
break; break;
#endif #endif
#ifdef IRCCONNECT #ifdef IRCCONNECT
case NA_TCP: case NA_TCP:
FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_TCP4Connect_EstablishConnection); FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_TCP4Connect_EstablishConnection, true);
break; break;
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
case NA_TCPV6: case NA_TCPV6:
FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_TCP6Connect_EstablishConnection); FTENET_AddToCollection(svs.sockets, NULL, s, FTENET_TCP6Connect_EstablishConnection, true);
break; break;
#endif #endif
#endif #endif
@ -3285,14 +3276,14 @@ void NET_InitClient(void)
cls.sockets = FTENET_CreateCollection(false); cls.sockets = FTENET_CreateCollection(false);
#ifndef CLIENTONLY #ifndef CLIENTONLY
FTENET_AddToCollection(cls.sockets, "CLLoopback", port, FTENET_Loop_EstablishConnection); FTENET_AddToCollection(cls.sockets, "CLLoopback", port, FTENET_Loop_EstablishConnection, false);
#endif #endif
FTENET_AddToCollection(cls.sockets, "CLUDP4", port, FTENET_UDP4_EstablishConnection); FTENET_AddToCollection(cls.sockets, "CLUDP4", port, FTENET_UDP4_EstablishConnection, true);
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
FTENET_AddToCollection(cls.sockets, "CLUDP6", port, FTENET_UDP6_EstablishConnection); FTENET_AddToCollection(cls.sockets, "CLUDP6", port, FTENET_UDP6_EstablishConnection, true);
#endif #endif
#ifdef USEIPX #ifdef USEIPX
FTENET_AddToCollection(cls.sockets, "CLIPX", port, FTENET_IPX_EstablishConnection); FTENET_AddToCollection(cls.sockets, "CLIPX", port, FTENET_IPX_EstablishConnection, true);
#endif #endif
// //
@ -3316,29 +3307,29 @@ void NET_InitClient(void)
#ifndef CLIENTONLY #ifndef CLIENTONLY
void SV_Tcpport_Callback(struct cvar_s *var, char *oldvalue) void SV_Tcpport_Callback(struct cvar_s *var, char *oldvalue)
{ {
FTENET_AddToCollection(svs.sockets, "SVTCP4", var->string, FTENET_TCP4Connect_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVTCP4", var->string, FTENET_TCP4Connect_EstablishConnection, true);
} }
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
void SV_Tcpport6_Callback(struct cvar_s *var, char *oldvalue) void SV_Tcpport6_Callback(struct cvar_s *var, char *oldvalue)
{ {
FTENET_AddToCollection(svs.sockets, "SVTCP6", var->string, FTENET_TCP6Connect_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVTCP6", var->string, FTENET_TCP6Connect_EstablishConnection, true);
} }
#endif #endif
void SV_Port_Callback(struct cvar_s *var, char *oldvalue) void SV_Port_Callback(struct cvar_s *var, char *oldvalue)
{ {
FTENET_AddToCollection(svs.sockets, "SVUDP4", var->string, FTENET_UDP4_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVUDP4", var->string, FTENET_UDP4_EstablishConnection, true);
} }
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
void SV_PortIPv6_Callback(struct cvar_s *var, char *oldvalue) void SV_PortIPv6_Callback(struct cvar_s *var, char *oldvalue)
{ {
FTENET_AddToCollection(svs.sockets, "SVUDP6", var->string, FTENET_UDP6_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVUDP6", var->string, FTENET_UDP6_EstablishConnection, true);
} }
#endif #endif
#ifdef USEIPX #ifdef USEIPX
void SV_PortIPX_Callback(struct cvar_s *var, char *oldvalue) void SV_PortIPX_Callback(struct cvar_s *var, char *oldvalue)
{ {
FTENET_AddToCollection(svs.sockets, "SVIPX", var->string, FTENET_IPX_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVIPX", var->string, FTENET_IPX_EstablishConnection, true);
} }
#endif #endif
#endif #endif
@ -3360,7 +3351,7 @@ void NET_InitServer(void)
{ {
svs.sockets = FTENET_CreateCollection(true); svs.sockets = FTENET_CreateCollection(true);
#ifndef SERVERONLY #ifndef SERVERONLY
FTENET_AddToCollection(svs.sockets, "SVLoopback", port, FTENET_Loop_EstablishConnection); FTENET_AddToCollection(svs.sockets, "SVLoopback", port, FTENET_Loop_EstablishConnection, true);
#endif #endif
} }

View file

@ -1530,7 +1530,7 @@ void PF_strdecolorize (progfuncs_t *prinst, struct globalvars_s *pr_globals)
char *in = PR_GetStringOfs(prinst, OFS_PARM0); char *in = PR_GetStringOfs(prinst, OFS_PARM0);
char result[8192]; char result[8192];
unsigned long flagged[8192]; unsigned long flagged[8192];
COM_ParseFunString(CON_WHITEMASK, in, flagged, sizeof(flagged)/sizeof(flagged[0])); COM_ParseFunString(CON_WHITEMASK, in, flagged, sizeof(flagged), false);
COM_DeFunString(flagged, result, sizeof(result), true); COM_DeFunString(flagged, result, sizeof(result), true);
RETURN_TSTRING(result); RETURN_TSTRING(result);
@ -1796,14 +1796,70 @@ void PF_crc16 (progfuncs_t *prinst, struct globalvars_s *pr_globals)
// #510 string(string in) uri_escape = #510; // #510 string(string in) uri_escape = #510;
void PF_uri_escape (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_uri_escape (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
char *s = PR_GetStringOfs(prinst, OFS_PARM0); static const char *hex = "0123456789ABCDEF";
RETURN_TSTRING(s);
unsigned char result[8192];
unsigned char *o = result;
unsigned char *s = PR_GetStringOfs(prinst, OFS_PARM0);
*result = 0;
while (*s && o < result+sizeof(result)-4)
{
if ((*s >= 'a' && *s <= 'z') || (*s >= 'A' && *s <= 'Z') || (*s >= '0' && *s <= '9')
|| *s == '.' || *s == '-' || *s == '_')
*o++ = *s++;
else
{
*o++ = '%';
*o++ = hex[*s>>4];
*o++ = hex[*s&0xf];
s++;
}
}
*o = 0;
RETURN_TSTRING(result);
} }
// #511 string(string in) uri_unescape = #511; // #511 string(string in) uri_unescape = #511;
void PF_uri_unescape (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_uri_unescape (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
char *s = PR_GetStringOfs(prinst, OFS_PARM0); unsigned char *s = (unsigned char*)PR_GetStringOfs(prinst, OFS_PARM0);
unsigned char *i, *o;
unsigned char hex;
i = s; o = s;
while (*i)
{
if (*i == '%')
{
hex = 0;
if (i[1] >= 'A' && i[1] <= 'F')
hex += i[1]-'A'+10;
else if (i[1] >= 'a' && i[1] <= 'f')
hex += i[1]-'a'+10;
else if (i[1] >= '0' && i[1] <= '9')
hex += i[1]-'0';
else
{
*o++ = *i++;
continue;
}
hex <<= 4;
if (i[2] >= 'A' && i[2] <= 'F')
hex += i[2]-'A'+10;
else if (i[2] >= 'a' && i[2] <= 'f')
hex += i[2]-'a'+10;
else if (i[2] >= '0' && i[2] <= '9')
hex += i[2]-'0';
else
{
*o++ = *i++;
continue;
}
*o++ = hex;
i += 3;
}
*o++ = *i++;
}
*o = 0;
RETURN_TSTRING(s); RETURN_TSTRING(s);
} }

View file

@ -230,7 +230,7 @@ static char *defaultlanguagetext =
"TLC_HOSTFATALERROR \"Host_Error: %s\\n\"\n" "TLC_HOSTFATALERROR \"Host_Error: %s\\n\"\n"
"TLC_CONFIGCFG_WRITEFAILED \"Couldn't write config.cfg.\\n\"\n" "TLC_CONFIGCFG_WRITEFAILED \"Couldn't write config.cfg.\\n\"\n"
"TLC_HOSTSPEEDSOUTPUT \"%3i tot %3i server %3i gfx %3i snd\\n\"\n" "TLC_HOSTSPEEDSOUTPUT \"%3i tot %3i server %3i gfx %3i snd\\n\"\n"
"TLC_QUAKEWORLD_INITED \"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QuakeWorld Initialized <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\\n\"\n" "TLC_QUAKEWORLD_INITED \"^Ue080^Ue081^Ue081^Ue081^Ue081^Ue081^Ue081 QuakeWorld Initialized ^Ue081^Ue081^Ue081^Ue081^Ue081^Ue081^Ue082\\n\"\n"
"TLC_DEDICATEDCANNOTCONNECT \"Connect ignored - dedicated. set a renderer first\\n\"\n" "TLC_DEDICATEDCANNOTCONNECT \"Connect ignored - dedicated. set a renderer first\\n\"\n"
"TLC_Q2CONLESSPACKET_UNKNOWN \"unknown connectionless packet for q2: %s\\n\"\n" "TLC_Q2CONLESSPACKET_UNKNOWN \"unknown connectionless packet for q2: %s\\n\"\n"
"TL_NORELATIVEPATHS \"Refusing to download a path with ..\\n\"\n" "TL_NORELATIVEPATHS \"Refusing to download a path with ..\\n\"\n"

View file

@ -763,14 +763,14 @@ void (D3D7_Draw_ImageColours) (float r, float g, float b, float a)
c[3] = a*255; c[3] = a*255;
} }
void (D3D7_Draw_ConsoleBackground) (int lines) void (D3D7_Draw_ConsoleBackground) (int firstline, int lastline, qboolean forceopaque)
{ {
D3D7_Draw_ImageColours(1,1,1,1); D3D7_Draw_ImageColours(1,1,1,1);
D3D7_Draw_Image(0, 0, vid.width, lines, 0, 1 - (float)lines/vid.height, 1, 1, conback_tex); D3D7_Draw_Image(0, 0, vid.width, lastline, 0, 1 - (float)lastline/vid.height, 1, 1, conback_tex);
} }
void (D3D7_Draw_EditorBackground) (int lines) void (D3D7_Draw_EditorBackground) (int lines)
{ {
D3D7_Draw_ConsoleBackground(lines); D3D7_Draw_ConsoleBackground(0, lines, false);
} }

View file

@ -344,7 +344,7 @@ void D3D7_DrawTextureChains(void)
continue; continue;
t->texturechain = NULL; t->texturechain = NULL;
pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, (LPDIRECTDRAWSURFACE7)t->gl_texturenum); pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, (LPDIRECTDRAWSURFACE7)t->tn.base);
pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
@ -466,7 +466,7 @@ void D3D7_BaseBModelTextures(entity_t *e)
{ {
t = R_TextureAnimation(s->texinfo->texture); t = R_TextureAnimation(s->texinfo->texture);
pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, (LPDIRECTDRAWSURFACE7)t->gl_texturenum); pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, (LPDIRECTDRAWSURFACE7)t->tn.base);
pD3DDev->lpVtbl->SetTexture(pD3DDev, 1, (LPDIRECTDRAWSURFACE7)lightmap_d3dtextures[s->lightmaptexturenum]); pD3DDev->lpVtbl->SetTexture(pD3DDev, 1, (LPDIRECTDRAWSURFACE7)lightmap_d3dtextures[s->lightmaptexturenum]);
{ {
m = s->mesh; m = s->mesh;

View file

@ -303,13 +303,13 @@ static LRESULT WINAPI D3D7_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), true); IN_TranslateKeyEvent(wParam, lParam, true);
break; break;
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), false); IN_TranslateKeyEvent(wParam, lParam, false);
break; break;
case WM_SYSCHAR: case WM_SYSCHAR:
@ -372,13 +372,13 @@ static LRESULT WINAPI D3D7_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
if ((short) HIWORD(wParam) > 0) if ((short) HIWORD(wParam) > 0)
{ {
Key_Event(K_MWHEELUP, true); Key_Event(K_MWHEELUP, 0, true);
Key_Event(K_MWHEELUP, false); Key_Event(K_MWHEELUP, 0, false);
} }
else else
{ {
Key_Event(K_MWHEELDOWN, true); Key_Event(K_MWHEELDOWN, 0, true);
Key_Event(K_MWHEELDOWN, false); Key_Event(K_MWHEELDOWN, 0, false);
} }
} }
break; break;
@ -716,7 +716,7 @@ void (D3D7_Mod_NowLoadExternal) (void)
void (D3D7_Mod_Think) (void) void (D3D7_Mod_Think) (void)
{ {
} }
qboolean(D3D7_Mod_GetTag) (struct model_s *model, int tagnum, int frame1, int frame2, float f2ness, float f1time, float f2time, float *result) qboolean(D3D7_Mod_GetTag) (struct model_s *model, int tagnum, framestate_t *fstate, float *result)
{ {
return false; return false;
} }
@ -728,6 +728,10 @@ int (D3D7_Mod_SkinForName) (struct model_s *model, char *name)
{ {
return 0; return 0;
} }
int (D3D7_Mod_FrameForName) (struct model_s *model, char *name)
{
return 0;
}
void (D3D7_VID_DeInit) (void) void (D3D7_VID_DeInit) (void)
{ {
@ -1185,6 +1189,7 @@ rendererinfo_t d3d7rendererinfo =
D3D7_Mod_GetTag, D3D7_Mod_GetTag,
D3D7_Mod_TagNumForName, D3D7_Mod_TagNumForName,
D3D7_Mod_SkinForName, D3D7_Mod_SkinForName,
D3D7_Mod_FrameForName,
D3D7_VID_Init, D3D7_VID_Init,

View file

@ -803,14 +803,14 @@ void D3D9_Draw_ImageColours (float r, float g, float b, float a)
c[3] = a*255; c[3] = a*255;
} }
void D3D9_Draw_ConsoleBackground (int lines) void D3D9_Draw_ConsoleBackground (int firstline, int lastline, qboolean forceopaque)
{ {
D3D9_Draw_ImageColours(1,1,1,1); D3D9_Draw_ImageColours(1,1,1,1);
D3D9_Draw_Image(0, 0, vid.width, lines, 0, 1 - (float)lines/vid.height, 1, 1, conback_tex); D3D9_Draw_Image(0, 0, vid.width, lastline, 0, 1 - (float)lastline/vid.height, 1, 1, conback_tex);
} }
void D3D9_Draw_EditorBackground (int lines) void D3D9_Draw_EditorBackground (int lines)
{ {
D3D9_Draw_ConsoleBackground(lines); D3D9_Draw_ConsoleBackground(0, lines, false);
} }

View file

@ -600,12 +600,12 @@ void D3D9_DrawTextureChains(void)
if (s->flags & SURF_DRAWTURB) if (s->flags & SURF_DRAWTURB)
{ {
IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->gl_texturenum); IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->tn.base);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_TEXCOORDINDEX, 0); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_TEXCOORDINDEX, 0);
IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->gl_texturenum); IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->tn.base);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 1, D3DTSS_TEXCOORDINDEX, 1); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 1, D3DTSS_TEXCOORDINDEX, 1);
IDirect3DDevice9_SetTexture(pD3DDev9, 1, (void*)t->gl_texturenum); IDirect3DDevice9_SetTexture(pD3DDev9, 1, (void*)t->tn.base);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
@ -654,7 +654,7 @@ IDirect3DDevice9_SetTextureStageState(pD3DDev9, 1, D3DTSS_COLOROP, D3DTOP_MODULA
continue; continue;
} }
IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->gl_texturenum); IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->tn.base);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
@ -792,7 +792,7 @@ void D3D9_BaseBModelTextures(entity_t *e)
if (s->lightmaptexturenum < 0) if (s->lightmaptexturenum < 0)
continue; continue;
IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->gl_texturenum); IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)t->tn.base);
IDirect3DDevice9_SetTexture(pD3DDev9, 1, (void*)lightmap_d3d9textures[s->lightmaptexturenum]); IDirect3DDevice9_SetTexture(pD3DDev9, 1, (void*)lightmap_d3d9textures[s->lightmaptexturenum]);
{ {
m = s->mesh; m = s->mesh;

View file

@ -16,7 +16,7 @@ void D3D9_Draw_BeginDisc (void);
mpic_t* D3D9_Draw_CachePic (char *path); mpic_t* D3D9_Draw_CachePic (char *path);
void D3D9_Draw_Character (int x, int y, unsigned int num); void D3D9_Draw_Character (int x, int y, unsigned int num);
void D3D9_Draw_ColouredCharacter (int x, int y, unsigned int num); void D3D9_Draw_ColouredCharacter (int x, int y, unsigned int num);
void D3D9_Draw_ConsoleBackground (int lines); void D3D9_Draw_ConsoleBackground (int firstline, int lastline, qboolean forceopaque);
void D3D9_Draw_Crosshair (void); void D3D9_Draw_Crosshair (void);
void D3D9_Draw_DebugChar (qbyte num); void D3D9_Draw_DebugChar (qbyte num);
void D3D9_Draw_EditorBackground (int lines); void D3D9_Draw_EditorBackground (int lines);

View file

@ -310,13 +310,13 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), true); IN_TranslateKeyEvent (wParam, lParam, true);
break; break;
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), false); IN_TranslateKeyEvent (wParam, lParam, false);
break; break;
case WM_SYSCHAR: case WM_SYSCHAR:
@ -379,13 +379,13 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
if ((short) HIWORD(wParam) > 0) if ((short) HIWORD(wParam) > 0)
{ {
Key_Event(K_MWHEELUP, true); Key_Event(K_MWHEELUP, 0, true);
Key_Event(K_MWHEELUP, false); Key_Event(K_MWHEELUP, 0, false);
} }
else else
{ {
Key_Event(K_MWHEELDOWN, true); Key_Event(K_MWHEELDOWN, 0, true);
Key_Event(K_MWHEELDOWN, false); Key_Event(K_MWHEELDOWN, 0, false);
} }
} }
break; break;
@ -897,6 +897,10 @@ int (D3D9_Mod_SkinForName) (struct model_s *model, char *name)
{ {
return 0; return 0;
} }
int (D3D9_Mod_FrameForName) (struct model_s *model, char *name)
{
return 0;
}
void (D3D9_VID_DeInit) (void) void (D3D9_VID_DeInit) (void)
{ {
@ -1310,7 +1314,7 @@ void (D3D9_Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic);
void (D3D9_Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height); void (D3D9_Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height);
void (D3D9_Draw_TransPic) (int x, int y, mpic_t *pic); void (D3D9_Draw_TransPic) (int x, int y, mpic_t *pic);
void (D3D9_Draw_TransPicTranslate) (int x, int y, int w, int h, qbyte *pic, qbyte *translation); void (D3D9_Draw_TransPicTranslate) (int x, int y, int w, int h, qbyte *pic, qbyte *translation);
void (D3D9_Draw_ConsoleBackground) (int lines); void D3D9_Draw_ConsoleBackground (int firstline, int lastline, qboolean forceopaque);
void (D3D9_Draw_EditorBackground) (int lines); void (D3D9_Draw_EditorBackground) (int lines);
void (D3D9_Draw_TileClear) (int x, int y, int w, int h); void (D3D9_Draw_TileClear) (int x, int y, int w, int h);
void (D3D9_Draw_Fill) (int x, int y, int w, int h, unsigned int c); void (D3D9_Draw_Fill) (int x, int y, int w, int h, unsigned int c);
@ -1449,6 +1453,7 @@ rendererinfo_t d3d9rendererinfo =
Mod_GetTag, Mod_GetTag,
Mod_TagNumForName, Mod_TagNumForName,
D3D9_Mod_SkinForName, D3D9_Mod_SkinForName,
D3D9_Mod_FrameForName,
D3D9_VID_Init, D3D9_VID_Init,

View file

@ -1598,7 +1598,7 @@ qglColor3f(0,0,1);
} }
//returns result in the form of the result vector //returns result in the form of the result vector
void RotateLightVector(vec3_t *axis, vec3_t origin, vec3_t lightpoint, vec3_t result) void RotateLightVector(const vec3_t *axis, const vec3_t origin, const vec3_t lightpoint, vec3_t result)
{ {
vec3_t offs; vec3_t offs;

View file

@ -1277,6 +1277,10 @@ void R_ModifyTextureCoords ( shaderpass_t *pass, int unit )
{ {
qglTexCoordPointer(2, GL_FLOAT, 0, lightmapCoordsArray); qglTexCoordPointer(2, GL_FLOAT, 0, lightmapCoordsArray);
} }
else if (pass->tcgen == TC_GEN_NORMAL)
{
qglTexCoordPointer(3, GL_FLOAT, 0, normalsArray);
}
else else
{ {
qglTexCoordPointer(2, GL_FLOAT, 0, R_VertexTCBase(pass->tcgen, unit)); qglTexCoordPointer(2, GL_FLOAT, 0, R_VertexTCBase(pass->tcgen, unit));
@ -2080,7 +2084,20 @@ void R_RenderMeshProgram ( meshbuffer_t *mb, shaderpass_t *pass )
switch(s->progparm[i].type) switch(s->progparm[i].type)
{ {
case SP_EYEPOS: case SP_EYEPOS:
qglUniform3fvARB(s->progparm[i].handle, 1, r_origin); {
vec3_t t, v;
VectorSubtract(r_origin, currententity->origin, t);
if (!Matrix3_Compare(currententity->axis, axisDefault))
{
Matrix3_Multiply_Vec3(currententity->axis, t, v );
}
else
{
VectorCopy(t, v);
}
qglUniform3fvARB(s->progparm[i].handle, 1, v);
}
break; break;
case SP_TIME: case SP_TIME:
qglUniform1fARB(s->progparm[i].handle, r_localShaderTime); qglUniform1fARB(s->progparm[i].handle, r_localShaderTime);

View file

@ -47,6 +47,10 @@ index_t r_quad_indexes[6] = {0, 1, 2, 0, 2, 3};
extern qbyte gammatable[256]; extern qbyte gammatable[256];
#ifdef AVAIL_FREETYPE
struct font_s *conchar_font;
#endif
unsigned char *d_15to8table; unsigned char *d_15to8table;
qboolean inited15to8; qboolean inited15to8;
extern cvar_t crosshair, crosshairimage, crosshairalpha, cl_crossx, cl_crossy, crosshaircolor, crosshairsize; extern cvar_t crosshair, crosshairimage, crosshairalpha, cl_crossx, cl_crossy, crosshaircolor, crosshairsize;
@ -1185,6 +1189,10 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
#ifdef PLUGINS #ifdef PLUGINS
Plug_DrawReloadImages(); Plug_DrawReloadImages();
#endif #endif
#ifdef AVAIL_FREETYPE
conchar_font = Font_LoadFont(16, "C:/Windows/Fonts/cour.ttf");
#endif
} }
void GLDraw_Init (void) void GLDraw_Init (void)
@ -1213,6 +1221,12 @@ void GLDraw_Init (void)
void GLDraw_DeInit (void) void GLDraw_DeInit (void)
{ {
Cmd_RemoveCommand ("gl_texture_anisotropic_filtering"); Cmd_RemoveCommand ("gl_texture_anisotropic_filtering");
#ifdef AVAIL_FREETYPE
if (conchar_font)
Font_Free(conchar_font);
conchar_font = NULL;
Font_Shutdown();
#endif
draw_disc = NULL; draw_disc = NULL;
@ -1307,10 +1321,11 @@ void GLDraw_Character (int x, int y, unsigned int num)
if (y <= -8) if (y <= -8)
return; // totally off screen return; // totally off screen
num &= 255; num &= CON_CHARMASK;
if (num == 32) if (num == 32)
return; // space return; // space
// if ((num&0xff00) != 0xe000 && num & ~0x7f)
// num = '?';
row = num>>4; row = num>>4;
col = num&15; col = num&15;
@ -2356,6 +2371,8 @@ void GL_Font_Callback(struct cvar_s *var, char *oldvalue)
mpic_t *pic; mpic_t *pic;
int old_char_texture = char_texture; int old_char_texture = char_texture;
//testfont = Font_LoadFont(testfontheight, var->string);
if (!*var->string if (!*var->string
|| (!(char_texture=Mod_LoadHiResTexture(var->string, "fonts", false, true, true)) || (!(char_texture=Mod_LoadHiResTexture(var->string, "fonts", false, true, true))
&& !(char_texture=Mod_LoadHiResTexture(var->string, "charsets", false, true, true)))) && !(char_texture=Mod_LoadHiResTexture(var->string, "charsets", false, true, true))))

516
engine/gl/gl_font.c Normal file
View file

@ -0,0 +1,516 @@
#include "quakedef.h"
#ifdef AVAIL_FREETYPE
#include "glquake.h"
#pragma comment(lib, "../libs/freetype2/objs/freetype239.lib")
#include <ft2build.h>
#include FT_FREETYPE_H
static FT_Library fontlib;
#define FONTCHARS (1<<16)
#define FONTPLANES (1<<2) //no more than 16 textures per font
#define PLANEIDXTYPE unsigned char
#define CHARIDXTYPE unsigned short
#define INVALIDPLANE ((1<<(8*sizeof(PLANEIDXTYPE)))-1)
#define PLANEWIDTH (1<<8)
#define PLANEHEIGHT PLANEWIDTH
#define GEN_CONCHAR_GLYPHS 0 //set to 0 or 1 to define whether to generate glyphs from conchars too, or if it should just draw them as glquake always used to
extern cvar_t cl_noblink;
typedef struct font_s
{
struct charcache_s
{
struct charcache_s *nextchar;
PLANEIDXTYPE texplane;
unsigned char bmx;
unsigned char bmy;
unsigned char bmw;
unsigned char bmh;
short top;
short left;
unsigned char advance; //how wide this char is, when drawn
char pad;
} chars[FONTCHARS];
short charheight;
FT_Face face;
} font_t;
typedef struct {
int texnum[FONTPLANES];
unsigned char plane[PLANEWIDTH*PLANEHEIGHT][4]; //tracks the current plane
PLANEIDXTYPE activeplane;
unsigned char planerowx;
unsigned char planerowy;
unsigned char planerowh;
qboolean planechanged;
struct charcache_s *oldestchar;
struct charcache_s *newestchar;
} fontplanes_t;
static fontplanes_t fontplanes;
void Font_Shutdown(void)
{
int i;
for (i = 0; i < FONTPLANES; i++)
fontplanes.texnum[i] = 0;
fontplanes.activeplane = 0;
fontplanes.oldestchar = NULL;
fontplanes.newestchar = NULL;
fontplanes.planechanged = 0;
fontplanes.planerowx = 0;
fontplanes.planerowy = 0;
fontplanes.planerowh = 0;
}
void Font_FlushPlane(font_t *f)
{
/*
assumption:
oldest chars must be of the oldest plane
*/
if (fontplanes.planechanged)
{
GL_Bind(fontplanes.texnum[fontplanes.activeplane]);
GL_Upload32(NULL, (void*)fontplanes.plane, PLANEWIDTH, PLANEHEIGHT, false, true);
fontplanes.planechanged = false;
}
fontplanes.activeplane++;
fontplanes.activeplane = fontplanes.activeplane % FONTPLANES;
fontplanes.planerowh = 0;
fontplanes.planerowx = 0;
fontplanes.planerowy = 0;
for (; fontplanes.oldestchar; fontplanes.oldestchar = fontplanes.oldestchar->nextchar)
{
if (fontplanes.oldestchar->texplane != fontplanes.activeplane)
break;
//invalidate it
fontplanes.oldestchar->texplane = INVALIDPLANE;
}
if (!fontplanes.oldestchar)
fontplanes.newestchar = NULL;
}
struct charcache_s *Font_GetChar(font_t *f, CHARIDXTYPE charidx)
{
struct charcache_s *c = &f->chars[charidx];
if (c->texplane == INVALIDPLANE)
{
//not cached, can't get.
return NULL;
}
return c;
}
struct charcache_s *Font_LoadGlyphData(font_t *f, CHARIDXTYPE charidx, int alphaonly, void *data, unsigned char bmw, unsigned char bmh, unsigned int pitch)
{
int x, y;
unsigned char *out;
struct charcache_s *c = &f->chars[charidx];
if (fontplanes.planerowx + (int)bmw >= PLANEWIDTH)
{
fontplanes.planerowx = 0;
fontplanes.planerowy += fontplanes.planerowh;
fontplanes.planerowh = 0;
}
if (fontplanes.planerowy+(int)bmh >= PLANEHEIGHT)
Font_FlushPlane(f);
if (fontplanes.newestchar)
fontplanes.newestchar->nextchar = c;
else
fontplanes.oldestchar = c;
fontplanes.newestchar = c;
c->nextchar = NULL;
c->texplane = fontplanes.activeplane;
c->bmx = fontplanes.planerowx;
c->bmy = fontplanes.planerowy;
c->bmw = bmw;
c->bmh = bmh;
if (fontplanes.planerowh < (int)bmh)
fontplanes.planerowh = bmh;
fontplanes.planerowx += bmw;
out = (unsigned char *)&fontplanes.plane[c->bmx+(int)c->bmy*PLANEHEIGHT];
if (alphaonly)
{
for (y = 0; y < bmh; y++)
{
for (x = 0; x < bmw; x++)
{
*(unsigned int *)&out[x*4] = 0xffffffff;
out[x*4+3] = ((unsigned char*)data)[x];
}
data = (char*)data + pitch;
out += PLANEWIDTH*4;
}
}
else
{
pitch*=4;
for (y = 0; y < bmh; y++)
{
for (x = 0; x < bmw; x++)
{
((unsigned int*)out)[x] = ((unsigned int*)data)[x];
}
data = (char*)data + pitch;
out += PLANEWIDTH*4;
}
}
fontplanes.planechanged = true;
return c;
}
struct charcache_s *Font_TryLoadGlyph(font_t *f, CHARIDXTYPE charidx)
{
struct charcache_s *c;
FT_GlyphSlot slot;
FT_Bitmap *bm;
#if GEN_CONCHAR_GLYPHS != 0
if (charidx >= 0xe000 && charidx <= 0xe0ff && draw_chars)
{
int cpos = charidx & 0xff;
unsigned int img[64*64], *d;
unsigned char *s;
int scale;
int x,y, ys;
if (draw_chars)
{
d = img;
s = draw_chars + 8*(cpos&15)+128*8*(cpos/16);
scale = f->charheight/8;
if (scale < 1)
scale = 1;
if (scale > 64/8)
scale = 64/8;
for (y = 0; y < 8; y++)
{
for (ys = 0; ys < scale; ys++)
{
for (x = 0; x < 8*scale; x++)
d[x] = d_8to24rgbtable[s[x/scale]];
d+=8*scale;
}
s+=128;
}
c = Font_LoadGlyphData(f, charidx, false, img, 8*scale, 8*scale, 8*scale);
if (c)
{
c->advance = 8*scale;
c->left = 0;
c->top = 7*scale;
}
return c;
}
charidx &= 0x7f;
}
#endif
if (FT_Load_Char(f->face, charidx, FT_LOAD_RENDER))
return NULL;
slot = f->face->glyph;
bm = &slot->bitmap;
c = Font_LoadGlyphData(f, charidx, true, bm->buffer, bm->width, bm->rows, bm->pitch);
if (c)
{
c->advance = slot->advance.x >> 6;
c->left = slot->bitmap_left;
c->top = slot->bitmap_top;
}
return c;
}
struct font_s *Font_LoadFont(int height, char *fontfilename)
{
int i;
struct font_s *f;
FT_Face face;
int error;
if (!fontlib)
{
error = FT_Init_FreeType(&fontlib);
if (error)
return NULL;
}
//fixme: use FT_Open_Face eventually
if (FT_New_Face(fontlib, fontfilename, 0, &face))
{
return NULL;
}
error = FT_Set_Pixel_Sizes(face, 0, height);
if (error)
{
return NULL;
}
f = malloc(sizeof(*f));
memset(f, 0, sizeof(*f));
f->face = face;
f->charheight = height;
fontplanes.texnum[0] = GL_AllocNewTexture();
fontplanes.texnum[1] = GL_AllocNewTexture();
fontplanes.texnum[2] = GL_AllocNewTexture();
fontplanes.texnum[3] = GL_AllocNewTexture();
for (i = 0; i < FONTCHARS; i++)
{
f->chars[i].texplane = INVALIDPLANE;
}
return f;
}
void Font_Free(struct font_s *f)
{
FT_Done_Face(f->face);
free(f);
}
void GLFont_BeginString(struct font_s *font, int vx, int vy, int *px, int *py)
{
*px = (vx*glwidth) / (float)vid.width;
*py = (vy*glheight) / (float)vid.height;
}
int GLFont_CharHeight(struct font_s *font, unsigned int charcode)
{
if (!font)
return 8;
return font->charheight;
}
int GLFont_CharWidth(struct font_s *font, unsigned int charcode)
{
struct charcache_s *c;
if (!font)
return 8;
#if GEN_CONCHAR_GLYPHS == 0
if ((charcode&CON_CHARMASK) >= 0xe000 && (charcode&CON_CHARMASK) <= 0xe0ff)
return font->charheight;
#endif
c = Font_GetChar(font, charcode&CON_CHARMASK);
if (!c)
{
c = Font_TryLoadGlyph(font, charcode&CON_CHARMASK);
if (!c)
return 0;
}
return c->advance;
}
int GLFont_LineBreaks(struct font_s *font, conchar_t *start, conchar_t *end, int scrwidth, int maxlines, conchar_t **starts, conchar_t **ends)
{
int l, bt;
int px;
int foundlines = 0;
while (start < end)
{
// scan the width of the line
for (px=0, l=0 ; px <= scrwidth;)
{
if ((start[l]&CON_CHARMASK) == '\n' || (start+l >= end))
break;
l++;
px += GLFont_CharWidth(font, start[l]);
}
//if we did get to the end
if (px > scrwidth)
{
bt = l;
//backtrack until we find a space
while(l > 0 && (start[l-1]&CON_CHARMASK)>' ')
{
l--;
}
if (l == 0 && bt>0)
l = bt-1;
px -= GLFont_CharWidth(font, start[l]);
}
starts[foundlines] = start;
ends[foundlines] = start+l;
foundlines++;
if (foundlines == maxlines)
break;
start+=l;
// for (l=0 ; l<40 && *start && *start != '\n'; l++)
// start++;
if ((*start&CON_CHARMASK) == '\n'||!l)
start++; // skip the \n
}
return foundlines;
}
void GLDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b);
int GLFont_DrawChar(struct font_s *font, int px, int py, unsigned int charcode)
{
struct charcache_s *c;
float s0, s1;
float t0, t1;
float nextx;
float sx, sy, sw, sh;
int col;
if (!font)
return px;
#if GEN_CONCHAR_GLYPHS == 0
if ((charcode&CON_CHARMASK) >= 0xe000 && (charcode&CON_CHARMASK) <= 0xe0ff)
{
extern char_texture;
if (charcode == 32)
return px+font->charheight; // space
if (charcode & CON_BLINKTEXT)
{
if (!cl_noblink.value)
if ((int)(realtime*3) & 1)
return px+font->charheight;
}
qglEnable(GL_BLEND);
qglDisable(GL_ALPHA_TEST);
col = (charcode & CON_FGMASK) >> CON_FGSHIFT;
qglColor4f(consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb, (charcode & CON_HALFALPHA)?0.5:1);
charcode &= 0xff;
sx = ((px)*vid.width) / (float)glwidth;
sy = ((py+font->charheight/8)*vid.height) / (float)glheight;
sw = ((font->charheight)*vid.width) / (float)glwidth;
sh = ((font->charheight)*vid.height) / (float)glheight;
col = charcode&15;
s0 = (float)col/16;
s1 = (float)(col+1)/16;
col = charcode>>4;
t0 = (float)col/16;
t1 = (float)(col+1)/16;
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL_Bind(char_texture);
qglBegin(GL_QUADS);
qglTexCoord2f(s0, t0);
qglVertex2f(sx, sy);
qglTexCoord2f(s1, t0);
qglVertex2f(sx+sw, sy);
qglTexCoord2f(s1, t1);
qglVertex2f(sx+sw, sy+sh);
qglTexCoord2f(s0, t1);
qglVertex2f(sx, sy+sh);
qglEnd();
qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
return px+font->charheight;
}
#endif
c = Font_GetChar(font, charcode&CON_CHARMASK);
if (!c)
{
c = Font_TryLoadGlyph(font, charcode&CON_CHARMASK);
if (!c)
return px;
}
nextx = px + c->advance;
if (charcode & CON_BLINKTEXT)
{
if (!cl_noblink.value)
if ((int)(realtime*3) & 1)
return nextx;
}
// draw background
if (charcode & CON_NONCLEARBG)
{
sx = ((px)*vid.width) / (float)glwidth;
sy = ((py+font->charheight/3)*vid.height) / (float)glheight;
sw = ((c->advance)*vid.width) / (float)glwidth;
sh = ((font->charheight)*vid.height) / (float)glheight;
col = (charcode & CON_BGMASK) >> CON_BGSHIFT;
GLDraw_FillRGB(sx, sy, sw, sh, consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb);
}
sx = ((px+c->left)*vid.width) / (float)glwidth;
sy = ((py+font->charheight-c->top)*vid.height) / (float)glheight;
sw = ((c->bmw)*vid.width) / (float)glwidth;
sh = ((c->bmh)*vid.height) / (float)glheight;
s0 = (float)c->bmx/PLANEWIDTH;
t0 = (float)c->bmy/PLANEWIDTH;
s1 = (float)(c->bmx+c->bmw)/PLANEWIDTH;
t1 = (float)(c->bmy+c->bmh)/PLANEWIDTH;
qglEnable(GL_BLEND);
qglDisable(GL_ALPHA_TEST);
col = (charcode & CON_FGMASK) >> CON_FGSHIFT;
qglColor4f(consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb, (charcode & CON_HALFALPHA)?0.5:1);
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (fontplanes.planechanged)
{
GL_Bind(fontplanes.texnum[fontplanes.activeplane]);
GL_Upload32(NULL, (void*)fontplanes.plane, PLANEWIDTH, PLANEHEIGHT, false, true);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
fontplanes.planechanged = false;
}
GL_Bind(fontplanes.texnum[c->texplane]);
qglBegin(GL_QUADS);
qglTexCoord2f(s0, t0);
qglVertex2f(sx, sy);
qglTexCoord2f(s1, t0);
qglVertex2f(sx+sw, sy);
qglTexCoord2f(s1, t1);
qglVertex2f(sx+sw, sy+sh);
qglTexCoord2f(s0, t1);
qglVertex2f(sx, sy+sh);
qglEnd();
qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
return nextx;
}
#endif

View file

@ -327,12 +327,7 @@ void GLMod_ClearAll (void)
{ {
if (!mod->textures[t]) if (!mod->textures[t])
continue; continue;
if (mod->textures[t]->gl_vboe) GL_ClearVBO(&mod->textures[t]->vbo);
qglDeleteBuffersARB(1, &mod->textures[t]->gl_vboe);
if (mod->textures[t]->gl_vbov)
qglDeleteBuffersARB(1, &mod->textures[t]->gl_vbov);
mod->textures[t]->gl_vboe = 0;
mod->textures[t]->gl_vbov = 0;
} }
} }
@ -932,7 +927,6 @@ Mod_LoadTextures
*/ */
qboolean GLMod_LoadTextures (lump_t *l) qboolean GLMod_LoadTextures (lump_t *l)
{ {
extern cvar_t gl_shadeq1, gl_shadeq1_name;
extern int gl_bumpmappingpossible; extern int gl_bumpmappingpossible;
int i, j, pixels, num, max, altmax; int i, j, pixels, num, max, altmax;
miptex_t *mt; miptex_t *mt;
@ -996,13 +990,8 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
if (!mt->offsets[0]) //this is a hl external style texture, load it a little later (from a wad) if (!mt->offsets[0]) //this is a hl external style texture, load it a little later (from a wad)
{ {
// tx->gl_texturenum = Mod_LoadReplacementTexture("light1_4", true, false);
continue; continue;
} }
// 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); //have to be saved for dynamic screen changing (done by reloading entire vid/draw subsystem and all textures)
if (!Q_strncmp(mt->name,"sky",3)) if (!Q_strncmp(mt->name,"sky",3))
{ {
@ -1094,30 +1083,6 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
} }
} }
} }
#ifdef NEWBACKEND
tx->shader = R_RegisterCustom(mt->name, Shader_DefaultBSP, &tx->tn);
#pragma message("warning: fix the following block")
#endif
#ifdef Q3SHADERS //load q3 syntax shader last, after the textures inside the bsp have been loaded and stuff.
if (cls.allow_shaders && gl_shadeq1.value && *gl_shadeq1_name.string)
{
char *star;
//find the *
if (!strcmp(gl_shadeq1_name.string, "*"))
// tx->shader = R_RegisterCustom(mt->name, NULL); //just load the regular name.
tx->shader = R_RegisterShader(mt->name); //just load the regular name.
else if (!(star = strchr(gl_shadeq1_name.string, '*')) || (strlen(gl_shadeq1_name.string)+strlen(mt->name)+1>=sizeof(altname))) //it's got to fit.
tx->shader = R_RegisterCustom(gl_shadeq1_name.string, NULL, NULL);
else
{
strncpy(altname, gl_shadeq1_name.string, star-gl_shadeq1_name.string); //copy the left
altname[star-gl_shadeq1_name.string] = '\0';
strcat(altname, mt->name); //insert the *
strcat(altname, star+1); //add any final text.
tx->shader = R_RegisterCustom(altname, NULL, NULL);
}
}
#endif
} }
// //
// sequence the animations // sequence the animations
@ -1229,14 +1194,13 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n"));
void GLMod_NowLoadExternal(void) void GLMod_NowLoadExternal(void)
{ {
extern cvar_t gl_shadeq1, gl_shadeq1_name;
extern int gl_bumpmappingpossible; extern int gl_bumpmappingpossible;
int i, width, height; int i, width, height;
qboolean alphaed; qboolean alphaed;
texture_t *tx; texture_t *tx;
if (loadmodel->fromgame != fg_halflife)
return;
for (i=0 ; i<loadmodel->numtextures ; i++) for (i=0 ; i<loadmodel->numtextures ; i++)
{ {
tx = loadmodel->textures[i]; tx = loadmodel->textures[i];
@ -1287,6 +1251,33 @@ void GLMod_NowLoadExternal(void)
tx->tn.bump = R_LoadTexture8Bump (va("%s_bump", tx->name), width, height, heightmap-j, true, r_shadow_bumpscale_basetexture.value); tx->tn.bump = R_LoadTexture8Bump (va("%s_bump", tx->name), width, height, heightmap-j, true, r_shadow_bumpscale_basetexture.value);
} }
} }
#ifdef NEWBACKEND
tx->shader = R_RegisterCustom(tx->name, Shader_DefaultBSP, &tx->tn);
#pragma message("warning: fix the following block")
#endif
#ifdef Q3SHADERS //load q3 syntax shader last, after the textures inside the bsp have been loaded and stuff.
if (cls.allow_shaders && gl_shadeq1.value && *gl_shadeq1_name.string)
{
char altname[MAX_QPATH];
char *star;
//find the *
if (!strcmp(gl_shadeq1_name.string, "*"))
// tx->shader = R_RegisterCustom(mt->name, NULL); //just load the regular name.
tx->shader = R_RegisterShader(tx->name); //just load the regular name.
else if (!(star = strchr(gl_shadeq1_name.string, '*')) || (strlen(gl_shadeq1_name.string)+strlen(tx->name)+1>=sizeof(altname))) //it's got to fit.
tx->shader = R_RegisterCustom(gl_shadeq1_name.string, NULL, NULL);
else
{
strncpy(altname, gl_shadeq1_name.string, star-gl_shadeq1_name.string); //copy the left
altname[star-gl_shadeq1_name.string] = '\0';
strcat(altname, tx->name); //insert the *
strcat(altname, star+1); //add any final text.
tx->shader = R_RegisterCustom(altname, NULL, NULL);
}
}
#endif
} }
} }

View file

@ -77,6 +77,8 @@ typedef struct mesh_s
int numvertexes; int numvertexes;
vec3_t *xyz_array; vec3_t *xyz_array;
vec3_t *normals_array; vec3_t *normals_array;
vec3_t *snormals_array;
vec3_t *tnormals_array;
vec2_t *st_array; vec2_t *st_array;
vec2_t *lmst_array; vec2_t *lmst_array;
byte_vec4_t *colors_array; byte_vec4_t *colors_array;
@ -173,6 +175,26 @@ typedef struct {
int fullbright; int fullbright;
} texnums_t; } texnums_t;
typedef struct
{
int vboe;
index_t *indicies;
int vbocoord;
vec3_t *coord;
int vbotexcoord;
vec2_t *texcoord;
int vbolmcoord;
vec2_t *lmcoord;
int vbonormals;
vec3_t *normals;
int vbosvector;
vec3_t *svector;
int vbotvector;
vec3_t *tvector;
} vbo_t;
typedef struct texture_s typedef struct texture_s
{ {
char name[64]; char name[64];
@ -187,8 +209,7 @@ typedef struct texture_s
struct shader_s *shader; struct shader_s *shader;
int gl_vbov; vbo_t vbo;
int gl_vboe;
struct msurface_s *texturechain; // for gl_texsort drawing struct msurface_s *texturechain; // for gl_texsort drawing
int anim_total; // total tenths in sequence ( 0 = no) int anim_total; // total tenths in sequence ( 0 = no)
@ -197,14 +218,18 @@ typedef struct texture_s
struct texture_s *alternate_anims; // bmodels in frmae 1 use these struct texture_s *alternate_anims; // bmodels in frmae 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored unsigned offsets[MIPLEVELS]; // four mip maps stored
} texture_t; } texture_t;
/*
typedef struct typedef struct
{ {
float coord[3]; float coord[3];
float texcoord[2]; float texcoord[2];
float lmcoord[2]; float lmcoord[2];
} vbovertex_t;
float normals[3];
float svector[3];
float tvector[3];
} vbovertex_t;
*/
#define SURF_DRAWSKYBOX 0x00001 #define SURF_DRAWSKYBOX 0x00001
#define SURF_PLANEBACK 0x00002 #define SURF_PLANEBACK 0x00002
#define SURF_DRAWSKY 0x00004 #define SURF_DRAWSKY 0x00004

View file

@ -498,10 +498,10 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t
varrayactive = false; varrayactive = false;
qglDisableClientState(GL_COLOR_ARRAY); qglDisableClientState(GL_COLOR_ARRAY);
qglEnableClientState(GL_VERTEX_ARRAY); qglEnableClientState(GL_VERTEX_ARRAY);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->gl_vbov); qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tex->vbo.vboe);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tex->gl_vboe);
qglVertexPointer(3, GL_FLOAT, sizeof(vbovertex_t), ((vbovertex_t*)NULL)->coord); qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbocoord);
qglVertexPointer(3, GL_FLOAT, 0, tex->vbo.coord);
if (tex->alphaed || currententity->shaderRGBAf[3]<1) if (tex->alphaed || currententity->shaderRGBAf[3]<1)
{ {
@ -526,11 +526,13 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t
GL_MBind(GL_TEXTURE0_ARB, tex->tn.base); GL_MBind(GL_TEXTURE0_ARB, tex->tn.base);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY); qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer(2, GL_FLOAT, sizeof(vbovertex_t), ((vbovertex_t*)NULL)->texcoord); qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbotexcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, tex->vbo.texcoord);
GL_SelectTexture(GL_TEXTURE1_ARB); GL_SelectTexture(GL_TEXTURE1_ARB);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY); qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer(2, GL_FLOAT, sizeof(vbovertex_t), ((vbovertex_t*)NULL)->lmcoord); qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbolmcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, tex->vbo.lmcoord);
GL_TexEnv(GL_MODULATE); GL_TexEnv(GL_MODULATE);
@ -762,7 +764,7 @@ static void PPL_BaseChain_Bump_2TMU(msurface_t *first, texture_t *tex)
lightmap[vi]->deluxmodified = false; lightmap[vi]->deluxmodified = false;
theRect = &lightmap[vi]->deluxrectchange; theRect = &lightmap[vi]->deluxrectchange;
qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t, qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t,
LMBLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE, LMBLOCK_WIDTH, theRect->h, GL_RGB, GL_UNSIGNED_BYTE,
lightmap[vi]->deluxmaps+(theRect->t) *LMBLOCK_WIDTH*3); lightmap[vi]->deluxmaps+(theRect->t) *LMBLOCK_WIDTH*3);
theRect->l = LMBLOCK_WIDTH; theRect->l = LMBLOCK_WIDTH;
theRect->t = LMBLOCK_HEIGHT; theRect->t = LMBLOCK_HEIGHT;
@ -1705,8 +1707,7 @@ static void PPL_BaseTextureChain(msurface_t *first)
dl->radius = 50; dl->radius = 50;
//flashblend only //flashblend only
dl->noppl = true; dl->flags = LFLAG_ALLOW_FLASH;
dl->nodynamic = true;
first = first->texturechain; first = first->texturechain;
} }
@ -1851,7 +1852,7 @@ static void PPL_BaseTextureChain(msurface_t *first)
{ {
// PPL_BaseChain_NoBump_2TMU_TEST(first, t); // PPL_BaseChain_NoBump_2TMU_TEST(first, t);
// PPL_BaseChain_NoBump_2TMU(first, t); // PPL_BaseChain_NoBump_2TMU(first, t);
if (t->gl_vbov) if (t->vbo.vbocoord)
PPL_BaseChain_VBO_NoBump_2TMU_Overbright(first, t); PPL_BaseChain_VBO_NoBump_2TMU_Overbright(first, t);
else else
PPL_BaseChain_NoBump_2TMU_Overbright(first, t); PPL_BaseChain_NoBump_2TMU_Overbright(first, t);
@ -2037,7 +2038,7 @@ void PPL_BaseBModelTextures(entity_t *e)
{ {
if (!cl_dlights[k].radius) if (!cl_dlights[k].radius)
continue; continue;
if (cl_dlights[k].nodynamic) if (!(cl_dlights[k].flags & LFLAG_ALLOW_LMHACK))
continue; continue;
currentmodel->funcs.MarkLights (&cl_dlights[k], 1<<k, currentmodel->funcs.MarkLights (&cl_dlights[k], 1<<k,
@ -5178,12 +5179,12 @@ void PPL_DrawWorld (void)
// lc = NULL; // lc = NULL;
for (l = cl_dlights, i=0 ; i<dlights_running ; i++, l++) for (l = cl_dlights, i=0 ; i<dlights_running ; i++, l++)
{ {
if (!l->radius || l->noppl) if (!l->radius || !(l->flags & LFLAG_ALLOW_PPL))
continue; continue;
if (l->color[0]<0) if (l->color[0]<0)
continue; //quick check for darklight continue; //quick check for darklight
if (l->isstatic) if (l->flags & LFLAG_REALTIMEMODE)
{ {
if (!r_shadow_realtime_world.value) if (!r_shadow_realtime_world.value)
continue; continue;
@ -5236,21 +5237,9 @@ void PPL_DrawWorld (void)
for (l = lc; l; l = l->next) //we now have our quotaed list for (l = lc; l; l = l->next) //we now have our quotaed list
{ {
#endif #endif
if(!l->isstatic)
{
l->color[0]*=10;
l->color[1]*=10;
l->color[2]*=10;
}
TRACE(("dbg: calling PPL_AddLight\n")); TRACE(("dbg: calling PPL_AddLight\n"));
if (PPL_AddLight(l)) if (PPL_AddLight(l))
numlights++; numlights++;
if(!l->isstatic)
{
l->color[0]/=10;
l->color[1]/=10;
l->color[2]/=10;
}
} }
qglEnable(GL_TEXTURE_2D); qglEnable(GL_TEXTURE_2D);
@ -5507,7 +5496,7 @@ void PPL_BeginShadowMesh(dlight_t *dl)
if (buildingmesh) if (buildingmesh)
return; return;
if (!dl->isstatic) if (dl->die)
return; return;
sh_maxverts = 0; sh_maxverts = 0;

View file

@ -188,7 +188,7 @@ void GLR_RenderDlights (void)
l = cl_dlights; l = cl_dlights;
for (i=0 ; i<dlights_running ; i++, l++) for (i=0 ; i<dlights_running ; i++, l++)
{ {
if (!l->radius || l->noflash) if (!l->radius || !(l->flags & LFLAG_ALLOW_FLASH))
continue; continue;
//dlights emitting from the local player are not visible as flashblends //dlights emitting from the local player are not visible as flashblends
@ -399,7 +399,7 @@ void GLR_PushDlights (void)
l = cl_dlights; l = cl_dlights;
for (i=0 ; i<dlights_software ; i++, l++) for (i=0 ; i<dlights_software ; i++, l++)
{ {
if (!l->radius || l->nodynamic) if (!l->radius || !(l->flags & LFLAG_ALLOW_LMHACK))
continue; continue;
currentmodel->funcs.MarkLights( l, 1<<i, currentmodel->nodes ); currentmodel->funcs.MarkLights( l, 1<<i, currentmodel->nodes );
} }

View file

@ -1045,17 +1045,18 @@ void R_SetupGL (void)
screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height; screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
if (r_refdef.useperspective) if (r_refdef.useperspective)
{ {
if ((!r_shadows.value || !gl_canstencil) && gl_maxdist.value>256)//gl_nv_range_clamp) if ((!r_shadows.value || !gl_canstencil) && gl_maxdist.value>=100)//gl_nv_range_clamp)
{ {
// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI; // yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI;
// yfov = (2.0 * tan (scr_fov.value/360*M_PI)) / screenaspect; // yfov = (2.0 * tan (scr_fov.value/360*M_PI)) / screenaspect;
// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*(scr_fov.value*2)/M_PI; // yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*(scr_fov.value*2)/M_PI;
// MYgluPerspective (yfov, screenaspect, 4, 4096); // MYgluPerspective (yfov, screenaspect, 4, 4096);
MYgluPerspective (fov_x, fov_y, gl_mindist.value, gl_maxdist.value);
Matrix4_Projection_Far(r_projection_matrix, fov_x, fov_y, gl_mindist.value, gl_maxdist.value);
} }
else else
{ {
GL_InfinatePerspective(fov_x, fov_y, gl_mindist.value); Matrix4_Projection_Inf(r_projection_matrix, fov_x, fov_y, gl_mindist.value);
} }
} }
else else
@ -1151,7 +1152,7 @@ void R_RenderScene (void)
r_refdef.flags |= Q2RDF_NOWORLDMODEL; r_refdef.flags |= Q2RDF_NOWORLDMODEL;
#ifdef NEWBACKEND #ifdef NEWBACKEND
PPL_GenShadowMaps(); Sh_GenShadowMaps();
#endif #endif
GLR_SetupFrame (); GLR_SetupFrame ();

View file

@ -24,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "glquake.h" #include "glquake.h"
#include "gl_draw.h" #include "gl_draw.h"
void R_ReloadRTLights_f(void);
#ifdef WATERLAYERS #ifdef WATERLAYERS
cvar_t r_waterlayers = SCVAR("r_waterlayers","3"); cvar_t r_waterlayers = SCVAR("r_waterlayers","3");
#endif #endif
@ -716,6 +719,7 @@ void GLR_DeInit (void)
{ {
Cmd_RemoveCommand ("timerefresh"); Cmd_RemoveCommand ("timerefresh");
Cmd_RemoveCommand ("envmap"); Cmd_RemoveCommand ("envmap");
Cmd_RemoveCommand ("r_editlights_reload");
Cmd_RemoveCommand ("pointfile"); Cmd_RemoveCommand ("pointfile");
Cmd_RemoveCommand ("makewad"); Cmd_RemoveCommand ("makewad");
@ -750,6 +754,7 @@ void GLR_Init (void)
{ {
Cmd_AddRemCommand ("timerefresh", GLR_TimeRefresh_f); Cmd_AddRemCommand ("timerefresh", GLR_TimeRefresh_f);
Cmd_AddRemCommand ("envmap", R_Envmap_f); Cmd_AddRemCommand ("envmap", R_Envmap_f);
Cmd_AddRemCommand ("r_editlights_reload", R_ReloadRTLights_f);
// Cmd_AddRemCommand ("makewad", R_MakeTexWad_f); // Cmd_AddRemCommand ("makewad", R_MakeTexWad_f);
@ -779,6 +784,224 @@ void GLR_Init (void)
GLR_ReInit(); GLR_ReInit();
} }
void R_ImportRTLights(char *entlump)
{
typedef enum lighttype_e {LIGHTTYPE_MINUSX, LIGHTTYPE_RECIPX, LIGHTTYPE_RECIPXX, LIGHTTYPE_NONE, LIGHTTYPE_SUN, LIGHTTYPE_MINUSXX} lighttype_t;
/*I'm using the DP code so I know I'll get the DP results*/
int entnum, style, islight, skin, pflags, effects, n;
lighttype_t type;
float origin[3], angles[3], radius, color[3], light[4], fadescale, lightscale, originhack[3], overridecolor[3], vec[4];
char key[256], value[8192];
for (entnum = 0; ;entnum++)
{
entlump = COM_Parse(entlump);
if (com_token[0] != '{')
break;
type = LIGHTTYPE_MINUSX;
origin[0] = origin[1] = origin[2] = 0;
originhack[0] = originhack[1] = originhack[2] = 0;
angles[0] = angles[1] = angles[2] = 0;
color[0] = color[1] = color[2] = 1;
light[0] = light[1] = light[2] = 1;light[3] = 300;
overridecolor[0] = overridecolor[1] = overridecolor[2] = 1;
fadescale = 1;
lightscale = 1;
style = 0;
skin = 0;
pflags = 0;
effects = 0;
islight = false;
while (1)
{
entlump = COM_Parse(entlump);
if (!entlump)
break; // error
if (com_token[0] == '}')
break; // end of entity
if (com_token[0] == '_')
Q_strncpyz(key, com_token + 1, sizeof(key));
else
Q_strncpyz(key, com_token, sizeof(key));
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
entlump = COM_Parse(entlump);
if (!entlump)
break; // error
Q_strncpyz(value, com_token, sizeof(value));
// now that we have the key pair worked out...
if (!strcmp("light", key))
{
n = sscanf(value, "%f %f %f %f", &vec[0], &vec[1], &vec[2], &vec[3]);
if (n == 1)
{
// quake
light[0] = vec[0] * (1.0f / 256.0f);
light[1] = vec[0] * (1.0f / 256.0f);
light[2] = vec[0] * (1.0f / 256.0f);
light[3] = vec[0];
}
else if (n == 4)
{
// halflife
light[0] = vec[0] * (1.0f / 255.0f);
light[1] = vec[1] * (1.0f / 255.0f);
light[2] = vec[2] * (1.0f / 255.0f);
light[3] = vec[3];
}
}
else if (!strcmp("delay", key))
type = atoi(value);
else if (!strcmp("origin", key))
sscanf(value, "%f %f %f", &origin[0], &origin[1], &origin[2]);
else if (!strcmp("angle", key))
angles[0] = 0, angles[1] = atof(value), angles[2] = 0;
else if (!strcmp("angles", key))
sscanf(value, "%f %f %f", &angles[0], &angles[1], &angles[2]);
else if (!strcmp("color", key))
sscanf(value, "%f %f %f", &color[0], &color[1], &color[2]);
else if (!strcmp("wait", key))
fadescale = atof(value);
else if (!strcmp("classname", key))
{
if (!strncmp(value, "light", 5))
{
islight = true;
if (!strcmp(value, "light_fluoro"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 1;
overridecolor[2] = 1;
}
if (!strcmp(value, "light_fluorospark"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 1;
overridecolor[2] = 1;
}
if (!strcmp(value, "light_globe"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.8;
overridecolor[2] = 0.4;
}
if (!strcmp(value, "light_flame_large_yellow"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
}
if (!strcmp(value, "light_flame_small_yellow"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
}
if (!strcmp(value, "light_torch_small_white"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
}
if (!strcmp(value, "light_torch_small_walltorch"))
{
originhack[0] = 0;
originhack[1] = 0;
originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
}
}
}
else if (!strcmp("style", key))
style = atoi(value);
else if (!strcmp("skin", key))
skin = (int)atof(value);
else if (!strcmp("pflags", key))
pflags = (int)atof(value);
else if (!strcmp("effects", key))
effects = (int)atof(value);
else if (!strcmp("scale", key))
lightscale = atof(value);
else if (!strcmp("fade", key))
fadescale = atof(value);
}
if (!islight)
continue;
if (lightscale <= 0)
lightscale = 1;
if (fadescale <= 0)
fadescale = 1;
if (color[0] == color[1] && color[0] == color[2])
{
color[0] *= overridecolor[0];
color[1] *= overridecolor[1];
color[2] *= overridecolor[2];
}
radius = light[3] * 1/*r_editlights_quakelightsizescale*/ * lightscale / fadescale;
color[0] = color[0] * light[0];
color[1] = color[1] * light[1];
color[2] = color[2] * light[2];
switch (type)
{
case LIGHTTYPE_MINUSX:
break;
case LIGHTTYPE_RECIPX:
radius *= 2;
VectorScale(color, (1.0f / 16.0f), color);
break;
case LIGHTTYPE_RECIPXX:
radius *= 2;
VectorScale(color, (1.0f / 16.0f), color);
break;
default:
case LIGHTTYPE_NONE:
break;
case LIGHTTYPE_SUN:
break;
case LIGHTTYPE_MINUSXX:
break;
}
VectorAdd(origin, originhack, origin);
if (radius >= 1)
{
dlight_t *dl = CL_AllocDlight(0);
VectorCopy(origin, dl->origin);
AngleVectors(angles, dl->axis[0], dl->axis[1], dl->axis[2]);
dl->radius = radius;
VectorCopy(color, dl->color);
dl->flags |= LFLAG_REALTIMEMODE;
dl->flags |= (pflags & PFLAGS_CORONA)?LFLAG_ALLOW_FLASH:0;
dl->flags |= (pflags & PFLAGS_NOSHADOW)?LFLAG_NOSHADOWS:0;
dl->style = style+1;
//FIXME: cubemaps if skin >= 16
}
}
}
void R_LoadRTLights(void) void R_LoadRTLights(void)
{ {
@ -791,6 +1014,9 @@ void R_LoadRTLights(void)
vec3_t org; vec3_t org;
float radius; float radius;
vec3_t rgb; vec3_t rgb;
unsigned int flags;
vec3_t angles;
//delete all old lights //delete all old lights
dlights_running = 0; dlights_running = 0;
@ -800,8 +1026,7 @@ void R_LoadRTLights(void)
strncat(fname, ".rtlights", MAX_QPATH-1); strncat(fname, ".rtlights", MAX_QPATH-1);
file = COM_LoadTempFile(fname); file = COM_LoadTempFile(fname);
if (!file) if (file)
return;
while(1) while(1)
{ {
end = strchr(file, '\n'); end = strchr(file, '\n');
@ -822,26 +1047,55 @@ void R_LoadRTLights(void)
radius = atof(com_token); radius = atof(com_token);
file = COM_Parse(file); file = COM_Parse(file);
rgb[0] = atof(com_token); rgb[0] = file?atof(com_token):1;
file = COM_Parse(file); file = COM_Parse(file);
rgb[1] = atof(com_token); rgb[1] = file?atof(com_token):1;
file = COM_Parse(file); file = COM_Parse(file);
rgb[2] = atof(com_token); rgb[2] = file?atof(com_token):1;
file = COM_Parse(file); file = COM_Parse(file);
style = atoi(com_token); style = file?atof(com_token):0;
if (file) file = COM_Parse(file);
//cubemap
file = COM_Parse(file);
//corona
file = COM_Parse(file);
angles[0] = atof(com_token);
file = COM_Parse(file);
angles[1] = atof(com_token);
file = COM_Parse(file);
angles[2] = atof(com_token);
file = COM_Parse(file);
//corrona scale
file = COM_Parse(file);
//ambient
file = COM_Parse(file);
//diffuse
file = COM_Parse(file);
//specular
file = COM_Parse(file);
if (*com_token)
flags = atoi(com_token);
else
flags = LFLAG_REALTIMEMODE;
if (radius)
{ {
dl = CL_AllocDlight(0); dl = CL_AllocDlight(0);
VectorCopy(org, dl->origin); VectorCopy(org, dl->origin);
dl->radius = radius; dl->radius = radius;
VectorCopy(rgb, dl->color); VectorCopy(rgb, dl->color);
dl->die = cl.time + 0x7fffffff; dl->die = 0;
dl->isstatic = true; dl->flags = flags;
AngleVectors(angles, dl->axis[0], dl->axis[1], dl->axis[2]);
dl->nodynamic = true;
dl->noflash = true;
dl->style = style+1; dl->style = style+1;
} }
@ -849,6 +1103,25 @@ void R_LoadRTLights(void)
} }
} }
void R_ReloadRTLights_f(void)
{
if (!cl.worldmodel)
{
Con_Printf("Cannot reload lights at this time\n");
return;
}
dlights_running = 0;
dlights_software = 0;
if (strcmp(Cmd_Argv(1), "bsp"))
R_LoadRTLights();
if (!dlights_running)
{
Con_Printf("Importing rtlights from BSP\n");
R_ImportRTLights(cl.worldmodel->entities);
}
}
/* /*
=============== ===============
R_NewMap R_NewMap

View file

@ -384,7 +384,7 @@ void GLR_AddDynamicLights (msurface_t *surf)
if ( !(surf->dlightbits & (1<<lnum) ) ) if ( !(surf->dlightbits & (1<<lnum) ) )
continue; // not lit by this light continue; // not lit by this light
if (cl_dlights[lnum].nodynamic) if (!(cl_dlights[lnum].flags & LFLAG_ALLOW_LMHACK))
continue; continue;
rad = cl_dlights[lnum].radius; rad = cl_dlights[lnum].radius;
@ -452,7 +452,7 @@ void GLR_AddDynamicLightNorms (msurface_t *surf)
if ( !(surf->dlightbits & (1<<lnum) ) ) if ( !(surf->dlightbits & (1<<lnum) ) )
continue; // not lit by this light continue; // not lit by this light
if (cl_dlights[lnum].nodynamic) if (!(cl_dlights[lnum].flags & LFLAG_ALLOW_LMHACK))
continue; continue;
rad = cl_dlights[lnum].radius; rad = cl_dlights[lnum].radius;
@ -2778,16 +2778,18 @@ void GL_BuildSurfaceDisplayList (msurface_t *fa)
vertpage = 0; vertpage = 0;
if (lnumverts<3) if (lnumverts<3)
return; //q3 map. return; //q3 flares.
{ //build a nice mesh instead of a poly. { //build a nice mesh instead of a poly.
int size = sizeof(mesh_t) + sizeof(index_t)*(lnumverts-2)*3 + (sizeof(vec3_t) + sizeof(vec3_t) + 2*sizeof(vec2_t) + sizeof(byte_vec4_t))*lnumverts; int size = sizeof(mesh_t) + sizeof(index_t)*(lnumverts-2)*3 + (sizeof(vec3_t) + 3*sizeof(vec3_t) + 2*sizeof(vec2_t) + sizeof(byte_vec4_t))*lnumverts;
mesh_t *mesh; mesh_t *mesh;
fa->mesh = mesh = Hunk_Alloc(size); fa->mesh = mesh = Hunk_Alloc(size);
mesh->xyz_array = (vec3_t*)(mesh + 1); mesh->xyz_array = (vec3_t*)(mesh + 1);
mesh->normals_array = (vec3_t*)(mesh->xyz_array + lnumverts); mesh->normals_array = (vec3_t*)(mesh->xyz_array + lnumverts);
mesh->st_array = (vec2_t*)(mesh->normals_array + lnumverts); mesh->snormals_array = (vec3_t*)(mesh->normals_array + lnumverts);
mesh->tnormals_array = (vec3_t*)(mesh->snormals_array + lnumverts);
mesh->st_array = (vec2_t*)(mesh->tnormals_array + lnumverts);
mesh->lmst_array = (vec2_t*)(mesh->st_array + lnumverts); mesh->lmst_array = (vec2_t*)(mesh->st_array + lnumverts);
mesh->colors_array = (byte_vec4_t*)(mesh->lmst_array + lnumverts); mesh->colors_array = (byte_vec4_t*)(mesh->lmst_array + lnumverts);
mesh->indexes = (index_t*)(mesh->colors_array + lnumverts); mesh->indexes = (index_t*)(mesh->colors_array + lnumverts);
@ -2845,6 +2847,8 @@ void GL_BuildSurfaceDisplayList (msurface_t *fa)
VectorNegate(fa->plane->normal, mesh->normals_array[i]); VectorNegate(fa->plane->normal, mesh->normals_array[i]);
else else
VectorCopy(fa->plane->normal, mesh->normals_array[i]); VectorCopy(fa->plane->normal, mesh->normals_array[i]);
VectorCopy(fa->texinfo->vecs[0], mesh->snormals_array[i]);
VectorCopy(fa->texinfo->vecs[1], mesh->tnormals_array[i]);
mesh->colors_array[i][0] = 255; mesh->colors_array[i][0] = 255;
mesh->colors_array[i][1] = 255; mesh->colors_array[i][1] = 255;
@ -2922,6 +2926,93 @@ void GLSurf_DeInit(void)
numlightmaps=0; numlightmaps=0;
} }
void GL_ClearVBO(vbo_t *vbo)
{
int vboh[7];
int i, j;
vboh[0] = vbo->vboe;
vboh[1] = vbo->vbocoord;
vboh[2] = vbo->vbotexcoord;
vboh[3] = vbo->vbolmcoord;
vboh[4] = vbo->vbonormals;
vboh[5] = vbo->vbosvector;
vboh[6] = vbo->vbotvector;
for (i = 0; i < 7; i++)
{
if (!vboh[i])
continue;
for (j = 0; j < 7; j++)
{
if (vboh[j] == vboh[i])
break; //already freed by one of the other ones
}
if (j == 7)
qglDeleteBuffersARB(1, &vboh[i]);
}
memset(vbo, 0, sizeof(*vbo));
}
qboolean GL_BuildVBO(vbo_t *vbo, void *vdata, int vsize, void *edata, int elementsize)
{
unsigned int vbos[2];
// if (!qglGenBuffersARB)
return false;
qglGenBuffersARB(2, vbos);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbos[0]);
qglBufferDataARB(GL_ARRAY_BUFFER_ARB, vsize, vdata, GL_STATIC_DRAW_ARB);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbos[1]);
qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, elementsize, edata, GL_STATIC_DRAW_ARB);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
if (qglGetError())
{
qglDeleteBuffersARB(2, vbos);
return false;
}
//opengl ate our data, fixup the vbo arrays to point to the vbo instead of the raw data
if (vbo->indicies)
{
vbo->vboe = vbos[1];
vbo->indicies = (index_t*)((char*)vbo->indicies - (char*)edata);
}
if (vbo->coord)
{
vbo->vbocoord = vbos[0];
vbo->coord = (vec3_t*)((char*)vbo->coord - (char*)vdata);
}
if (vbo->texcoord)
{
vbo->vbotexcoord = vbos[0];
vbo->texcoord = (vec2_t*)((char*)vbo->texcoord - (char*)vdata);
}
if (vbo->lmcoord)
{
vbo->vbolmcoord = vbos[0];
vbo->lmcoord = (vec2_t*)((char*)vbo->lmcoord - (char*)vdata);
}
if (vbo->normals)
{
vbo->vbonormals = vbos[0];
vbo->normals = (vec3_t*)((char*)vbo->normals - (char*)vdata);
}
if (vbo->svector)
{
vbo->vbosvector = vbos[0];
vbo->svector = (vec3_t*)((char*)vbo->svector - (char*)vdata);
}
if (vbo->tvector)
{
vbo->vbotvector = vbos[0];
vbo->tvector = (vec3_t*)((char*)vbo->tvector - (char*)vdata);
}
return true;
}
static void GL_GenBrushModelVBO(model_t *mod) static void GL_GenBrushModelVBO(model_t *mod)
{ {
unsigned int maxvboverts; unsigned int maxvboverts;
@ -2929,23 +3020,24 @@ static void GL_GenBrushModelVBO(model_t *mod)
unsigned int t; unsigned int t;
unsigned int i; unsigned int i;
unsigned int vbos[2];
unsigned int v; unsigned int v;
unsigned int vcount, ecount; unsigned int vcount, ecount;
vbovertex_t *vbovdata; unsigned int pervertsize; //erm, that name wasn't intentional
index_t *vboedata;
mesh_t *m;
if (!qglGenBuffersARB || !mod->numsurfaces) vbo_t *vbo;
char *vboedata;
mesh_t *m;
char *vbovdata;
if (!mod->numsurfaces)
return; return;
for (t = 0; t < mod->numtextures; t++) for (t = 0; t < mod->numtextures; t++)
{ {
if (!mod->textures[t]) if (!mod->textures[t])
continue; continue;
vbo = &mod->textures[t]->vbo;
mod->textures[t]->gl_vbov = 0; GL_ClearVBO(vbo);
mod->textures[t]->gl_vboe = 0;
maxvboverts = 0; maxvboverts = 0;
maxvboelements = 0; maxvboelements = 0;
@ -2964,13 +3056,27 @@ static void GL_GenBrushModelVBO(model_t *mod)
continue; continue;
//fixme: stop this from leaking! //fixme: stop this from leaking!
qglGenBuffersARB(2, vbos);
mod->textures[t]->gl_vbov = vbos[0];
mod->textures[t]->gl_vboe = vbos[1];
vcount = 0; vcount = 0;
ecount = 0; ecount = 0;
vbovdata = Hunk_TempAlloc(maxvboverts*sizeof(vbovertex_t));
vboedata = Hunk_TempAllocMore(maxvboelements*sizeof(index_t)); pervertsize = sizeof(vec3_t)+ //cord
sizeof(vec2_t)+ //tex
sizeof(vec2_t)+ //lm
sizeof(vec3_t)+ //normal
sizeof(vec3_t)+ //sdir
sizeof(vec3_t); //tdir
vbovdata = BZ_Malloc(maxvboverts*pervertsize);
vboedata = BZ_Malloc(maxvboelements*sizeof(index_t));
vbo->coord = (vec3_t*)(vbovdata);
vbo->texcoord = (vec2_t*)((char*)vbo->coord+maxvboverts*sizeof(*vbo->coord));
vbo->lmcoord = (vec2_t*)((char*)vbo->texcoord+maxvboverts*sizeof(*vbo->texcoord));
vbo->normals = (vec3_t*)((char*)vbo->lmcoord+maxvboverts*sizeof(*vbo->lmcoord));
vbo->svector = (vec3_t*)((char*)vbo->normals+maxvboverts*sizeof(*vbo->normals));
vbo->tvector = (vec3_t*)((char*)vbo->svector+maxvboverts*sizeof(*vbo->svector));
vbo->indicies = (index_t*)vboedata;
for (i=0 ; i<mod->numsurfaces ; i++) for (i=0 ; i<mod->numsurfaces ; i++)
{ {
if (mod->surfaces[i].texinfo->texture != mod->textures[t]) if (mod->surfaces[i].texinfo->texture != mod->textures[t])
@ -2980,31 +3086,41 @@ static void GL_GenBrushModelVBO(model_t *mod)
m->vbofirstvert = vcount; m->vbofirstvert = vcount;
m->vbofirstelement = ecount; m->vbofirstelement = ecount;
for (v = 0; v < m->numindexes; v++) for (v = 0; v < m->numindexes; v++)
vboedata[ecount++] = vcount + m->indexes[v]; vbo->indicies[ecount++] = vcount + m->indexes[v];
for (v = 0; v < m->numvertexes; v++) for (v = 0; v < m->numvertexes; v++)
{ {
vbovdata[vcount+v].coord[0] = m->xyz_array[v][0]; vbo->coord[vcount+v][0] = m->xyz_array[v][0];
vbovdata[vcount+v].coord[1] = m->xyz_array[v][1]; vbo->coord[vcount+v][1] = m->xyz_array[v][1];
vbovdata[vcount+v].coord[2] = m->xyz_array[v][2]; vbo->coord[vcount+v][2] = m->xyz_array[v][2];
if (m->st_array) if (m->st_array)
{ {
vbovdata[vcount+v].texcoord[0] = m->st_array[v][0]; vbo->texcoord[vcount+v][0] = m->st_array[v][0];
vbovdata[vcount+v].texcoord[1] = m->st_array[v][1]; vbo->texcoord[vcount+v][1] = m->st_array[v][1];
} }
if (m->lmst_array) if (m->lmst_array)
{ {
vbovdata[vcount+v].lmcoord[0] = m->lmst_array[v][0]; vbo->lmcoord[vcount+v][0] = m->lmst_array[v][0];
vbovdata[vcount+v].lmcoord[1] = m->lmst_array[v][1]; vbo->lmcoord[vcount+v][1] = m->lmst_array[v][1];
} }
vbo->normals[vcount+v][0] = m->normals_array[v][0];
vbo->normals[vcount+v][1] = m->normals_array[v][1];
vbo->normals[vcount+v][2] = m->normals_array[v][2];
vbo->svector[vcount+v][0] = m->snormals_array[v][0];
vbo->svector[vcount+v][1] = m->snormals_array[v][1];
vbo->svector[vcount+v][2] = m->snormals_array[v][2];
vbo->tvector[vcount+v][0] = m->tnormals_array[v][0];
vbo->tvector[vcount+v][1] = m->tnormals_array[v][1];
vbo->tvector[vcount+v][2] = m->tnormals_array[v][2];
} }
vcount += v; vcount += v;
} }
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, mod->textures[t]->gl_vbov);
qglBufferDataARB(GL_ARRAY_BUFFER_ARB, vcount*sizeof(vbovertex_t), vbovdata, GL_STATIC_DRAW_ARB); if (GL_BuildVBO(vbo, vbovdata, vcount*pervertsize, vboedata, ecount*sizeof(index_t)))
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); {
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mod->textures[t]->gl_vboe); BZ_Free(vbovdata);
qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ecount*sizeof(vboedata[0]), vboedata, GL_STATIC_DRAW_ARB); BZ_Free(vboedata);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); }
} }
} }

View file

@ -46,6 +46,9 @@ extern cvar_t vid_conautoscale;
// console size manipulation callbacks // console size manipulation callbacks
void GLVID_Console_Resize(void) void GLVID_Console_Resize(void)
{ {
#ifdef AVAIL_FREETYPE
extern struct font_s *conchar_font;
#endif
extern cvar_t vid_conwidth, vid_conheight; extern cvar_t vid_conwidth, vid_conheight;
int cwidth, cheight; int cwidth, cheight;
float xratio; float xratio;
@ -96,6 +99,12 @@ void GLVID_Console_Resize(void)
vid.recalc_refdef = true; vid.recalc_refdef = true;
Con_CheckResize(); Con_CheckResize();
#ifdef AVAIL_FREETYPE
if (conchar_font)
Font_Free(conchar_font);
conchar_font = Font_LoadFont(8*glheight/vid.height, "C:/Windows/Fonts/cour.ttf");
#endif
#ifdef PLUGINS #ifdef PLUGINS
Plug_ResChanged(); Plug_ResChanged();
#endif #endif

View file

@ -542,14 +542,62 @@ static void Shader_ProgramName ( shader_t *shader, shaderpass_t *pass, char **pt
token = Shader_ParseString ( ptr ); token = Shader_ParseString ( ptr );
return; return;
} }
token = *ptr;
while (*token == ' ' || *token == '\t' || *token == '\r')
token++;
if (*token == '\n')
{
int count;
token++;
while (*token == ' ' || *token == '\t')
token++;
if (*token != '{')
{
Con_Printf("shader \"%s\" missing program string\n", shader->name);
}
else
{
token++;
vert = frag = token;
for (count = 1; *token; token++)
{
if (*token == '}')
{
count--;
if (!count)
break;
}
else if (*token == '{')
count++;
}
*token = 0;
*ptr = token+1;
shader->programhandle = GLSlang_CreateProgram("", (char *)vert, (char *)frag);
frag = NULL;
vert = NULL;
return;
}
}
token = Shader_ParseString ( ptr ); token = Shader_ParseString ( ptr );
FS_LoadFile(token, &vert); FS_LoadFile(token, &vert);
token = Shader_ParseString ( ptr ); token = Shader_ParseString ( ptr );
if (!*token)
frag = vert;
else
FS_LoadFile(token, &frag); FS_LoadFile(token, &frag);
if (vert && frag) if (vert && frag)
shader->programhandle = GLSlang_CreateProgram("", (char *)vert, (char *)frag); shader->programhandle = GLSlang_CreateProgram("", (char *)vert, (char *)frag);
if (vert) if (vert)
{
if (frag == vert)
frag = NULL;
FS_FreeFile(vert); FS_FreeFile(vert);
}
if (frag) if (frag)
FS_FreeFile(frag); FS_FreeFile(frag);
} }
@ -1090,6 +1138,12 @@ static void Shaderpass_TcGen ( shader_t *shader, shaderpass_t *pass, char **ptr
pass->tcgen = TC_GEN_ENVIRONMENT; pass->tcgen = TC_GEN_ENVIRONMENT;
} else if ( !Q_stricmp (token, "vector") ) { } else if ( !Q_stricmp (token, "vector") ) {
pass->tcgen = TC_GEN_BASE; pass->tcgen = TC_GEN_BASE;
} else if ( !Q_stricmp (token, "normal") ) {
pass->tcgen = TC_GEN_NORMAL;
} else if ( !Q_stricmp (token, "svector") ) {
pass->tcgen = TC_GEN_SVECTOR;
} else if ( !Q_stricmp (token, "tvector") ) {
pass->tcgen = TC_GEN_TVECTOR;
} }
} }
static void Shaderpass_EnvMap ( shader_t *shader, shaderpass_t *pass, char **ptr ) //for alienarena static void Shaderpass_EnvMap ( shader_t *shader, shaderpass_t *pass, char **ptr ) //for alienarena
@ -1678,6 +1732,7 @@ void Shader_SetFeatures ( shader_t *s )
s->features |= MF_LMCOORDS; s->features |= MF_LMCOORDS;
break; break;
case TC_GEN_ENVIRONMENT: case TC_GEN_ENVIRONMENT:
case TC_GEN_NORMAL:
s->features |= MF_NORMALS; s->features |= MF_NORMALS;
break; break;
} }

View file

@ -63,6 +63,7 @@ void (APIENTRY *qglTexEnvf) (GLenum target, GLenum pname, GLfloat param);
void (APIENTRY *qglTexEnvfv) (GLenum target, GLenum pname, const GLfloat *param); void (APIENTRY *qglTexEnvfv) (GLenum target, GLenum pname, const GLfloat *param);
void (APIENTRY *qglTexEnvi) (GLenum target, GLenum pname, GLint param); void (APIENTRY *qglTexEnvi) (GLenum target, GLenum pname, GLint param);
void (APIENTRY *qglTexGeni) (GLenum coord, GLenum pname, GLint param); void (APIENTRY *qglTexGeni) (GLenum coord, GLenum pname, GLint param);
void (APIENTRY *qglTexGenfv) (GLenum coord, GLenum pname, const GLfloat *param);
void (APIENTRY *qglTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); void (APIENTRY *qglTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (APIENTRY *qglTexParameteri) (GLenum target, GLenum pname, GLint param); void (APIENTRY *qglTexParameteri) (GLenum target, GLenum pname, GLint param);
void (APIENTRY *qglTexParameterf) (GLenum target, GLenum pname, GLfloat param); void (APIENTRY *qglTexParameterf) (GLenum target, GLenum pname, GLfloat param);
@ -412,15 +413,27 @@ GLhandleARB GLSlang_CreateShader (char *precompilerconstants, char *shadersource
GLint compiled; GLint compiled;
char str[1024]; char str[1024];
char *prstrings[2]; char *prstrings[3];
if (!precompilerconstants) if (!precompilerconstants)
precompilerconstants = ""; precompilerconstants = "";
prstrings[0] = precompilerconstants; switch (shadertype)
prstrings[1] = shadersource; {
case GL_FRAGMENT_SHADER_ARB:
prstrings[0] = "#define FRAGMENT_SHADER\n";
break;
case GL_VERTEX_SHADER_ARB:
prstrings[0] = "#define VERTEX_SHADER\n";
break;
default:
prstrings[0] = "#define UNKNOWN_SHADER\n";
break;
}
prstrings[1] = precompilerconstants;
prstrings[2] = shadersource;
shader = qglCreateShaderObjectARB(shadertype); shader = qglCreateShaderObjectARB(shadertype);
qglShaderSourceARB(shader, 2, (const GLcharARB**)prstrings, NULL); qglShaderSourceARB(shader, 3, (const GLcharARB**)prstrings, NULL);
qglCompileShaderARB(shader); qglCompileShaderARB(shader);
qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled);
@ -553,6 +566,7 @@ void GL_Init(void *(*getglfunction) (char *name))
qglTexEnvfv = (void *)getglcore("glTexEnvfv"); qglTexEnvfv = (void *)getglcore("glTexEnvfv");
qglTexEnvi = (void *)getglcore("glTexEnvi"); qglTexEnvi = (void *)getglcore("glTexEnvi");
qglTexGeni = (void *)getglcore("glTexGeni"); qglTexGeni = (void *)getglcore("glTexGeni");
qglTexGenfv = (void *)getglcore("glTexGenfv");
qglTexImage2D = (void *)getglcore("glTexImage2D"); qglTexImage2D = (void *)getglcore("glTexImage2D");
qglTexParameteri = (void *)getglcore("glTexParameteri"); qglTexParameteri = (void *)getglcore("glTexParameteri");
qglTexParameterf = (void *)getglcore("glTexParameterf"); qglTexParameterf = (void *)getglcore("glTexParameterf");

View file

@ -1393,7 +1393,7 @@ void ClearAllStates (void)
// send an up event for each key, to make sure the server clears them all // send an up event for each key, to make sure the server clears them all
for (i=0 ; i<256 ; i++) for (i=0 ; i<256 ; i++)
{ {
Key_Event (i, false); Key_Event (i, 0, false);
} }
Key_ClearStates (); Key_ClearStates ();
@ -1521,17 +1521,26 @@ LONG WINAPI GLMainWndProc (
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), true); {
IN_TranslateKeyEvent(wParam, lParam, true);
}
break;
// case WM_UNICHAR:
case WM_DEADCHAR:
case WM_SYSDEADCHAR:
case WM_CHAR:
case WM_SYSCHAR:
// if (!vid_initializing)
// IN_TranslateKeyEvent(wParam, lParam, true);
break; break;
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), false); {
break; IN_TranslateKeyEvent(wParam, lParam, false);
}
case WM_SYSCHAR:
// keep Alt-Space from happening
break; break;
// this is complicated because Win32 seems to pack multiple mouse events into // this is complicated because Win32 seems to pack multiple mouse events into
@ -1595,13 +1604,13 @@ LONG WINAPI GLMainWndProc (
{ {
if ((short) HIWORD(wParam) > 0) if ((short) HIWORD(wParam) > 0)
{ {
Key_Event(K_MWHEELUP, true); Key_Event(K_MWHEELUP, 0, true);
Key_Event(K_MWHEELUP, false); Key_Event(K_MWHEELUP, 0, false);
} }
else else
{ {
Key_Event(K_MWHEELDOWN, true); Key_Event(K_MWHEELDOWN, 0, true);
Key_Event(K_MWHEELDOWN, false); Key_Event(K_MWHEELDOWN, 0, false);
} }
} }
break; break;

View file

@ -218,7 +218,7 @@ void GL_DrawSkyChain (msurface_t *s)
#ifdef D3DQUAKE #ifdef D3DQUAKE
static void R_DrawSkyBoxChain (msurface_t *s); static void R_DrawSkyBoxChain (msurface_t *s);
static void D3D7_DrawSkyChain (msurface_t *s) void D3D7_DrawSkyChain (msurface_t *s)
{ {
//msurface_t *fa; //msurface_t *fa;
@ -271,7 +271,7 @@ static void D3D7_DrawSkyChain (msurface_t *s)
D3D7_DrawSkySphere(s); D3D7_DrawSkySphere(s);
} }
static void D3D9_DrawSkyChain (msurface_t *s) void D3D9_DrawSkyChain (msurface_t *s)
{ {
//msurface_t *fa; //msurface_t *fa;

View file

@ -343,9 +343,7 @@ void R_AddSkySurface (msurface_t *fa);
#endif #endif
#ifdef D3DQUAKE #ifdef D3DQUAKE
void D3D7_DrawSkyChain (msurface_t *s); void D3D7_DrawSkyChain (msurface_t *s);
void D3D7_DrawSkySphere (msurface_t *fa);
void D3D9_DrawSkyChain (msurface_t *s); void D3D9_DrawSkyChain (msurface_t *s);
void D3D9_DrawSkySphere (msurface_t *fa);
#endif #endif
// //
@ -452,7 +450,7 @@ typedef struct {
//gl_ppl.c //gl_ppl.c
void PPL_DrawWorld (void); void PPL_DrawWorld (void);
qboolean PPL_ShouldDraw(void); qboolean PPL_ShouldDraw(void);
void RotateLightVector(vec3_t *angles, vec3_t origin, vec3_t lightpoint, vec3_t result); void RotateLightVector(const vec3_t *angles, const vec3_t origin, const vec3_t lightpoint, vec3_t result);
// //
// gl_refrag.c // gl_refrag.c
@ -932,4 +930,210 @@ extern vec3_t r_pright, r_pup, r_ppn;
extern float xscaleshrink, yscaleshrink; extern float xscaleshrink, yscaleshrink;
#endif #endif
/*
//opengl 3 deprecation
. Application-generated object names - the names of all object types, such as
buffer, query, and texture objects, must be generated using the corresponding
Gen* commands. Trying to bind an object name not returned by a Gen*
command will result in an INVALID OPERATION error. This behavior is
already the case for framebuffer, renderbuffer, and vertex array objects. Object
types which have default objects (objects named zero) , such as vertex
array, framebuffer, and texture objects, may also bind the default object, even
though it is not returned by Gen*.
. OpenGL Shading Language versions 1.10 and 1.20. These versions of the
shading language depend on many API features that have also been deprecated.
. Pixel transfer modes and operations - all pixel transfer modes, including
pixel maps, shift and bias, color table lookup, color matrix, and convolution
commands and state, and all associated state and commands defining
that state.
. Legacy OpenGL 1.0 pixel formats - the values 1, 2, 3, and 4 are no longer
accepted as internal formats by TexImage* or any other command taking
an internal format argument. The initial internal format of a texel array is
RGBA instead of 1.
. Texture borders - the border value to TexImage* must always be zero, or
an INVALID VALUE error is generated (section 3.8.1); all language in section
3.8 referring to nonzero border widths during texture image specification
and texture sampling; and all associated state.
GL_COLOR_INDEX
glBegin
glEnd
glEdgeFlag*;
glColor*,
glFogCoord*
glIndex*
glNormal3*
glSecondaryColor3*
glTexCoord*
glVertex*
glColorPointer
glEdgeFlagPointer
glFogCoordPointer
glIndexPointer
glNormalPointer
glSecondary-
glColorPointer,
glTexCoordPointer
glVertexPointer
glEnableClientState
glDisableClientState,
glInterleavedArrays
glClientActiveTexture
glFrustum,
glLoadIdentity
glLoadMatrix
glLoadTransposeMatrix
glMatrixMode,
glMultMatrix
glMultTransposeMatrix
glOrtho
glPopMatrix
glPushMatrix,
glRotate
glScale
glTranslate
GL_RESCALE_NORMAL
GL_NORMALIZE
glTexGen*
GL_TEXTURE_GEN_*,
Material*
glLight*
glLightModel*
glColorMaterial
glShadeModel
GL_LIGHTING
GL_VERTEX_PROGRAM_TWO_SIDE
GL_LIGHTi,
GL_COLOR_MATERIAL
glClipPlane
GL_CLAMP_VERTEX_COLOR
GL_CLAMP_FRAGMENT_COLOR
glRect*
glRasterPos*
glWindowPos*
GL_POINT_SMOOTH
GL_POINT_SPRITE
glLineStipple
GL_LINE_STIPPLE
GL_POLYGON
GL_QUADS
GL_QUAD_STRIP
glPolygonMode
glPolygonStipple
GL_POLYGON_STIPPLE
glDrawPixels
glPixelZoom
glBitmap
GL_BITMAP
GL_TEXTURE_COMPONENTS
GL_ALPHA
GL_LUMINANCE
GL_LUMINANCE_ALPHA
GL_INTENSITY
GL_DEPTH_TEXTURE_MODE
GL_CLAMP
GL_GENERATE_MIPMAP
glAreTexturesResident
glPrioritizeTextures,
GL_TEXTURE_PRIORITY
GL_TEXTURE_ENV
GL_TEXTURE_FILTER_CONTROL
GL_TEXTURE_LOD_BIAS
GL_TEXTURE_1D
GL_TEXTURE_2D,
GL_TEXTURE_3D
GL_TEXTURE_1D_ARRAY
GL_TEXTURE_2D_ARRAY
GL_TEXTURE_CUBE_MAP
GL_COLOR_SUM
GL_FOG
glFog
GL_MAX_TEXTURE_UNITS
GL_MAX_TEXTURE_COORDS
glAlphaFunc
GL_ALPHA_TEST
glClearAccum
GL_ACCUM_BUFFER_BIT
glCopyPixels
GL_AUX0
GL_RED_BITS
GL_GREEN_BITS
GL_BLUE_BITS
GL_ALPHA_BITS
GL_DEPTH_BITS
STENCIL BITS
glMap*
glEvalCoord*
glMapGrid*
glEvalMesh*
glEvalPoint*
glRenderMode
glInitNames
glPopName
glPushName
glLoadName
glSelectBuffer
glFeedbackBuffer
glPassThrough
glNewList
glEndList
glCallList
glCallLists
glListBase
glGenLists,
glIsList
glDeleteLists
GL_PERSPECTIVE_CORRECTION_HINT
GL_POINT_SMOOTH_HINT,
GL_FOG_HINT
GL_GENERATE_MIPMAP_HINT
glPushAttrib
glPushClientAttrib
glPopAttrib
glPopClientAttrib,
GL_MAX_ATTRIB_STACK_DEPTH,
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
GL_ATTRIB_STACK_DEPTH
GL_CLIENT_ATTRIB_STACK_DEPTH
GL_ALL_ATTRIB_BITS
GL_CLIENT_ALL_ATTRIB_BITS.
GL_EXTENSIONS
*/
#endif #endif

View file

@ -99,10 +99,24 @@ extern qlpMTex2FUNC qglMultiTexCoord2fARB;
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
#endif #endif
#ifndef GL_ARB_depth_texture
#define GL_ARB_depth_texture
#define GL_DEPTH_COMPONENT16_ARB 0x81A5
#define GL_DEPTH_COMPONENT24_ARB 0x81A6
#define GL_DEPTH_COMPONENT32_ARB 0x81A7
#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
#endif
#ifndef GL_ARB_shadow
#define GL_ARB_shadow
#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
#endif
#ifndef GL_EXT_texture3D #ifndef GL_EXT_texture3D
#define define GL_EXT_texture3D 1 #define GL_EXT_texture3D 1
#define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_SKIP_IMAGES 0x806B
#define GL_PACK_SKIP_IMAGES_EXT 0x806B #define GL_PACK_SKIP_IMAGES_EXT 0x806B
#define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_PACK_IMAGE_HEIGHT 0x806C

View file

@ -130,7 +130,12 @@ typedef struct shaderpass_s {
TC_GEN_LIGHTMAP, //use loaded lightmap coords TC_GEN_LIGHTMAP, //use loaded lightmap coords
TC_GEN_ENVIRONMENT, TC_GEN_ENVIRONMENT,
TC_GEN_DOTPRODUCT, TC_GEN_DOTPRODUCT,
TC_GEN_VECTOR TC_GEN_VECTOR,
//these are really for use only in glsl stuff.
TC_GEN_NORMAL,
TC_GEN_SVECTOR,
TC_GEN_TVECTOR,
} tcgen; } tcgen;
enum { enum {
RGB_GEN_WAVE, RGB_GEN_WAVE,

View file

@ -1355,7 +1355,7 @@ void SV_WritePlayerToClient(sizebuf_t *msg, clstate_t *ent)
#endif #endif
#ifdef PEXT_FATNESS #ifdef PEXT_FATNESS
if (pflags & PF_FATNESS_Z) if (pflags & PF_FATNESS_Z)
MSG_WriteChar (msg, ent->fatness*2); MSG_WriteChar (msg, ent->fatness*10);
#endif #endif
#ifdef PEXT_HULLSIZE //shrunken or crouching in halflife levels. (possibly enlarged) #ifdef PEXT_HULLSIZE //shrunken or crouching in halflife levels. (possibly enlarged)
if (pflags & PF_HULLSIZE_Z) if (pflags & PF_HULLSIZE_Z)
@ -2332,7 +2332,7 @@ void SV_Snapshot_BuildStateQ1(entity_state_t *state, edict_t *ent, client_t *cli
} }
#endif #endif
#ifdef PEXT_FATNESS #ifdef PEXT_FATNESS
state->fatness = ent->xv->fatness*2; state->fatness = ent->xv->fatness*16;
#endif #endif
} }

View file

@ -268,7 +268,7 @@ void SV_EdictToEntState (int num, edict_t *ent, entity_state_t *state)
else else
state->scale = ent->xv->scale*16; state->scale = ent->xv->scale*16;
state->fatness = ent->xv->fatness*2; state->fatness = ent->xv->fatness*16;
} }
void SVNQ_CreateBaseline (void) void SVNQ_CreateBaseline (void)

View file

@ -3770,6 +3770,9 @@ void Master_Heartbeat (void)
} }
else else
{ {
if (sv_masterlist[i].adr.type == NA_TCP || sv_masterlist[i].adr.type == NA_TCPV6)
NET_EnsureRoute(svs.sockets, sv_masterlist[i].cv.name, sv_masterlist[i].cv.string, false);
//choose default port //choose default port
switch (sv_masterlist[i].protocol) switch (sv_masterlist[i].protocol)
{ {

View file

@ -3781,6 +3781,7 @@ void Cmd_FPSList_f(void)
frames = 0; frames = 0;
inbytes = 0; inbytes = 0;
outbytes = 0; outbytes = 0;
msecs = 0;
if (!cl->state) if (!cl->state)
continue; continue;

View file

@ -383,13 +383,13 @@ LONG WINAPI MainWndProc (
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), true); IN_TranslateKeyEvent(wParam, lParam, true);
break; break;
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
if (!vid_initializing) if (!vid_initializing)
Key_Event (MapKey(lParam), false); IN_TranslateKeyEvent(wParam, lParam, false);
break; break;
// this is complicated because Win32 seems to pack multiple mouse events into // this is complicated because Win32 seems to pack multiple mouse events into
@ -446,11 +446,11 @@ LONG WINAPI MainWndProc (
// Event. // Event.
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
if ((short) HIWORD(wParam) > 0) { if ((short) HIWORD(wParam) > 0) {
Key_Event(K_MWHEELUP, true); Key_Event(K_MWHEELUP, 0, true);
Key_Event(K_MWHEELUP, false); Key_Event(K_MWHEELUP, 0, false);
} else { } else {
Key_Event(K_MWHEELDOWN, true); Key_Event(K_MWHEELDOWN, 0, true);
Key_Event(K_MWHEELDOWN, false); Key_Event(K_MWHEELDOWN, 0, false);
} }
break; break;
case WM_INPUT: case WM_INPUT:
@ -953,7 +953,6 @@ void SWVID_Shutdown (void)
void SWVID_Update (vrect_t *rects) //end frame... void SWVID_Update (vrect_t *rects) //end frame...
{ {
extern qboolean mouseactive; extern qboolean mouseactive;
qboolean mouse;
#ifdef MGL #ifdef MGL
if (usingmgl) if (usingmgl)
{ {