Browse Source

build: stop defining ANDROID_NDK and check for __ANDROID__ instead.

According to David Turner, “it should be the only thing that NDK users
should be testing again.”
legacy
Sam Hocevar sam 13 years ago
parent
commit
7b7d4fe003
7 changed files with 61 additions and 44 deletions
  1. +21
    -21
      src/debug/quad.cpp
  2. +6
    -6
      src/image/image.cpp
  3. +5
    -5
      src/log.cpp
  4. +2
    -0
      src/matrix.cpp
  5. +21
    -6
      src/matrix.h
  6. +1
    -1
      src/platform.cpp
  7. +5
    -5
      src/video.cpp

+ 21
- 21
src/debug/quad.cpp View File

@@ -65,7 +65,7 @@ private:


int initialised; int initialised;
float time; float time;
#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
GLuint array[NUM_ARRAYS]; GLuint array[NUM_ARRAYS];
#endif #endif
GLuint buffer[NUM_BUFFERS]; GLuint buffer[NUM_BUFFERS];
@@ -153,7 +153,7 @@ void DebugQuad::TickDraw(float deltams)


if (!data->initialised && !IsDestroying()) if (!data->initialised && !IsDestroying())
{ {
#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
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_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
glDeleteVertexArrays(NUM_ARRAYS, data->array); glDeleteVertexArrays(NUM_ARRAYS, data->array);
#endif #endif
glDeleteBuffers(NUM_BUFFERS, data->buffer); glDeleteBuffers(NUM_BUFFERS, data->buffer);
@@ -236,7 +236,7 @@ void DebugQuad::TickDraw(float deltams)
vec4 orange(0.8f, 0.5f, 0.2f, 1.0f); vec4 orange(0.8f, 0.5f, 0.2f, 1.0f);


/* Cheap iterators */ /* Cheap iterators */
#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
GLuint *array = data->array; GLuint *array = data->array;
#endif #endif
GLuint *buffer = data->buffer; GLuint *buffer = data->buffer;
@@ -494,7 +494,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders an orange square. * Renders an orange square.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
glColor4f(orange.x, orange.y, orange.z, orange.w); glColor4f(orange.x, orange.y, orange.z, orange.w);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);


@@ -512,7 +512,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders a green sine wave made of 1-pixel points. * 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); glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glPointSize(1.0f); glPointSize(1.0f);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
@@ -531,7 +531,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders a multicoloured square with varying colors. * Renders a multicoloured square with varying colors.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);


