Merge branch 'next' into video-refactor

This commit is contained in:
Jaime Passos 2020-07-16 22:09:42 -03:00
commit b4bc5da00a
55 changed files with 1679 additions and 1094 deletions

View file

@ -472,7 +472,6 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glide.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h

View file

@ -647,7 +647,7 @@ ifdef SDL
ifdef MINGW
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
command.h hardware/hw_data.h hardware/hw_defs.h \
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
@ -656,7 +656,7 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
else
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
command.h hardware/hw_data.h hardware/hw_defs.h \
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
@ -734,7 +734,7 @@ ifndef SDL
ifndef NOHW
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
command.h hardware/hw_data.h hardware/hw_defs.h \
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
@ -743,7 +743,7 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
$(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
command.h hardware/hw_data.h hardware/hw_defs.h \
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \

View file

@ -150,15 +150,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
#undef DEALIGNED
#define WRITESTRINGN(p,s,n) { size_t tmp_i = 0; for (; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); if (tmp_i < n) WRITECHAR(p, '\0');}
#define WRITESTRING(p,s) { size_t tmp_i = 0; for (; s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); WRITECHAR(p, '\0');}
#define WRITEMEM(p,s,n) { memcpy(p, s, n); p += n; }
#define WRITESTRINGN(p,s,n) do { size_t tmp_i = 0; for (; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); if (tmp_i < n) WRITECHAR(p, '\0');} while (0)
#define WRITESTRING(p,s) do { size_t tmp_i = 0; for (; s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); WRITECHAR(p, '\0');} while (0)
#define WRITEMEM(p,s,n) do { memcpy(p, s, n); p += n; } while (0)
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
#define READSTRINGN(p,s,n) { size_t tmp_i = 0; for (; tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';}
#define READSTRING(p,s) { size_t tmp_i = 0; for (; (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';}
#define READMEM(p,s,n) { memcpy(s, p, n); p += n; }
#define READSTRINGN(p,s,n) ({ size_t tmp_i = 0; for (; tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';})
#define READSTRING(p,s) ({ size_t tmp_i = 0; for (; (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';})
#define READMEM(p,s,n) ({ memcpy(s, p, n); p += n; })
#if 0 // old names
#define WRITEBYTE(p,b) WRITEUINT8(p,b)

View file

@ -33,6 +33,7 @@
#include "p_setup.h"
#include "lua_script.h"
#include "d_netfil.h" // findfile
#include "r_data.h" // Color_cons_t
//========
// protos.
@ -56,7 +57,13 @@ static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr);
static boolean CV_Command(void);
consvar_t *CV_FindVar(const char *name);
static const char *CV_StringValue(const char *var_name);
static consvar_t *consvar_vars; // list of registered console variables
static UINT16 consvar_number_of_netids = 0;
#ifdef OLD22DEMOCOMPAT
static old_demo_var_t *consvar_old_demo_vars;
#endif
static char com_token[1024];
static char *COM_Parse(char *data);
@ -620,7 +627,7 @@ static void COM_ExecuteString(char *ptext)
// check cvars
// Hurdler: added at Ebola's request ;)
// (don't flood the console in software mode with bad gr_xxx command)
// (don't flood the console in software mode with bad gl_xxx command)
if (!CV_Command() && con_destlines)
CONS_Printf(M_GetText("Unknown command '%s'\n"), COM_Argv(0));
}
@ -812,6 +819,18 @@ static void COM_Help_f(void)
CONS_Printf(" Yes or No (On or Off, 1 or 0)\n");
else if (cvar->PossibleValue == CV_OnOff)
CONS_Printf(" On or Off (Yes or No, 1 or 0)\n");
else if (cvar->PossibleValue == Color_cons_t)
{
for (i = 1; i < numskincolors; ++i)
{
if (skincolors[i].accessible)
{
CONS_Printf(" %-2d : %s\n", i, skincolors[i].name);
if (i == cvar->value)
cvalue = skincolors[i].name;
}
}
}
else
{
#define MINVAL 0
@ -1121,14 +1140,16 @@ consvar_t *CV_FindVar(const char *name)
return NULL;
}
/** Builds a unique Net Variable identifier number, which is used
* in network packets instead of the full name.
#ifdef OLD22DEMOCOMPAT
/** Builds a unique Net Variable identifier number, which was used
* in network packets and demos instead of the full name.
*
* This function only still exists to keep compatibility with old demos.
*
* \param s Name of the variable.
* \return A new unique identifier.
* \sa CV_FindNetVar
*/
static inline UINT16 CV_ComputeNetid(const char *s)
static inline UINT16 CV_ComputeOldDemoID(const char *s)
{
UINT16 ret = 0, i = 0;
static UINT16 premiers[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
@ -1142,16 +1163,47 @@ static inline UINT16 CV_ComputeNetid(const char *s)
return ret;
}
/** Finds a net variable based on its old style hash. If a hash collides, a
* warning is printed and this function returns NULL.
*
* \param chk The variable's old style hash.
* \return A pointer to the variable itself if found, or NULL.
*/
static old_demo_var_t *CV_FindOldDemoVar(UINT16 chk)
{
old_demo_var_t *demovar;
for (demovar = consvar_old_demo_vars; demovar; demovar = demovar->next)
{
if (demovar->checksum == chk)
{
if (demovar->collides)
{
CONS_Alert(CONS_WARNING,
"Old demo netvar id %hu is a collision\n", chk);
return NULL;
}
return demovar;
}
}
return NULL;
}
#endif/*OLD22DEMOCOMPAT*/
/** Finds a net variable based on its identifier number.
*
* \param netid The variable's identifier number.
* \return A pointer to the variable itself if found, or NULL.
* \sa CV_ComputeNetid
*/
static consvar_t *CV_FindNetVar(UINT16 netid)
{
consvar_t *cvar;
if (netid >= consvar_number_of_netids)
return NULL;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
if (cvar->netid == netid)
return cvar;
@ -1161,6 +1213,32 @@ static consvar_t *CV_FindNetVar(UINT16 netid)
static void Setvalue(consvar_t *var, const char *valstr, boolean stealth);
#ifdef OLD22DEMOCOMPAT
/* Sets up a netvar for compatibility with old demos. */
static void CV_RegisterOldDemoVar(consvar_t *variable)
{
old_demo_var_t *demovar;
UINT16 old_demo_id;
old_demo_id = CV_ComputeOldDemoID(variable->name);
demovar = CV_FindOldDemoVar(old_demo_id);
if (demovar)
demovar->collides = true;
else
{
demovar = ZZ_Calloc(sizeof *demovar);
demovar->checksum = old_demo_id;
demovar->cvar = variable;
demovar->next = consvar_old_demo_vars;
consvar_old_demo_vars = demovar;
}
}
#endif
/** Registers a variable for later use from the console.
*
* \param variable The variable to register.
@ -1184,11 +1262,15 @@ void CV_RegisterVar(consvar_t *variable)
// check net variables
if (variable->flags & CV_NETVAR)
{
const consvar_t *netvar;
variable->netid = CV_ComputeNetid(variable->name);
netvar = CV_FindNetVar(variable->netid);
if (netvar)
I_Error("Variables %s and %s have same netid\n", variable->name, netvar->name);
variable->netid = consvar_number_of_netids++;
/* in case of overflow... */
if (variable->netid > consvar_number_of_netids)
I_Error("Way too many netvars");
#ifdef OLD22DEMOCOMPAT
CV_RegisterOldDemoVar(variable);
#endif
}
// link the variable in
@ -1448,12 +1530,100 @@ badinput:
static boolean serverloading = false;
static consvar_t *
ReadNetVar (UINT8 **p, char **return_value, boolean *return_stealth)
{
UINT16 netid;
char *val;
boolean stealth;
consvar_t *cvar;
netid = READUINT16 (*p);
val = (char *)*p;
SKIPSTRING (*p);
stealth = READUINT8 (*p);
cvar = CV_FindNetVar(netid);
if (cvar)
{
(*return_value) = val;
(*return_stealth) = stealth;
DEBFILE(va("Netvar received: %s [netid=%d] value %s\n", cvar->name, netid, val));
}
else
CONS_Alert(CONS_WARNING, "Netvar not found with netid %hu\n", netid);
return cvar;
}
#ifdef OLD22DEMOCOMPAT
static consvar_t *
ReadOldDemoVar (UINT8 **p, char **return_value, boolean *return_stealth)
{
UINT16 id;
char *val;
boolean stealth;
old_demo_var_t *demovar;
id = READUINT16 (*p);
val = (char *)*p;
SKIPSTRING (*p);
stealth = READUINT8 (*p);
demovar = CV_FindOldDemoVar(id);
if (demovar)
{
(*return_value) = val;
(*return_stealth) = stealth;
return demovar->cvar;
}
else
{
CONS_Alert(CONS_WARNING, "Netvar not found with old demo id %hu\n", id);
return NULL;
}
}
#endif/*OLD22DEMOCOMPAT*/
static consvar_t *
ReadDemoVar (UINT8 **p, char **return_value, boolean *return_stealth)
{
char *name;
char *val;
boolean stealth;
consvar_t *cvar;
name = (char *)*p;
SKIPSTRING (*p);
val = (char *)*p;
SKIPSTRING (*p);
stealth = READUINT8 (*p);
cvar = CV_FindVar(name);
if (cvar)
{
(*return_value) = val;
(*return_stealth) = stealth;
}
else
CONS_Alert(CONS_WARNING, "Netvar not found with name %s\n", name);
return cvar;
}
static void Got_NetVar(UINT8 **p, INT32 playernum)
{
consvar_t *cvar;
UINT16 netid;
char *svalue;
UINT8 stealth = false;
boolean stealth;
if (playernum != serverplayer && !IsPlayerAdmin(playernum) && !serverloading)
{
@ -1463,23 +1633,14 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY);
return;
}
netid = READUINT16(*p);
cvar = CV_FindNetVar(netid);
svalue = (char *)*p;
SKIPSTRING(*p);
stealth = READUINT8(*p);
if (!cvar)
{
CONS_Alert(CONS_WARNING, "Netvar not found with netid %hu\n", netid);
return;
}
DEBFILE(va("Netvar received: %s [netid=%d] value %s\n", cvar->name, netid, svalue));
cvar = ReadNetVar(p, &svalue, &stealth);
if (cvar)
Setvalue(cvar, svalue, stealth);
}
void CV_SaveNetVars(UINT8 **p)
void CV_SaveVars(UINT8 **p, boolean in_demo)
{
consvar_t *cvar;
UINT8 *count_p = *p;
@ -1491,6 +1652,9 @@ void CV_SaveNetVars(UINT8 **p)
for (cvar = consvar_vars; cvar; cvar = cvar->next)
if ((cvar->flags & CV_NETVAR) && !CV_IsSetToDefault(cvar))
{
if (in_demo)
WRITESTRING(*p, cvar->name);
else
WRITEUINT16(*p, cvar->netid);
WRITESTRING(*p, cvar->string);
WRITEUINT8(*p, false);
@ -1499,11 +1663,15 @@ void CV_SaveNetVars(UINT8 **p)
WRITEUINT16(count_p, count);
}
void CV_LoadNetVars(UINT8 **p)
static void CV_LoadVars(UINT8 **p,
consvar_t *(*got)(UINT8 **p, char **ret_value, boolean *ret_stealth))
{
consvar_t *cvar;
UINT16 count;
char *val;
boolean stealth;
// prevent "invalid command received"
serverloading = true;
@ -1513,11 +1681,33 @@ void CV_LoadNetVars(UINT8 **p)
count = READUINT16(*p);
while (count--)
Got_NetVar(p, 0);
{
cvar = (*got)(p, &val, &stealth);
if (cvar)
Setvalue(cvar, val, stealth);
}
serverloading = false;
}
void CV_LoadNetVars(UINT8 **p)
{
CV_LoadVars(p, ReadNetVar);
}
#ifdef OLD22DEMOCOMPAT
void CV_LoadOldDemoVars(UINT8 **p)
{
CV_LoadVars(p, ReadOldDemoVar);
}
#endif
void CV_LoadDemoVars(UINT8 **p)
{
CV_LoadVars(p, ReadDemoVar);
}
static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth);
void CV_ResetCheatNetVars(void)

