q3rally/engine/code/tools/stringify.c
zturtleman 1568196e27 ioquake3 resync to revision 6920 from 6893.
Updated to latest recommended build settings, increased deployment target to 10.7
Further tweaks to Xcode project
Now works as well as possible in Xcode 11
Figured out method of referencing GLSL generated C files outside of code directory
Update README.md
Add C syntax highlighting to readme
Simplify glsl -> C stringification
Make LCC path resolution more robust
GitHub Actions setup
Remove old CI system configurations
Add status badge to README
Fix shader stringify
Run apt-get update before installing deps
Avoid platform sed differences
Run actions on pull request too
Use `r_texturemode GL_LINEAR_MIPMAP_LINEAR` by default
[sdl] Turn tentative definition into actual definition.
Add TOOLS_CFLAGS to build preamble
Fix use of TOOLS_CC being reported as CC
Use the correct compiler for tools when cross building under cygwin
Allow using pulseaudio for SDL audio capture
Restore bots crushing unseen player on q3tourney6 in non-CTF
Fix the number of weights in the IQM model calculation
Fixes a crash when compiling the project on windows in 64 bit mode.
2021-06-07 09:11:19 +00:00

51 lines
953 B
C

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <libgen.h>
int main(int argc, char **argv)
{
FILE *ifp;
FILE *ofp;
char buffer[1024];
if(argc < 3)
return 1;
char *inFile = argv[1];
char *outFile = argv[2];
ifp = fopen(inFile, "r");
if(!ifp)
return 2;
ofp = fopen(outFile, "w");
if(!ofp)
return 3;
// Strip extension
char *base = basename(inFile);
*strrchr(base, '.') = '\0';
fprintf(ofp, "const char *fallbackShader_%s =\n", base);
while(fgets(buffer, sizeof(buffer), ifp))
{
// Strip trailing whitespace from line
char *end = buffer + strlen(buffer) - 1;
while(end >= buffer && isspace(*end))
end--;
end[1] = '\0';
// Write line enquoted, with a newline
fprintf(ofp, "\"%s\\n\"\n", buffer);
}
fprintf(ofp, ";\n");
fclose(ifp);
fclose(ofp);
return 0;
}