@@ -552,7 +552,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors multiplied with an * Renders a multicoloured square with varying colors multiplied with an
* animated distorted checkerboard. * animated distorted checkerboard.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, data->texture[0]); glBindTexture(GL_TEXTURE_2D, data->texture[0]);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
@@ -580,7 +580,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders an orange square. * Renders an orange square.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
if (!shader[0]) if (!shader[0])
#if !defined __CELLOS_LV2__ #if !defined __CELLOS_LV2__
shader[0] = Shader::Create( shader[0] = Shader::Create(
@@ -626,7 +626,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders an orange square. * Renders an orange square.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
if (!shader[0]) if (!shader[0])
{ {
#if !defined __CELLOS_LV2__ #if !defined __CELLOS_LV2__
@@ -679,7 +679,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders a static, coloured and tiled pattern. * Renders a static, coloured and tiled pattern.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
if (!shader[0]) if (!shader[0])
#if !defined __CELLOS_LV2__ #if !defined __CELLOS_LV2__
shader[0] = Shader::Create( shader[0] = Shader::Create(
@@ -732,7 +732,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders a multicoloured square with varying colors. * Renders a multicoloured square with varying colors.
*/ */
#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
if (!shader[0]) if (!shader[0])
{ {
#if !defined __CELLOS_LV2__ #if !defined __CELLOS_LV2__
@@ -796,7 +796,7 @@ void DebugQuad::TickDraw(float deltams)
* *
* Renders an antialiased green sine wave made of 1-pixel points. * 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]) if (!shader[0])
shader[0] = Shader::Create( shader[0] = Shader::Create(
"#version 120\n" "#version 120\n"
@@ -842,7 +842,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 ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
if (!shader[0]) if (!shader[0])
#if !defined __CELLOS_LV2__ #if !defined __CELLOS_LV2__
shader[0] = Shader::Create( shader[0] = Shader::Create(
@@ -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_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
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_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
if (!shader[0]) if (!shader[0])
{ {
shader[0] = Shader::Create( shader[0] = Shader::Create(
@@ -1050,7 +1050,7 @@ void DebugQuad::TickDraw(float deltams)
ResetState(); ResetState();


/* Check that we didn't overflow our list */ /* 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) if (array > data->array + NUM_ARRAYS)
Log::Error("too many arrays used\n"); Log::Error("too many arrays used\n");
#endif #endif
@@ -1073,7 +1073,7 @@ void DebugQuad::ResetState()
glLoadIdentity(); glLoadIdentity();
#endif #endif


#if !defined ANDROID_NDK && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
#endif #endif


@@ -1082,13 +1082,13 @@ void DebugQuad::ResetState()
#if defined HAVE_GLBEGIN || defined USE_GLEW || defined __CELLOS_LV2__ #if defined HAVE_GLBEGIN || defined USE_GLEW || defined __CELLOS_LV2__
glClientActiveTexture(GL_TEXTURE0); glClientActiveTexture(GL_TEXTURE0);
#endif #endif
#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE); glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE);
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);


glDisable(GL_BLEND); glDisable(GL_BLEND);
#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
glDisable(GL_POINT_SPRITE); glDisable(GL_POINT_SPRITE);
#endif #endif


@@ -1100,7 +1100,7 @@ void DebugQuad::ResetState()
cgGLDisableProfile(cgGLGetLatestProfile(CG_GL_FRAGMENT)); cgGLDisableProfile(cgGLGetLatestProfile(CG_GL_FRAGMENT));
#endif #endif


#if !defined __CELLOS_LV2__ && !defined ANDROID_NDK
#if !defined __CELLOS_LV2__ && !defined __ANDROID__
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif #endif
} }


+ 6
- 6
src/image/image.cpp View File

@@ -19,7 +19,7 @@
#elif defined USE_SDL #elif defined USE_SDL
# include <SDL.h> # include <SDL.h>
# include <SDL_image.h> # include <SDL_image.h>
#elif defined ANDROID_NDK
#elif defined __ANDROID__
# include <jni.h> # include <jni.h>
# include <android/log.h> # include <android/log.h>
#elif defined __CELLOS_LV2__ #elif defined __CELLOS_LV2__
@@ -34,7 +34,7 @@ using namespace std;
namespace lol namespace lol
{ {


#if defined ANDROID_NDK
#if defined __ANDROID__
extern JavaVM *g_vm; extern JavaVM *g_vm;
extern jobject g_activity; extern jobject g_activity;
#endif #endif
@@ -55,7 +55,7 @@ private:
uint8_t *pixels; uint8_t *pixels;
#elif defined USE_SDL #elif defined USE_SDL
SDL_Surface *img; SDL_Surface *img;
#elif defined ANDROID_NDK
#elif defined __ANDROID__
jobject bmp; jobject bmp;
jintArray array; jintArray array;
jint *pixels; jint *pixels;
@@ -125,7 +125,7 @@ Image::Image(char const *path)


data->size = ivec2(data->img->w, data->img->h); data->size = ivec2(data->img->w, data->img->h);
data->format = data->img->format->Amask ? FORMAT_RGBA : FORMAT_RGB; data->format = data->img->format->Amask ? FORMAT_RGBA : FORMAT_RGB;
#elif defined ANDROID_NDK
#elif defined __ANDROID__
JNIEnv *env; JNIEnv *env;
jint res = g_vm->GetEnv((void **)&env, JNI_VERSION_1_2); jint res = g_vm->GetEnv((void **)&env, JNI_VERSION_1_2);
if (res < 0) if (res < 0)
@@ -336,7 +336,7 @@ void * Image::GetData() const
return data->pixels; return data->pixels;
#elif defined USE_SDL #elif defined USE_SDL
return data->img->pixels; return data->img->pixels;
#elif defined ANDROID_NDK
#elif defined __ANDROID__
return data->pixels; return data->pixels;
#elif defined __CELLOS_LV2__ #elif defined __CELLOS_LV2__
return data->pixels; return data->pixels;
@@ -351,7 +351,7 @@ Image::~Image()
free(data->pixels); free(data->pixels);
#elif defined USE_SDL #elif defined USE_SDL
SDL_FreeSurface(data->img); SDL_FreeSurface(data->img);
#elif defined ANDROID_NDK
#elif defined __ANDROID__
JNIEnv *env; JNIEnv *env;
jint res = g_vm->GetEnv((void **)&env, JNI_VERSION_1_2); jint res = g_vm->GetEnv((void **)&env, JNI_VERSION_1_2);
if (res < 0) if (res < 0)


+ 5
- 5
src/log.cpp View File

@@ -15,7 +15,7 @@
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>


#if defined ANDROID_NDK
#if defined __ANDROID__
# include <android/log.h> # include <android/log.h>
#else #else
# include <cstdarg> # include <cstdarg>
@@ -34,7 +34,7 @@ void Log::Debug(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#if defined ANDROID_NDK
#if defined __ANDROID__
__android_log_vprint(ANDROID_LOG_DEBUG, "LOL", fmt, ap); __android_log_vprint(ANDROID_LOG_DEBUG, "LOL", fmt, ap);
#else #else
fprintf(stderr, "DEBUG: "); fprintf(stderr, "DEBUG: ");
@@ -47,7 +47,7 @@ void Log::Info(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#if defined ANDROID_NDK
#if defined __ANDROID__
__android_log_vprint(ANDROID_LOG_INFO, "LOL", fmt, ap); __android_log_vprint(ANDROID_LOG_INFO, "LOL", fmt, ap);
#else #else
fprintf(stderr, "INFO: "); fprintf(stderr, "INFO: ");
@@ -60,7 +60,7 @@ void Log::Warn(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#if defined ANDROID_NDK
#if defined __ANDROID__
__android_log_vprint(ANDROID_LOG_WARN, "LOL", fmt, ap); __android_log_vprint(ANDROID_LOG_WARN, "LOL", fmt, ap);
#else #else
fprintf(stderr, "WARN: "); fprintf(stderr, "WARN: ");
@@ -73,7 +73,7 @@ void Log::Error(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#if defined ANDROID_NDK
#if defined __ANDROID__
__android_log_vprint(ANDROID_LOG_ERROR, "LOL", fmt, ap); __android_log_vprint(ANDROID_LOG_ERROR, "LOL", fmt, ap);
#else #else
fprintf(stderr, "ERROR: "); fprintf(stderr, "ERROR: ");


+ 2
- 0
src/matrix.cpp View File

@@ -80,6 +80,7 @@ template<> void mat4::printf() const
p[0][3], p[1][3], p[2][3], p[3][3]); 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) template<> std::ostream &operator<<(std::ostream &stream, ivec2 const &v)
{ {
return stream << "(" << v.x << ", " << v.y << ")"; 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] << "))"; << ", " << m[2][3] << ", " << m[3][3] << "))";
return stream; return stream;
} }
#endif


template<> mat4 mat4::ortho(float left, float right, float bottom, template<> mat4 mat4::ortho(float left, float right, float bottom,
float top, float near, float far) float top, float near, float far)


+ 21
- 6
src/matrix.h View File

@@ -17,7 +17,9 @@
#define __LOL_MATRIX_H__ #define __LOL_MATRIX_H__


#include <cmath> #include <cmath>
#include <iostream>
#if !defined __ANDROID__
# include <iostream>
#endif


namespace lol namespace lol
{ {
@@ -126,11 +128,7 @@ namespace lol
{ \ { \
using namespace std; \ using namespace std; \
return sqrtf((float)sqlen()); \ return sqrtf((float)sqlen()); \
} \
\
template<typename U> \
friend std::ostream &operator<<(std::ostream &stream, \
Vec##elems<U> const &v);
}


template <typename T> struct Vec2; template <typename T> struct Vec2;
template <typename T> struct Vec3; template <typename T> struct Vec3;
@@ -144,6 +142,11 @@ template <typename T> struct Vec2


OPERATORS(2) OPERATORS(2)


#if !defined __ANDROID__
template<typename U>
friend std::ostream &operator<<(std::ostream &stream, Vec2<U> const &v);
#endif

union { T x; T a; T i; }; union { T x; T a; T i; };
union { T y; T b; T j; }; union { T y; T b; T j; };
}; };
@@ -159,6 +162,11 @@ template <typename T> struct Vec3


OPERATORS(3) OPERATORS(3)


#if !defined __ANDROID__
template<typename U>
friend std::ostream &operator<<(std::ostream &stream, Vec3<U> const &v);
#endif

union { T x; T a; T i; }; union { T x; T a; T i; };
union { T y; T b; T j; }; union { T y; T b; T j; };
union { T z; T c; T k; }; union { T z; T c; T k; };
@@ -175,6 +183,11 @@ template <typename T> struct Vec4


OPERATORS(4) OPERATORS(4)


#if !defined __ANDROID__
template<typename U>
friend std::ostream &operator<<(std::ostream &stream, Vec4<U> const &v);
#endif

union { T x; T a; T i; }; union { T x; T a; T i; };
union { T y; T b; T j; }; union { T y; T b; T j; };
union { T z; T c; T k; }; union { T z; T c; T k; };
@@ -237,8 +250,10 @@ template <typename T> struct Mat4


void printf() const; void printf() const;


#if !defined __ANDROID__
template<class U> template<class U>
friend std::ostream &operator<<(std::ostream &stream, Mat4<U> const &m); friend std::ostream &operator<<(std::ostream &stream, Mat4<U> const &m);
#endif


inline Mat4<T> operator +(Mat4<T> const val) const inline Mat4<T> operator +(Mat4<T> const val) const
{ {


+ 1
- 1
src/platform.cpp View File

@@ -25,7 +25,7 @@ namespace lol


int Platform::GetMouseCount() int Platform::GetMouseCount()
{ {
#if defined ANDROID_NDK
#if defined __ANDROID__
/* Assume Android devices are touch devices that don't have a mouse */ /* Assume Android devices are touch devices that don't have a mouse */
return 0; return 0;
#endif #endif


+ 5
- 5
src/video.cpp View File

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


private: private:
static mat4 proj_matrix, view_matrix; static mat4 proj_matrix, view_matrix;
#if defined ANDROID_NDK || defined __CELLOS_LV2__
#if defined __ANDROID__ || defined __CELLOS_LV2__
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_NDK || defined __CELLOS_LV2__
#if defined __ANDROID__ || defined __CELLOS_LV2__
ivec2 VideoData::saved_viewport = 0; ivec2 VideoData::saved_viewport = 0;
#endif #endif


@@ -64,7 +64,7 @@ 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_NDK || defined __CELLOS_LV2__
#if defined __ANDROID__ || defined __CELLOS_LV2__
VideoData::saved_viewport = size; VideoData::saved_viewport = size;
#endif #endif


@@ -85,7 +85,7 @@ void Video::SetFov(float theta)
float near = -size.x - size.y; float near = -size.x - size.y;
float far = size.x + size.y; float far = size.x + size.y;


#if defined ANDROID_NDK
#if defined __ANDROID__
size = vec2(640.0f, 480.0f); size = vec2(640.0f, 480.0f);
#endif #endif


@@ -178,7 +178,7 @@ void Video::Capture(uint32_t *buffer)


ivec2 Video::GetSize() ivec2 Video::GetSize()
{ {
#if defined ANDROID_NDK
#if defined __ANDROID__
return VideoData::saved_viewport; return VideoData::saved_viewport;
#elif defined __CELLOS_LV2__ #elif defined __CELLOS_LV2__
// FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions


Loading…
Cancel
Save