mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 13:40:45 +00:00
Fix shader reading yet again
This commit is contained in:
parent
bdd43efb25
commit
c87119f18f
3 changed files with 28 additions and 14 deletions
|
@ -6147,13 +6147,14 @@ void HWR_AddSessionCommands(void)
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
void HWR_Startup(void)
|
void HWR_Startup(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
|
||||||
static boolean startupdone = false;
|
static boolean startupdone = false;
|
||||||
|
|
||||||
// do this once
|
// do this once
|
||||||
if (!startupdone)
|
if (!startupdone)
|
||||||
{
|
{
|
||||||
|
INT32 i;
|
||||||
CONS_Printf("HWR_Startup()...\n");
|
CONS_Printf("HWR_Startup()...\n");
|
||||||
|
|
||||||
HWR_InitPolyPool();
|
HWR_InitPolyPool();
|
||||||
HWR_AddSessionCommands();
|
HWR_AddSessionCommands();
|
||||||
HWR_InitTextureCache();
|
HWR_InitTextureCache();
|
||||||
|
@ -6161,16 +6162,17 @@ void HWR_Startup(void)
|
||||||
#ifdef ALAM_LIGHTING
|
#ifdef ALAM_LIGHTING
|
||||||
HWR_InitLight();
|
HWR_InitLight();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// read every custom shader
|
||||||
|
for (i = 0; i < numwadfiles; i++)
|
||||||
|
HWR_ReadShaders(i, (wadfiles[i]->type == RET_PK3));
|
||||||
|
HWR_LoadShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
textureformat = patchformat = GR_RGBA;
|
textureformat = patchformat = GR_RGBA;
|
||||||
|
|
||||||
startupdone = true;
|
startupdone = true;
|
||||||
|
|
||||||
for (i = 0; i < numwadfiles; i++)
|
|
||||||
HWR_LoadShaders(i, (wadfiles[i]->type == RET_PK3));
|
|
||||||
HWD.pfnInitCustomShaders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -6466,7 +6468,12 @@ static inline UINT16 HWR_CheckShader(UINT16 wadnum)
|
||||||
return INT16_MAX;
|
return INT16_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
|
void HWR_LoadShaders(void)
|
||||||
|
{
|
||||||
|
HWD.pfnInitCustomShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HWR_ReadShaders(UINT16 wadnum, boolean PK3)
|
||||||
{
|
{
|
||||||
UINT16 lump;
|
UINT16 lump;
|
||||||
char *shaderdef, *line;
|
char *shaderdef, *line;
|
||||||
|
@ -6497,9 +6504,6 @@ void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
|
||||||
size = W_LumpLengthPwad(wadnum, lump);
|
size = W_LumpLengthPwad(wadnum, lump);
|
||||||
|
|
||||||
line = Z_Malloc(size+1, PU_STATIC, NULL);
|
line = Z_Malloc(size+1, PU_STATIC, NULL);
|
||||||
if (!line)
|
|
||||||
I_Error("HWR_LoadShaders: No more free memory\n");
|
|
||||||
|
|
||||||
M_Memcpy(line, shaderdef, size);
|
M_Memcpy(line, shaderdef, size);
|
||||||
line[size] = '\0';
|
line[size] = '\0';
|
||||||
|
|
||||||
|
@ -6518,7 +6522,7 @@ void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
|
||||||
value = strtok(NULL, "\r\n ");
|
value = strtok(NULL, "\r\n ");
|
||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_WARNING, "HWR_LoadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
||||||
stoken = strtok(NULL, "\r\n"); // skip end of line
|
stoken = strtok(NULL, "\r\n"); // skip end of line
|
||||||
goto skip_lump;
|
goto skip_lump;
|
||||||
}
|
}
|
||||||
|
@ -6537,14 +6541,14 @@ skip_lump:
|
||||||
value = strtok(NULL, "\r\n= ");
|
value = strtok(NULL, "\r\n= ");
|
||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_WARNING, "HWR_LoadShaders: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
||||||
stoken = strtok(NULL, "\r\n"); // skip end of line
|
stoken = strtok(NULL, "\r\n"); // skip end of line
|
||||||
goto skip_field;
|
goto skip_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shadertype)
|
if (!shadertype)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "HWR_LoadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
||||||
Z_Free(line);
|
Z_Free(line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6575,7 +6579,7 @@ skip_lump:
|
||||||
|
|
||||||
if (shader_lumpnum == INT16_MAX)
|
if (shader_lumpnum == INT16_MAX)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "HWR_LoadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
|
CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
|
||||||
Z_Free(shader_lumpname);
|
Z_Free(shader_lumpname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@ void HWR_DrawScreenFinalTexture(int width, int height);
|
||||||
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
|
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
|
||||||
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
|
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
|
||||||
|
|
||||||
void HWR_LoadShaders(UINT16 wadnum, boolean PK3);
|
void HWR_ReadShaders(UINT16 wadnum, boolean PK3);
|
||||||
|
void HWR_LoadShaders(void);
|
||||||
|
|
||||||
extern CV_PossibleValue_t granisotropicmode_cons_t[];
|
extern CV_PossibleValue_t granisotropicmode_cons_t[];
|
||||||
|
|
||||||
|
|
|
@ -788,6 +788,15 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
|
||||||
wadfiles[numwadfiles] = wadfile;
|
wadfiles[numwadfiles] = wadfile;
|
||||||
numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
|
numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
|
||||||
|
|
||||||
|
#ifdef HWRENDER
|
||||||
|
// Read shaders from file
|
||||||
|
if (rendermode == render_opengl && hwrenderloaded)
|
||||||
|
{
|
||||||
|
HWR_ReadShaders(numwadfiles - 1, (type == RET_PK3));
|
||||||
|
HWR_LoadShaders();
|
||||||
|
}
|
||||||
|
#endif // HWRENDER
|
||||||
|
|
||||||
// TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now.
|
// TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now.
|
||||||
switch (wadfile->type)
|
switch (wadfile->type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue