Mercurial > sdl-ios-xcode
changeset 4704:611d39792201
Added minimal test project
author | Paul Hunkin <paul@bieh.net> |
---|---|
date | Thu, 17 Jun 2010 22:19:27 +1200 |
parents | c93b44ddc63e |
children | 190f043af37d |
files | android/testproject/AndroidManifest.xml android/testproject/build.properties android/testproject/build.xml android/testproject/default.properties android/testproject/jni/Android.mk android/testproject/jni/app-android.c android/testproject/jni/importgl.c android/testproject/jni/importgl.h android/testproject/libs/armeabi/libsanangeles.so android/testproject/local.properties android/testproject/res/drawable-hdpi/icon.png android/testproject/res/drawable-ldpi/icon.png android/testproject/res/drawable-mdpi/icon.png android/testproject/res/layout/main.xml android/testproject/res/values/strings.xml android/testproject/src/org/libsdl/android/TestActivity.java |
diffstat | 16 files changed, 648 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/AndroidManifest.xml Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.libsdl.android" + android:versionCode="1" + android:versionName="1.0"> + <application android:label="@string/app_name" android:icon="@drawable/icon"> + <activity android:name="TestActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/build.properties Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked in Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/build.xml Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="Test" default="help"> + + <!-- The local.properties file is created and updated by the 'android' tool. + It contains the path to the SDK. It should *NOT* be checked in in Version + Control Systems. --> + <property file="local.properties" /> + + <!-- The build.properties file can be created by you and is never touched + by the 'android' tool. This is the place to change some of the default property values + used by the Ant rules. + Here are some properties you may want to change/update: + + application.package + the name of your application package as defined in the manifest. Used by the + 'uninstall' rule. + source.dir + the name of the source directory. Default is 'src'. + out.dir + the name of the output directory. Default is 'bin'. + + Properties related to the SDK location or the project target should be updated + using the 'android' tool with the 'update' action. + + This file is an integral part of the build system for your application and + should be checked in in Version Control Systems. + + --> + <property file="build.properties" /> + + <!-- The default.properties file is created and updated by the 'android' tool, as well + as ADT. + This file is an integral part of the build system for your application and + should be checked in in Version Control Systems. --> + <property file="default.properties" /> + + <!-- Custom Android task to deal with the project target, and import the proper rules. + This requires ant 1.6.0 or above. --> + <path id="android.antlibs"> + <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> + <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" /> + <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" /> + <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" /> + <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" /> + </path> + + <taskdef name="setup" + classname="com.android.ant.SetupTask" + classpathref="android.antlibs" /> + + <!-- Execute the Android Setup task that will setup some properties specific to the target, + and import the build rules files. + + The rules file is imported from + <SDK>/platforms/<target_platform>/templates/android_rules.xml + + To customize some build steps for your project: + - copy the content of the main node <project> from android_rules.xml + - paste it in this build.xml below the <setup /> task. + - disable the import by changing the setup task below to <setup import="false" /> + + This will ensure that the properties are setup correctly but that your customized + build steps are used. + --> + <setup /> + +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/default.properties Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=Google Inc.:Google APIs:7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/jni/Android.mk Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,16 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := sanangeles + +LOCAL_CFLAGS := -DANDROID_NDK \ + -DDISABLE_IMPORTGL + +LOCAL_SRC_FILES := \ + importgl.c \ + app-android.c \ + +LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog + +include $(BUILD_SHARED_LIBRARY)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/jni/app-android.c Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,79 @@ +/******************************************************************************* + Headers +*******************************************************************************/ +#include <jni.h> +#include <sys/time.h> +#include <time.h> +#include <android/log.h> +#include <stdint.h> + +/******************************************************************************* + Globals +*******************************************************************************/ +int gAppAlive = 1; + +static int sWindowWidth = 320; +static int sWindowHeight = 480; +static int sDemoStopped = 0; + +static long _getTime(void){ + struct timeval now; + gettimeofday(&now, NULL); + return (long)(now.tv_sec*1000 + now.tv_usec/1000); +} + +/******************************************************************************* + Initialize the graphics state +*******************************************************************************/ +void Java_org_libsdl_android_TestRenderer_nativeInit( JNIEnv* env ) +{ + importGLInit(); + + gAppAlive = 1; + sDemoStopped = 0; +} + +/******************************************************************************* + Resize +*******************************************************************************/ +void Java_org_libsdl_android_TestRenderer_nativeResize( JNIEnv* env, + jobject thiz, + jint w, + jint h ) +{ + sWindowWidth = w; + sWindowHeight = h; + __android_log_print(ANDROID_LOG_INFO, "SDL", "resize w=%d h=%d", w, h); +} + +/******************************************************************************* + Finalize (ie: shutdown) +*******************************************************************************/ +void Java_org_libsdl_android_TestRenderer_nativeDone( JNIEnv* env ) +{ + + //shut down the app + + importGLDeinit(); +} + +/******************************************************************************* + Pause (ie: stop as soon as possible) +*******************************************************************************/ +void Java_org_libsdl_android_TestGLSurfaceView_nativePause( JNIEnv* env ) +{ + sDemoStopped = !sDemoStopped; + if (sDemoStopped) { + //we paused + } else { + //we resumed + } +} + +/******************************************************************************* + Render the next frame +*******************************************************************************/ +void Java_org_libsdl_android_TestRenderer_nativeRender( JNIEnv* env ) +{ + //TODO: Render here +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/jni/importgl.c Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,168 @@ +/* San Angeles Observation OpenGL ES version example + * Copyright 2004-2005 Jetro Lauha + * All rights reserved. + * Web: http://iki.fi/jetro/ + * + * This source is free software; you can redistribute it and/or + * modify it under the terms of EITHER: + * (1) The GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. The text of the GNU Lesser + * General Public License is included with this source in the + * file LICENSE-LGPL.txt. + * (2) The BSD-style license that is included with this source in + * the file LICENSE-BSD.txt. + * + * This source is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files + * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. + * + * $Id: importgl.c,v 1.4 2005/02/08 18:42:55 tonic Exp $ + * $Revision: 1.4 $ + */ + +#undef WIN32 +#undef LINUX +#ifdef _MSC_VER +// Desktop or mobile Win32 environment: +#define WIN32 +#else +// Linux environment: +#define LINUX +#endif + +#ifndef DISABLE_IMPORTGL + +#if defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <tchar.h> +static HMODULE sGLESDLL = NULL; +#endif // WIN32 + +#ifdef LINUX +#include <stdlib.h> +#include <dlfcn.h> +static void *sGLESSO = NULL; +#endif // LINUX + +#endif /* DISABLE_IMPORTGL */ + +#define IMPORTGL_NO_FNPTR_DEFS +#define IMPORTGL_API +#define IMPORTGL_FNPTRINIT = NULL +#include "importgl.h" + + +/* Imports function pointers to selected function calls in OpenGL ES Common + * or Common Lite profile DLL or shared object. The function pointers are + * stored as global symbols with equivalent function name but prefixed with + * "funcPtr_". Standard gl/egl calls are redirected to the function pointers + * with preprocessor macros (see importgl.h). + */ +int importGLInit() +{ + int result = 1; + +#ifndef DISABLE_IMPORTGL + +#undef IMPORT_FUNC + +#ifdef WIN32 + sGLESDLL = LoadLibrary(_T("libGLES_CM.dll")); + if (sGLESDLL == NULL) + sGLESDLL = LoadLibrary(_T("libGLES_CL.dll")); + if (sGLESDLL == NULL) + return 0; // Cannot find OpenGL ES Common or Common Lite DLL. + + /* The following fetches address to each egl & gl function call + * and stores it to the related function pointer. Casting through + * void * results in warnings with VC warning level 4, which + * could be fixed by casting to the true type for each fetch. + */ +#define IMPORT_FUNC(funcName) do { \ + void *procAddress = (void *)GetProcAddress(sGLESDLL, _T(#funcName)); \ + if (procAddress == NULL) result = 0; \ + *((void **)&FNPTR(funcName)) = procAddress; } while (0) +#endif // WIN32 + +#ifdef LINUX +#ifdef ANDROID_NDK + sGLESSO = dlopen("libGLESv1_CM.so", RTLD_NOW); +#else /* !ANDROID_NDK */ + sGLESSO = dlopen("libGLES_CM.so", RTLD_NOW); + if (sGLESSO == NULL) + sGLESSO = dlopen("libGLES_CL.so", RTLD_NOW); +#endif /* !ANDROID_NDK */ + if (sGLESSO == NULL) + return 0; // Cannot find OpenGL ES Common or Common Lite SO. + +#define IMPORT_FUNC(funcName) do { \ + void *procAddress = (void *)dlsym(sGLESSO, #funcName); \ + if (procAddress == NULL) result = 0; \ + *((void **)&FNPTR(funcName)) = procAddress; } while (0) +#endif // LINUX + +#ifndef ANDROID_NDK + IMPORT_FUNC(eglChooseConfig); + IMPORT_FUNC(eglCreateContext); + IMPORT_FUNC(eglCreateWindowSurface); + IMPORT_FUNC(eglDestroyContext); + IMPORT_FUNC(eglDestroySurface); + IMPORT_FUNC(eglGetConfigAttrib); + IMPORT_FUNC(eglGetConfigs); + IMPORT_FUNC(eglGetDisplay); + IMPORT_FUNC(eglGetError); + IMPORT_FUNC(eglInitialize); + IMPORT_FUNC(eglMakeCurrent); + IMPORT_FUNC(eglSwapBuffers); + IMPORT_FUNC(eglTerminate); +#endif /* !ANDROID_NDK */ + + IMPORT_FUNC(glBlendFunc); + IMPORT_FUNC(glClear); + IMPORT_FUNC(glClearColorx); + IMPORT_FUNC(glColor4x); + IMPORT_FUNC(glColorPointer); + IMPORT_FUNC(glDisable); + IMPORT_FUNC(glDisableClientState); + IMPORT_FUNC(glDrawArrays); + IMPORT_FUNC(glEnable); + IMPORT_FUNC(glEnableClientState); + IMPORT_FUNC(glFrustumx); + IMPORT_FUNC(glGetError); + IMPORT_FUNC(glLightxv); + IMPORT_FUNC(glLoadIdentity); + IMPORT_FUNC(glMaterialx); + IMPORT_FUNC(glMaterialxv); + IMPORT_FUNC(glMatrixMode); + IMPORT_FUNC(glMultMatrixx); + IMPORT_FUNC(glNormalPointer); + IMPORT_FUNC(glPopMatrix); + IMPORT_FUNC(glPushMatrix); + IMPORT_FUNC(glRotatex); + IMPORT_FUNC(glScalex); + IMPORT_FUNC(glShadeModel); + IMPORT_FUNC(glTranslatex); + IMPORT_FUNC(glVertexPointer); + IMPORT_FUNC(glViewport); + +#endif /* DISABLE_IMPORTGL */ + + return result; +} + + +void importGLDeinit() +{ +#ifndef DISABLE_IMPORTGL +#ifdef WIN32 + FreeLibrary(sGLESDLL); +#endif + +#ifdef LINUX + dlclose(sGLESSO); +#endif +#endif /* DISABLE_IMPORTGL */ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/jni/importgl.h Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,172 @@ +/* San Angeles Observation OpenGL ES version example + * Copyright 2004-2005 Jetro Lauha + * All rights reserved. + * Web: http://iki.fi/jetro/ + * + * This source is free software; you can redistribute it and/or + * modify it under the terms of EITHER: + * (1) The GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. The text of the GNU Lesser + * General Public License is included with this source in the + * file LICENSE-LGPL.txt. + * (2) The BSD-style license that is included with this source in + * the file LICENSE-BSD.txt. + * + * This source is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files + * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. + * + * $Id: importgl.h,v 1.4 2005/02/24 20:29:33 tonic Exp $ + * $Revision: 1.4 $ + */ + +#ifndef IMPORTGL_H_INCLUDED +#define IMPORTGL_H_INCLUDED + + +#ifdef __cplusplus +extern "C" { +#endif + + +#include <GLES/gl.h> +#ifndef ANDROID_NDK +#include <GLES/egl.h> +#endif /* !ANDROID_NDK */ + +/* Use DISABLE_IMPORTGL if you want to link the OpenGL ES at + * compile/link time and not import it dynamically runtime. + */ +#ifndef DISABLE_IMPORTGL + + +/* Dynamically fetches pointers to the egl & gl functions. + * Should be called once on application initialization. + * Returns non-zero on success and 0 on failure. + */ +extern int importGLInit(); + +/* Frees the handle to egl & gl functions library. + */ +extern void importGLDeinit(); + + +#ifndef IMPORTGL_API +#define IMPORTGL_API extern +#endif +#ifndef IMPORTGL_FNPTRINIT +#define IMPORTGL_FNPTRINIT +#endif + +#define FNDEF(retType, funcName, args) IMPORTGL_API retType (*funcPtr_##funcName) args IMPORTGL_FNPTRINIT + +#ifndef ANDROID_NDK +FNDEF(EGLBoolean, eglChooseConfig, (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)); +FNDEF(EGLContext, eglCreateContext, (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)); +FNDEF(EGLSurface, eglCreateWindowSurface, (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list)); +FNDEF(EGLBoolean, eglDestroyContext, (EGLDisplay dpy, EGLContext ctx)); +FNDEF(EGLBoolean, eglDestroySurface, (EGLDisplay dpy, EGLSurface surface)); +FNDEF(EGLBoolean, eglGetConfigAttrib, (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)); +FNDEF(EGLBoolean, eglGetConfigs, (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)); +FNDEF(EGLDisplay, eglGetDisplay, (NativeDisplayType display)); +FNDEF(EGLint, eglGetError, (void)); +FNDEF(EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint *major, EGLint *minor)); +FNDEF(EGLBoolean, eglMakeCurrent, (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)); +FNDEF(EGLBoolean, eglSwapBuffers, (EGLDisplay dpy, EGLSurface draw)); +FNDEF(EGLBoolean, eglTerminate, (EGLDisplay dpy)); +#endif /* !ANDROID_NDK */ + +FNDEF(void, glBlendFunc, (GLenum sfactor, GLenum dfactor)); +FNDEF(void, glClear, (GLbitfield mask)); +FNDEF(void, glClearColorx, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)); +FNDEF(void, glColor4x, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)); +FNDEF(void, glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)); +FNDEF(void, glDisable, (GLenum cap)); +FNDEF(void, glDisableClientState, (GLenum array)); +FNDEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)); +FNDEF(void, glEnable, (GLenum cap)); +FNDEF(void, glEnableClientState, (GLenum array)); +FNDEF(void, glFrustumx, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)); +FNDEF(GLenum, glGetError, (void)); +FNDEF(void, glLightxv, (GLenum light, GLenum pname, const GLfixed *params)); +FNDEF(void, glLoadIdentity, (void)); +FNDEF(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param)); +FNDEF(void, glMaterialxv, (GLenum face, GLenum pname, const GLfixed *params)); +FNDEF(void, glMatrixMode, (GLenum mode)); +FNDEF(void, glMultMatrixx, (const GLfixed *m)); +FNDEF(void, glNormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer)); +FNDEF(void, glPopMatrix, (void)); +FNDEF(void, glPushMatrix, (void)); +FNDEF(void, glRotatex, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)); +FNDEF(void, glScalex, (GLfixed x, GLfixed y, GLfixed z)); +FNDEF(void, glShadeModel, (GLenum mode)); +FNDEF(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z)); +FNDEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)); +FNDEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)); + + +#undef FN +#define FNPTR(name) funcPtr_##name + +#ifndef IMPORTGL_NO_FNPTR_DEFS + +// Redirect egl* and gl* function calls to funcPtr_egl* and funcPtr_gl*. + +#ifndef ANDROID_NDK +#define eglChooseConfig FNPTR(eglChooseConfig) +#define eglCreateContext FNPTR(eglCreateContext) +#define eglCreateWindowSurface FNPTR(eglCreateWindowSurface) +#define eglDestroyContext FNPTR(eglDestroyContext) +#define eglDestroySurface FNPTR(eglDestroySurface) +#define eglGetConfigAttrib FNPTR(eglGetConfigAttrib) +#define eglGetConfigs FNPTR(eglGetConfigs) +#define eglGetDisplay FNPTR(eglGetDisplay) +#define eglGetError FNPTR(eglGetError) +#define eglInitialize FNPTR(eglInitialize) +#define eglMakeCurrent FNPTR(eglMakeCurrent) +#define eglSwapBuffers FNPTR(eglSwapBuffers) +#define eglTerminate FNPTR(eglTerminate) +#endif /* !ANDROID_NDK */ + +#define glBlendFunc FNPTR(glBlendFunc) +#define glClear FNPTR(glClear) +#define glClearColorx FNPTR(glClearColorx) +#define glColor4x FNPTR(glColor4x) +#define glColorPointer FNPTR(glColorPointer) +#define glDisable FNPTR(glDisable) +#define glDisableClientState FNPTR(glDisableClientState) +#define glDrawArrays FNPTR(glDrawArrays) +#define glEnable FNPTR(glEnable) +#define glEnableClientState FNPTR(glEnableClientState) +#define glFrustumx FNPTR(glFrustumx) +#define glGetError FNPTR(glGetError) +#define glLightxv FNPTR(glLightxv) +#define glLoadIdentity FNPTR(glLoadIdentity) +#define glMaterialx FNPTR(glMaterialx) +#define glMaterialxv FNPTR(glMaterialxv) +#define glMatrixMode FNPTR(glMatrixMode) +#define glMultMatrixx FNPTR(glMultMatrixx) +#define glNormalPointer FNPTR(glNormalPointer) +#define glPopMatrix FNPTR(glPopMatrix) +#define glPushMatrix FNPTR(glPushMatrix) +#define glRotatex FNPTR(glRotatex) +#define glScalex FNPTR(glScalex) +#define glShadeModel FNPTR(glShadeModel) +#define glTranslatex FNPTR(glTranslatex) +#define glVertexPointer FNPTR(glVertexPointer) +#define glViewport FNPTR(glViewport) + +#endif // !IMPORTGL_NO_FNPTR_DEFS + + +#endif // !DISABLE_IMPORTGL + + +#ifdef __cplusplus +} +#endif + + +#endif // !IMPORTGL_H_INCLUDED
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/local.properties Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,10 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must *NOT* be checked in Version Control Systems, +# as it contains information specific to your local configuration. + +# location of the SDK. This is only used by Ant +# For customization when using a Version Control System, please read the +# header note. +sdk.dir=/home/paul/Projects/gsoc/sdk/android-sdk-linux_86
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/res/layout/main.xml Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > +<TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="Hello World, TestActivity" + /> +</LinearLayout> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/res/values/strings.xml Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">TestActivity</string> +</resources>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android/testproject/src/org/libsdl/android/TestActivity.java Thu Jun 17 22:19:27 2010 +1200 @@ -0,0 +1,76 @@ +package org.libsdl.android; + +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; + +import android.app.Activity; +import android.content.Context; +import android.opengl.GLSurfaceView; +import android.os.Bundle; +import android.view.MotionEvent; + +public class TestActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mGLView = new TestGLSurfaceView(this); + setContentView(mGLView); + } + + @Override + protected void onPause() { + super.onPause(); + mGLView.onPause(); + } + + @Override + protected void onResume() { + super.onResume(); + mGLView.onResume(); + } + + private GLSurfaceView mGLView; + + static { + System.loadLibrary("sanangeles"); + } +} + +class TestGLSurfaceView extends GLSurfaceView { + public TestGLSurfaceView(Context context) { + super(context); + mRenderer = new TestRenderer(); + setRenderer(mRenderer); + } + + public boolean onTouchEvent(final MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + nativePause(); + } + return true; + } + + TestRenderer mRenderer; + + private static native void nativePause(); +} + +class TestRenderer implements GLSurfaceView.Renderer { + public void onSurfaceCreated(GL10 gl, EGLConfig config) { + nativeInit(); + } + + public void onSurfaceChanged(GL10 gl, int w, int h) { + //gl.glViewport(0, 0, w, h); + nativeResize(w, h); + } + + public void onDrawFrame(GL10 gl) { + nativeRender(); + } + + private static native void nativeInit(); + private static native void nativeResize(int w, int h); + private static native void nativeRender(); + private static native void nativeDone(); +}