View file

@ -144,6 +144,19 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL
struct consvar_s *next;
} consvar_t;
#ifdef OLD22DEMOCOMPAT
typedef struct old_demo_var old_demo_var_t;
struct old_demo_var
{
UINT16 checksum;
boolean collides;/* this var is a collision of multiple hashes */
consvar_t *cvar;
old_demo_var_t *next;
};
#endif/*OLD22DEMOCOMPAT*/
extern CV_PossibleValue_t CV_OnOff[];
extern CV_PossibleValue_t CV_YesNo[];
extern CV_PossibleValue_t CV_Unsigned[];
@ -184,9 +197,18 @@ void CV_AddValue(consvar_t *var, INT32 increment);
void CV_SaveVariables(FILE *f);
// load/save gamesate (load and save option and for network join in game)
void CV_SaveNetVars(UINT8 **p);
void CV_SaveVars(UINT8 **p, boolean in_demo);
#define CV_SaveNetVars(p) CV_SaveVars(p, false)
void CV_LoadNetVars(UINT8 **p);
#define CV_SaveDemoVars(p) CV_SaveVars(p, true)
void CV_LoadDemoVars(UINT8 **p);
#ifdef OLD22DEMOCOMPAT
void CV_LoadOldDemoVars(UINT8 **p);
#endif
// reset cheat netvars after cheats is deactivated
void CV_ResetCheatNetVars(void);

View file

@ -602,7 +602,7 @@ static void D_Display(void)
V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor);
V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s);
if (cv_grbatching.value)
if (cv_glbatching.value)
{
snprintf(s, sizeof s - 1, "bsrt %d", rs_hw_batchsorttime / divisor);
V_DrawThinString(80, 55, V_MONOSPACE | V_REDMAP, s);

View file

@ -806,8 +806,41 @@ static void readskincolor(MYFILE *f, INT32 num)
if (fastcmp(word, "NAME"))
{
deh_strlcpy(skincolors[num].name, word2,
sizeof (skincolors[num].name), va("Skincolor %d: name", num));
size_t namesize = sizeof(skincolors[num].name);
char truncword[namesize];
deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes
if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword)))
{
size_t lastchar = strlen(truncword);
char oldword[lastchar+1];
char dupenum = '1';
strlcpy(oldword, truncword, lastchar+1);
lastchar--;
if (lastchar == namesize-2) // exactly max length, replace last character with 0
truncword[lastchar] = '0';
else // append 0
{
strcat(truncword, "0");
lastchar++;
}
while (R_GetColorByName(truncword))
{
truncword[lastchar] = dupenum;
if (dupenum == '9')
dupenum = 'A';
else if (dupenum == 'Z') // give up :?
break;
else
dupenum++;
}
deh_warning("Skincolor %d: name %s is a duplicate of another skincolor's name - renamed to %s", num, oldword, truncword);
}
strlcpy(skincolors[num].name, truncword, namesize); // already truncated
}
else if (fastcmp(word, "RAMP"))
{
@ -821,7 +854,11 @@ static void readskincolor(MYFILE *f, INT32 num)
}
else if (fastcmp(word, "INVCOLOR"))
{
skincolors[num].invcolor = (UINT16)get_number(word2);
UINT16 v = (UINT16)get_number(word2);
if (v < numskincolors)
skincolors[num].invcolor = v;
else
skincolors[num].invcolor = SKINCOLOR_GREEN;
}
else if (fastcmp(word, "INVSHADE"))
{
@ -10627,7 +10664,7 @@ static inline int lib_freeslot(lua_State *L)
CONS_Printf("State S_%s allocated.\n",word);
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_STATES[i],word);
lua_pushinteger(L, i);
lua_pushinteger(L, S_FIRSTFREESLOT + i);
r++;
break;
}
@ -10642,7 +10679,7 @@ static inline int lib_freeslot(lua_State *L)
CONS_Printf("MobjType MT_%s allocated.\n",word);
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_MOBJS[i],word);
lua_pushinteger(L, i);
lua_pushinteger(L, MT_FIRSTFREESLOT + i);
r++;
break;
}
@ -10658,7 +10695,7 @@ static inline int lib_freeslot(lua_State *L)
FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_SKINCOLORS[i],word);
M_AddMenuColor(numskincolors++);
lua_pushinteger(L, i);
lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT + i);
r++;
break;
}
@ -10679,11 +10716,12 @@ static inline int lib_freeslot(lua_State *L)
CONS_Printf("Sprite SPR2_%s allocated.\n",word);
strncpy(spr2names[free_spr2],word,4);
spr2defaults[free_spr2] = 0;
lua_pushinteger(L, free_spr2);
r++;
spr2names[free_spr2++][4] = 0;
} else
CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n");
}
r++;
}
else if (fastcmp(type, "TOL"))
{

View file

@ -643,4 +643,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Render flats on walls
#define WALLFLATS
/// Maintain compatibility with older 2.2 demos
#define OLD22DEMOCOMPAT
#endif // __DOOMDEF__

View file

@ -1684,7 +1684,7 @@ void F_GameEvaluationDrawer(void)
endingtext = va("%s & %s, %s%s", skins[players[consoleplayer].skin].realname, skins[botskin-1].realname, rtatext, cuttext);
else
endingtext = va("%s, %s%s", skins[players[consoleplayer].skin].realname, rtatext, cuttext);
V_DrawCenteredString(BASEVIDWIDTH/2, 182, (ultimatemode ? V_REDMAP : V_YELLOWMAP), endingtext);
V_DrawCenteredString(BASEVIDWIDTH/2, 182, V_SNAPTOBOTTOM|(ultimatemode ? V_REDMAP : V_YELLOWMAP), endingtext);
}
}

View file

@ -1525,7 +1525,7 @@ void G_BeginRecording(void)
}
// Save netvar data
CV_SaveNetVars(&demo_p);
CV_SaveDemoVars(&demo_p);
memset(&oldcmd,0,sizeof(oldcmd));
memset(&oldghost,0,sizeof(oldghost));
@ -1756,6 +1756,9 @@ void G_DoPlayDemo(char *defdemoname)
UINT32 randseed, followitem;
fixed_t camerascale,shieldscale,actionspd,mindash,maxdash,normalspeed,runspeed,jumpfactor,height,spinheight;
char msg[1024];
#ifdef OLD22DEMOCOMPAT
boolean use_old_demo_vars = false;
#endif
skin[16] = '\0';
color[MAXCOLORNAME] = '\0';
@ -1818,10 +1821,13 @@ void G_DoPlayDemo(char *defdemoname)
case DEMOVERSION: // latest always supported
cnamelen = MAXCOLORNAME;
break;
#ifdef OLD22DEMOCOMPAT
// all that changed between then and now was longer color name
case 0x000c:
cnamelen = 16;
use_old_demo_vars = true;
break;
#endif
// too old, cannot support.
default:
snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname);
@ -1923,7 +1929,13 @@ void G_DoPlayDemo(char *defdemoname)
}
// net var data
CV_LoadNetVars(&demo_p);
#ifdef OLD22DEMOCOMPAT
if (use_old_demo_vars)
CV_LoadOldDemoVars(&demo_p);
else
#else
CV_LoadDemoVars(&demo_p);
#endif
// Sigh ... it's an empty demo.
if (*demo_p == DEMOMARKER)

View file

@ -4505,7 +4505,7 @@ void G_SaveGame(UINT32 slot, INT16 mapnum)
{
UINT32 writetime = marathontime;
if (!(marathonmode & MA_INGAME))
marathontime += TICRATE*5; // live event backup penalty because we don't know how long it takes to get to the next map
writetime += TICRATE*5; // live event backup penalty because we don't know how long it takes to get to the next map
WRITEUINT32(save_p, writetime);
WRITEUINT8(save_p, (marathonmode & ~MA_INIT));
}

View file

@ -250,7 +250,7 @@ void HWR_RenderBatches(void)
// sort polygons
rs_hw_batchsorttime = I_GetTimeMicros();
if (cv_grshaders.value && gr_shadersavailable)
if (cv_glshaders.value && gl_shadersavailable)
qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons);
else
qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders);
@ -273,7 +273,7 @@ void HWR_RenderBatches(void)
// set state for first batch
if (cv_grshaders.value && gr_shadersavailable)
if (cv_glshaders.value && gl_shadersavailable)
{
HWD.pfnSetShader(currentShader);
}
@ -355,7 +355,7 @@ void HWR_RenderBatches(void)
nextSurfaceInfo = polygonArray[nextIndex].surf;
if (nextPolyFlags & PF_NoTexture)
nextTexture = 0;
if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable)
if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable)
{
changeState = true;
changeShader = true;
@ -370,7 +370,7 @@ void HWR_RenderBatches(void)
changeState = true;
changePolyFlags = true;
}
if (cv_grshaders.value && gr_shadersavailable)
if (cv_glshaders.value && gl_shadersavailable)
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||

View file

@ -61,17 +61,17 @@ static INT32 totalsubsecpolys = 0;
/// \todo check out how much is used
static size_t POLYPOOLSIZE = 1024000;
static UINT8 *gr_polypool = NULL;
static UINT8 *gr_ppcurrent;
static size_t gr_ppfree;
static UINT8 *gl_polypool = NULL;
static UINT8 *gl_ppcurrent;
static size_t gl_ppfree;
#endif
// only between levels, clear poly pool
static void HWR_ClearPolys(void)
{
#ifndef ZPLANALLOC
gr_ppcurrent = gr_polypool;
gr_ppfree = POLYPOOLSIZE;
gl_ppcurrent = gl_polypool;
gl_ppfree = POLYPOOLSIZE;
#endif
}
@ -86,8 +86,8 @@ void HWR_InitPolyPool(void)
POLYPOOLSIZE = atoi(myargv[pnum+1])*1024; // (in kb)
CONS_Debug(DBG_RENDER, "HWR_InitPolyPool(): allocating %d bytes\n", POLYPOOLSIZE);
gr_polypool = malloc(POLYPOOLSIZE);
if (!gr_polypool)
gl_polypool = malloc(POLYPOOLSIZE);
if (!gl_polypool)
I_Error("HWR_InitPolyPool(): couldn't malloc polypool\n");
HWR_ClearPolys();
#endif
@ -96,9 +96,9 @@ void HWR_InitPolyPool(void)
void HWR_FreePolyPool(void)
{
#ifndef ZPLANALLOC
if (gr_polypool)
free(gr_polypool);
gr_polypool = NULL;
if (gl_polypool)
free(gl_polypool);
gl_polypool = NULL;
#endif
}
@ -110,19 +110,19 @@ static poly_t *HWR_AllocPoly(INT32 numpts)
p = Z_Malloc(size, PU_HWRPLANE, NULL);
#else
#ifdef PARANOIA
if (!gr_polypool)
I_Error("Used gr_polypool without init!\n");
if (!gr_ppcurrent)
I_Error("gr_ppcurrent == NULL!\n");
if (!gl_polypool)
I_Error("Used gl_polypool without init!\n");
if (!gl_ppcurrent)
I_Error("gl_ppcurrent == NULL!\n");
#endif
if (gr_ppfree < size)
if (gl_ppfree < size)
I_Error("HWR_AllocPoly(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
gr_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
gl_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
p = (poly_t *)gr_ppcurrent;
gr_ppcurrent += size;
gr_ppfree -= size;
p = (poly_t *)gl_ppcurrent;
gl_ppcurrent += size;
gl_ppfree -= size;
#endif
p->numpts = numpts;
return p;
@ -135,13 +135,13 @@ static polyvertex_t *HWR_AllocVertex(void)
#ifdef ZPLANALLOC
p = Z_Malloc(size, PU_HWRPLANE, NULL);
#else
if (gr_ppfree < size)
if (gl_ppfree < size)
I_Error("HWR_AllocVertex(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
gr_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
gl_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
p = (polyvertex_t *)gr_ppcurrent;
gr_ppcurrent += size;
gr_ppfree -= size;
p = (polyvertex_t *)gl_ppcurrent;
gl_ppcurrent += size;
gl_ppfree -= size;
#endif
return p;
}
@ -829,7 +829,7 @@ static INT32 SolveTProblem(void)
INT32 i;
size_t l;
if (cv_grsolvetjoin.value == 0)
if (cv_glsolvetjoin.value == 0)
return 0;
CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n");
@ -983,9 +983,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors));
// allocate table for back to front drawing of subsectors
/*gr_drawsubsectors = (INT16 *)malloc(sizeof (*gr_drawsubsectors) * totsubsectors);
if (!gr_drawsubsectors)
I_Error("couldn't malloc gr_drawsubsectors\n");*/
/*gl_drawsubsectors = (INT16 *)malloc(sizeof (*gl_drawsubsectors) * totsubsectors);
if (!gl_drawsubsectors)
I_Error("couldn't malloc gl_drawsubsectors\n");*/
// number of the first new subsector that might be added
addsubsector = numsubsectors;

