Last active
March 7, 2021 18:34
-
-
Save hikiko/7ecc794fbc978e2e9ef57701f6828571 to your computer and use it in GitHub Desktop.
copy paste it to dump float rgba textures (*data = the pointer I'd give in TexImage2D)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool | |
dump_float_image_rgba(const char *fname, | |
int w, int h, | |
float *data) | |
{ | |
FILE *fp; | |
int i; | |
float *p; | |
if (!(fp = fopen(fname, "wb"))) { | |
fprintf(stderr, "Failed to open file: %s.\n", fname); | |
return false; | |
} | |
p = data; | |
fprintf(fp, "P6\n%d %d\n255\n", w, h); | |
for (i = 0; i < w * h; i++) { | |
fputc(p[0] * 255, fp); | |
fputc(p[1] * 255, fp); | |
fputc(p[2] * 255, fp); | |
p += 4; | |
} | |
fclose(fp); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment