2016-07-12 00:40:13 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
char shaders[][64] =
|
|
|
|
{
|
|
|
|
"fixedemu",
|
2018-07-05 16:21:44 +00:00
|
|
|
"q3terrain",
|
2016-07-12 00:40:13 +00:00
|
|
|
"altwater",
|
|
|
|
"bloom_blur",
|
|
|
|
"bloom_filter",
|
|
|
|
"bloom_final",
|
|
|
|
"colourtint",
|
|
|
|
"crepuscular_opaque",
|
|
|
|
"crepuscular_rays",
|
|
|
|
"crepuscular_sky",
|
|
|
|
"depthonly",
|
|
|
|
"default2d",
|
|
|
|
"defaultadditivesprite",
|
|
|
|
"defaultskin",
|
|
|
|
"defaultsky",
|
2017-08-29 02:29:06 +00:00
|
|
|
"defaultskybox",
|
2016-07-12 00:40:13 +00:00
|
|
|
"defaultfill",
|
|
|
|
"defaultsprite",
|
|
|
|
"defaultwall",
|
|
|
|
"defaultwarp",
|
|
|
|
"defaultgammacb",
|
|
|
|
"drawflat_wall",
|
2017-03-06 14:06:12 +00:00
|
|
|
"wireframe",
|
2017-05-18 10:24:09 +00:00
|
|
|
"itemtimer",
|
2016-07-12 00:40:13 +00:00
|
|
|
"lpp_depthnorm",
|
|
|
|
"lpp_light",
|
|
|
|
"lpp_wall",
|
|
|
|
"postproc_fisheye",
|
|
|
|
"postproc_panorama",
|
|
|
|
"postproc_laea",
|
|
|
|
"postproc_stereographic",
|
|
|
|
"postproc_equirectangular",
|
2018-08-13 06:27:29 +00:00
|
|
|
"postproc_ascii",
|
2016-07-12 00:40:13 +00:00
|
|
|
"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')
|
|
|
|
{
|
2018-09-29 17:31:58 +00:00
|
|
|
for (; line[j]; j++)
|
|
|
|
{
|
|
|
|
if (line[j] != '\r')
|
|
|
|
fputc(line[j], out);
|
|
|
|
}
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
2016-07-28 13:18:22 +00:00
|
|
|
void dumpprogblob(FILE *out, FILE *src)
|
2016-07-12 00:40:13 +00:00
|
|
|
{
|
2016-07-28 13:18:22 +00:00
|
|
|
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);
|
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
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
|
|
|
|
{
|
2016-07-28 13:18:22 +00:00
|
|
|
char *abrv;
|
2016-07-12 00:40:13 +00:00
|
|
|
char *filepattern;
|
|
|
|
char *preprocessor;
|
|
|
|
char *rendererapi;
|
2016-07-28 13:18:22 +00:00
|
|
|
int apiversion; //-1 is a binary blob.
|
2016-07-12 00:40:13 +00:00
|
|
|
} shadertype[] =
|
|
|
|
{
|
2016-07-28 13:18:22 +00:00
|
|
|
{"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
|
2016-07-12 00:40:13 +00:00
|
|
|
};
|
|
|
|
//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");
|
2018-07-05 16:21:44 +00:00
|
|
|
return 0;
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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++)
|
|
|
|
{
|
2016-07-28 13:18:22 +00:00
|
|
|
printf("%25s: ", shaders[i]);
|
2016-07-12 00:40:13 +00:00
|
|
|
for (a = 0; a < sizeof(shadertype)/sizeof(shadertype[0]); a++)
|
|
|
|
{
|
2016-07-28 13:18:22 +00:00
|
|
|
sprintf(line, shadertype[a].filepattern, shaders[i]);
|
2016-07-12 00:40:13 +00:00
|
|
|
if (shadertype[a].apiversion == -1)
|
2016-07-28 13:18:22 +00:00
|
|
|
s = fopen(line, "rb");
|
|
|
|
else
|
|
|
|
s = fopen(line, "rt");
|
|
|
|
if (!s)
|
2016-07-12 00:40:13 +00:00
|
|
|
{
|
2016-07-28 13:18:22 +00:00
|
|
|
printf("%4s", "");
|
|
|
|
continue;
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
2016-07-28 13:18:22 +00:00
|
|
|
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);
|
2016-07-12 00:40:13 +00:00
|
|
|
else
|
|
|
|
dumpprogstring(c, s);
|
2016-07-28 13:18:22 +00:00
|
|
|
fputs("},\n", c);
|
|
|
|
fprintf(c, "#endif\n");
|
|
|
|
fclose(s);
|
2016-07-12 00:40:13 +00:00
|
|
|
fflush(c);
|
2016-07-28 13:18:22 +00:00
|
|
|
|
|
|
|
printf("%4s", shadertype[a].abrv);
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
2016-07-28 13:18:22 +00:00
|
|
|
printf("\n");
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose(c);
|
2018-07-05 16:21:44 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|