View file

@ -27,27 +27,18 @@
#include "../r_patch.h"
#include "../p_setup.h"
INT32 patchformat = GR_TEXFMT_AP_88; // use alpha for holes
INT32 textureformat = GR_TEXFMT_P_8; // use chromakey for hole
INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes
INT32 textureformat = GL_TEXFMT_P_8; // use chromakey for hole
static const INT32 format2bpp[16] =
static INT32 format2bpp(GLTextureFormat_t format)
{
0, //0
0, //1
1, //2 GR_TEXFMT_ALPHA_8
1, //3 GR_TEXFMT_INTENSITY_8
1, //4 GR_TEXFMT_ALPHA_INTENSITY_44
1, //5 GR_TEXFMT_P_8
4, //6 GR_RGBA
0, //7
0, //8
0, //9
2, //10 GR_TEXFMT_RGB_565
2, //11 GR_TEXFMT_ARGB_1555
2, //12 GR_TEXFMT_ARGB_4444
2, //13 GR_TEXFMT_ALPHA_INTENSITY_88
2, //14 GR_TEXFMT_AP_88
};
if (format == GL_TEXFMT_RGBA)
return 4;
else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88)
return 2;
else
return 1;
}
// This code was originally placed directly in HWR_DrawPatchInCache.
// It is now split from it for my sanity! (and the sanity of others)
@ -126,7 +117,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
{
case 2 : // uhhhhhhhh..........
if ((originPatch != NULL) && (originPatch->style != AST_COPY))
texel = ASTBlendPixel_8bpp(*(dest+1), texel, originPatch->style, originPatch->alpha);
texel = ASTBlendPaletteIndexes(*(dest+1), texel, originPatch->style, originPatch->alpha);
texelu16 = (UINT16)((alpha<<8) | texel);
memcpy(dest, &texelu16, sizeof(UINT16));
break;
@ -135,7 +126,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
{
RGBA_t rgbatexel;
rgbatexel.rgba = *(UINT32 *)dest;
colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
}
memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8));
break;
@ -145,14 +136,14 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
{
RGBA_t rgbatexel;
rgbatexel.rgba = *(UINT32 *)dest;
colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
}
memcpy(dest, &colortemp, sizeof(RGBA_t));
break;
// default is 1
default:
if ((originPatch != NULL) && (originPatch->style != AST_COPY))
*dest = ASTBlendPixel_8bpp(*dest, texel, originPatch->style, originPatch->alpha);
*dest = ASTBlendPaletteIndexes(*dest, texel, originPatch->style, originPatch->alpha);
else
*dest = texel;
break;
@ -238,7 +229,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
{
case 2 : // uhhhhhhhh..........
if ((originPatch != NULL) && (originPatch->style != AST_COPY))
texel = ASTBlendPixel_8bpp(*(dest+1), texel, originPatch->style, originPatch->alpha);
texel = ASTBlendPaletteIndexes(*(dest+1), texel, originPatch->style, originPatch->alpha);
texelu16 = (UINT16)((alpha<<8) | texel);
memcpy(dest, &texelu16, sizeof(UINT16));
break;
@ -247,7 +238,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
{
RGBA_t rgbatexel;
rgbatexel.rgba = *(UINT32 *)dest;
colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
}
memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8));
break;
@ -257,14 +248,14 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
{
RGBA_t rgbatexel;
rgbatexel.rgba = *(UINT32 *)dest;
colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha);
}
memcpy(dest, &colortemp, sizeof(RGBA_t));
break;
// default is 1
default:
if ((originPatch != NULL) && (originPatch->style != AST_COPY))
*dest = ASTBlendPixel_8bpp(*dest, texel, originPatch->style, originPatch->alpha);
*dest = ASTBlendPaletteIndexes(*dest, texel, originPatch->style, originPatch->alpha);
else
*dest = texel;
break;
@ -292,7 +283,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y;
const column_t *patchcol;
UINT8 *block = mipmap->grInfo.data;
UINT8 *block = mipmap->data;
INT32 bpp;
INT32 blockmodulo;
@ -307,7 +298,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
yfracstep = FRACUNIT;
scale_y = FRACUNIT;
bpp = format2bpp[mipmap->grInfo.format];
bpp = format2bpp(mipmap->format);
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
@ -339,7 +330,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y;
const column_t *patchcol;
UINT8 *block = mipmap->grInfo.data;
UINT8 *block = mipmap->data;
INT32 bpp;
INT32 blockmodulo;
INT32 width, height;
@ -400,7 +391,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
yfracstep = (texture->height<< FRACBITS) / pblockheight;
scale_y = (pblockheight << FRACBITS) / texture->height;
bpp = format2bpp[mipmap->grInfo.format];
bpp = format2bpp(mipmap->format);
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
@ -431,8 +422,8 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX);
INT32 blocksize = (grMipmap->width * grMipmap->height);
bpp = format2bpp[grMipmap->grInfo.format];
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->grInfo.data));
bpp = format2bpp(grMipmap->format);
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));
switch (bpp)
{
@ -453,7 +444,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
// Create a composite texture from patches, adapt the texture size to a power of 2
// height and width for the hardware texture cache.
//
static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
{
UINT8 *block;
texture_t *texture;
@ -483,7 +474,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
grtex->mipmap.width = (UINT16)texture->width;
grtex->mipmap.height = (UINT16)texture->height;
grtex->mipmap.grInfo.format = textureformat;
grtex->mipmap.format = textureformat;
blockwidth = texture->width;
blockheight = texture->height;
@ -530,7 +521,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
HWR_DrawTexturePatchInCache(&grtex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp[grtex->mipmap.grInfo.format]==4)
if (format2bpp(grtex->mipmap.format)==4)
{
for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp
{
@ -574,15 +565,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
// no wrap around, no chroma key
grMipmap->flags = 0;
// setup the texture info
grMipmap->grInfo.format = patchformat;
grMipmap->format = patchformat;
//grPatch->max_s = grPatch->max_t = 1.0f;
grPatch->max_s = (float)grPatch->width / (float)grMipmap->width;
grPatch->max_t = (float)grPatch->height / (float)grMipmap->height;
}
Z_Free(grMipmap->grInfo.data);
grMipmap->grInfo.data = NULL;
Z_Free(grMipmap->data);
grMipmap->data = NULL;
if (makebitmap)
{
@ -600,15 +591,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
// CACHING HANDLING
// =================================================
static size_t gr_numtextures = 0; // Texture count
static GLTexture_t *gr_textures; // For all textures
static GLTexture_t *gr_flats; // For all (texture) flats, as normal flats don't need to be cached
boolean gr_leveltexturesloaded = false;
static size_t gl_numtextures = 0; // Texture count
static GLMapTexture_t *gl_textures; // For all textures
static GLMapTexture_t *gl_flats; // For all (texture) flats, as normal flats don't need to be cached
boolean gl_leveltexturesloaded = false;
void HWR_InitTextureCache(void)
{
gr_textures = NULL;
gr_flats = NULL;
gl_textures = NULL;
gl_flats = NULL;
}
// Callback function for HWR_FreeTextureCache.
@ -642,9 +633,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
pat->mipmap->nextcolormap = next->nextcolormap;
// Free image data from memory.
if (next->grInfo.data)
Z_Free(next->grInfo.data);
next->grInfo.data = NULL;
if (next->data)
Z_Free(next->data);
next->data = NULL;
// Free the old colormap mipmap from memory.
free(next);
@ -686,14 +677,14 @@ void HWR_FreeTextureCache(void)
// now the heap don't have any 'user' pointing to our
// texturecache info, we can free it
if (gr_textures)
free(gr_textures);
if (gr_flats)
free(gr_flats);
gr_textures = NULL;
gr_flats = NULL;
gr_numtextures = 0;
gr_leveltexturesloaded = false;
if (gl_textures)
free(gl_textures);
if (gl_flats)
free(gl_flats);
gl_textures = NULL;
gl_flats = NULL;
gl_numtextures = 0;
gl_leveltexturesloaded = false;
}
void HWR_LoadTextures(size_t pnumtextures)
@ -702,16 +693,16 @@ void HWR_LoadTextures(size_t pnumtextures)
HWR_FreeTextureCache();
// Why not Z_Malloc?
gr_numtextures = pnumtextures;
gr_textures = calloc(gr_numtextures, sizeof(*gr_textures));
gr_flats = calloc(gr_numtextures, sizeof(*gr_flats));
gl_numtextures = pnumtextures;
gl_textures = calloc(gl_numtextures, sizeof(*gl_textures));
gl_flats = calloc(gl_numtextures, sizeof(*gl_flats));
// Doesn't tell you which it _is_, but hopefully
// should never ever happen (right?!)
if ((gr_textures == NULL) || (gr_flats == NULL))
if ((gl_textures == NULL) || (gl_flats == NULL))
I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!");
gr_leveltexturesloaded = true;
gl_leveltexturesloaded = true;
}
void HWR_SetPalette(RGBA_t *palette)
@ -720,7 +711,7 @@ void HWR_SetPalette(RGBA_t *palette)
// hardware driver will flush there own cache if cache is non paletized
// now flush data texture cache so 32 bit texture are recomputed
if (patchformat == GR_RGBA || textureformat == GR_RGBA)
if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
{
Z_FreeTag(PU_HWRCACHE);
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
@ -730,20 +721,20 @@ void HWR_SetPalette(RGBA_t *palette)
// --------------------------------------------------------------------------
// Make sure texture is downloaded and set it as the source
// --------------------------------------------------------------------------
GLTexture_t *HWR_GetTexture(INT32 tex)
GLMapTexture_t *HWR_GetTexture(INT32 tex)
{
GLTexture_t *grtex;
GLMapTexture_t *grtex;
#ifdef PARANOIA
if ((unsigned)tex >= gr_numtextures)
if ((unsigned)tex >= gl_numtextures)
I_Error("HWR_GetTexture: tex >= numtextures\n");
#endif
// Every texture in memory, stored in the
// hardware renderer's bit depth format. Wow!
grtex = &gr_textures[tex];
grtex = &gl_textures[tex];
// Generate texture if missing from the cache
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_GenerateTexture(tex, grtex);
// If hardware does not have the texture, then call pfnSetTexture to upload it
@ -753,7 +744,7 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
HWR_SetCurrentTexture(&grtex->mipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
return grtex;
}
@ -763,7 +754,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
size_t size, pflatsize;
// setup the texture info
grMipmap->grInfo.format = GR_TEXFMT_P_8;
grMipmap->format = GL_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
size = W_LumpLength(flatlumpnum);
@ -798,7 +789,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
// the flat raw data needn't be converted with palettized textures
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
PU_HWRCACHE, &grMipmap->grInfo.data));
PU_HWRCACHE, &grMipmap->data));
}
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
@ -806,13 +797,13 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
UINT8 *flat;
// setup the texture info
grMipmap->grInfo.format = GR_TEXFMT_P_8;
grMipmap->format = GL_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
grMipmap->width = (UINT16)textures[texturenum]->width;
grMipmap->height = (UINT16)textures[texturenum]->height;
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data);
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->data);
memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height);
R_TextureToFlat(texturenum, flat);
@ -826,7 +817,7 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum)
return;
grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data)
if (!grmip->downloaded && !grmip->data)
HWR_CacheFlat(grmip, flatlumpnum);
// If hardware does not have the texture, then call pfnSetTexture to upload it
@ -836,7 +827,7 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum)
HWR_SetCurrentTexture(grmip);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
}
void HWR_GetLevelFlat(levelflat_t *levelflat)
@ -849,10 +840,10 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
HWR_LiterallyGetFlat(levelflat->u.flat.lumpnum);
else if (levelflat->type == LEVELFLAT_TEXTURE)
{
GLTexture_t *grtex;
GLMapTexture_t *grtex;
INT32 texturenum = levelflat->u.texture.num;
#ifdef PARANOIA
if ((unsigned)texturenum >= gr_numtextures)
if ((unsigned)texturenum >= gl_numtextures)
I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n");
#endif
@ -861,10 +852,10 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
return;
// Every texture in memory, stored as a 8-bit flat. Wow!
grtex = &gr_flats[texturenum];
grtex = &gl_flats[texturenum];
// Generate flat if missing from the cache
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum);
// If hardware does not have the texture, then call pfnSetTexture to upload it
@ -874,7 +865,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
HWR_SetCurrentTexture(&grtex->mipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
}
else // set no texture
HWR_SetCurrentTexture(NULL);
@ -886,7 +877,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
//
static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
{
if (!grmip->downloaded && !grmip->grInfo.data)
if (!grmip->downloaded && !grmip->data)
{
patch_t *lumppatch = NULL;
@ -909,7 +900,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
HWR_SetCurrentTexture(grmip);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
}
// -----------------+
@ -918,7 +909,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
void HWR_GetPatch(GLPatch_t *gpatch)
{
// is it in hardware cache?
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->grInfo.data)
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data)
{
// load the software patch, PU_STATIC or the Z_Malloc for hardware patch will
// flush the software patch before the conversion! oh yeah I suffered
@ -945,7 +936,7 @@ void HWR_GetPatch(GLPatch_t *gpatch)
HWR_SetCurrentTexture(gpatch->mipmap);
// The system-memory patch data can be purged now.
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
}
@ -995,17 +986,17 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
if (!gpatch)
return;
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED);
}
static const INT32 picmode2GR[] =
{
GR_TEXFMT_P_8, // PALETTE
GL_TEXFMT_P_8, // PALETTE
0, // INTENSITY (unsupported yet)
GR_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this)
GL_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this)
0, // RGB24 (unsupported yet)
GR_RGBA, // RGBA32 (opengl only)
GL_TEXFMT_RGBA, // RGBA32 (opengl only)
};
static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheight,
@ -1020,7 +1011,7 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig
stepy = ((INT32)SHORT(pic->height)<<FRACBITS)/pblockheight;
stepx = ((INT32)SHORT(pic->width)<<FRACBITS)/pblockwidth;
picbpp = format2bpp[picmode2GR[pic->mode]];
picbpp = format2bpp(picmode2GR[pic->mode]);
posy = 0;
for (j = 0; j < pblockheight; j++)
{
@ -1080,7 +1071,7 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig
GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
{
GLPatch_t *grpatch = HWR_GetCachedGLPatch(lumpnum);
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data)
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
{
pic_t *pic;
UINT8 *block;
@ -1098,27 +1089,27 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
grpatch->mipmap->height = (UINT16)grpatch->height;
if (pic->mode == PALETTE)
grpatch->mipmap->grInfo.format = textureformat; // can be set by driver
grpatch->mipmap->format = textureformat; // can be set by driver
else
grpatch->mipmap->grInfo.format = picmode2GR[pic->mode];
grpatch->mipmap->format = picmode2GR[pic->mode];
Z_Free(grpatch->mipmap->grInfo.data);
Z_Free(grpatch->mipmap->data);
// allocate block
block = MakeBlock(grpatch->mipmap);
if (grpatch->width == SHORT(pic->width) &&
grpatch->height == SHORT(pic->height) &&
format2bpp[grpatch->mipmap->grInfo.format] == format2bpp[picmode2GR[pic->mode]])
format2bpp(grpatch->mipmap->format) == format2bpp(picmode2GR[pic->mode]))
{
// no conversion needed
M_Memcpy(grpatch->mipmap->grInfo.data, pic->data,len);
M_Memcpy(grpatch->mipmap->data, pic->data,len);
}
else
HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height),
SHORT(pic->width)*format2bpp[grpatch->mipmap->grInfo.format],
SHORT(pic->width)*format2bpp(grpatch->mipmap->format),
pic,
format2bpp[grpatch->mipmap->grInfo.format]);
format2bpp(grpatch->mipmap->format));
Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED);
@ -1126,7 +1117,7 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
grpatch->max_s = grpatch->max_t = 1.0f;
}
HWD.pfnSetTexture(grpatch->mipmap);
//CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.grInfo.data, grpatch->mipmap.downloaded);
//CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.data, grpatch->mipmap.downloaded);
return grpatch;
}
@ -1159,7 +1150,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
{
INT32 i,j;
fixed_t posx, posy, stepx, stepy;
UINT8 *block = mipmap->grInfo.data; // places the data directly into here
UINT8 *block = mipmap->data; // places the data directly into here
UINT8 *flat;
UINT8 *dest, *src, texel;
RGBA_t col;
@ -1198,7 +1189,7 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
UINT16 fmheight = 0, fmwidth = 0;
// setup the texture info
grMipmap->grInfo.format = GR_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
grMipmap->format = GL_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
grMipmap->flags = 0;
size = W_LumpLength(fademasklumpnum);
@ -1242,13 +1233,13 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
{
GLMipmap_t *grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data)
if (!grmip->downloaded && !grmip->data)
HWR_CacheFadeMask(grmip, fademasklumpnum);
HWD.pfnSetTexture(grmip);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
}
#endif //HWRENDER

