d1d0d86fea
Fix sound source issues in Q3. Fix q2 air acceleration/prediction omission. Don't change console completion while typing (while that option is still possible). Shift+tab now cycles completion backwards (now ctrl+shift for cycle subconsoles). Allow a few things to ignore sv_pure - including csprogs files (which is useful for all the mods that come with the csprogs.dat distributed separately). clamp pitch values to the range documented by openal, to hopefully avoid error spam. add some colour coding to the text editor when shader files are being edited/viewed. Changed how overbrights are clamped on q3bsp. Added portalfboscale for explicit texture scales on portal/refract/reflect fbos. qc decompiler can now at least attempt to decompile qtest's qc. fteqccgui can now be pointed at a .pak file, and decompile the progs.dat inside. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5269 fc73d0e0-1445-4013-8a0c-d673dee63da5
172 lines
3.3 KiB
C
172 lines
3.3 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
char shaders[][64] =
|
|
{
|
|
"fixedemu",
|
|
"q3terrain",
|
|
"altwater",
|
|
"bloom_blur",
|
|
"bloom_filter",
|
|
"bloom_final",
|
|
"colourtint",
|
|
"crepuscular_opaque",
|
|
"crepuscular_rays",
|
|
"crepuscular_sky",
|
|
"depthonly",
|
|
"default2d",
|
|
"defaultadditivesprite",
|
|
"defaultskin",
|
|
"defaultsky",
|
|
"defaultskybox",
|
|
"defaultfill",
|
|
"defaultsprite",
|
|
"defaultwall",
|
|
"defaultwarp",
|
|
"defaultgammacb",
|
|
"drawflat_wall",
|
|
"wireframe",
|
|
"itemtimer",
|
|
"lpp_depthnorm",
|
|
"lpp_light",
|
|
"lpp_wall",
|
|
"postproc_fisheye",
|
|
"postproc_panorama",
|
|
"postproc_laea",
|
|
"postproc_stereographic",
|
|
"postproc_equirectangular",
|
|
"fxaa",
|
|
"underwaterwarp",
|
|
"menutint",
|
|
"terrain",
|
|
"rtlight",
|
|
""
|
|
};
|
|
|
|
void dumpprogstring(FILE *out, FILE *src)
|
|
{
|
|
int j;
|
|
char line[1024];
|
|
|
|
while(fgets(line, sizeof(line), src))
|
|
{
|
|
j = 0;
|
|
while (line[j] == ' ' || line[j] == '\t')
|
|
j++;
|
|
if ((line[j] == '/' && line[j] == '/') || line[j] == '\r' || line[j] == '\n')
|
|
{
|
|
while (line[j])
|
|
fputc(line[j++], out);
|
|
}
|
|
else
|
|
{
|
|
fputc('\"', out);
|
|
while (line[j] && line[j] != '\r' && line[j] != '\n')
|
|
{
|
|
if (line[j] == '\t')
|
|
fputc(' ', out);
|
|
else if (line[j] == '\"')
|
|
{
|
|
fputc('\\', out);
|
|
fputc(line[j], out);
|
|
}
|
|
else
|
|
fputc(line[j], out);
|
|
j++;
|
|
}
|
|
fputs("\\n\"\n", out);
|
|
}
|
|
}
|
|
fflush(out);
|
|
}
|
|
void dumpprogblob(FILE *out, FILE *src)
|
|
{
|
|
unsigned char *buf;
|
|
unsigned int size;
|
|
fseek(src, 0, SEEK_END);
|
|
size = ftell(src);
|
|
fseek(src, 0, SEEK_SET);
|
|
buf = malloc(size);
|
|
fread(buf, size, 1, src);
|
|
|
|
size_t totallen, i, linelen;
|
|
totallen = 0;
|
|
linelen = 32;
|
|
fprintf(out, "\"");
|
|
for (i=0;i<size;i++)
|
|
{
|
|
fprintf(out, "\\x%02X",buf[i]);
|
|
if (i % linelen == linelen - 1)
|
|
fprintf(out, "\"\n\"");
|
|
}
|
|
fprintf(out, "\"");
|
|
}
|
|
|
|
struct shadertype_s
|
|
{
|
|
char *abrv;
|
|
char *filepattern;
|
|
char *preprocessor;
|
|
char *rendererapi;
|
|
int apiversion; //-1 is a binary blob.
|
|
} shadertype[] =
|
|
{
|
|
{"GL", "glsl/%s.glsl", "GLQUAKE", "QR_OPENGL", 110}, //gl2+
|
|
//{"ES","gles/%s.glsl", "GLQUAKE", "QR_OPENGL", 100}, //gles
|
|
{"VK", "vulkanblobs/%s.fvb", "VKQUAKE", "QR_VULKAN", -1}, //vulkan
|
|
{"D9", "hlsl9/%s.hlsl", "D3D9QUAKE", "QR_DIRECT3D9", 9}, //d3d9
|
|
{"D11","hlsl11/%s.hlsl", "D3D11QUAKE", "QR_DIRECT3D11", 11}, //d3d11
|
|
};
|
|
//tbh we should precompile the d3d shaders.
|
|
|
|
int main(void)
|
|
{
|
|
FILE *c, *s;
|
|
char line[1024];
|
|
int i, j, a;
|
|
c = fopen("../gl/r_bishaders.h", "wt");
|
|
|
|
if (!c)
|
|
{
|
|
printf("unable to open a file\n");
|
|
return 0;
|
|
}
|
|
|
|
fprintf(c, "/*\nWARNING: THIS FILE IS GENERATED BY '"__FILE__"'.\nYOU SHOULD NOT EDIT THIS FILE BY HAND\n*/\n\n");
|
|
|
|
for (i = 0; *shaders[i]; i++)
|
|
{
|
|
printf("%25s: ", shaders[i]);
|
|
for (a = 0; a < sizeof(shadertype)/sizeof(shadertype[0]); a++)
|
|
{
|
|
sprintf(line, shadertype[a].filepattern, shaders[i]);
|
|
if (shadertype[a].apiversion == -1)
|
|
s = fopen(line, "rb");
|
|
else
|
|
s = fopen(line, "rt");
|
|
if (!s)
|
|
{
|
|
printf("%4s", "");
|
|
continue;
|
|
}
|
|
fprintf(c, "#ifdef %s\n", shadertype[a].preprocessor);
|
|
fprintf(c, "{%s, %i, \"%s\",\n", shadertype[a].rendererapi, shadertype[a].apiversion, shaders[i]);
|
|
if (shadertype[a].apiversion == -1)
|
|
dumpprogblob(c,s);
|
|
else
|
|
dumpprogstring(c, s);
|
|
fputs("},\n", c);
|
|
fprintf(c, "#endif\n");
|
|
fclose(s);
|
|
fflush(c);
|
|
|
|
printf("%4s", shadertype[a].abrv);
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
fclose(c);
|
|
|
|
return 0;
|
|
}
|