mirror of
https://github.com/snesrev/zelda3.git
synced 2025-12-19 18:05:55 -05:00
Add support for PNG files to shader code
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_ONLY_PNG
|
||||
#define STBI_MAX_DIMENSIONS 4096
|
||||
#define STBI_NO_FAILURE_STRINGS
|
||||
#include "third_party/stb/stb_image.h"
|
||||
|
||||
static GlslPass *ParseConfigKeyPass(GlslShader *gs, const char *key, const char *match) {
|
||||
char *endp;
|
||||
@@ -367,8 +372,19 @@ GlslShader *GlslShader_CreateFromFile(const char *filename) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, t->filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, t->mipmap ?
|
||||
(t->filter == GL_LINEAR ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST) : t->filter);
|
||||
// code to load png mssing
|
||||
fprintf(stderr, "PNG file reading not supported\n");
|
||||
if (t->filename) {
|
||||
char *new_filename = ReplaceFilenameWithNewPath(filename, t->filename);
|
||||
int imw, imh, imn;
|
||||
unsigned char *data = stbi_load(new_filename, &imw, &imh, &imn, 0);
|
||||
if (!data) {
|
||||
fprintf(stderr, "Unable to read PNG '%s'\n", new_filename);
|
||||
} else {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imw, imh, 0,
|
||||
(imn == 4) ? GL_RGBA : (imn == 3) ? GL_RGB : GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
|
||||
}
|
||||
free(data);
|
||||
free(new_filename);
|
||||
}
|
||||
if (t->mipmap)
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ IF NOT EXIST "tables\zelda3_assets.dat" (
|
||||
|
||||
|
||||
echo Building with TCC...
|
||||
third_party\tcc\tcc.exe -ozelda3.exe -DCOMPILER_TCC=1 -DHAVE_STDINT_H=1 -D_HAVE_STDINT_H=1 -DSYSTEM_VOLUME_MIXER_AVAILABLE=0 -I%SDL2%/include -L%SDL2%/lib/x64 -lSDL2 *.c snes/*.c third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
|
||||
third_party\tcc\tcc.exe -ozelda3.exe -DCOMPILER_TCC=1 -DSTBI_NO_SIMD=1 -DHAVE_STDINT_H=1 -D_HAVE_STDINT_H=1 -DSYSTEM_VOLUME_MIXER_AVAILABLE=0 -I%SDL2%/include -L%SDL2%/lib/x64 -lSDL2 *.c snes/*.c third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
|
||||
IF ERRORLEVEL 1 goto GETOUT
|
||||
|
||||
copy %SDL2%\lib\x64\SDL2.dll .
|
||||
|
||||
7897
third_party/stb/stb_image.h
vendored
Normal file
7897
third_party/stb/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user