View file

@ -20,8 +20,6 @@
#endif
#include "../doomdef.h"
//THIS MUST DISAPPEAR!!!
#include "hw_glide.h"
#include "../screen.h"
@ -29,12 +27,27 @@
// TEXTURE INFO
// ==========================================================================
// grInfo.data holds the address of the graphics data cached in heap memory
typedef enum GLTextureFormat_e
{
GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */
GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */
GL_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */
GL_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */
GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */
GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
} GLTextureFormat_t;
// data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache.
struct GLMipmap_s
{
GrTexInfo grInfo; //for TexDownloadMipMap
FxU32 flags;
//for TexDownloadMipMap
GLTextureFormat_t format;
void *data;
UINT32 flags;
UINT16 height;
UINT16 width;
UINT32 downloaded; // the dll driver have it in there cache ?
@ -51,13 +64,13 @@ typedef struct GLMipmap_s GLMipmap_t;
//
// Doom texture info, as cached for hardware rendering
//
struct GLTexture_s
struct GLMapTexture_s
{
GLMipmap_t mipmap;
float scaleX; //used for scaling textures on walls
float scaleY;
};
typedef struct GLTexture_s GLTexture_t;
typedef struct GLMapTexture_s GLMapTexture_t;
// a cached patch as converted to hardware format, holding the original patch_t

View file

@ -936,17 +936,17 @@ void HWR_DrawViewBorder(INT32 clearlines)
INT32 basewindowx, basewindowy;
GLPatch_t *patch;
// if (gr_viewwidth == vid.width)
// if (gl_viewwidth == vid.width)
// return;
if (!clearlines)
clearlines = BASEVIDHEIGHT; // refresh all
// calc view size based on original game resolution
baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewwidth), vid.fdupx)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7;
baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewheight), vid.fdupy));
top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_baseviewwindowy), vid.fdupy));
side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewwindowx), vid.fdupx));
baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwidth), vid.fdupx)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7;
baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewheight), vid.fdupy));
top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowy), vid.fdupy));
side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwindowx), vid.fdupx));
// top
HWR_DrawFlatFill(0, 0,

View file

@ -1,41 +0,0 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_glide.h
/// \brief Declaration needed by Glide renderer
/// !!! To be replaced by our own def in the future !!!
#ifndef _GLIDE_H_
#define _GLIDE_H_
#ifndef __GLIDE_H__
typedef unsigned long FxU32;
typedef long FxI32;
typedef FxI32 GrTextureFormat_t;
#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */
#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */
#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */
#define GR_TEXFMT_RGB_565 0xa
#define GR_TEXFMT_ARGB_1555 0xb
#define GR_TEXFMT_ARGB_4444 0xc
#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */
#define GR_RGBA 0x6 // 32 bit RGBA !
typedef struct
{
GrTextureFormat_t format;
void *data;
} GrTexInfo;
#endif // __GLIDE_H__ (defined in <glide.h>)
#endif // _GLIDE_H_

View file

@ -59,18 +59,19 @@ typedef struct
// needed for sprite rendering
// equivalent of the software renderer's vissprites
typedef struct gr_vissprite_s
typedef struct gl_vissprite_s
{
float x1, x2;
float z1, z2;
float tz, ty;
float originx, originy, originz;
angle_t angle;
float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting
//lumpnum_t patchlumpnum;
GLPatch_t *gpatch;
boolean flip;
UINT8 translucency; //alpha level 0-255
mobj_t *mobj;
mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out.
boolean precip; // Tails 08-25-2002
boolean vflip;
//Hurdler: 25/04/2000: now support colormap in hardware mode
@ -80,7 +81,7 @@ typedef struct gr_vissprite_s
angle_t rollangle;
float pivotx, pivoty;
#endif
} gr_vissprite_t;
} gl_vissprite_t;
// --------
// hw_bsp.c
@ -101,7 +102,7 @@ void HWR_FreeExtraSubsectors(void);
void HWR_GetLevelFlat(levelflat_t *levelflat);
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
GLTexture_t *HWR_GetTexture(INT32 tex);
GLMapTexture_t *HWR_GetTexture(INT32 tex);
void HWR_GetPatch(GLPatch_t *gpatch);
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
@ -111,7 +112,7 @@ GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum, void *hwrcach
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
extern boolean gr_leveltexturesloaded;
extern boolean gl_leveltexturesloaded;
// --------
// hw_draw.c

View file

