Преглед изворни кода

osx: link with the proper OpenGL libraries on OS X.

legacy
Sam Hocevar sam пре 13 година
родитељ
комит
356917292d
6 измењених фајлова са 44 додато и 36 уклоњено
  1. +12
    -14
      configure.ac
  2. +4
    -4
      src/debug/quad.cpp
  3. +4
    -4
      src/gradient.cpp
  4. +11
    -3
      src/lolgl.h
  5. +6
    -6
      src/scene.cpp
  6. +7
    -5
      src/video.cpp

+ 12
- 14
configure.ac Прегледај датотеку

@@ -104,6 +104,18 @@ AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
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?
ac_cv_my_have_gl="no"
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")


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?
ac_cv_my_have_egl="no"
PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])


+ 4
- 4
src/debug/quad.cpp Прегледај датотеку

@@ -153,7 +153,7 @@ void DebugQuad::TickDraw(float deltams)

if (!data->initialised && !IsDestroying())
{
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
glGenVertexArrays(NUM_ARRAYS, data->array);
#endif
glGenBuffers(NUM_BUFFERS, data->buffer);
@@ -183,7 +183,7 @@ void DebugQuad::TickDraw(float deltams)
}
else if (data->initialised && IsDestroying())
{
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
glDeleteVertexArrays(NUM_ARRAYS, data->array);
#endif
glDeleteBuffers(NUM_BUFFERS, data->buffer);
@@ -915,7 +915,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors xored with an
* animated distorted checkerboard.
*/
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
if (!shader[0])
{
shader[0] = Shader::Create(
@@ -985,7 +985,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors xored with an
* animated distorted checkerboard.
*/
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
if (!shader[0])
{
shader[0] = Shader::Create(


+ 4
- 4
src/gradient.cpp Прегледај датотеку

@@ -33,7 +33,7 @@ class GradientData
private:
Shader *shader;
GLuint bufs[2];
#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
GLuint vaos[1];
#endif
};
@@ -154,7 +154,7 @@ void Gradient::TickDraw(float deltams)
#endif
#if !defined __CELLOS_LV2__
glGenBuffers(2, data->bufs);
# if defined HAVE_GL_2X
# if defined HAVE_GL_2X && !defined __APPLE__
glGenVertexArrays(1, data->vaos);
# endif
#endif
@@ -195,7 +195,7 @@ void Gradient::TickDraw(float deltams)

/* Bind vertex, color and texture coordinate buffers */
#if !defined __CELLOS_LV2__
# if defined HAVE_GL_2X
# if defined HAVE_GL_2X && !defined __APPLE__
glBindVertexArray(data->vaos[0]);
# endif
glEnableVertexAttribArray(attr_pos);
@@ -222,7 +222,7 @@ void Gradient::TickDraw(float deltams)
glDrawArrays(GL_TRIANGLES, 0, 6);

#if !defined __CELLOS_LV2__
# if defined HAVE_GL_2X
# if defined HAVE_GL_2X && !defined __APPLE__
glBindVertexArray(0);
# endif
glDisableVertexAttribArray(attr_pos);


+ 11
- 3
src/lolgl.h Прегледај датотеку

@@ -23,12 +23,20 @@
# undef HAVE_GLES_2X
#endif

/* Include GL */
#if defined USE_GLEW
/* Include GL development headers.
* 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>
#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/glext.h>
# else
# define GL_GLEXT_PROTOTYPES
# include <GL/gl.h>


+ 6
- 6
src/scene.cpp Прегледај датотеку

@@ -59,7 +59,7 @@ private:
int ntiles;
float angle;

#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
GLuint vao;
#endif
GLuint *bufs;
@@ -84,7 +84,7 @@ Scene::Scene(float angle)
data->bufs = 0;
data->nbufs = 0;

#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
glGenVertexArrays(1, &data->vao);
#endif
}
@@ -96,7 +96,7 @@ Scene::~Scene()
/* XXX: The test is necessary because of a crash with PSGL. */
if (data->nbufs > 0)
glDeleteBuffers(data->nbufs, data->bufs);
#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
glDeleteVertexArrays(1, &data->vao);
#endif
free(data->bufs);
@@ -320,7 +320,7 @@ void Scene::Render() // XXX: rename to Blit()
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.01f);
#endif
@@ -359,7 +359,7 @@ void Scene::Render() // XXX: rename to Blit()
data->tiles[i].tileset->Bind();

/* Bind vertex, color and texture coordinate buffers */
#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
glBindVertexArray(data->vao);
#endif
#if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc.
@@ -386,7 +386,7 @@ void Scene::Render() // XXX: rename to Blit()
/* Draw arrays */
glDrawArrays(GL_TRIANGLES, 0, (n - i) * 6);

#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
glBindVertexArray(0);
#endif
#if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc.


+ 7
- 5
src/video.cpp Прегледај датотеку

@@ -33,7 +33,7 @@ class VideoData

private:
static mat4 proj_matrix, view_matrix;
#if defined __ANDROID__ || defined __CELLOS_LV2__
#if defined __ANDROID__ || defined __CELLOS_LV2__ || defined __APPLE__
static ivec2 saved_viewport;
#endif
};
@@ -41,7 +41,7 @@ private:
mat4 VideoData::proj_matrix;
mat4 VideoData::view_matrix;

#if defined __ANDROID__ || defined __CELLOS_LV2__
#if defined __ANDROID__ || defined __CELLOS_LV2__ || defined __APPLE__
ivec2 VideoData::saved_viewport = 0;
#endif

@@ -51,7 +51,7 @@ ivec2 VideoData::saved_viewport = 0;

void Video::Setup(ivec2 size)
{
#if defined USE_GLEW
#if defined USE_GLEW && !defined __APPLE__
/* Initialise GLEW if necessary */
GLenum glerr = glewInit();
if (glerr != GLEW_OK)
@@ -64,14 +64,14 @@ void Video::Setup(ivec2 size)
/* Initialise OpenGL */
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;
#endif

glClearColor(0.1f, 0.2f, 0.3f, 0.0f);
glClearDepth(1.0);

#if defined HAVE_GL_2X
#if defined HAVE_GL_2X && !defined __APPLE__
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
#endif
@@ -183,6 +183,8 @@ ivec2 Video::GetSize()
#elif defined __CELLOS_LV2__
// FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
return VideoData::saved_viewport;
#elif defined __APPLE__
return VideoData::saved_viewport;
#else
GLint v[4];
glGetIntegerv(GL_VIEWPORT, v);


Loading…
Откажи
Сачувај