Parcourir la 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 il y a 13 ans
Parent
révision
7b7d4fe003
7 fichiers modifiés avec 61 ajouts et 44 suppressions
  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 Voir le fichier

@@ -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
}


+ 6
- 6
src/image/image.cpp Voir le fichier

@@ -19,7 +19,7 @@
#elif defined USE_SDL
# include <SDL.h>
# include <SDL_image.h>
#elif defined ANDROID_NDK
#elif defined __ANDROID__
# include <jni.h>
# include <android/log.h>
#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)


+ 5
- 5
src/log.cpp Voir le fichier

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

#if defined ANDROID_NDK
#if defined __ANDROID__
# include <android/log.h>
#else
# include <cstdarg>
@@ -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: ");


+ 2
- 0
src/matrix.cpp Voir le fichier

@@ -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)


+ 21
- 6
src/matrix.h Voir le fichier

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

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

namespace lol
{
@@ -126,11 +128,7 @@ namespace lol
{ \
using namespace std; \
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 Vec3;
@@ -144,6 +142,11 @@ template <typename T> struct Vec2

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 y; T b; T j; };
};
@@ -159,6 +162,11 @@ template <typename T> struct Vec3

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 y; T b; T j; };
union { T z; T c; T k; };
@@ -175,6 +183,11 @@ template <typename T> struct Vec4

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 y; T b; T j; };
union { T z; T c; T k; };
@@ -237,8 +250,10 @@ template <typename T> struct Mat4

void printf() const;

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

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


+ 1
- 1
src/platform.cpp Voir le fichier

@@ -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


+ 5
- 5
src/video.cpp Voir le fichier

@@ -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


Chargement…
Annuler
Enregistrer