@ -821,7 +821,7 @@ void HWR_WallLighting(FOutVector *wlVerts)
{
int i, j;
// dynlights->nb == 0 if cv_grdynamiclighting.value is not set
// dynlights->nb == 0 if cv_gldynamiclighting.value is not set
for (j = 0; j < dynlights->nb; j++)
{
FVector inter;
@ -970,7 +970,7 @@ static lumpnum_t coronalumpnum = LUMPERROR;
// --------------------------------------------------------------------------
// coronas lighting
// --------------------------------------------------------------------------
void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr)
void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr)
{
light_t *p_lspr;
@ -985,7 +985,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr)
p_lspr = &lspr[ROCKETEXP_L];
}
if (cv_grcoronas.value && (p_lspr->type & CORONA_SPR))
if (cv_glcoronas.value && (p_lspr->type & CORONA_SPR))
{ // it's an object which emits light
FOutVector light[4];
FSurfaceInfo Surf;
@ -1010,7 +1010,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr)
}
if (size > p_lspr->corona_radius)
size = p_lspr->corona_radius;
size *= FIXED_TO_FLOAT(cv_grcoronasize.value<<1);
size *= FIXED_TO_FLOAT(cv_glcoronasize.value<<1);
// compute position doing average
for (i = 0; i < 4; i++)
@ -1067,7 +1067,7 @@ void HWR_DrawCoronas(void)
{
int j;
if (!cv_grcoronas.value || dynlights->nb <= 0 || coronalumpnum == LUMPERROR)
if (!cv_glcoronas.value || dynlights->nb <= 0 || coronalumpnum == LUMPERROR)
return;
HWR_GetPic(coronalumpnum); /// \todo use different coronas
@ -1121,7 +1121,7 @@ void HWR_DrawCoronas(void)
}
if (size > p_lspr->corona_radius)
size = p_lspr->corona_radius;
size = (float)(FIXED_TO_FLOAT(cv_grcoronasize.value<<1)*size);
size = (float)(FIXED_TO_FLOAT(cv_glcoronasize.value<<1)*size);
// put light little forward the sprite so there is no
// z-buffer problem (coplanar polygons)
@ -1170,13 +1170,13 @@ void HWR_SetLights(int viewnumber)
// Add a light for dynamic lighting
// The light position is already transformed execpt for mlook
// --------------------------------------------------------------------------
void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch)
void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch)
{
light_t *p_lspr;
//Hurdler: moved here because it's better;-)
(void)patch;
if (!cv_grdynamiclighting.value)
if (!cv_gldynamiclighting.value)
return;
if (!spr->mobj)
@ -1193,7 +1193,7 @@ void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch)
p_lspr = t_lspr[spr->mobj->sprite];
if (!(p_lspr->type & DYNLIGHT_SPR))
return;
if ((p_lspr->type != LIGHT_SPR) || cv_grstaticlighting.value)
if ((p_lspr->type != LIGHT_SPR) || cv_glstaticlighting.value)
return;
LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(spr->mobj->x);
@ -1229,10 +1229,10 @@ static void HWR_SetLight(void)
{
int i, j;
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->grInfo.data)
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data)
{
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->grInfo.data);
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data);
for (i = 0; i < 128; i++)
{
@ -1245,7 +1245,7 @@ static void HWR_SetLight(void)
Data[i*128+j] = 0;
}
}
lightmappatch.mipmap->grInfo.format = GR_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.mipmap->format = GL_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.width = 128;
lightmappatch.height = 128;
@ -1256,7 +1256,7 @@ static void HWR_SetLight(void)
HWD.pfnSetTexture(lightmappatch.mipmap);
// The system-memory data can be purged now.
Z_ChangeTag(lightmappatch.mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(lightmappatch.mipmap->data, PU_HWRCACHE_UNLOCKED);
}
//**********************************************************
@ -1265,8 +1265,8 @@ static void HWR_SetLight(void)
#ifdef STATICLIGHT
// is this really necessary?
static sector_t *lgr_backsector;
static seg_t *lgr_curline;
static sector_t *lgl_backsector;
static seg_t *lgl_curline;
#endif
// p1 et p2 c'est le deux bou du seg en float
@ -1304,27 +1304,27 @@ static void HWR_AddLightMapForLine(int lightnum, seg_t *line)
*/
FVector p1,p2;
lgr_curline = line;
lgr_backsector = line->backsector;
lgl_curline = line;
lgl_backsector = line->backsector;
// Reject empty lines used for triggers and special events.
// Identical floor and ceiling on both sides,
// identical light levels on both sides,
// and no middle texture.
/*
if ( lgr_backsector->ceilingpic == gr_frontsector->ceilingpic
&& lgr_backsector->floorpic == gr_frontsector->floorpic
&& lgr_backsector->lightlevel == gr_frontsector->lightlevel
&& lgr_curline->sidedef->midtexture == 0)
if ( lgl_backsector->ceilingpic == gl_frontsector->ceilingpic
&& lgl_backsector->floorpic == gl_frontsector->floorpic
&& lgl_backsector->lightlevel == gl_frontsector->lightlevel
&& lgl_curline->sidedef->midtexture == 0)
{
return;
}
*/
p1.y = FIXED_TO_FLOAT(lgr_curline->v1->y);
p1.x = FIXED_TO_FLOAT(lgr_curline->v1->x);
p2.y = FIXED_TO_FLOAT(lgr_curline->v2->y);
p2.x = FIXED_TO_FLOAT(lgr_curline->v2->x);
p1.y = FIXED_TO_FLOAT(lgl_curline->v1->y);
p1.x = FIXED_TO_FLOAT(lgl_curline->v1->x);
p2.y = FIXED_TO_FLOAT(lgl_curline->v2->y);
p2.x = FIXED_TO_FLOAT(lgl_curline->v2->x);
// check bbox of the seg
// if (CircleTouchBBox(&p1, &p2, &LIGHT_POS(lightnum), DL_RADIUS(lightnum))==false)

View file

@ -24,7 +24,7 @@
#define DL_MAX_LIGHT 256 // maximum number of lights (extra lights are ignored)
void HWR_InitLight(void);
void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch);
void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch);
void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts);
void HWR_WallLighting(FOutVector *wlVerts);
void HWR_ResetLights(void);
@ -33,7 +33,7 @@ void HWR_SetLights(int viewnumber);
#ifdef NEWCORONAS
void HWR_DrawCoronas(void);
#else
void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr);
void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr);
#endif
typedef struct

File diff suppressed because it is too large Load diff

View file

@ -74,31 +74,31 @@ boolean HWR_LoadShaders(void);
extern CV_PossibleValue_t granisotropicmode_cons_t[];
#ifdef ALAM_LIGHTING
extern consvar_t cv_grdynamiclighting;
extern consvar_t cv_grstaticlighting;
extern consvar_t cv_grcoronas;
extern consvar_t cv_grcoronasize;
extern consvar_t cv_gldynamiclighting;
extern consvar_t cv_glstaticlighting;
extern consvar_t cv_glcoronas;
extern consvar_t cv_glcoronasize;
#endif
extern consvar_t cv_grshaders;
extern consvar_t cv_grmodels;
extern consvar_t cv_grmodelinterpolation;
extern consvar_t cv_grmodellighting;
extern consvar_t cv_grfiltermode;
extern consvar_t cv_granisotropicmode;
extern consvar_t cv_glshaders;
extern consvar_t cv_glmodels;
extern consvar_t cv_glmodelinterpolation;
extern consvar_t cv_glmodellighting;
extern consvar_t cv_glfiltermode;
extern consvar_t cv_glanisotropicmode;
extern consvar_t cv_fovchange;
extern consvar_t cv_grsolvetjoin;
extern consvar_t cv_grshearing;
extern consvar_t cv_grspritebillboarding;
extern consvar_t cv_grskydome;
extern consvar_t cv_grfakecontrast;
extern consvar_t cv_grslopecontrast;
extern consvar_t cv_glsolvetjoin;
extern consvar_t cv_glshearing;
extern consvar_t cv_glspritebillboarding;
extern consvar_t cv_glskydome;
extern consvar_t cv_glfakecontrast;
extern consvar_t cv_glslopecontrast;
extern consvar_t cv_grbatching;
extern consvar_t cv_glbatching;
extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy;
extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowy;
extern float gr_viewwindowx, gr_basewindowcentery;
extern float gl_viewwindowx, gl_basewindowcentery;
// BP: big hack for a test in lighting ref : 1249753487AB
extern fixed_t *hwbbox;
@ -122,6 +122,6 @@ extern int rs_hw_numcolors;
extern int rs_hw_batchsorttime;
extern int rs_hw_batchdrawtime;
extern boolean gr_shadersavailable;
extern boolean gl_shadersavailable;
#endif

View file

