mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-14 21:39:09 +00:00
Add glf patching utility
This commit is contained in:
parent
d676d81137
commit
b844dee736
2 changed files with 80 additions and 0 deletions
10
tools/Makefile
Normal file
10
tools/Makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
CC=gcc
|
||||
|
||||
CFLAGS=-Wall -pedantic -pipe -O2
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: glfpatch
|
||||
|
||||
glfpatch: glfpatch.c
|
||||
${CC} ${CFLAGS} -o $@ $<
|
70
tools/glfpatch.c
Normal file
70
tools/glfpatch.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* Conversion utility to hackpatch glf files. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float dx, dy;
|
||||
float tx1, ty1;
|
||||
float tx2, ty2;
|
||||
} GLFontChar;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int tex; /* tex id, unused */
|
||||
unsigned int tw; /* tex width */
|
||||
unsigned int th; /* tex height */
|
||||
unsigned int sc; /* start char number */
|
||||
unsigned int ec; /* end char number */
|
||||
unsigned int chrs; /* chars cound, unused*/
|
||||
} GLFontHeader;
|
||||
|
||||
#define CHR_SIZE_KOEFF_X 8.0f/256.0f
|
||||
#define CHR_SIZE_KOEFF_Y 8.5f/256.0f
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned int i, num_chars;
|
||||
GLFontChar cc;
|
||||
GLFontHeader h;
|
||||
FILE *in, *out;
|
||||
|
||||
|
||||
in = fopen("in.glf", "rb");
|
||||
out = fopen("out.glf", "wb");
|
||||
|
||||
if(!(in && out))
|
||||
return 1;
|
||||
|
||||
fread(&h, 1, sizeof(h), in);
|
||||
|
||||
/* Fix it. */
|
||||
h.tw *= 2;
|
||||
h.th *= 2;
|
||||
|
||||
fwrite(&h, 1, sizeof(h), out);
|
||||
|
||||
num_chars = h.ec - h.sc + 1;
|
||||
|
||||
|
||||
for(i = 0; i < num_chars; ++i)
|
||||
{
|
||||
fread(&cc, 1, sizeof(cc), in);
|
||||
|
||||
/* Fix it. */
|
||||
cc.dx *= CHR_SIZE_KOEFF_X;
|
||||
cc.dy *= CHR_SIZE_KOEFF_Y;
|
||||
|
||||
fwrite(&cc, 1, sizeof(cc), out);
|
||||
}
|
||||
|
||||
/* We don't write actual image data. */
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue