diff --git a/configure.ac b/configure.ac index 219ea585..41c6a6a7 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,28 @@ CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Ws AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm") +# Which version of OpenGL to use? +ac_cv_my_have_gl="no" +PKG_CHECK_MODULES(GLES1, glesv1_cm, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GLES_1X, 1, Define to 1 if GLES 1.x is available) + GL_CFLAGS="${GLES1_CFLAGS}" + GL_LIBS="${GLES1_LIBS}"], + [:]) +PKG_CHECK_MODULES(GLES2, glesv2, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) + GL_CFLAGS="${GLES2_CFLAGS}" + GL_LIBS="${GLES2_LIBS}"], + [:]) +AC_CHECK_LIB(GL, glLoadIdentity, + [ac_cv_my_have_gl="yes" + AC_DEFINE(HAVE_GL_1X, 1, Define to 1 if GL 1.x is available) + GL_LIBS="-lGL"]) # FIXME: hackish +if test "${ac_cv_my_have_gl}" = "no"; then + AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]]) +fi + # Use SDL? (always required) ac_cv_my_have_sdl="yes" AC_PATH_PROG(SDL_CONFIG, sdl-config, no) @@ -83,17 +105,18 @@ if test "${SDL_CONFIG}" != "no"; then SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`" SDL_LIBS="${SDL_LIBS} `sdl-config --libs`" fi +SDL_CFLAGS="${SDL_CFLAGS} ${GL_CFLAGS}" +SDL_LIBS="${SDL_LIBS} ${GL_LIBS}" PKG_CHECK_MODULES(SDL, sdl, [:], [SDL_LIBS="${SDL_LIBS} -lSDL"]) -AC_CHECK_LIB(GL, glLoadIdentity, SDL_LIBS="${SDL_LIBS} -lGL") # FIXME: hackish PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:], [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"]) PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:], [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"]) -save_CPPFLAGS="${CPPFLAGS}" SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}" SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}" +save_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}" AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"]) AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"]) diff --git a/src/Makefile.am b/src/Makefile.am index 12bddfcf..0239393f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ noinst_LIBRARIES = liblol.a liblol_a_SOURCES = \ core.h matrix.cpp matrix.h tiler.cpp tiler.h dict.cpp dict.h \ audio.cpp audio.h scene.cpp scene.h font.cpp font.h layer.cpp layer.h \ - map.cpp map.h entity.cpp entity.h ticker.cpp ticker.h \ + map.cpp map.h entity.cpp entity.h ticker.cpp ticker.h lolgl.h \ tileset.cpp tileset.h forge.cpp forge.h video.cpp video.h \ timer.cpp timer.h bitfield.h profiler.cpp profiler.h input.h input.cpp \ world.cpp world.h sample.cpp sample.h sampler.cpp sampler.h \ diff --git a/src/debugsphere.cpp b/src/debugsphere.cpp index 75e38fff..d1dfe580 100644 --- a/src/debugsphere.cpp +++ b/src/debugsphere.cpp @@ -17,17 +17,12 @@ # define WIN32_LEAN_AND_MEAN # include #endif -#if defined __APPLE__ && defined __MACH__ -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -#endif #include #include #include "core.h" +#include "lolgl.h" #include "debugsphere.h" /* diff --git a/src/lolgl.h b/src/lolgl.h new file mode 100644 index 00000000..04ea2beb --- /dev/null +++ b/src/lolgl.h @@ -0,0 +1,33 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2011 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/projects/COPYING.WTFPL for more details. +// + +// +// The GL support +// -------------- +// + +#if !defined __DH_LOLGL_H__ +#define __DH_LOLGL_H__ + +#if defined HAVE_GL_1X +# if defined __APPLE__ && defined __MACH__ +# include +# else +# define GL_GLEXT_PROTOTYPES +# include +# endif +#elif defined HAVE_GLES_1X +# include +#elif defined HAVE_GLES_2X +# include +#endif + +#endif // __DH_LOLGL_H__ + diff --git a/src/scene.cpp b/src/scene.cpp index a30fbb95..4e91c2c9 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -20,14 +20,9 @@ # define WIN32_LEAN_AND_MEAN # include #endif -#if defined __APPLE__ && defined __MACH__ -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -#endif #include "core.h" +#include "lolgl.h" struct Tile { diff --git a/src/shader.cpp b/src/shader.cpp index b0a8da55..38e6f0ec 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -19,14 +19,9 @@ # define WIN32_LEAN_AND_MEAN # include #endif -#if defined __APPLE__ && defined __MACH__ -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -#endif #include "core.h" +#include "lolgl.h" /* * Shader implementation class diff --git a/src/tileset.cpp b/src/tileset.cpp index d64709b5..de579a36 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -19,17 +19,12 @@ # define WIN32_LEAN_AND_MEAN # include #endif -#if defined __APPLE__ && defined __MACH__ -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -#endif #include #include #include "core.h" +#include "lolgl.h" /* * TileSet implementation class diff --git a/src/video.cpp b/src/video.cpp index 156d0db6..6e0dd7d3 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -19,14 +19,9 @@ # define WIN32_LEAN_AND_MEAN # include #endif -#if defined __APPLE__ && defined __MACH__ -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -#endif #include "core.h" +#include "lolgl.h" #if LOL_EXPERIMENTAL Shader *stdshader; diff --git a/win32/deushax.vcxproj b/win32/deushax.vcxproj index 9080c437..fac23f40 100644 --- a/win32/deushax.vcxproj +++ b/win32/deushax.vcxproj @@ -28,6 +28,7 @@ + diff --git a/win32/deushax.vcxproj.filters b/win32/deushax.vcxproj.filters index 326f36a7..4cfc9306 100644 --- a/win32/deushax.vcxproj.filters +++ b/win32/deushax.vcxproj.filters @@ -48,6 +48,9 @@ lolengine + + lolengine + lolengine diff --git a/win32/editor.vcxproj b/win32/editor.vcxproj index 168a20f6..211f6f32 100644 --- a/win32/editor.vcxproj +++ b/win32/editor.vcxproj @@ -28,6 +28,7 @@ + diff --git a/win32/editor.vcxproj.filters b/win32/editor.vcxproj.filters index 708aa665..bbcfa161 100644 --- a/win32/editor.vcxproj.filters +++ b/win32/editor.vcxproj.filters @@ -48,6 +48,9 @@ lolengine + + lolengine + lolengine diff --git a/win32/monsterz.vcxproj b/win32/monsterz.vcxproj index cf25073d..a842a73b 100644 --- a/win32/monsterz.vcxproj +++ b/win32/monsterz.vcxproj @@ -33,6 +33,7 @@ + diff --git a/win32/monsterz.vcxproj.filters b/win32/monsterz.vcxproj.filters index 873799ff..2390c597 100644 --- a/win32/monsterz.vcxproj.filters +++ b/win32/monsterz.vcxproj.filters @@ -48,6 +48,9 @@ lolengine + + lolengine + lolengine