@ -141,7 +141,7 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext)
CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
}
static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch)
static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch)
{
png_structp png_ptr;
png_infop png_info_ptr;
@ -191,7 +191,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
//CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
fclose(png_FILE);
Z_Free(grpatch->mipmap->grInfo.data);
Z_Free(grpatch->mipmap->data);
return 0;
}
#ifdef USE_FAR_KEYWORD
@ -232,7 +232,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
{
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
for (i = 0; i < height; i++)
row_pointers[i] = PNG_image + i*pitch;
@ -245,7 +245,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
fclose(png_FILE);
*w = (int)width;
*h = (int)height;
return GR_RGBA;
return GL_TEXFMT_RGBA;
}
#endif
@ -271,7 +271,7 @@ typedef struct
UINT8 filler[54];
} PcxHeader;
static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
GLPatch_t *grpatch)
{
PcxHeader header;
@ -306,7 +306,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
pw = *w = header.xmax - header.xmin + 1;
ph = *h = header.ymax - header.ymin + 1;
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data);
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
{
@ -340,7 +340,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
}
}
fclose(file);
return GR_RGBA;
return GL_TEXFMT_RGBA;
}
// -----------------+
@ -354,7 +354,7 @@ static void md2_loadTexture(md2_t *model)
if (model->grpatch)
{
grpatch = model->grpatch;
Z_Free(grpatch->mipmap->grInfo.data);
Z_Free(grpatch->mipmap->data);
}
else
{
@ -363,18 +363,18 @@ static void md2_loadTexture(md2_t *model)
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
}
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data)
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
{
int w = 0, h = 0;
UINT32 size;
RGBA_t *image;
#ifdef HAVE_PNG
grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0)
grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
#endif
grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0)
grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
{
model->notexturefile = true; // mark it so its not searched for again repeatedly
return;
@ -389,7 +389,7 @@ static void md2_loadTexture(md2_t *model)
grpatch->mipmap->height = (UINT16)h;
// Lactozilla: Apply colour cube
image = grpatch->mipmap->grInfo.data;
image = grpatch->mipmap->data;
size = w*h;
while (size--)
{
@ -414,7 +414,7 @@ static void md2_loadBlendTexture(md2_t *model)
if (model->blendgrpatch)
{
grpatch = model->blendgrpatch;
Z_Free(grpatch->mipmap->grInfo.data);
Z_Free(grpatch->mipmap->data);
}
else
{
@ -423,15 +423,15 @@ static void md2_loadBlendTexture(md2_t *model)
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
}
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data)
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
{
int w = 0, h = 0;
#ifdef HAVE_PNG
grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0)
grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
#endif
grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->grInfo.format == 0)
grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
{
model->noblendfile = true; // mark it so its not searched for again repeatedly
Z_Free(filename);
@ -686,20 +686,20 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
// no wrap around, no chroma key
grmip->flags = 0;
// setup the texture info
grmip->grInfo.format = GR_RGBA;
grmip->format = GL_TEXFMT_RGBA;
}
if (grmip->grInfo.data)
if (grmip->data)
{
Z_Free(grmip->grInfo.data);
grmip->grInfo.data = NULL;
Z_Free(grmip->data);
grmip->data = NULL;
}
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->grInfo.data);
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->data);
memset(cur, 0x00, size*4);
image = gpatch->mipmap->grInfo.data;
blendimage = blendgpatch->mipmap->grInfo.data;
image = gpatch->mipmap->data;
blendimage = blendgpatch->mipmap->data;
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
if (skinnum == TC_METALSONIC)
@ -1050,7 +1050,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
return;
}
if ((blendgpatch && blendgpatch->mipmap->grInfo.format)
if ((blendgpatch && blendgpatch->mipmap->format)
&& (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height))
{
// Blend image exists, but it's bad.
@ -1065,10 +1065,10 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
grmip = grmip->nextcolormap;
if (grmip->colormap == colormap)
{
if (grmip->downloaded && grmip->grInfo.data)
if (grmip->downloaded && grmip->data)
{
HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture
Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED);
Z_ChangeTag(grmip->data, PU_HWRMODELTEXTURE_UNLOCKED);
return;
}
}
@ -1090,7 +1090,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
HWD.pfnSetTexture(newmip);
Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED);
Z_ChangeTag(newmip->data, PU_HWRMODELTEXTURE_UNLOCKED);
}
#define NORMALFOG 0x00000000
@ -1108,14 +1108,14 @@ static boolean HWR_AllowModel(mobj_t *mobj)
static boolean HWR_CanInterpolateModel(mobj_t *mobj, model_t *model)
{
if (cv_grmodelinterpolation.value == 2) // Always interpolate
if (cv_glmodelinterpolation.value == 2) // Always interpolate
return true;
return model->interpolate[(mobj->frame & FF_FRAMEMASK)];
}
static boolean HWR_CanInterpolateSprite2(modelspr2frames_t *spr2frame)
{
if (cv_grmodelinterpolation.value == 2) // Always interpolate
if (cv_glmodelinterpolation.value == 2) // Always interpolate
return true;
return spr2frame->interpolate;
}
@ -1209,7 +1209,7 @@ static void adjustTextureCoords(model_t *model, GLPatch_t *gpatch)
// HWR_DrawModel
//
boolean HWR_DrawModel(gr_vissprite_t *spr)
boolean HWR_DrawModel(gl_vissprite_t *spr)
{
md2_t *md2;
@ -1220,7 +1220,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
FTransform p;
FSurfaceInfo Surf;
if (!cv_grmodels.value)
if (!cv_glmodels.value)
return false;
if (spr->precip)
@ -1309,13 +1309,13 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
// texture loading before model init, so it knows if sprite graphics are used, which
// means that texture coordinates have to be adjusted
gpatch = md2->grpatch;
if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !md2->notexturefile))
if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !md2->notexturefile))
md2_loadTexture(md2);
gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
if ((gpatch && gpatch->mipmap->grInfo.format) // don't load the blend texture if the base texture isn't available
if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available
&& (!md2->blendgrpatch
|| ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded)
|| ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded)
&& !md2->noblendfile)))
md2_loadBlendTexture(md2);
@ -1332,7 +1332,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
md2_printModelInfo(md2->model);
// if model uses sprite patch as texture, then
// adjust texture coordinates to take power of two textures into account
if (!gpatch || !gpatch->mipmap->grInfo.format)
if (!gpatch || !gpatch->mipmap->format)
adjustTextureCoords(md2->model, spr->gpatch);
HWD.pfnCreateModelVBOs(md2->model);
}
@ -1352,7 +1352,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
if (gpatch && gpatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
{
INT32 skinnum = TC_DEFAULT;
@ -1423,7 +1423,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
#ifdef USE_MODEL_NEXTFRAME
#define INTERPOLERATION_LIMIT TICRATE/4
if (cv_grmodelinterpolation.value && tics <= durs && tics <= INTERPOLERATION_LIMIT)
if (cv_glmodelinterpolation.value && tics <= durs && tics <= INTERPOLERATION_LIMIT)
{
if (durs > INTERPOLERATION_LIMIT)
durs = INTERPOLERATION_LIMIT;

View file

@ -42,7 +42,7 @@ extern md2_t md2_playermodels[MAXSKINS];
void HWR_InitModels(void);
void HWR_AddPlayerModel(INT32 skin);
void HWR_AddSpriteModel(size_t spritenum);
boolean HWR_DrawModel(gr_vissprite_t *spr);
boolean HWR_DrawModel(gl_vissprite_t *spr);
#define PLAYERMODELPREFIX "PLAYER"

View file

@ -58,8 +58,8 @@ static GLuint tex_downloaded = 0;
static GLfloat fov = 90.0f;
static FBITFIELD CurrentPolyFlags;
static FTextureInfo *gr_cachetail = NULL;
static FTextureInfo *gr_cachehead = NULL;
static FTextureInfo *gl_cachetail = NULL;
static FTextureInfo *gl_cachehead = NULL;
RGBA_t myPaletteData[256];
GLint screen_width = 0; // used by Draw2DLine()
@ -1200,7 +1200,7 @@ void SetModelView(GLint w, GLint h)
pglLoadIdentity();
GLPerspective(fov, ASPECT_RATIO);
//pglScalef(1.0f, 320.0f/200.0f, 1.0f); // gr_scalefrustum (ORIGINAL_ASPECT)
//pglScalef(1.0f, 320.0f/200.0f, 1.0f); // gl_scalefrustum (ORIGINAL_ASPECT)
// added for new coronas' code (without depth buffer)
pglGetIntegerv(GL_VIEWPORT, viewport);
@ -1277,14 +1277,14 @@ void Flush(void)
{
//GL_DBG_Printf ("HWR_Flush()\n");
while (gr_cachehead)
while (gl_cachehead)
{
if (gr_cachehead->downloaded)
pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded);
gr_cachehead->downloaded = 0;
gr_cachehead = gr_cachehead->nextmipmap;
if (gl_cachehead->downloaded)
pglDeleteTextures(1, (GLuint *)&gl_cachehead->downloaded);
gl_cachehead->downloaded = 0;
gl_cachehead = gl_cachehead->nextmipmap;
}
gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL
gl_cachetail = gl_cachehead = NULL; //Hurdler: well, gl_cachehead is already NULL
tex_downloaded = 0;
}
@ -1657,15 +1657,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
else
texnum = pTexInfo->downloaded;
//GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data);
//GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->data);
w = pTexInfo->width;
h = pTexInfo->height;
if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) ||
(pTexInfo->grInfo.format == GR_TEXFMT_AP_88))
if ((pTexInfo->format == GL_TEXFMT_P_8) ||
(pTexInfo->format == GL_TEXFMT_AP_88))
{
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
const GLubyte *pImgData = (const GLubyte *)pTexInfo->data;
INT32 i, j;
for (j = 0; j < h; j++)
@ -1691,7 +1691,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
pImgData++;
if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88)
if (pTexInfo->format == GL_TEXFMT_AP_88)
{
if (!(pTexInfo->flags & TF_CHROMAKEYED))
tex[w*j+i].s.alpha = *pImgData;
@ -1701,15 +1701,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
}
}
}
else if (pTexInfo->grInfo.format == GR_RGBA)
else if (pTexInfo->format == GL_TEXFMT_RGBA)
{
// corona test : passed as ARGB 8888, which is not in glide formats
// Hurdler: not used for coronas anymore, just for dynamic lighting
ptex = pTexInfo->grInfo.data;
ptex = pTexInfo->data;
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88)
else if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88)
{
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
const GLubyte *pImgData = (const GLubyte *)pTexInfo->data;
INT32 i, j;
for (j = 0; j < h; j++)
@ -1725,9 +1725,9 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
}
}
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) // Used for fade masks
else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) // Used for fade masks
{
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
const GLubyte *pImgData = (const GLubyte *)pTexInfo->data;
INT32 i, j;
for (j = 0; j < h; j++)
@ -1743,7 +1743,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
}
}
else
GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->format);
// the texture number was already generated by pglGenTextures
pglBindTexture(GL_TEXTURE_2D, texnum);
@ -1761,7 +1761,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
}
if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88)
if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88)
{
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap)
@ -1782,7 +1782,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
}
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8)
else if (pTexInfo->format == GL_TEXFMT_ALPHA_8)
{
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap)
@ -1860,13 +1860,13 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
{
UpdateTexture(pTexInfo);
pTexInfo->nextmipmap = NULL;
if (gr_cachetail)
if (gl_cachetail)
{ // insertion at the tail
gr_cachetail->nextmipmap = pTexInfo;
gr_cachetail = pTexInfo;
gl_cachetail->nextmipmap = pTexInfo;
gl_cachetail = pTexInfo;
}
else // initialization of the linked list
gr_cachetail = gr_cachehead = pTexInfo;
gl_cachetail = gl_cachehead = pTexInfo;
}
}
@ -2961,7 +2961,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
EXPORT INT32 HWRAPI(GetTextureUsed) (void)
{
FTextureInfo *tmp = gr_cachehead;
FTextureInfo *tmp = gl_cachehead;
INT32 res = 0;
while (tmp)
@ -2970,14 +2970,10 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void)
// I don't know which one the game actually _uses_ but this
// follows format2bpp in hw_cache.c
int bpp = 1;
int format = tmp->grInfo.format;
if (format == GR_RGBA)
int format = tmp->format;
if (format == GL_TEXFMT_RGBA)
bpp = 4;
else if (format == GR_TEXFMT_RGB_565
|| format == GR_TEXFMT_ARGB_1555
|| format == GR_TEXFMT_ARGB_4444
|| format == GR_TEXFMT_ALPHA_INTENSITY_88
|| format == GR_TEXFMT_AP_88)
else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88)
bpp = 2;
// Add it up!

View file

@ -1880,7 +1880,7 @@ static inline void HU_DrawCrosshair(void)
#ifdef HWRENDER
if (rendermode != render_soft)
y = (INT32)gr_basewindowcentery;
y = (INT32)gl_basewindowcentery;
else
#endif
y = viewwindowy + (viewheight>>1);
@ -1901,7 +1901,7 @@ static inline void HU_DrawCrosshair2(void)
#ifdef HWRENDER
if (rendermode != render_soft)
y = (INT32)gr_basewindowcentery;
y = (INT32)gl_basewindowcentery;
else
#endif
y = viewwindowy + (viewheight>>1);
@ -1910,7 +1910,7 @@ static inline void HU_DrawCrosshair2(void)
{
#ifdef HWRENDER
if (rendermode != render_soft)
y += (INT32)gr_viewheight;
y += (INT32)gl_viewheight;
else
#endif
y += viewheight;

View file

@ -903,6 +903,94 @@ static int lib_pMaceRotate(lua_State *L)
return 0;
}
static int lib_pRailThinker(lua_State *L)
{
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_RailThinker(mobj));
return 1;
}
static int lib_pXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_XYMovement(actor);
return 0;
}
static int lib_pRingXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_RingXYMovement(actor);
return 0;
}
static int lib_pSceneryXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_SceneryXYMovement(actor);
return 0;
}
static int lib_pZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_ZMovement(actor));
return 1;
}
static int lib_pRingZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_RingZMovement(actor);
return 0;
}
static int lib_pSceneryZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_SceneryZMovement(actor));
return 1;
}
static int lib_pPlayerZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_PlayerZMovement(actor);
return 0;
}
// P_USER
////////////
@ -1273,6 +1361,17 @@ static int lib_pSpawnSkidDust(lua_State *L)
return 0;
}
static int lib_pMovePlayer(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
P_MovePlayer(player);
return 0;
}
static int lib_pDoPlayerFinish(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -2462,6 +2561,14 @@ static int lib_rGetColorByName(lua_State *L)
return 1;
}
static int lib_rGetSuperColorByName(lua_State *L)
{
const char* colorname = luaL_checkstring(L, 1);
//HUDSAFE
lua_pushinteger(L, R_GetSuperColorByName(colorname));
return 1;
}
// Lua exclusive function, returns the name of a color from the SKINCOLOR_ constant.
// SKINCOLOR_GREEN > "Green" for example
static int lib_rGetNameByColor(lua_State *L)
@ -3270,6 +3377,14 @@ static luaL_Reg lib[] = {
{"P_CheckSolidLava",lib_pCheckSolidLava},
{"P_CanRunOnWater",lib_pCanRunOnWater},
{"P_MaceRotate",lib_pMaceRotate},
{"P_RailThinker",lib_pRailThinker},
{"P_XYMovement",lib_pXYMovement},
{"P_RingXYMovement",lib_pRingXYMovement},
{"P_SceneryXYMovement",lib_pSceneryXYMovement},
{"P_ZMovement",lib_pZMovement},
{"P_RingZMovement",lib_pRingZMovement},
{"P_SceneryZMovement",lib_pSceneryZMovement},
{"P_PlayerZMovement",lib_pPlayerZMovement},
// p_user
{"P_GetPlayerHeight",lib_pGetPlayerHeight},
@ -3301,6 +3416,7 @@ static luaL_Reg lib[] = {
{"P_BlackOw",lib_pBlackOw},
{"P_ElementalFire",lib_pElementalFire},
{"P_SpawnSkidDust", lib_pSpawnSkidDust},
{"P_MovePlayer",lib_pMovePlayer},
{"P_DoPlayerFinish",lib_pDoPlayerFinish},
{"P_DoPlayerExit",lib_pDoPlayerExit},
{"P_InstaThrust",lib_pInstaThrust},
@ -3401,6 +3517,7 @@ static luaL_Reg lib[] = {
// r_draw
{"R_GetColorByName", lib_rGetColorByName},
{"R_GetSuperColorByName", lib_rGetSuperColorByName},
{"R_GetNameByColor", lib_rGetNameByColor},
// s_sound

View file

@ -444,7 +444,7 @@ static int lib_consPrintf(lua_State *L)
if (n < 2)
return luaL_error(L, "CONS_Printf requires at least two arguments: player and text.");
//HUDSAFE
INLEVEL
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!plr)
return LUA_ErrInvalid(L, "player_t");

View file

@ -20,6 +20,7 @@
#include "r_patch.h"
#include "r_rotsprite.h"
#include "r_things.h"
#include "r_draw.h" // R_GetColorByName
#include "doomstat.h" // luabanks[]
#include "lua_script.h"
@ -1532,7 +1533,16 @@ static int lib_setSkinColor(lua_State *L)
const char* n = luaL_checkstring(L, 3);
strlcpy(info->name, n, MAXCOLORNAME+1);
if (strlen(n) > MAXCOLORNAME)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; shortened to %s.\n", n, MAXCOLORNAME, info->name);
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name);
if (strchr(info->name, ' ') != NULL)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
if (info->name[0] != '\0') // don't check empty string for dupe
{
UINT16 dupecheck = R_GetColorByName(info->name);
if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors)))
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name);
}
} else if (i == 2 || (str && fastcmp(str,"ramp"))) {
if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL)
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array.");
@ -1542,19 +1552,17 @@ static int lib_setSkinColor(lua_State *L)
for (j=0; j<COLORRAMPSIZE; j++)
info->ramp[j] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[j];
R_FlushTranslationColormapCache();
} else if (i == 3 || (str && fastcmp(str,"invcolor")))
info->invcolor = (UINT16)luaL_checkinteger(L, 3);
else if (i == 4 || (str && fastcmp(str,"invshade")))
} else if (i == 3 || (str && fastcmp(str,"invcolor"))) {
UINT16 v = (UINT16)luaL_checkinteger(L, 3);
if (v >= numskincolors)
return luaL_error(L, "attempt to set skincolors[%d].invcolor to out of range value %d.", cnum, v);
info->invcolor = v;
} else if (i == 4 || (str && fastcmp(str,"invshade")))
info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE;
else if (i == 5 || (str && fastcmp(str,"chatcolor")))
info->chatcolor = (UINT16)luaL_checkinteger(L, 3);
else if (i == 6 || (str && fastcmp(str,"accessible"))) {
boolean v = lua_isboolean(L,3) ? lua_toboolean(L, 3) : true;
if (cnum < FIRSTSUPERCOLOR && v != skincolors[cnum].accessible)
return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", i);
else
info->accessible = v;
}
else if (i == 6 || (str && fastcmp(str,"accessible")))
info->accessible = lua_toboolean(L, 3);
lua_pop(L, 1);
}
return 0;
@ -1608,11 +1616,18 @@ static int skincolor_set(lua_State *L)
if (fastcmp(field,"name")) {
const char* n = luaL_checkstring(L, 3);
if (strchr(n, ' ') != NULL)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", n);
strlcpy(info->name, n, MAXCOLORNAME+1);
if (strlen(n) > MAXCOLORNAME)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name);
if (strchr(info->name, ' ') != NULL)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
if (info->name[0] != '\0') // don't check empty string for dupe
{
UINT16 dupecheck = R_GetColorByName(info->name);
if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors)))
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name);
}
} else if (fastcmp(field,"ramp")) {
if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL)
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array.");
@ -1622,14 +1637,17 @@ static int skincolor_set(lua_State *L)
for (i=0; i<COLORRAMPSIZE; i++)
info->ramp[i] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[i];
R_FlushTranslationColormapCache();
} else if (fastcmp(field,"invcolor"))
info->invcolor = (UINT16)luaL_checkinteger(L, 3);
else if (fastcmp(field,"invshade"))
} else if (fastcmp(field,"invcolor")) {
UINT16 v = (UINT16)luaL_checkinteger(L, 3);
if (v >= numskincolors)
return luaL_error(L, "attempt to set skincolor_t field 'invcolor' to out of range value %d.", v);
info->invcolor = v;
} else if (fastcmp(field,"invshade"))
info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE;
else if (fastcmp(field,"chatcolor"))
info->chatcolor = (UINT16)luaL_checkinteger(L, 3);
else if (fastcmp(field,"accessible"))
info->accessible = lua_isboolean(L,3);
info->accessible = lua_toboolean(L, 3);
else
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field);
return 1;

