Clean up ugly inline stuff. :\

This commit is contained in:
Themaister 2011-05-18 22:40:42 +02:00
parent 36d9adbc0f
commit 2f858b7948
5 changed files with 45 additions and 24 deletions

View File

@ -15,6 +15,7 @@ HAVE_RSOUND = 1
HAVE_DYLIB = 1
HAVE_NETPLAY = 1
HAVE_FBO = 1
HAVE_CG = 0
libsnes ?= -lsnes
LIBS = -lm
@ -38,6 +39,12 @@ ifeq ($(HAVE_SDL), 1)
DEFINES += $(SDL_CFLAGS) -DHAVE_SDL
endif
ifeq ($(HAVE_CG), 1)
OBJ += gfx/shader_cg.o
LIBS += -lcg -lcgGL
DEFINES += -DHAVE_CG
endif
ifeq ($(HAVE_XAUDIO), 1)
OBJ += audio/xaudio.o
DEFINES += -DHAVE_XAUDIO

View File

@ -15,6 +15,7 @@ HAVE_RSOUND = 0
HAVE_DYLIB = 1
HAVE_NETPLAY = 1
HAVE_FBO = 1
HAVE_CG = 0
libsnes ?= -lsnes
LIBS = -lm
@ -38,6 +39,12 @@ ifeq ($(HAVE_SDL), 1)
DEFINES += $(SDL_CFLAGS) -DHAVE_SDL
endif
ifeq ($(HAVE_CG), 1)
OBJ += gfx/shader_cg.o
LIBS += -lcg -lcgGL
DEFINES += -DHAVE_CG
endif
ifeq ($(HAVE_XAUDIO), 1)
OBJ += audio/xaudio.o
DEFINES += -DHAVE_XAUDIO

View File

@ -103,6 +103,22 @@ static bool load_fbo_proc(void) { return true; }
#endif
#endif
#if defined(HAVE_XML) && defined(_WIN32)
PFNGLCLIENTACTIVETEXTUREPROC pglClientActiveTexture = NULL;
PFNGLACTIVETEXTUREPROC pglActiveTexture = NULL;
static inline bool load_gl_proc(void)
{
LOAD_SYM(glClientActiveTexture);
LOAD_SYM(glActiveTexture);
return pglClientActiveTexture && pglActiveTexture;
}
#else
#define pglClientActiveTexture glClientActiveTexture
#define pglActiveTexture glActiveTexture
static inline bool load_gl_proc(void) { return true; }
#endif
#define MAX_SHADERS 16
@ -929,10 +945,22 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo
if (attr <= 0)
SSNES_WARN("GL double buffer has not been enabled!\n");
#if defined(HAVE_XML) && defined(_WIN32)
// Win32 GL lib doesn't have some functions needed for XML shaders.
// Need to load dynamically :(
if (!load_gl_proc())
{
SDL_QuitSubSystem(SDL_INIT_VIDEO);
return NULL;
}
#endif
gl_t *gl = calloc(1, sizeof(gl_t));
if (!gl)
{
SDL_QuitSubSystem(SDL_INIT_VIDEO);
return NULL;
}
gl->full_x = full_x;
gl->full_y = full_y;
@ -1012,8 +1040,6 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo
#ifdef HAVE_XML
// For texture images.
// 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);

View File

@ -34,10 +34,6 @@
#include <GL/glext.h>
#endif
#define NO_SDL_GLEXT
#include "SDL.h"
#include "SDL_opengl.h"
static inline bool gl_check_error(void)
{
int error = glGetError();
@ -103,23 +99,12 @@ struct gl_fbo_scale
};
// 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);
}
#if defined(HAVE_XML) && defined(_WIN32)
extern PFNGLCLIENTACTIVETEXTUREPROC pglClientActiveTexture;
extern PFNGLACTIVETEXTUREPROC pglActiveTexture;
#else
#define pglClientActiveTexture glClientActiveTexture
#define pglActiveTexture glActiveTexture
#define load_gl_proc()
#endif
#endif
#endif

View File

@ -330,12 +330,8 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr)
glGenTextures(1, &gl_teximage[gl_teximage_cnt]);
// 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);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear ? GL_LINEAR : GL_NEAREST);