diff --git a/Makefile b/Makefile index 7e77dcb263..e0615153e3 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include config.mk TARGET = ssnes tools/ssnes-joyconfig -OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o ups.o strl.o screenshot.o gfx/image.o +OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o ups.o strl.o screenshot.o JOYCONFIG_OBJ = tools/ssnes-joyconfig.o conf/config_file.o HEADERS = $(wildcard */*.h) $(wildcard *.h) @@ -92,7 +92,7 @@ ifeq ($(HAVE_CG), 1) endif ifeq ($(HAVE_XML), 1) - OBJ += gfx/shader_glsl.o sha256.o cheats.o + OBJ += gfx/shader_glsl.o gfx/image.o sha256.o cheats.o LIBS += $(XML_LIBS) DEFINES += $(XML_CFLAGS) endif diff --git a/Makefile.win32 b/Makefile.win32 index 564e777301..a77dc93da2 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -50,7 +50,7 @@ ifeq ($(HAVE_RSOUND), 1) endif ifeq ($(HAVE_XML), 1) - OBJ += gfx/shader_glsl.o sha256.o cheats.o + OBJ += gfx/shader_glsl.o gfx/image.o sha256.o cheats.o DEFINES += $(XML_CFLAGS) -DHAVE_XML LIBS += -lxml2 endif diff --git a/Makefile.win64 b/Makefile.win64 index 7d2e07f9fd..ee468c5737 100644 --- a/Makefile.win64 +++ b/Makefile.win64 @@ -50,7 +50,7 @@ ifeq ($(HAVE_RSOUND), 1) endif ifeq ($(HAVE_XML), 1) - OBJ += gfx/shader_glsl.o sha256.o cheats.o + OBJ += gfx/shader_glsl.o gfx/image.o sha256.o cheats.o DEFINES += $(XML_CFLAGS) -DHAVE_XML -DLIBXML_STATIC LIBS += -lxml2 -lz -lws2_32 endif diff --git a/config.features.h b/config.features.h index 59264f639d..268e1cbd85 100644 --- a/config.features.h +++ b/config.features.h @@ -80,6 +80,12 @@ static const bool _xml_supp = true; static const bool _xml_supp = false; #endif +#ifdef HAVE_IMLIB +static const bool _imlib_supp = true; +#else +static const bool _imlib_supp = false; +#endif + #ifdef HAVE_FBO static const bool _fbo_supp = true; #else diff --git a/gfx/gl.c b/gfx/gl.c index 7c36c63039..768f89ebf2 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -103,6 +103,7 @@ static bool load_fbo_proc(void) { return true; } #endif #endif + #define MAX_SHADERS 16 typedef struct gl @@ -1009,11 +1010,15 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo memcpy(gl->tex_coords, tex_coords, sizeof(tex_coords)); glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), gl->tex_coords); +#ifdef HAVE_XML // For texture images. - glClientActiveTexture(GL_TEXTURE1); + // Win32 GL lib doesn't have this. Just remacro for other platforms. + load_gl_proc(); + pglClientActiveTexture(GL_TEXTURE1); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), tex_coords); - glClientActiveTexture(GL_TEXTURE0); + pglClientActiveTexture(GL_TEXTURE0); +#endif gl->tex_w = 256 * video->input_scale; gl->tex_h = 256 * video->input_scale; diff --git a/gfx/gl_common.h b/gfx/gl_common.h index fe3e52f720..3794a33091 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -19,6 +19,11 @@ #define __GL_COMMON_H #include "general.h" +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #ifdef __APPLE__ #include @@ -29,6 +34,10 @@ #include #endif +#define NO_SDL_GLEXT +#include "SDL.h" +#include "SDL_opengl.h" + static inline bool gl_check_error(void) { int error = glGetError(); @@ -93,4 +102,24 @@ struct gl_fbo_scale bool valid; }; +// Windows ... <_< +#ifdef HAVE_XML +#ifdef _WIN32 +static PFNGLCLIENTACTIVETEXTUREPROC pglClientActiveTexture = NULL; +static PFNGLACTIVETEXTUREPROC pglActiveTexture = NULL; +#define LOAD_SYM(sym) if (!p##sym) p##sym = ((void*)SDL_GL_GetProcAddress(#sym)) +static void load_gl_proc(void) +{ + LOAD_SYM(glClientActiveTexture); + LOAD_SYM(glActiveTexture); + + assert(pglClientActiveTexture && pglActiveTexture); +} +#else +#define pglClientActiveTexture glClientActiveTexture +#define pglActiveTexture glActiveTexture +#define load_gl_proc() +#endif +#endif + #endif diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index efc2291580..135ff78e7d 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -329,7 +329,11 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr) strlcpy(gl_teximage_uniforms[gl_teximage_cnt], (const char*)id, sizeof(gl_teximage_uniforms[0])); glGenTextures(1, &gl_teximage[gl_teximage_cnt]); - glActiveTexture(GL_TEXTURE0 + gl_teximage_cnt + 1); + + // Win32 GL lib doesn't have this. Just remacro for other platforms. + load_gl_proc(); + pglActiveTexture(GL_TEXTURE0 + gl_teximage_cnt + 1); + glBindTexture(GL_TEXTURE_2D, gl_teximage[gl_teximage_cnt]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); @@ -342,7 +346,7 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width, img.height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, img.pixels); - glActiveTexture(GL_TEXTURE0); + pglActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); free(img.pixels); diff --git a/ssnes.c b/ssnes.c index 4f94c82548..c19d1772b2 100644 --- a/ssnes.c +++ b/ssnes.c @@ -340,6 +340,7 @@ static void print_features(void) _PSUPP(dylib, "External", "External filter and driver support"); _PSUPP(cg, "Cg", "Cg pixel shaders"); _PSUPP(xml, "XML", "bSNES XML pixel shaders"); + _PSUPP(imlib, "Imlib2", "Imlib2 image loading"); _PSUPP(fbo, "FBO", "OpenGL render-to-texture (multi-pass shaders)"); _PSUPP(dynamic, "Dynamic", "Dynamic run-time loading of libsnes library"); _PSUPP(ffmpeg, "FFmpeg", "On-the-fly recording of gameplay with libavcodec");