View file

@ -165,14 +165,15 @@ static int mobj_get(lua_State *L)
enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt);
lua_settop(L, 2);
INLEVEL
if (!mo) {
if (!mo || !ISINLEVEL) {
if (field == mobj_valid) {
lua_pushboolean(L, 0);
return 1;
}
if (!mo) {
return LUA_ErrInvalid(L, "mobj_t");
} else
return luaL_error(L, "Do not access an mobj_t field outside a level!");
}
switch(field)

View file

@ -1442,19 +1442,19 @@ static menuitem_t OP_ColorOptionsMenu[] =
static menuitem_t OP_OpenGLOptionsMenu[] =
{
{IT_HEADER, NULL, "3D Models", NULL, 0},
{IT_STRING|IT_CVAR, NULL, "Models", &cv_grmodels, 12},
{IT_STRING|IT_CVAR, NULL, "Frame interpolation", &cv_grmodelinterpolation, 22},
{IT_STRING|IT_CVAR, NULL, "Ambient lighting", &cv_grmodellighting, 32},
{IT_STRING|IT_CVAR, NULL, "Models", &cv_glmodels, 12},
{IT_STRING|IT_CVAR, NULL, "Frame interpolation", &cv_glmodelinterpolation, 22},
{IT_STRING|IT_CVAR, NULL, "Ambient lighting", &cv_glmodellighting, 32},
{IT_HEADER, NULL, "General", NULL, 51},
{IT_STRING|IT_CVAR, NULL, "Shaders", &cv_grshaders, 63},
{IT_STRING|IT_CVAR, NULL, "Lack of perspective", &cv_grshearing, 73},
{IT_STRING|IT_CVAR, NULL, "Shaders", &cv_glshaders, 63},
{IT_STRING|IT_CVAR, NULL, "Lack of perspective", &cv_glshearing, 73},
{IT_STRING|IT_CVAR, NULL, "Field of view", &cv_fov, 83},
{IT_HEADER, NULL, "Miscellaneous", NULL, 102},
{IT_STRING|IT_CVAR, NULL, "Bit depth", &cv_scr_depth, 114},
{IT_STRING|IT_CVAR, NULL, "Texture filter", &cv_grfiltermode, 124},
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 134},
{IT_STRING|IT_CVAR, NULL, "Texture filter", &cv_glfiltermode, 124},
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 134},
#ifdef ALAM_LIGHTING
{IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 144},
#endif
@ -1466,10 +1466,10 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
#ifdef ALAM_LIGHTING
static menuitem_t OP_OpenGLLightingMenu[] =
{
{IT_STRING|IT_CVAR, NULL, "Coronas", &cv_grcoronas, 0},
{IT_STRING|IT_CVAR, NULL, "Coronas size", &cv_grcoronasize, 10},
{IT_STRING|IT_CVAR, NULL, "Dynamic lighting", &cv_grdynamiclighting, 20},
{IT_STRING|IT_CVAR, NULL, "Static lighting", &cv_grstaticlighting, 30},
{IT_STRING|IT_CVAR, NULL, "Coronas", &cv_glcoronas, 0},
{IT_STRING|IT_CVAR, NULL, "Coronas size", &cv_glcoronasize, 10},
{IT_STRING|IT_CVAR, NULL, "Dynamic lighting", &cv_gldynamiclighting, 20},
{IT_STRING|IT_CVAR, NULL, "Static lighting", &cv_glstaticlighting, 30},
};
#endif // ALAM_LIGHTING

View file

@ -467,10 +467,22 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if ((P_MobjFlip(toucher)*toucher->momz < 0) && (elementalpierce != 1))
{
if (elementalpierce == 2)
if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2))
{
fixed_t setmomz = -toucher->momz; // Store this, momz get changed by P_DoJump within P_DoBubbleBounce
if (elementalpierce == 2) // Reset bubblewrap, part 1
P_DoBubbleBounce(player);
else if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2))
toucher->momz = -toucher->momz;
toucher->momz = setmomz;
if (elementalpierce == 2) // Reset bubblewrap, part 2
{
boolean underwater = toucher->eflags & MFE_UNDERWATER;
if (underwater)
toucher->momz /= 2;
toucher->momz -= (toucher->momz/(underwater ? 8 : 4)); // Cap the height!
}
}
}
if (player->pflags & PF_BOUNCING)
P_DoAbilityBounce(player, false);

View file

@ -177,6 +177,7 @@ void P_BlackOw(player_t *player);
void P_ElementalFire(player_t *player, boolean cropcircle);
void P_SpawnSkidDust(player_t *player, fixed_t radius, boolean sound);
void P_MovePlayer(player_t *player);
void P_DoPityCheck(player_t *player);
void P_PlayerThink(player_t *player);
void P_PlayerAfterThink(player_t *player);

View file

@ -1678,13 +1678,23 @@ static boolean PIT_CheckThing(mobj_t *thing)
&& (flipval*(*momz) < 0) // monitor is on the floor and you're going down, or on the ceiling and you're going up
&& (elementalpierce != 1)) // you're not piercing through the monitor...
{
if (elementalpierce == 2)
P_DoBubbleBounce(player);
else if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2))
if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2))
{
*momz = -*momz; // Therefore, you should be thrust in the opposite direction, vertically.
fixed_t setmomz = -*momz; // Store this, momz get changed by P_DoJump within P_DoBubbleBounce
if (elementalpierce == 2) // Reset bubblewrap, part 1
P_DoBubbleBounce(player);
*momz = setmomz; // Therefore, you should be thrust in the opposite direction, vertically.
if (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY)
P_TwinSpinRejuvenate(player, player->thokitem);
if (elementalpierce == 2) // Reset bubblewrap, part 2
{
boolean underwater = tmthing->eflags & MFE_UNDERWATER;
if (underwater)
*momz /= 2;
*momz -= (*momz/(underwater ? 8 : 4)); // Cap the height!
}
}
}
if (!(elementalpierce == 1 && thing->flags & MF_GRENADEBOUNCE)) // prevent gold monitor clipthrough.

View file

