@@ -104,6 +104,18 @@ AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule, | |||||
AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no") | AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no") | ||||
LIBS_save="$LIBS" | |||||
LIBS="$LIBS -Wl,-framework -Wl,OpenGL" | |||||
AC_MSG_CHECKING(for -framework OpenGL) | |||||
AC_TRY_LINK([], [], | |||||
[ac_cv_my_have_cocoa="yes" | |||||
AC_MSG_RESULT(yes) | |||||
GL_LIBS="${GL_LIBS} -framework OpenGL" | |||||
CXXFLAGS="${CXXFLAGS} -ObjC++"], | |||||
[AC_MSG_RESULT(no)]) | |||||
LIBS="$LIBS_save" | |||||
dnl Which version of OpenGL to use? | dnl Which version of OpenGL to use? | ||||
ac_cv_my_have_gl="no" | ac_cv_my_have_gl="no" | ||||
PKG_CHECK_MODULES(GLES2, glesv2, | PKG_CHECK_MODULES(GLES2, glesv2, | ||||
@@ -232,20 +244,6 @@ AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes") | |||||
AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes") | AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes") | ||||
dnl Use Cocoa? | |||||
ac_cv_my_have_cocoa="no" | |||||
LIBS_save="$LIBS" | |||||
LIBS="$LIBS -Wl,-framework -Wl,Cocoa" | |||||
AC_MSG_CHECKING(for -framework Cocoa) | |||||
AC_TRY_LINK([], [], | |||||
[ac_cv_my_have_cocoa="yes" | |||||
AC_MSG_RESULT(yes) | |||||
CXXFLAGS="${CXXFLAGS} -ObjC++"], | |||||
[AC_MSG_RESULT(no)]) | |||||
LIBS="$LIBS_save" | |||||
AM_CONDITIONAL(USE_COCOA, test "${ac_cv_my_have_cocoa}" != "no") | |||||
dnl Use EGL? | dnl Use EGL? | ||||
ac_cv_my_have_egl="no" | ac_cv_my_have_egl="no" | ||||
PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:]) | PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:]) | ||||
@@ -153,7 +153,7 @@ void DebugQuad::TickDraw(float deltams) | |||||
if (!data->initialised && !IsDestroying()) | if (!data->initialised && !IsDestroying()) | ||||
{ | { | ||||
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ | #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ | ||||
glGenVertexArrays(NUM_ARRAYS, data->array); | glGenVertexArrays(NUM_ARRAYS, data->array); | ||||
#endif | #endif | ||||
glGenBuffers(NUM_BUFFERS, data->buffer); | glGenBuffers(NUM_BUFFERS, data->buffer); | ||||
@@ -183,7 +183,7 @@ void DebugQuad::TickDraw(float deltams) | |||||
} | } | ||||
else if (data->initialised && IsDestroying()) | else if (data->initialised && IsDestroying()) | ||||
{ | { | ||||
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ | #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ | ||||
glDeleteVertexArrays(NUM_ARRAYS, data->array); | glDeleteVertexArrays(NUM_ARRAYS, data->array); | ||||
#endif | #endif | ||||
glDeleteBuffers(NUM_BUFFERS, data->buffer); | glDeleteBuffers(NUM_BUFFERS, data->buffer); | ||||
@@ -915,7 +915,7 @@ void DebugQuad::TickDraw(float deltams) | |||||
* Renders a multicoloured square with varying colors xored with an | * Renders a multicoloured square with varying colors xored with an | ||||
* animated distorted checkerboard. | * animated distorted checkerboard. | ||||
*/ | */ | ||||
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ | #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ | ||||
if (!shader[0]) | if (!shader[0]) | ||||
{ | { | ||||
shader[0] = Shader::Create( | shader[0] = Shader::Create( | ||||
@@ -985,7 +985,7 @@ void DebugQuad::TickDraw(float deltams) | |||||
* Renders a multicoloured square with varying colors xored with an | * Renders a multicoloured square with varying colors xored with an | ||||
* animated distorted checkerboard. | * animated distorted checkerboard. | ||||
*/ | */ | ||||
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ | #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ | ||||
if (!shader[0]) | if (!shader[0]) | ||||
{ | { | ||||
shader[0] = Shader::Create( | shader[0] = Shader::Create( | ||||
@@ -33,7 +33,7 @@ class GradientData | |||||
private: | private: | ||||
Shader *shader; | Shader *shader; | ||||
GLuint bufs[2]; | GLuint bufs[2]; | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
GLuint vaos[1]; | GLuint vaos[1]; | ||||
#endif | #endif | ||||
}; | }; | ||||
@@ -154,7 +154,7 @@ void Gradient::TickDraw(float deltams) | |||||
#endif | #endif | ||||
#if !defined __CELLOS_LV2__ | #if !defined __CELLOS_LV2__ | ||||
glGenBuffers(2, data->bufs); | glGenBuffers(2, data->bufs); | ||||
# if defined HAVE_GL_2X | # if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glGenVertexArrays(1, data->vaos); | glGenVertexArrays(1, data->vaos); | ||||
# endif | # endif | ||||
#endif | #endif | ||||
@@ -195,7 +195,7 @@ void Gradient::TickDraw(float deltams) | |||||
/* Bind vertex, color and texture coordinate buffers */ | /* Bind vertex, color and texture coordinate buffers */ | ||||
#if !defined __CELLOS_LV2__ | #if !defined __CELLOS_LV2__ | ||||
# if defined HAVE_GL_2X | # if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glBindVertexArray(data->vaos[0]); | glBindVertexArray(data->vaos[0]); | ||||
# endif | # endif | ||||
glEnableVertexAttribArray(attr_pos); | glEnableVertexAttribArray(attr_pos); | ||||
@@ -222,7 +222,7 @@ void Gradient::TickDraw(float deltams) | |||||
glDrawArrays(GL_TRIANGLES, 0, 6); | glDrawArrays(GL_TRIANGLES, 0, 6); | ||||
#if !defined __CELLOS_LV2__ | #if !defined __CELLOS_LV2__ | ||||
# if defined HAVE_GL_2X | # if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glBindVertexArray(0); | glBindVertexArray(0); | ||||
# endif | # endif | ||||
glDisableVertexAttribArray(attr_pos); | glDisableVertexAttribArray(attr_pos); | ||||
@@ -23,12 +23,20 @@ | |||||
# undef HAVE_GLES_2X | # undef HAVE_GLES_2X | ||||
#endif | #endif | ||||
/* Include GL */ | /* Include GL development headers. | ||||
#if defined USE_GLEW | * Do not include glew.h on OS X, because the version shipped with Fink | ||||
* links with X11 whereas we want the system’s Cocoa-friendly GL libs. */ | |||||
#if defined USE_GLEW && !defined __APPLE__ | |||||
# include <glew.h> | # include <glew.h> | ||||
#elif defined HAVE_GL_2X | #elif defined HAVE_GL_2X | ||||
# if defined __APPLE__ && defined __MACH__ | # if defined __APPLE__ && defined __MACH__ && defined __arm__ | ||||
# include <OpenGL/gl.h> | |||||
# elif defined __APPLE__ && defined __MACH__ | |||||
# define MACOS_OPENGL | |||||
# define GL_GLEXT_PROTOTYPES | |||||
# include <OpenGL/OpenGL.h> | |||||
# include <OpenGL/gl.h> | # include <OpenGL/gl.h> | ||||
# include <OpenGL/glext.h> | |||||
# else | # else | ||||
# define GL_GLEXT_PROTOTYPES | # define GL_GLEXT_PROTOTYPES | ||||
# include <GL/gl.h> | # include <GL/gl.h> | ||||
@@ -59,7 +59,7 @@ private: | |||||
int ntiles; | int ntiles; | ||||
float angle; | float angle; | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
GLuint vao; | GLuint vao; | ||||
#endif | #endif | ||||
GLuint *bufs; | GLuint *bufs; | ||||
@@ -84,7 +84,7 @@ Scene::Scene(float angle) | |||||
data->bufs = 0; | data->bufs = 0; | ||||
data->nbufs = 0; | data->nbufs = 0; | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glGenVertexArrays(1, &data->vao); | glGenVertexArrays(1, &data->vao); | ||||
#endif | #endif | ||||
} | } | ||||
@@ -96,7 +96,7 @@ Scene::~Scene() | |||||
/* XXX: The test is necessary because of a crash with PSGL. */ | /* XXX: The test is necessary because of a crash with PSGL. */ | ||||
if (data->nbufs > 0) | if (data->nbufs > 0) | ||||
glDeleteBuffers(data->nbufs, data->bufs); | glDeleteBuffers(data->nbufs, data->bufs); | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glDeleteVertexArrays(1, &data->vao); | glDeleteVertexArrays(1, &data->vao); | ||||
#endif | #endif | ||||
free(data->bufs); | free(data->bufs); | ||||
@@ -320,7 +320,7 @@ void Scene::Render() // XXX: rename to Blit() | |||||
glEnable(GL_TEXTURE_2D); | glEnable(GL_TEXTURE_2D); | ||||
glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
glDepthFunc(GL_LEQUAL); | glDepthFunc(GL_LEQUAL); | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glEnable(GL_ALPHA_TEST); | glEnable(GL_ALPHA_TEST); | ||||
glAlphaFunc(GL_GEQUAL, 0.01f); | glAlphaFunc(GL_GEQUAL, 0.01f); | ||||
#endif | #endif | ||||
@@ -359,7 +359,7 @@ void Scene::Render() // XXX: rename to Blit() | |||||
data->tiles[i].tileset->Bind(); | data->tiles[i].tileset->Bind(); | ||||
/* Bind vertex, color and texture coordinate buffers */ | /* Bind vertex, color and texture coordinate buffers */ | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glBindVertexArray(data->vao); | glBindVertexArray(data->vao); | ||||
#endif | #endif | ||||
#if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc. | #if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc. | ||||
@@ -386,7 +386,7 @@ void Scene::Render() // XXX: rename to Blit() | |||||
/* Draw arrays */ | /* Draw arrays */ | ||||
glDrawArrays(GL_TRIANGLES, 0, (n - i) * 6); | glDrawArrays(GL_TRIANGLES, 0, (n - i) * 6); | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glBindVertexArray(0); | glBindVertexArray(0); | ||||
#endif | #endif | ||||
#if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc. | #if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc. | ||||
@@ -33,7 +33,7 @@ class VideoData | |||||
private: | private: | ||||
static mat4 proj_matrix, view_matrix; | static mat4 proj_matrix, view_matrix; | ||||
#if defined __ANDROID__ || defined __CELLOS_LV2__ | #if defined __ANDROID__ || defined __CELLOS_LV2__ || defined __APPLE__ | ||||
static ivec2 saved_viewport; | static ivec2 saved_viewport; | ||||
#endif | #endif | ||||
}; | }; | ||||
@@ -41,7 +41,7 @@ private: | |||||
mat4 VideoData::proj_matrix; | mat4 VideoData::proj_matrix; | ||||
mat4 VideoData::view_matrix; | mat4 VideoData::view_matrix; | ||||
#if defined __ANDROID__ || defined __CELLOS_LV2__ | #if defined __ANDROID__ || defined __CELLOS_LV2__ || defined __APPLE__ | ||||
ivec2 VideoData::saved_viewport = 0; | ivec2 VideoData::saved_viewport = 0; | ||||
#endif | #endif | ||||
@@ -51,7 +51,7 @@ ivec2 VideoData::saved_viewport = 0; | |||||
void Video::Setup(ivec2 size) | void Video::Setup(ivec2 size) | ||||
{ | { | ||||
#if defined USE_GLEW | #if defined USE_GLEW && !defined __APPLE__ | ||||
/* Initialise GLEW if necessary */ | /* Initialise GLEW if necessary */ | ||||
GLenum glerr = glewInit(); | GLenum glerr = glewInit(); | ||||
if (glerr != GLEW_OK) | if (glerr != GLEW_OK) | ||||
@@ -64,14 +64,14 @@ void Video::Setup(ivec2 size) | |||||
/* Initialise OpenGL */ | /* Initialise OpenGL */ | ||||
glViewport(0, 0, size.x, size.y); | glViewport(0, 0, size.x, size.y); | ||||
#if defined __ANDROID__ || defined __CELLOS_LV2__ | #if defined __ANDROID__ || defined __CELLOS_LV2__ || defined __APPLE__ | ||||
VideoData::saved_viewport = size; | VideoData::saved_viewport = size; | ||||
#endif | #endif | ||||
glClearColor(0.1f, 0.2f, 0.3f, 0.0f); | glClearColor(0.1f, 0.2f, 0.3f, 0.0f); | ||||
glClearDepth(1.0); | glClearDepth(1.0); | ||||
#if defined HAVE_GL_2X | #if defined HAVE_GL_2X && !defined __APPLE__ | ||||
glShadeModel(GL_SMOOTH); | glShadeModel(GL_SMOOTH); | ||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); | glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); | ||||
#endif | #endif | ||||
@@ -183,6 +183,8 @@ ivec2 Video::GetSize() | |||||
#elif defined __CELLOS_LV2__ | #elif defined __CELLOS_LV2__ | ||||
// FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions | // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions | ||||
return VideoData::saved_viewport; | return VideoData::saved_viewport; | ||||
#elif defined __APPLE__ | |||||
return VideoData::saved_viewport; | |||||
#else | #else | ||||
GLint v[4]; | GLint v[4]; | ||||
glGetIntegerv(GL_VIEWPORT, v); | glGetIntegerv(GL_VIEWPORT, v); | ||||