From 9ad9cbd7de0dbd153f49741af37c278da5f4fcfd Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 4 Feb 2011 06:46:51 -0600 Subject: [PATCH] Build fixes for OSX. (PPC) --- Makefile | 7 ++++++- driver.h | 12 ++++++------ gfx/gl.c | 23 +++++++++++++---------- gfx/shader_glsl.c | 14 ++++++++++---- qb/qb.comp.sh | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 9ec364d1d9..1750f494f8 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,13 @@ endif ifeq ($(HAVE_SDL), 1) OBJ += gfx/gl.o input/sdl.o audio/sdl.o audio/buffer.o - LIBS += $(SDL_LIBS) -lGL DEFINES += $(SDL_CFLAGS) + LIBS += $(SDL_LIBS) +ifneq ($(findstring Darwin,$(shell uname -a)),) + LIBS += -framework OpenGL +else + LIBS += -lGL +endif endif ifeq ($(HAVE_CG), 1) diff --git a/driver.h b/driver.h index d825b28d56..3f39b46b12 100644 --- a/driver.h +++ b/driver.h @@ -71,15 +71,15 @@ typedef struct audio_driver const char *ident; } audio_driver_t; -#define AXIS_NEG(x) ((uint32_t)(x << 16) | 0xFFFF) +#define AXIS_NEG(x) (((uint32_t)(x) << 16) | 0xFFFFU) #define AXIS_POS(x) ((uint32_t)(x) | 0xFFFF0000U) -#define AXIS_NONE ((uint32_t)0xFFFFFFFFU) +#define AXIS_NONE (0xFFFFFFFFU) -#define AXIS_NEG_GET(x) ((x >> 16) & 0xFFFF) -#define AXIS_POS_GET(x) (x & 0xFFFF) -#define AXIS_NONE ((uint32_t)0xFFFFFFFFU) +#define AXIS_NEG_GET(x) (((uint32_t)(x) >> 16) & 0xFFFFU) +#define AXIS_POS_GET(x) ((uint32_t)(x) & 0xFFFFU) +#define AXIS_NONE (0xFFFFFFFFU) -#define NO_BTN 0xFFFF // I hope no joypad will ever have this many buttons ... ;) +#define NO_BTN ((uint16_t)0xFFFFU) // I hope no joypad will ever have this many buttons ... ;) #define HAT_UP_MASK (1 << 15) #define HAT_DOWN_MASK (1 << 14) diff --git a/gfx/gl.c b/gfx/gl.c index 92df4d59f9..d8952f010d 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -29,18 +29,21 @@ #include "config.h" #endif + +#ifdef __APPLE__ +#include +#include +#else +#define GL_GLEXT_PROTOTYPES +#include +#include +#endif + #define NO_SDL_GLEXT #include "SDL.h" #include "SDL_opengl.h" #include "input/ssnes_sdl_input.h" -#define GL_GLEXT_PROTOTYPES -#include - -#ifndef _WIN32 -#include -#endif - #ifdef HAVE_CG #include "shader_cg.h" #endif @@ -424,12 +427,12 @@ static void gl_set_nonblock_state(void *data, bool state) SSNES_LOG("GL VSync => %s\n", state ? "off" : "on"); #ifdef _WIN32 static BOOL (APIENTRY *wgl_swap_interval)(int) = NULL; - if (!wgl_swap_interval) wgl_swap_interval = (BOOL (APIENTRY*)(int)) wglGetProcAddress("wglSwapIntervalEXT"); + if (!wgl_swap_interval) wgl_swap_interval = (BOOL (APIENTRY*)(int)) SDL_GL_GetProcAddress("wglSwapIntervalEXT"); if (wgl_swap_interval) wgl_swap_interval(state ? 0 : 1); #else static int (*glx_swap_interval)(int) = NULL; - if (!glx_swap_interval) glx_swap_interval = (int (*)(int))glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI"); - if (!glx_swap_interval) glx_swap_interval = (int (*)(int))glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA"); + if (!glx_swap_interval) glx_swap_interval = (int (*)(int))SDL_GL_GetProcAddress("glXSwapIntervalSGI"); + if (!glx_swap_interval) glx_swap_interval = (int (*)(int))SDL_GL_GetProcAddress("glXSwapIntervalMESA"); if (glx_swap_interval) glx_swap_interval(state ? 0 : 1); #endif } diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index 251659b704..7ec666b652 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -23,17 +23,23 @@ #include #include "general.h" -#define NO_SDL_GLEXT +#ifdef __APPLE__ +#include +#include +#else +#define GL_GLEXT_PROTOTYPES #include +#include +#endif + + +#define NO_SDL_GLEXT #include "SDL.h" #include "SDL_opengl.h" #include #include #include -#define GL_GLEXT_PROTOTYPES -#include - #include "gl_common.h" static PFNGLCREATEPROGRAMPROC pglCreateProgram = NULL; diff --git a/qb/qb.comp.sh b/qb/qb.comp.sh index 12c75a6074..37062f9f4c 100644 --- a/qb/qb.comp.sh +++ b/qb/qb.comp.sh @@ -6,7 +6,7 @@ TEMP_EXE=.tmp echo -n "Checking operating system ... " OS="Win32" # whatever ;D -unamestr="`uname -o`" +unamestr="`uname -a`" if [ ! -z "`echo $unamestr | grep -i Linux`" ]; then OS="Linux" elif [ ! -z "`echo $unamestr | grep -i Darwin`" ]; then