@ -2102,7 +2102,7 @@ void P_XYMovement(mobj_t *mo)
P_XYFriction(mo, oldx, oldy);
}
static void P_RingXYMovement(mobj_t *mo)
void P_RingXYMovement(mobj_t *mo)
{
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
@ -2111,7 +2111,7 @@ static void P_RingXYMovement(mobj_t *mo)
P_SlideMove(mo);
}
static void P_SceneryXYMovement(mobj_t *mo)
void P_SceneryXYMovement(mobj_t *mo)
{
fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls
@ -2270,7 +2270,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec)
}
}
static void P_RingZMovement(mobj_t *mo)
void P_RingZMovement(mobj_t *mo)
{
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
@ -2337,7 +2337,7 @@ boolean P_CheckSolidLava(ffloor_t *rover)
// P_ZMovement
// Returns false if the mobj was killed/exploded/removed, true otherwise.
//
static boolean P_ZMovement(mobj_t *mo)
boolean P_ZMovement(mobj_t *mo)
{
fixed_t dist, delta;
boolean onground;
@ -2891,7 +2891,7 @@ static boolean P_PlayerPolyObjectZMovement(mobj_t *mo)
return stopmovecut;
}
static void P_PlayerZMovement(mobj_t *mo)
void P_PlayerZMovement(mobj_t *mo)
{
boolean onground;
@ -3069,7 +3069,7 @@ nightsdone:
}
}
static boolean P_SceneryZMovement(mobj_t *mo)
boolean P_SceneryZMovement(mobj_t *mo)
{
// Intercept the stupid 'fall through 3dfloors' bug
if (mo->subsector->sector->ffloors)

View file

@ -471,6 +471,12 @@ void P_NullPrecipThinker(precipmobj_t *mobj);
void P_RemovePrecipMobj(precipmobj_t *mobj);
void P_SetScale(mobj_t *mobj, fixed_t newscale);
void P_XYMovement(mobj_t *mo);
void P_RingXYMovement(mobj_t *mo);
void P_SceneryXYMovement(mobj_t *mo);
boolean P_ZMovement(mobj_t *mo);
void P_RingZMovement(mobj_t *mo);
boolean P_SceneryZMovement(mobj_t *mo);
void P_PlayerZMovement(mobj_t *mo);
void P_EmeraldManager(void);
extern INT32 modulothing;

View file

@ -3755,7 +3755,7 @@ boolean P_LoadLevel(boolean fromnetsave)
if (!lastmaploaded) // Start a new game?
{
// I'd love to do this in the menu code instead of here, but everything's a mess and I can't guarantee saving proper player struct info before the first act's started. You could probably refactor it, but it'd be a lot of effort. Easier to just work off known good code. ~toast 22/06/2020
if (!(ultimatemode || netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking)
if (!(ultimatemode || netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || marathonmode)
&& (!modifiedgame || savemoddata) && cursaveslot > 0)
G_SaveGame((UINT32)cursaveslot, gamemap);
// If you're looking for saving sp file progression (distinct from G_SaveGameOver), check G_DoCompleted.

View file

@ -4863,7 +4863,7 @@ void P_DoBubbleBounce(player_t *player)
player->pflags |= PF_THOKKED;
player->pflags &= ~PF_STARTJUMP;
player->secondjump = UINT8_MAX;
player->mo->momz = FixedMul(player->mo->momz, 5*FRACUNIT/4);
player->mo->momz = FixedMul(player->mo->momz, 11*FRACUNIT/8);
}
//
@ -5112,15 +5112,19 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
boolean elem = ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL);
player->pflags |= PF_THOKKED|PF_SHIELDABILITY;
if (elem)
{
player->mo->momx = player->mo->momy = 0;
S_StartSound(player->mo, sfx_s3k43);
}
else
{
player->mo->momx -= (player->mo->momx/3);
player->mo->momy -= (player->mo->momy/3);
player->pflags &= ~PF_NOJUMPDAMAGE;
P_SetPlayerMobjState(player->mo, S_PLAY_ROLL);
S_StartSound(player->mo, sfx_s3k44);
}
player->secondjump = 0;
player->mo->momx = player->mo->momy = 0;
P_SetObjectMomZ(player->mo, -24*FRACUNIT, false);
break;
}
@ -7885,7 +7889,7 @@ static void P_SkidStuff(player_t *player)
//
// P_MovePlayer
static void P_MovePlayer(player_t *player)
void P_MovePlayer(player_t *player)
{
ticcmd_t *cmd;
INT32 i;
@ -10042,7 +10046,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (camorbit) //Sev here, I'm guessing this is where orbital cam lives
{
#ifdef HWRENDER
if (rendermode == render_opengl && !cv_grshearing.value)
if (rendermode == render_opengl && !cv_glshearing.value)
distxy = FixedMul(dist, FINECOSINE((focusaiming>>ANGLETOFINESHIFT) & FINEMASK));
else
#endif

View file

@ -227,6 +227,8 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex
}
}
// Blends two pixels together, using the equation
// that matches the specified alpha style.
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha)
{
RGBA_t output;
@ -245,7 +247,13 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph
// if the background pixel is empty,
// match software and don't blend anything
if (!background.s.alpha)
output.s.alpha = 0;
{
// ...unless the foreground pixel ISN'T actually translucent.
if (alpha == 0xFF)
output.rgba = foreground.rgba;
else
output.rgba = 0;
}
else
{
UINT8 beta = (0xFF - alpha);
@ -302,18 +310,46 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph
return 0;
}
UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha)
INT32 ASTTextureBlendingThreshold[2] = {255/11, (10*255/11)};
// Blends a pixel for a texture patch.
UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha)
{
// Alpha style set to translucent?
if (style == AST_TRANSLUCENT)
{
// Is the alpha small enough for translucency?
if (alpha <= (10*255/11))
if (alpha <= ASTTextureBlendingThreshold[1])
{
// Is the patch way too translucent? Don't blend then.
if (alpha < ASTTextureBlendingThreshold[0])
return background.rgba;
return ASTBlendPixel(background, foreground, style, alpha);
}
else // just copy the pixel
return foreground.rgba;
}
else
return ASTBlendPixel(background, foreground, style, alpha);
}
// Blends two palette indexes for a texture patch, then
// finds the nearest palette index from the blended output.
UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT8 alpha)
{
// Alpha style set to translucent?
if (style == AST_TRANSLUCENT)
{
// Is the alpha small enough for translucency?
if (alpha <= ASTTextureBlendingThreshold[1])
{
UINT8 *mytransmap;
// Is the patch way too translucent? Don't blend then.
if (alpha < 255/11)
if (alpha < ASTTextureBlendingThreshold[0])
return background;
// The equation's not exact but it works as intended. I'll call it a day for now.
mytransmap = transtables + ((8*(alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT);
if (background != 0xFF)
@ -378,7 +414,7 @@ static inline void R_DrawBlendColumnInCache(column_t *patch, UINT8 *cache, texpa
{
for (; dest < cache + position + count; source++, dest++)
if (*source != 0xFF)
*dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha);
*dest = ASTBlendPaletteIndexes(*dest, *source, originPatch->style, originPatch->alpha);
}
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
@ -422,7 +458,7 @@ static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache
{
for (; dest < cache + position + count; --source, dest++)
if (*source != 0xFF)
*dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha);
*dest = ASTBlendPaletteIndexes(*dest, *source, originPatch->style, originPatch->alpha);
}
patch = (column_t *)((UINT8 *)patch + patch->length + 4);

View file

@ -26,7 +26,10 @@
enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY};
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha);
UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha);
UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha);
UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT8 alpha);
extern INT32 ASTTextureBlendingThreshold[2];
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);

View file

@ -429,12 +429,12 @@ UINT16 R_GetColorByName(const char *name)
for (color = 1; color < numskincolors; color++)
if (!stricmp(skincolors[color].name, name))
return color;
return SKINCOLOR_GREEN;
return SKINCOLOR_NONE;
}
UINT16 R_GetSuperColorByName(const char *name)
{
UINT16 i, color = SKINCOLOR_SUPERGOLD1;
UINT16 i, color = SKINCOLOR_NONE;
char *realname = Z_Malloc(MAXCOLORNAME+1, PU_STATIC, NULL);
snprintf(realname, MAXCOLORNAME+1, "Super %s 1", name);
for (i = 1; i < numskincolors; i++)

View file

@ -1064,7 +1064,7 @@ static void R_SetupFreelook(void)
// (lmps, network and use F12...)
if (rendermode == render_soft
#ifdef HWRENDER
|| cv_grshearing.value
|| cv_glshearing.value
#endif
)
{

View file

@ -319,11 +319,11 @@ void *Patch_CacheGL(UINT16 wad, UINT16 lump, INT32 tag, boolean store)
{
GLPatch_t *grPatch = HWR_GetCachedGLPatchPwad(wad, lump, Patch_GetRendererBaseSubTree(wad, render_opengl));
if (grPatch->mipmap->grInfo.data)
if (grPatch->mipmap->data)
{
if (tag == PU_CACHE)
tag = PU_HWRCACHE;
Z_ChangeTag(grPatch->mipmap->grInfo.data, tag);
Z_ChangeTag(grPatch->mipmap->data, tag);
}
else
{

View file

@ -464,12 +464,19 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
GETINT(contangle)
#undef GETINT
#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) skin->field = R_GetColorByName(value);
#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) \
{ \
UINT16 color = R_GetColorByName(value); \
skin->field = (color ? color : SKINCOLOR_GREEN); \
}
GETSKINCOLOR(prefcolor)
GETSKINCOLOR(prefoppositecolor)
#undef GETSKINCOLOR
else if (!stricmp(stoken, "supercolor"))
skin->supercolor = R_GetSuperColorByName(value);
{
UINT16 color = R_GetSuperColorByName(value);
skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1);
}
#define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value));
GETFLOAT(jumpfactor)

View file

@ -226,7 +226,6 @@
<ClInclude Include="..\hardware\hw_defs.h" />
<ClInclude Include="..\hardware\hw_dll.h" />
<ClInclude Include="..\hardware\hw_drv.h" />
<ClInclude Include="..\hardware\hw_glide.h" />
<ClInclude Include="..\hardware\hw_glob.h" />
<ClInclude Include="..\hardware\hw_light.h" />
<ClInclude Include="..\hardware\hw_main.h" />

View file

@ -237,9 +237,6 @@
<ClInclude Include="..\hardware\hw_drv.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\hardware\hw_glide.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\hardware\hw_glob.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>

View file

@ -2410,10 +2410,6 @@
RelativePath="..\hardware\hw_drv.h"
>
</File>
<File
RelativePath="..\hardware\hw_glide.h"
>
</File>
<File
RelativePath="..\hardware\hw_glob.h"
>

View file

@ -576,10 +576,6 @@ SOURCE=..\hardware\hw_drv.h
# End Source File
# Begin Source File
SOURCE=..\hardware\hw_glide.h
# End Source File
# Begin Source File
SOURCE=..\hardware\hw_glob.h
# End Source File
# Begin Source File

View file

@ -1064,13 +1064,6 @@
path = ../../hardware/hw_drv.h;
refType = 2;
};
8417773B085A106C000C01D8 = {
fileEncoding = 30;
isa = PBXFileReference;
name = hw_glide.h;
path = ../../hardware/hw_glide.h;
refType = 2;
};
8417773C085A106C000C01D8 = {
fileEncoding = 30;
isa = PBXFileReference;

View file

@ -181,7 +181,6 @@
1E44AE640B67CC2B00BAD059 /* hw_cache.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_cache.c; path = ../../hardware/hw_cache.c; sourceTree = SOURCE_ROOT; };
1E44AE650B67CC2B00BAD059 /* hw_dll.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_dll.h; path = ../../hardware/hw_dll.h; sourceTree = SOURCE_ROOT; };
1E44AE660B67CC2B00BAD059 /* hw_drv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_drv.h; path = ../../hardware/hw_drv.h; sourceTree = SOURCE_ROOT; };
1E44AE670B67CC2B00BAD059 /* hw_glide.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_glide.h; path = ../../hardware/hw_glide.h; sourceTree = SOURCE_ROOT; };
1E44AE680B67CC2B00BAD059 /* hw_light.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_light.c; path = ../../hardware/hw_light.c; sourceTree = SOURCE_ROOT; };
1E44AE690B67CC2B00BAD059 /* hw_light.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_light.h; path = ../../hardware/hw_light.h; sourceTree = SOURCE_ROOT; };
1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3sound.h; path = ../../hardware/hw3sound.h; sourceTree = SOURCE_ROOT; };
@ -536,7 +535,6 @@
1E44AE640B67CC2B00BAD059 /* hw_cache.c */,
1E44AE650B67CC2B00BAD059 /* hw_dll.h */,
1E44AE660B67CC2B00BAD059 /* hw_drv.h */,
1E44AE670B67CC2B00BAD059 /* hw_glide.h */,
1E44AE680B67CC2B00BAD059 /* hw_light.c */,
1E44AE690B67CC2B00BAD059 /* hw_light.h */,
1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */,

View file

@ -240,8 +240,8 @@ void ST_LoadGraphics(void)
int i;
// SRB2 border patch
st_borderpatchnum = W_GetNumForName("GFZFLR01");
scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX);
// st_borderpatchnum = W_GetNumForName("GFZFLR01");
// scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX);
// the original Doom uses 'STF' as base name for all face graphics
// Graue 04-08-2004: face/name graphics are now indexed by skins

View file

@ -400,7 +400,6 @@
<ClInclude Include="..\hardware\hw_defs.h" />
<ClInclude Include="..\hardware\hw_dll.h" />
<ClInclude Include="..\hardware\hw_drv.h" />
<ClInclude Include="..\hardware\hw_glide.h" />
<ClInclude Include="..\hardware\hw_glob.h" />
<ClInclude Include="..\hardware\hw_light.h" />
<ClInclude Include="..\hardware\hw_main.h" />

View file

@ -519,9 +519,6 @@
<ClInclude Include="..\hardware\hw_drv.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\hardware\hw_glide.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\hardware\hw_glob.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>

View file

@ -2151,10 +2151,6 @@
RelativePath="..\hardware\hw_drv.h"
>
</File>
<File
RelativePath="..\hardware\hw_glide.h"
>
</File>
<File
RelativePath="..\hardware\hw_glob.h"
>

View file

@ -535,10 +535,6 @@ SOURCE=..\hardware\hw_drv.h
# End Source File
# Begin Source File
SOURCE=..\hardware\hw_glide.h
# End Source File
# Begin Source File
SOURCE=..\hardware\hw_glob.h
# End Source File
# Begin Source File