diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-17 02:24:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-17 14:55:08 +0300 |
commit | 5a322df4da3102ae0c8d3bc3071386dc5f21e580 (patch) | |
tree | 4ca0cca3328baf7484074ad6e1cf9c5a9f9e3db0 | |
parent | e6e36b25a696212f0262e3e5ef520543b1b3a58b (diff) | |
download | plus-5a322df4da3102ae0c8d3bc3071386dc5f21e580.tar.gz plus-5a322df4da3102ae0c8d3bc3071386dc5f21e580.tar.bz2 plus-5a322df4da3102ae0c8d3bc3071386dc5f21e580.tar.xz plus-5a322df4da3102ae0c8d3bc3071386dc5f21e580.zip |
Add OpenGL support for Android builds (partially).
-rwxr-xr-x | configure.ac | 9 | ||||
-rw-r--r-- | src/graphicsmanager.cpp | 10 | ||||
-rw-r--r-- | src/graphicsmanager.h | 6 | ||||
-rw-r--r-- | src/graphicsvertexes.h | 8 | ||||
-rw-r--r-- | src/mgl.h | 17 | ||||
-rw-r--r-- | src/normalopenglgraphics.cpp | 17 | ||||
-rw-r--r-- | src/normalopenglgraphics.h | 8 | ||||
-rw-r--r-- | src/resources/fboinfo.h | 5 | ||||
-rw-r--r-- | src/resources/image.h | 6 | ||||
-rw-r--r-- | src/resources/openglimagehelper.h | 11 | ||||
-rw-r--r-- | src/resources/subimage.h | 11 | ||||
-rw-r--r-- | src/safeopenglgraphics.cpp | 5 | ||||
-rw-r--r-- | src/safeopenglgraphics.h | 7 |
13 files changed, 93 insertions, 27 deletions
diff --git a/configure.ac b/configure.ac index a4e9f68f0..512f42dfa 100755 --- a/configure.ac +++ b/configure.ac @@ -152,8 +152,13 @@ if test "x$with_opengl" == "xno"; then else with_opengl=yes if test "x$applebuild_enabled" == "xfalse"; then - AC_CHECK_LIB([GL], [glBegin], , - AC_MSG_ERROR([ *** Unable to find OpenGL library])) + + if test "x$androidbuild_enabled" == "xfalse"; then + AC_CHECK_LIB([GL], [glBegin], , + AC_MSG_ERROR([ *** Unable to find OpenGL library])) + else + LDFLAGS="$LDFLAGS -lGLESv2 -lEGL" + fi else LDFLAGS="$LDFLAGS -framework OpenGL" fi diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index c69937073..a9efd8e13 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -21,11 +21,19 @@ #include "graphicsmanager.h" #ifdef USE_OPENGL + #ifndef WIN32 +#ifdef ANDROID +#include <GLES2/gl2.h> +#include <GLES/glext.h> +#include <EGL/egl.h> +#else #include "GL/glx.h" #endif #endif +#endif + #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" @@ -53,6 +61,8 @@ #ifdef WIN32 #define getFunction(name) wglGetProcAddress(name) +#elif ANDROID +#define getFunction(name) eglGetProcAddress(name) #else #define getFunction(name) glXGetProcAddress(\ reinterpret_cast<const GLubyte*>(name)) diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h index b16c63fbf..53de59c46 100644 --- a/src/graphicsmanager.h +++ b/src/graphicsmanager.h @@ -24,6 +24,10 @@ #include "main.h" #ifdef USE_OPENGL + +#ifdef ANDROID +#include <GLES/gl.h> +#else #define GL_GLEXT_PROTOTYPES 1 #include <SDL_opengl.h> // hack to hide warnings @@ -31,6 +35,8 @@ #undef GL_GLEXT_PROTOTYPES #endif +#endif + #include <set> #include <string> diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 69d391864..789e9fd34 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -27,11 +27,15 @@ #include "localconsts.h" #ifdef USE_OPENGL -//#define NO_SDL_GLEXT + +#ifdef ANDROID +#include <GLES/gl.h> +#else #define GL_GLEXT_PROTOTYPES 1 +#include <SDL/SDL_opengl.h> +#endif #include <SDL/SDL.h> -#include <SDL/SDL_opengl.h> #include "safeopenglgraphics.h" #include "normalopenglgraphics.h" @@ -24,10 +24,15 @@ #include "main.h" #ifdef USE_OPENGL +#ifdef ANDROID +#include <GLES/gl.h> +#include <GLES/glext.h> +#define APIENTRY GL_APIENTRY +#else #define GL_GLEXT_PROTOTYPES 1 - #include <SDL_opengl.h> #include <GL/glext.h> +#endif #define GL_NUM_EXTENSIONS 0x821D #define GL_DEPTH_ATTACHMENT 0x8D00 @@ -35,6 +40,16 @@ #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 +#ifndef GL_COMPRESSED_RGBA_ARB +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif +#ifndef GL_MAX_ELEMENTS_VERTICES +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#endif + #define defNameE(name) extern name##_t m##name typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *); diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp index 32175c05f..cc0e05b3f 100644 --- a/src/normalopenglgraphics.cpp +++ b/src/normalopenglgraphics.cpp @@ -40,11 +40,6 @@ #include "debug.h" -#ifndef GL_TEXTURE_RECTANGLE_ARB -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - GLuint NormalOpenGLGraphics::mLastImage = 0; unsigned int vertexBufSize = 500; @@ -949,8 +944,13 @@ void NormalOpenGLGraphics::_beginDraw() glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifdef ANDROID + glOrthof(0.0, static_cast<float>(mTarget->w), + static_cast<float>(mTarget->h), 0.0, -1.0, 1.0); +#else glOrtho(0.0, static_cast<double>(mTarget->w), static_cast<double>(mTarget->h), 0.0, -1.0, 1.0); +#endif glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -963,14 +963,15 @@ void NormalOpenGLGraphics::_beginDraw() glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); +#ifndef ANDROID glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); - #ifndef __MINGW32__ glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); #endif +#endif // glScalef(0.5f, 0.5f, 0.5f); @@ -1093,9 +1094,13 @@ void NormalOpenGLGraphics::drawPoint(int x, int y) setTexturingAndBlending(false); restoreColor(); +#ifdef ANDROID + // TODO need fix +#else glBegin(GL_POINTS); glVertex2i(x, y); glEnd(); +#endif } void NormalOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) diff --git a/src/normalopenglgraphics.h b/src/normalopenglgraphics.h index b6a09728e..35bdf557e 100644 --- a/src/normalopenglgraphics.h +++ b/src/normalopenglgraphics.h @@ -31,11 +31,15 @@ #include "resources/fboinfo.h" -//#define NO_SDL_GLEXT +#ifdef ANDROID +#include <GLES/gl.h> +#include <GLES/glext.h> +#include <GLES2/gl2.h> +#else #define GL_GLEXT_PROTOTYPES 1 - #include <SDL_opengl.h> #include <GL/glext.h> +#endif #include <set> diff --git a/src/resources/fboinfo.h b/src/resources/fboinfo.h index 54415e697..dcc76d435 100644 --- a/src/resources/fboinfo.h +++ b/src/resources/fboinfo.h @@ -28,8 +28,13 @@ #include "resources/fboinfo.h" +#ifdef ANDROID +#include <GLES/gl.h> +#include <GLES/glext.h> +#else #include <SDL_opengl.h> #include <GL/glext.h> +#endif struct FBOInfo final { diff --git a/src/resources/image.h b/src/resources/image.h index 3752965bc..36404b2b1 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -37,10 +37,14 @@ * extensions anyway it's safe to just disable the SDL version. */ //#define NO_SDL_GLEXT -#define GL_GLEXT_PROTOTYPES 1 +#ifdef ANDROID +#include <GLES/gl.h> +#else +#define GL_GLEXT_PROTOTYPES 1 #include <SDL_opengl.h> #endif +#endif #include <map> diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h index 02641f85f..b0428f58a 100644 --- a/src/resources/openglimagehelper.h +++ b/src/resources/openglimagehelper.h @@ -27,14 +27,25 @@ #include "main.h" #ifdef USE_OPENGL + +#ifndef GL_TEXTURE_RECTANGLE_ARB +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + #include "utils/stringvector.h" #include "resources/imagehelper.h" #include <SDL.h> +#ifdef ANDROID +#include <GLES/gl.h> +#define GL_RGBA8 GL_RGBA8_OES +#else #define GL_GLEXT_PROTOTYPES 1 #include <SDL_opengl.h> +#endif class Dye; class Image; diff --git a/src/resources/subimage.h b/src/resources/subimage.h index 47d8476cb..69e0debab 100644 --- a/src/resources/subimage.h +++ b/src/resources/subimage.h @@ -30,16 +30,15 @@ #ifdef USE_OPENGL -/* The definition of OpenGL extensions by SDL is giving problems with recent - * gl.h headers, since they also include these definitions. As we're not using - * extensions anyway it's safe to just disable the SDL version. - */ -//#define NO_SDL_GLEXT +#ifdef ANDROID +#include <GLES/gl.h> +#else #define GL_GLEXT_PROTOTYPES 1 - #include <SDL_opengl.h> #endif +#endif + #include "resources/image.h" /** diff --git a/src/safeopenglgraphics.cpp b/src/safeopenglgraphics.cpp index 78210b7f8..113a33baa 100644 --- a/src/safeopenglgraphics.cpp +++ b/src/safeopenglgraphics.cpp @@ -37,11 +37,6 @@ #include "debug.h" -#ifndef GL_TEXTURE_RECTANGLE_ARB -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - GLuint SafeOpenGLGraphics::mLastImage = 0; SafeOpenGLGraphics::SafeOpenGLGraphics(): diff --git a/src/safeopenglgraphics.h b/src/safeopenglgraphics.h index 44c15545f..81494d5bd 100644 --- a/src/safeopenglgraphics.h +++ b/src/safeopenglgraphics.h @@ -30,11 +30,14 @@ #include "resources/fboinfo.h" -//#define NO_SDL_GLEXT +#ifdef ANDROID +#include <GLES/gl.h> +#include <GLES/glext.h> +#else #define GL_GLEXT_PROTOTYPES 1 - #include <SDL_opengl.h> #include <GL/glext.h> +#endif class SafeOpenGLGraphics final : public Graphics { |