diff --git a/src/debug/quad.cpp b/src/debug/quad.cpp index 358b9675..625a5679 100644 --- a/src/debug/quad.cpp +++ b/src/debug/quad.cpp @@ -65,7 +65,7 @@ private: int initialised; float time; -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ GLuint array[NUM_ARRAYS]; #endif GLuint buffer[NUM_BUFFERS]; @@ -153,7 +153,7 @@ void DebugQuad::TickDraw(float deltams) if (!data->initialised && !IsDestroying()) { -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ 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_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ glDeleteVertexArrays(NUM_ARRAYS, data->array); #endif glDeleteBuffers(NUM_BUFFERS, data->buffer); @@ -236,7 +236,7 @@ void DebugQuad::TickDraw(float deltams) vec4 orange(0.8f, 0.5f, 0.2f, 1.0f); /* Cheap iterators */ -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ GLuint *array = data->array; #endif GLuint *buffer = data->buffer; @@ -494,7 +494,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders an orange square. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ glColor4f(orange.x, orange.y, orange.z, orange.w); glEnableClientState(GL_VERTEX_ARRAY); @@ -512,7 +512,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders a green sine wave made of 1-pixel points. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glPointSize(1.0f); glEnableClientState(GL_VERTEX_ARRAY); @@ -531,7 +531,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders a multicoloured square with varying colors. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); @@ -552,7 +552,7 @@ void DebugQuad::TickDraw(float deltams) * Renders a multicoloured square with varying colors multiplied with an * animated distorted checkerboard. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, data->texture[0]); glEnableClientState(GL_VERTEX_ARRAY); @@ -580,7 +580,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders an orange square. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ if (!shader[0]) #if !defined __CELLOS_LV2__ shader[0] = Shader::Create( @@ -626,7 +626,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders an orange square. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ if (!shader[0]) { #if !defined __CELLOS_LV2__ @@ -679,7 +679,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders a static, coloured and tiled pattern. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ if (!shader[0]) #if !defined __CELLOS_LV2__ shader[0] = Shader::Create( @@ -732,7 +732,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders a multicoloured square with varying colors. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ if (!shader[0]) { #if !defined __CELLOS_LV2__ @@ -796,7 +796,7 @@ void DebugQuad::TickDraw(float deltams) * * Renders an antialiased green sine wave made of 1-pixel points. */ -#if !defined ANDROID_NDK && !defined __APPLE__ && !defined __CELLOS_LV2__ +#if !defined __ANDROID__ && !defined __APPLE__ && !defined __CELLOS_LV2__ if (!shader[0]) shader[0] = Shader::Create( "#version 120\n" @@ -842,7 +842,7 @@ void DebugQuad::TickDraw(float deltams) * Renders a multicoloured square with varying colors xored with an * animated distorted checkerboard. */ -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ if (!shader[0]) #if !defined __CELLOS_LV2__ shader[0] = Shader::Create( @@ -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_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ 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_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ if (!shader[0]) { shader[0] = Shader::Create( @@ -1050,7 +1050,7 @@ void DebugQuad::TickDraw(float deltams) ResetState(); /* Check that we didn't overflow our list */ -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ if (array > data->array + NUM_ARRAYS) Log::Error("too many arrays used\n"); #endif @@ -1073,7 +1073,7 @@ void DebugQuad::ResetState() glLoadIdentity(); #endif -#if !defined ANDROID_NDK && !defined __APPLE__ +#if !defined __ANDROID__ && !defined __APPLE__ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); #endif @@ -1082,13 +1082,13 @@ void DebugQuad::ResetState() #if defined HAVE_GLBEGIN || defined USE_GLEW || defined __CELLOS_LV2__ glClientActiveTexture(GL_TEXTURE0); #endif -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE); #endif glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ glDisable(GL_POINT_SPRITE); #endif @@ -1100,7 +1100,7 @@ void DebugQuad::ResetState() cgGLDisableProfile(cgGLGetLatestProfile(CG_GL_FRAGMENT)); #endif -#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK +#if !defined __CELLOS_LV2__ && !defined __ANDROID__ glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); #endif } diff --git a/src/image/image.cpp b/src/image/image.cpp index 6f4c179a..22a1c4b1 100644 --- a/src/image/image.cpp +++ b/src/image/image.cpp @@ -19,7 +19,7 @@ #elif defined USE_SDL # include # include -#elif defined ANDROID_NDK +#elif defined __ANDROID__ # include # include #elif defined __CELLOS_LV2__ @@ -34,7 +34,7 @@ using namespace std; namespace lol { -#if defined ANDROID_NDK +#if defined __ANDROID__ extern JavaVM *g_vm; extern jobject g_activity; #endif @@ -55,7 +55,7 @@ private: uint8_t *pixels; #elif defined USE_SDL SDL_Surface *img; -#elif defined ANDROID_NDK +#elif defined __ANDROID__ jobject bmp; jintArray array; jint *pixels; @@ -125,7 +125,7 @@ Image::Image(char const *path) data->size = ivec2(data->img->w, data->img->h); data->format = data->img->format->Amask ? FORMAT_RGBA : FORMAT_RGB; -#elif defined ANDROID_NDK +#elif defined __ANDROID__ JNIEnv *env; jint res = g_vm->GetEnv((void **)&env, JNI_VERSION_1_2); if (res < 0) @@ -336,7 +336,7 @@ void * Image::GetData() const return data->pixels; #elif defined USE_SDL return data->img->pixels; -#elif defined ANDROID_NDK +#elif defined __ANDROID__ return data->pixels; #elif defined __CELLOS_LV2__ return data->pixels; @@ -351,7 +351,7 @@ Image::~Image() free(data->pixels); #elif defined USE_SDL SDL_FreeSurface(data->img); -#elif defined ANDROID_NDK +#elif defined __ANDROID__ JNIEnv *env; jint res = g_vm->GetEnv((void **)&env, JNI_VERSION_1_2); if (res < 0) diff --git a/src/log.cpp b/src/log.cpp index ff749cf7..bfe98b9f 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -15,7 +15,7 @@ #include #include -#if defined ANDROID_NDK +#if defined __ANDROID__ # include #else # include @@ -34,7 +34,7 @@ void Log::Debug(char const *fmt, ...) { va_list ap; va_start(ap, fmt); -#if defined ANDROID_NDK +#if defined __ANDROID__ __android_log_vprint(ANDROID_LOG_DEBUG, "LOL", fmt, ap); #else fprintf(stderr, "DEBUG: "); @@ -47,7 +47,7 @@ void Log::Info(char const *fmt, ...) { va_list ap; va_start(ap, fmt); -#if defined ANDROID_NDK +#if defined __ANDROID__ __android_log_vprint(ANDROID_LOG_INFO, "LOL", fmt, ap); #else fprintf(stderr, "INFO: "); @@ -60,7 +60,7 @@ void Log::Warn(char const *fmt, ...) { va_list ap; va_start(ap, fmt); -#if defined ANDROID_NDK +#if defined __ANDROID__ __android_log_vprint(ANDROID_LOG_WARN, "LOL", fmt, ap); #else fprintf(stderr, "WARN: "); @@ -73,7 +73,7 @@ void Log::Error(char const *fmt, ...) { va_list ap; va_start(ap, fmt); -#if defined ANDROID_NDK +#if defined __ANDROID__ __android_log_vprint(ANDROID_LOG_ERROR, "LOL", fmt, ap); #else fprintf(stderr, "ERROR: "); diff --git a/src/matrix.cpp b/src/matrix.cpp index ef721d64..16d5ab14 100644 --- a/src/matrix.cpp +++ b/src/matrix.cpp @@ -80,6 +80,7 @@ template<> void mat4::printf() const p[0][3], p[1][3], p[2][3], p[3][3]); } +#if !defined __ANDROID__ template<> std::ostream &operator<<(std::ostream &stream, ivec2 const &v) { return stream << "(" << v.x << ", " << v.y << ")"; @@ -124,6 +125,7 @@ template<> std::ostream &operator<<(std::ostream &stream, mat4 const &m) << ", " << m[2][3] << ", " << m[3][3] << "))"; return stream; } +#endif template<> mat4 mat4::ortho(float left, float right, float bottom, float top, float near, float far) diff --git a/src/matrix.h b/src/matrix.h index 6c4ea5d2..0a9cf033 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -17,7 +17,9 @@ #define __LOL_MATRIX_H__ #include -#include +#if !defined __ANDROID__ +# include +#endif namespace lol { @@ -126,11 +128,7 @@ namespace lol { \ using namespace std; \ return sqrtf((float)sqlen()); \ - } \ - \ - template \ - friend std::ostream &operator<<(std::ostream &stream, \ - Vec##elems const &v); + } template struct Vec2; template struct Vec3; @@ -144,6 +142,11 @@ template struct Vec2 OPERATORS(2) +#if !defined __ANDROID__ + template + friend std::ostream &operator<<(std::ostream &stream, Vec2 const &v); +#endif + union { T x; T a; T i; }; union { T y; T b; T j; }; }; @@ -159,6 +162,11 @@ template struct Vec3 OPERATORS(3) +#if !defined __ANDROID__ + template + friend std::ostream &operator<<(std::ostream &stream, Vec3 const &v); +#endif + union { T x; T a; T i; }; union { T y; T b; T j; }; union { T z; T c; T k; }; @@ -175,6 +183,11 @@ template struct Vec4 OPERATORS(4) +#if !defined __ANDROID__ + template + friend std::ostream &operator<<(std::ostream &stream, Vec4 const &v); +#endif + union { T x; T a; T i; }; union { T y; T b; T j; }; union { T z; T c; T k; }; @@ -237,8 +250,10 @@ template struct Mat4 void printf() const; +#if !defined __ANDROID__ template friend std::ostream &operator<<(std::ostream &stream, Mat4 const &m); +#endif inline Mat4 operator +(Mat4 const val) const { diff --git a/src/platform.cpp b/src/platform.cpp index 4b894808..a8c1279e 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -25,7 +25,7 @@ namespace lol int Platform::GetMouseCount() { -#if defined ANDROID_NDK +#if defined __ANDROID__ /* Assume Android devices are touch devices that don't have a mouse */ return 0; #endif diff --git a/src/video.cpp b/src/video.cpp index 6a6e6192..6efcf506 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -33,7 +33,7 @@ class VideoData private: static mat4 proj_matrix, view_matrix; -#if defined ANDROID_NDK || defined __CELLOS_LV2__ +#if defined __ANDROID__ || defined __CELLOS_LV2__ static ivec2 saved_viewport; #endif }; @@ -41,7 +41,7 @@ private: mat4 VideoData::proj_matrix; mat4 VideoData::view_matrix; -#if defined ANDROID_NDK || defined __CELLOS_LV2__ +#if defined __ANDROID__ || defined __CELLOS_LV2__ ivec2 VideoData::saved_viewport = 0; #endif @@ -64,7 +64,7 @@ void Video::Setup(ivec2 size) /* Initialise OpenGL */ glViewport(0, 0, size.x, size.y); -#if defined ANDROID_NDK || defined __CELLOS_LV2__ +#if defined __ANDROID__ || defined __CELLOS_LV2__ VideoData::saved_viewport = size; #endif @@ -85,7 +85,7 @@ void Video::SetFov(float theta) float near = -size.x - size.y; float far = size.x + size.y; -#if defined ANDROID_NDK +#if defined __ANDROID__ size = vec2(640.0f, 480.0f); #endif @@ -178,7 +178,7 @@ void Video::Capture(uint32_t *buffer) ivec2 Video::GetSize() { -#if defined ANDROID_NDK +#if defined __ANDROID__ return VideoData::saved_viewport; #elif defined __CELLOS_LV2__ // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions