Removed obsolete test project
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Aug 2010 00:21:20 -0700
changeset 4728431c0381c696
parent 4727 8087bb208acf
child 4729 1f7ad083fd3c
Removed obsolete test project
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.cpp
android/testproject/jni/egl.h
android/testproject/jni/eglnatives.h
android/testproject/jni/egltypes.h
android/testproject/jni/importgl.cpp
android/testproject/jni/importgl.h
android/testproject/jni/lesson05.c
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/SDLActivity.java
     1.1 --- a/android/testproject/AndroidManifest.xml	Tue Aug 17 17:28:14 2010 +1200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,15 +0,0 @@
     1.4 -<?xml version="1.0" encoding="utf-8"?>
     1.5 -<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     1.6 -      package="org.libsdl.android"
     1.7 -      android:versionCode="1"
     1.8 -      android:versionName="1.0">
     1.9 -    <application android:label="@string/app_name" android:icon="@drawable/icon">
    1.10 -        <activity android:name="SDLActivity"
    1.11 -                  android:label="@string/app_name">
    1.12 -            <intent-filter>
    1.13 -                <action android:name="android.intent.action.MAIN" />
    1.14 -                <category android:name="android.intent.category.LAUNCHER" />
    1.15 -            </intent-filter>
    1.16 -        </activity>
    1.17 -    </application>
    1.18 -</manifest> 
     2.1 --- a/android/testproject/build.properties	Tue Aug 17 17:28:14 2010 +1200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,17 +0,0 @@
     2.4 -# This file is used to override default values used by the Ant build system.
     2.5 -# 
     2.6 -# This file must be checked in Version Control Systems, as it is
     2.7 -# integral to the build system of your project.
     2.8 -
     2.9 -# This file is only used by the Ant script.
    2.10 -
    2.11 -# You can use this to override default values such as
    2.12 -#  'source.dir' for the location of your java source folder and
    2.13 -#  'out.dir' for the location of your output folder.
    2.14 -
    2.15 -# You can also use it define how the release builds are signed by declaring
    2.16 -# the following properties:
    2.17 -#  'key.store' for the location of your keystore and
    2.18 -#  'key.alias' for the name of the key to use.
    2.19 -# The password will be asked during the build when you use the 'release' target.
    2.20 -
     3.1 --- a/android/testproject/build.xml	Tue Aug 17 17:28:14 2010 +1200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,67 +0,0 @@
     3.4 -<?xml version="1.0" encoding="UTF-8"?>
     3.5 -<project name="Test" default="help">
     3.6 -
     3.7 -    <!-- The local.properties file is created and updated by the 'android' tool.
     3.8 -         It contains the path to the SDK. It should *NOT* be checked in in Version
     3.9 -         Control Systems. -->
    3.10 -    <property file="local.properties" />
    3.11 -
    3.12 -    <!-- The build.properties file can be created by you and is never touched
    3.13 -         by the 'android' tool. This is the place to change some of the default property values
    3.14 -         used by the Ant rules.
    3.15 -         Here are some properties you may want to change/update:
    3.16 -
    3.17 -         application.package
    3.18 -             the name of your application package as defined in the manifest. Used by the
    3.19 -             'uninstall' rule.
    3.20 -         source.dir
    3.21 -             the name of the source directory. Default is 'src'.
    3.22 -         out.dir
    3.23 -             the name of the output directory. Default is 'bin'.
    3.24 -
    3.25 -         Properties related to the SDK location or the project target should be updated
    3.26 -          using the 'android' tool with the 'update' action.
    3.27 -
    3.28 -         This file is an integral part of the build system for your application and
    3.29 -         should be checked in in Version Control Systems.
    3.30 -
    3.31 -         -->
    3.32 -    <property file="build.properties" />
    3.33 -
    3.34 -    <!-- The default.properties file is created and updated by the 'android' tool, as well
    3.35 -         as ADT.
    3.36 -         This file is an integral part of the build system for your application and
    3.37 -         should be checked in in Version Control Systems. -->
    3.38 -    <property file="default.properties" />
    3.39 -
    3.40 -    <!-- Custom Android task to deal with the project target, and import the proper rules.
    3.41 -         This requires ant 1.6.0 or above. -->
    3.42 -    <path id="android.antlibs">
    3.43 -        <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
    3.44 -        <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
    3.45 -        <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
    3.46 -        <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
    3.47 -        <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
    3.48 -    </path>
    3.49 -
    3.50 -    <taskdef name="setup"
    3.51 -        classname="com.android.ant.SetupTask"
    3.52 -        classpathref="android.antlibs" />
    3.53 -
    3.54 -    <!-- Execute the Android Setup task that will setup some properties specific to the target,
    3.55 -         and import the build rules files.
    3.56 -
    3.57 -         The rules file is imported from
    3.58 -            <SDK>/platforms/<target_platform>/templates/android_rules.xml
    3.59 -
    3.60 -         To customize some build steps for your project:
    3.61 -         - copy the content of the main node <project> from android_rules.xml
    3.62 -         - paste it in this build.xml below the <setup /> task.
    3.63 -         - disable the import by changing the setup task below to <setup import="false" />
    3.64 -
    3.65 -         This will ensure that the properties are setup correctly but that your customized
    3.66 -         build steps are used.
    3.67 -    -->
    3.68 -    <setup />
    3.69 -
    3.70 -</project>
     4.1 --- a/android/testproject/default.properties	Tue Aug 17 17:28:14 2010 +1200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,11 +0,0 @@
     4.4 -# This file is automatically generated by Android Tools.
     4.5 -# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
     4.6 -# 
     4.7 -# This file must be checked in Version Control Systems.
     4.8 -# 
     4.9 -# To customize properties used by the Ant build system use,
    4.10 -# "build.properties", and override values to adapt the script to your
    4.11 -# project structure.
    4.12 -
    4.13 -# Project target.
    4.14 -target=Google Inc.:Google APIs:7
     5.1 --- a/android/testproject/jni/Android.mk	Tue Aug 17 17:28:14 2010 +1200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,20 +0,0 @@
     5.4 -LOCAL_PATH := $(call my-dir)
     5.5 -
     5.6 -include $(CLEAR_VARS)
     5.7 -
     5.8 -LOCAL_MODULE := sdltest
     5.9 -
    5.10 -SDL := /home/paul/Projects/gsoc/SDL-gsoc2010_android/
    5.11 -
    5.12 -LOCAL_CFLAGS := -DANDROID_NDK \
    5.13 -                -DDISABLE_IMPORTGL \
    5.14 -                -I$(SDL)/include
    5.15 -
    5.16 -LOCAL_SRC_FILES := \
    5.17 -    importgl.cpp \
    5.18 -    app-android.cpp \
    5.19 -    lesson05.c \
    5.20 -
    5.21 -LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lSDL -lEGL -lgcc -L$(SDL) -L$(SDL)/build-scripts/android_libs/
    5.22 -
    5.23 -include $(BUILD_SHARED_LIBRARY)
     6.1 --- a/android/testproject/jni/app-android.cpp	Tue Aug 17 17:28:14 2010 +1200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,236 +0,0 @@
     6.4 -/*******************************************************************************
     6.5 -                               Headers
     6.6 -*******************************************************************************/
     6.7 -#include <jni.h>
     6.8 -#include <sys/time.h>
     6.9 -#include <time.h>
    6.10 -#include <android/log.h>
    6.11 -#include <stdint.h>
    6.12 -
    6.13 -#include <stdio.h>
    6.14 -#include <stdlib.h>
    6.15 -#include <math.h>
    6.16 -
    6.17 -#include <pthread.h>
    6.18 -
    6.19 -//#include "importgl.h"
    6.20 -//#include "egl.h"
    6.21 -
    6.22 -/*******************************************************************************
    6.23 -                               Globals
    6.24 -*******************************************************************************/
    6.25 -static long _getTime(void){
    6.26 -	struct timeval  now;
    6.27 -	gettimeofday(&now, NULL);
    6.28 -	return (long)(now.tv_sec*1000 + now.tv_usec/1000);
    6.29 -}
    6.30 -
    6.31 -JNIEnv* mEnv = NULL;
    6.32 -JNIEnv* mAudioThreadEnv = NULL; //See the note below for why this is necessary
    6.33 -JavaVM* mVM = NULL;
    6.34 -
    6.35 -//Main activity
    6.36 -jclass mActivityInstance;
    6.37 -
    6.38 -//method signatures
    6.39 -jmethodID midCreateGLContext;
    6.40 -jmethodID midFlipBuffers;
    6.41 -jmethodID midEnableFeature;
    6.42 -jmethodID midUpdateAudio;
    6.43 -
    6.44 -extern "C" int SDL_main();
    6.45 -extern "C" int Android_OnKeyDown(int keycode);
    6.46 -extern "C" int Android_OnKeyUp(int keycode);
    6.47 -extern "C" void Android_SetScreenResolution(int width, int height);
    6.48 -extern "C" void Android_OnResize(int width, int height, int format);
    6.49 -extern "C" int SDL_SendQuit();
    6.50 -extern "C" void Android_EnableFeature(int featureid, bool enabled);
    6.51 -
    6.52 -//If we're not the active app, don't try to render
    6.53 -bool bRenderingEnabled = false;
    6.54 -
    6.55 -//Feature IDs
    6.56 -static const int FEATURE_AUDIO = 1;
    6.57 -static const int FEATURE_ACCEL = 2;
    6.58 -
    6.59 -//Accelerometer data storage
    6.60 -float fLastAccelerometer[3];
    6.61 -
    6.62 -
    6.63 -/*******************************************************************************
    6.64 -                 Functions called by JNI
    6.65 -*******************************************************************************/	
    6.66 -
    6.67 -//Library init
    6.68 -extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved){
    6.69 -
    6.70 -    JNIEnv* env = NULL;
    6.71 -    jint result = -1;
    6.72 -
    6.73 -    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
    6.74 -        return result;
    6.75 -    }
    6.76 -
    6.77 -    mEnv = env;
    6.78 -
    6.79 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: OnLoad");
    6.80 -
    6.81 -    jclass cls = mEnv->FindClass ("org/libsdl/android/SDLActivity"); 
    6.82 -    mActivityInstance = cls;
    6.83 -    midCreateGLContext = mEnv->GetStaticMethodID(cls,"createGLContext","()V");
    6.84 -    midFlipBuffers = mEnv->GetStaticMethodID(cls,"flipBuffers","()V");
    6.85 -    midEnableFeature = mEnv->GetStaticMethodID(cls,"enableFeature","(II)V");
    6.86 -    midUpdateAudio = mEnv->GetStaticMethodID(cls,"updateAudio","([B)V");
    6.87 -
    6.88 -    if(!midCreateGLContext || !midFlipBuffers || !midEnableFeature ||
    6.89 -        !midUpdateAudio){
    6.90 -        __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Bad mids\n");
    6.91 -    }else{
    6.92 -        __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Good mids\n");
    6.93 -    }
    6.94 -    
    6.95 -    return JNI_VERSION_1_4;
    6.96 -}
    6.97 -
    6.98 -//Start up the SDL app
    6.99 -extern "C" void Java_org_libsdl_android_SDLActivity_nativeInit( JNIEnv* env, 
   6.100 -                                                                jobject obj ){ 
   6.101 -                                                                   
   6.102 -	__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Native Init");
   6.103 -
   6.104 -	mEnv = env;
   6.105 -	bRenderingEnabled = true;
   6.106 -
   6.107 -	Android_EnableFeature(FEATURE_ACCEL, true);
   6.108 -
   6.109 -    SDL_main();
   6.110 -}
   6.111 -
   6.112 -//Keydown
   6.113 -extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyDown(JNIEnv* env, 
   6.114 -               jobject obj, jint keycode){
   6.115 -    
   6.116 -    int r = Android_OnKeyDown(keycode);
   6.117 -    __android_log_print(ANDROID_LOG_INFO, "SDL", 
   6.118 -                        "SDL: native key down %d, %d\n", keycode, r);
   6.119 -                        
   6.120 -}
   6.121 -
   6.122 -//Keyup
   6.123 -extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyUp(JNIEnv* env, 
   6.124 -               jobject obj, jint keycode){
   6.125 -    
   6.126 -    int r = Android_OnKeyUp(keycode);
   6.127 -    __android_log_print(ANDROID_LOG_INFO, "SDL", 
   6.128 -                        "SDL: native key up %d, %d\n", keycode, r);
   6.129 -                        
   6.130 -}
   6.131 -
   6.132 -//Touch
   6.133 -extern "C" void Java_org_libsdl_android_SDLActivity_onNativeTouch(JNIEnv* env, 
   6.134 -               jobject obj, jint action, jfloat x, jfloat y, jfloat p){
   6.135 -
   6.136 -    __android_log_print(ANDROID_LOG_INFO, "SDL", 
   6.137 -                        "SDL: native touch event %d @ %f/%f, pressure %f\n", 
   6.138 -                        action, x, y, p);
   6.139 -
   6.140 -    //TODO: Pass this off to the SDL multitouch stuff
   6.141 -                        
   6.142 -}
   6.143 -
   6.144 -//Quit
   6.145 -extern "C" void Java_org_libsdl_android_SDLActivity_nativeQuit( JNIEnv*  env, 
   6.146 -                                                                jobject obj ){    
   6.147 -
   6.148 -    //Stop rendering as we're no longer in the foreground
   6.149 -	bRenderingEnabled = false;
   6.150 -
   6.151 -    //Inject a SDL_QUIT event
   6.152 -    int r = SDL_SendQuit();
   6.153 -
   6.154 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Native quit %d", r);        
   6.155 -}
   6.156 -
   6.157 -//Screen size
   6.158 -extern "C" void Java_org_libsdl_android_SDLActivity_nativeSetScreenSize(
   6.159 -                JNIEnv*  env, jobject obj, jint width, jint height){
   6.160 -
   6.161 -    __android_log_print(ANDROID_LOG_INFO, "SDL", 
   6.162 -                        "SDL: Set screen size on init: %d/%d\n", width, height);
   6.163 -    Android_SetScreenResolution(width, height);
   6.164 -                        
   6.165 -}
   6.166 -
   6.167 -//Resize
   6.168 -extern "C" void Java_org_libsdl_android_SDLActivity_onNativeResize(
   6.169 -                                        JNIEnv*  env, jobject obj, jint width, 
   6.170 -                                        jint height, jint format){
   6.171 -    Android_OnResize(width, height, format);
   6.172 -}
   6.173 -
   6.174 -extern "C" void Java_org_libsdl_android_SDLActivity_onNativeAccel(
   6.175 -                                        JNIEnv*  env, jobject obj,
   6.176 -                                        jfloat x, jfloat y, jfloat z){
   6.177 -    fLastAccelerometer[0] = x;
   6.178 -    fLastAccelerometer[1] = y;
   6.179 -    fLastAccelerometer[2] = z;   
   6.180 -}
   6.181 -
   6.182 -
   6.183 -
   6.184 -/*******************************************************************************
   6.185 -             Functions called by SDL into Java
   6.186 -*******************************************************************************/
   6.187 -extern "C" void Android_CreateContext(){
   6.188 -	__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: sdl_create_context()\n");
   6.189 -
   6.190 -	bRenderingEnabled = true;
   6.191 -
   6.192 -    mEnv->CallStaticVoidMethod(mActivityInstance, midCreateGLContext ); 
   6.193 -}
   6.194 -
   6.195 -extern "C" void Android_Render(){
   6.196 -
   6.197 -    if(!bRenderingEnabled){
   6.198 -        return;
   6.199 -    }
   6.200 -
   6.201 -    //When we get here, we've accumulated a full frame    
   6.202 -    mEnv->CallStaticVoidMethod(mActivityInstance, midFlipBuffers ); 
   6.203 -}
   6.204 -
   6.205 -extern "C" void Android_EnableFeature(int featureid, bool enabled){
   6.206 -
   6.207 -    mEnv->CallStaticVoidMethod(mActivityInstance, midEnableFeature, 
   6.208 -                                featureid, (int)enabled); 
   6.209 -}
   6.210 -
   6.211 -extern "C" void Android_UpdateAudioBuffer(unsigned char *buf, int len){
   6.212 -
   6.213 -    //Annoyingly we can't just call into Java from any thread. Because the audio
   6.214 -    //callback is dispatched from the SDL audio thread (that wasn't made from
   6.215 -    //java, we have to do some magic here to let the JVM know about the thread.
   6.216 -    //Because everything it touches on the Java side is static anyway, it's 
   6.217 -    //not a big deal, just annoying.
   6.218 -    if(!mAudioThreadEnv){
   6.219 -        __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Need to set up audio thread env\n");
   6.220 -
   6.221 -        mJVM->AttachCurrentThread(&mAudioThreadEnv, NULL);
   6.222 -
   6.223 -        __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: ok\n");
   6.224 -    }
   6.225 -    
   6.226 -    jbyteArray arr = mAudioThreadEnv->NewByteArray(len);
   6.227 -
   6.228 -    //blah. We probably should rework this so we avoid the copy. 
   6.229 -    mAudioThreadEnv->SetByteArrayRegion(arr, 0, len, (jbyte *)buf);
   6.230 -    
   6.231 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: copied\n");
   6.232 -
   6.233 -    mAudioThreadEnv->CallStaticVoidMethod(  mActivityInstance, 
   6.234 -                                            midUpdateAudio, arr );
   6.235 -
   6.236 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: invoked\n");
   6.237 -    
   6.238 -}
   6.239 -
     7.1 --- a/android/testproject/jni/egl.h	Tue Aug 17 17:28:14 2010 +1200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,269 +0,0 @@
     7.4 -/*
     7.5 - * Copyright (C) 2007 The Android Open Source Project
     7.6 - *
     7.7 - * Licensed under the Apache License, Version 2.0 (the "License");
     7.8 - * you may not use this file except in compliance with the License.
     7.9 - * You may obtain a copy of the License at
    7.10 - *
    7.11 - *      http://www.apache.org/licenses/LICENSE-2.0
    7.12 - *
    7.13 - * Unless required by applicable law or agreed to in writing, software
    7.14 - * distributed under the License is distributed on an "AS IS" BASIS,
    7.15 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    7.16 - * See the License for the specific language governing permissions and
    7.17 - * limitations under the License.
    7.18 - */
    7.19 -
    7.20 -#ifndef ANDROID_EGL_H
    7.21 -#define ANDROID_EGL_H
    7.22 -
    7.23 -#include <GLES/gl.h>
    7.24 -#include <egltypes.h>
    7.25 -#include <eglnatives.h>
    7.26 -
    7.27 -#ifdef __cplusplus
    7.28 -extern "C" {
    7.29 -#endif
    7.30 -
    7.31 -#define EGL_VERSION_1_0         1
    7.32 -#define EGL_VERSION_1_1         1
    7.33 -#define EGL_VERSION_1_2         1
    7.34 -
    7.35 -#define EGL_FALSE               0
    7.36 -#define EGL_TRUE                1
    7.37 -
    7.38 -/* Errors */
    7.39 -#define EGL_SUCCESS                     0x3000
    7.40 -#define EGL_NOT_INITIALIZED             0x3001
    7.41 -#define EGL_BAD_ACCESS                  0x3002
    7.42 -#define EGL_BAD_ALLOC                   0x3003
    7.43 -#define EGL_BAD_ATTRIBUTE               0x3004
    7.44 -#define EGL_BAD_CONFIG                  0x3005
    7.45 -#define EGL_BAD_CONTEXT                 0x3006
    7.46 -#define EGL_BAD_CURRENT_SURFACE         0x3007
    7.47 -#define EGL_BAD_DISPLAY                 0x3008
    7.48 -#define EGL_BAD_MATCH                   0x3009
    7.49 -#define EGL_BAD_NATIVE_PIXMAP           0x300A
    7.50 -#define EGL_BAD_NATIVE_WINDOW           0x300B
    7.51 -#define EGL_BAD_PARAMETER               0x300C
    7.52 -#define EGL_BAD_SURFACE                 0x300D
    7.53 -#define EGL_CONTEXT_LOST                0x300E
    7.54 -
    7.55 -/* Config attributes */
    7.56 -#define EGL_BUFFER_SIZE                 0x3020
    7.57 -#define EGL_ALPHA_SIZE                  0x3021
    7.58 -#define EGL_BLUE_SIZE                   0x3022
    7.59 -#define EGL_GREEN_SIZE                  0x3023
    7.60 -#define EGL_RED_SIZE                    0x3024
    7.61 -#define EGL_DEPTH_SIZE                  0x3025
    7.62 -#define EGL_STENCIL_SIZE                0x3026
    7.63 -#define EGL_CONFIG_CAVEAT               0x3027
    7.64 -#define EGL_CONFIG_ID                   0x3028
    7.65 -#define EGL_LEVEL                       0x3029
    7.66 -#define EGL_MAX_PBUFFER_HEIGHT          0x302A
    7.67 -#define EGL_MAX_PBUFFER_PIXELS          0x302B
    7.68 -#define EGL_MAX_PBUFFER_WIDTH           0x302C
    7.69 -#define EGL_NATIVE_RENDERABLE           0x302D
    7.70 -#define EGL_NATIVE_VISUAL_ID            0x302E
    7.71 -#define EGL_NATIVE_VISUAL_TYPE          0x302F
    7.72 -#define EGL_SAMPLES                     0x3031
    7.73 -#define EGL_SAMPLE_BUFFERS              0x3032
    7.74 -#define EGL_SURFACE_TYPE                0x3033
    7.75 -#define EGL_TRANSPARENT_TYPE            0x3034
    7.76 -#define EGL_TRANSPARENT_BLUE_VALUE      0x3035
    7.77 -#define EGL_TRANSPARENT_GREEN_VALUE     0x3036
    7.78 -#define EGL_TRANSPARENT_RED_VALUE       0x3037
    7.79 -#define EGL_NONE                        0x3038
    7.80 -#define EGL_BIND_TO_TEXTURE_RGB         0x3039
    7.81 -#define EGL_BIND_TO_TEXTURE_RGBA        0x303A
    7.82 -#define EGL_MIN_SWAP_INTERVAL           0x303B
    7.83 -#define EGL_MAX_SWAP_INTERVAL           0x303C
    7.84 -#define EGL_LUMINANCE_SIZE              0x303D
    7.85 -#define EGL_ALPHA_MASK_SIZE             0x303E
    7.86 -#define EGL_COLOR_BUFFER_TYPE           0x303F
    7.87 -#define EGL_RENDERABLE_TYPE             0x3040
    7.88 -
    7.89 -/* Config values */
    7.90 -#define EGL_DONT_CARE                   ((EGLint)-1)
    7.91 -
    7.92 -#define EGL_SLOW_CONFIG                 0x3050
    7.93 -#define EGL_NON_CONFORMANT_CONFIG       0x3051
    7.94 -#define EGL_TRANSPARENT_RGB             0x3052
    7.95 -#define EGL_NO_TEXTURE                  0x305C
    7.96 -#define EGL_TEXTURE_RGB                 0x305D
    7.97 -#define EGL_TEXTURE_RGBA                0x305E
    7.98 -#define EGL_TEXTURE_2D                  0x305F
    7.99 -#define EGL_RGB_BUFFER                  0x308E
   7.100 -#define EGL_LUMINANCE_BUFFER            0x308F
   7.101 -
   7.102 -/* Config attribute mask bits */
   7.103 -#define EGL_PBUFFER_BIT                 0x01
   7.104 -#define EGL_PIXMAP_BIT                  0x02
   7.105 -#define EGL_WINDOW_BIT                  0x04
   7.106 -#define EGL_OPENGL_ES_BIT               0x01
   7.107 -#define EGL_OPENVG_BIT                  0x02
   7.108 -
   7.109 -/* String names */
   7.110 -#define EGL_VENDOR                      0x3053
   7.111 -#define EGL_VERSION                     0x3054
   7.112 -#define EGL_EXTENSIONS                  0x3055
   7.113 -#define EGL_CLIENT_APIS                 0x308D
   7.114 -
   7.115 -/* Surface attributes */
   7.116 -#define EGL_HEIGHT                      0x3056
   7.117 -#define EGL_WIDTH                       0x3057
   7.118 -#define EGL_LARGEST_PBUFFER             0x3058
   7.119 -#define EGL_TEXTURE_FORMAT              0x3080
   7.120 -#define EGL_TEXTURE_TARGET              0x3081
   7.121 -#define EGL_MIPMAP_TEXTURE              0x3082
   7.122 -#define EGL_MIPMAP_LEVEL                0x3083
   7.123 -#define EGL_RENDER_BUFFER               0x3086
   7.124 -#define EGL_COLORSPACE                  0x3087
   7.125 -#define EGL_ALPHA_FORMAT                0x3088
   7.126 -#define EGL_HORIZONTAL_RESOLUTION       0x3090
   7.127 -#define EGL_VERTICAL_RESOLUTION         0x3091
   7.128 -#define EGL_PIXEL_ASPECT_RATIO          0x3092
   7.129 -#define EGL_SWAP_BEHAVIOR               0x3093
   7.130 -
   7.131 -#define EGL_BACK_BUFFER                 0x3084
   7.132 -#define EGL_SINGLE_BUFFER               0x3085
   7.133 -
   7.134 -#define EGL_DISPLAY_SCALING             10000
   7.135 -
   7.136 -#define EGL_UNKNOWN                     ((EGLint)-1)
   7.137 -
   7.138 -/* Back buffer swap behaviors */
   7.139 -#define EGL_BUFFER_PRESERVED            0x3094
   7.140 -#define EGL_BUFFER_DESTROYED            0x3095
   7.141 -
   7.142 -/* CreatePbufferFromClientBuffer buffer types */
   7.143 -#define EGL_OPENVG_IMAGE                0x3096
   7.144 -
   7.145 -/* QueryContext targets */
   7.146 -#define EGL_CONTEXT_CLIENT_TYPE         0x3097
   7.147 -
   7.148 -/* BindAPI/QueryAPI targets */
   7.149 -#define EGL_OPENGL_ES_API               0x30A0
   7.150 -#define EGL_OPENVG_API                  0x30A1
   7.151 -
   7.152 -/* WaitNative engines */
   7.153 -#define EGL_CORE_NATIVE_ENGINE          0x305B
   7.154 -
   7.155 -/* Current surfaces */
   7.156 -#define EGL_DRAW                        0x3059
   7.157 -#define EGL_READ                        0x305A
   7.158 -
   7.159 -
   7.160 -EGLDisplay eglGetDisplay(NativeDisplayType display);
   7.161 -EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
   7.162 -EGLBoolean eglTerminate(EGLDisplay dpy);
   7.163 -
   7.164 -EGLBoolean eglGetConfigs(   EGLDisplay dpy,
   7.165 -                            EGLConfig *configs,
   7.166 -                            EGLint config_size, EGLint *num_config);
   7.167 -
   7.168 -EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
   7.169 -                            EGLConfig *configs, EGLint config_size,
   7.170 -                            EGLint *num_config);
   7.171 -
   7.172 -EGLBoolean eglGetConfigAttrib(  EGLDisplay dpy, EGLConfig config,
   7.173 -                                EGLint attribute, EGLint *value);
   7.174 -
   7.175 -EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config,
   7.176 -                                    NativeWindowType window,
   7.177 -                                    const EGLint *attrib_list);
   7.178 -
   7.179 -EGLSurface eglCreatePixmapSurface(  EGLDisplay dpy, EGLConfig config,
   7.180 -                                    NativePixmapType pixmap,
   7.181 -                                    const EGLint *attrib_list);
   7.182 -
   7.183 -EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config,
   7.184 -                                    const EGLint *attrib_list);
   7.185 -                                    
   7.186 -EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
   7.187 -
   7.188 -EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
   7.189 -                            EGLint attribute, EGLint *value);
   7.190 -
   7.191 -EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
   7.192 -                            EGLContext share_list, const EGLint *attrib_list);
   7.193 -
   7.194 -EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
   7.195 -
   7.196 -EGLBoolean eglMakeCurrent(  EGLDisplay dpy, EGLSurface draw,
   7.197 -                            EGLSurface read, EGLContext ctx);
   7.198 -
   7.199 -EGLContext eglGetCurrentContext(void);
   7.200 -EGLSurface eglGetCurrentSurface(EGLint readdraw);
   7.201 -EGLDisplay eglGetCurrentDisplay(void);
   7.202 -EGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx,
   7.203 -                            EGLint attribute, EGLint *value);
   7.204 -
   7.205 -EGLBoolean eglWaitGL(void);
   7.206 -EGLBoolean eglWaitNative(EGLint engine);
   7.207 -EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw);
   7.208 -EGLBoolean eglCopyBuffers(  EGLDisplay dpy, EGLSurface surface,
   7.209 -                            NativePixmapType target);
   7.210 -
   7.211 -EGLint eglGetError(void);
   7.212 -const char* eglQueryString(EGLDisplay dpy, EGLint name);
   7.213 -void (*eglGetProcAddress (const char *procname))();
   7.214 -
   7.215 -/* ----------------------------------------------------------------------------
   7.216 - * EGL 1.1
   7.217 - * ----------------------------------------------------------------------------
   7.218 - */
   7.219 -
   7.220 -EGLBoolean eglSurfaceAttrib(
   7.221 -        EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
   7.222 -EGLBoolean eglBindTexImage(
   7.223 -        EGLDisplay dpy, EGLSurface surface, EGLint buffer);
   7.224 -EGLBoolean eglReleaseTexImage(
   7.225 -        EGLDisplay dpy, EGLSurface surface, EGLint buffer);
   7.226 -
   7.227 -EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval);
   7.228 -
   7.229 -/* ----------------------------------------------------------------------------
   7.230 - * EGL 1.2
   7.231 - * ----------------------------------------------------------------------------
   7.232 - */
   7.233 -
   7.234 -EGLBoolean eglBindAPI(EGLenum api);
   7.235 -EGLenum eglQueryAPI(void);
   7.236 -EGLBoolean eglWaitClient(void);
   7.237 -EGLBoolean eglReleaseThread(void);
   7.238 -EGLSurface eglCreatePbufferFromClientBuffer(
   7.239 -          EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
   7.240 -          EGLConfig config, const EGLint *attrib_list);
   7.241 -
   7.242 -/* ----------------------------------------------------------------------------
   7.243 - * Android extentions
   7.244 - * ----------------------------------------------------------------------------
   7.245 - */
   7.246 -
   7.247 -EGLBoolean eglSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
   7.248 -        EGLint l, EGLint t, EGLint w, EGLint h);
   7.249 -
   7.250 -EGLBoolean eglCopyFrontToBackANDROID(EGLDisplay dpy,
   7.251 -        EGLSurface surface,
   7.252 -        EGLint l, EGLint t, EGLint w, EGLint h);
   7.253 -
   7.254 -const char* eglQueryStringConfigANDROID(
   7.255 -        EGLDisplay dpy, EGLConfig config, EGLint name);
   7.256 -
   7.257 -void* eglGetRenderBufferAddressANDROID(EGLDisplay dpy, EGLSurface surface);
   7.258 -
   7.259 -EGLBoolean eglCopyBitsANDROID(EGLDisplay dpy,
   7.260 -        NativeWindowType draw, EGLint x, EGLint y,
   7.261 -        NativeWindowType read,
   7.262 -        EGLint crop_x, EGLint crop_y, EGLint crop_w, EGLint crop_h,
   7.263 -        EGLint flags);
   7.264 -
   7.265 -
   7.266 -#ifdef __cplusplus
   7.267 -}
   7.268 -#endif
   7.269 -
   7.270 -
   7.271 -#endif /*ANDROID_EGL_H*/
   7.272 -
     8.1 --- a/android/testproject/jni/eglnatives.h	Tue Aug 17 17:28:14 2010 +1200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,277 +0,0 @@
     8.4 -/*
     8.5 - * Copyright (C) 2007 The Android Open Source Project
     8.6 - *
     8.7 - * Licensed under the Apache License, Version 2.0 (the "License");
     8.8 - * you may not use this file except in compliance with the License.
     8.9 - * You may obtain a copy of the License at
    8.10 - *
    8.11 - *      http://www.apache.org/licenses/LICENSE-2.0
    8.12 - *
    8.13 - * Unless required by applicable law or agreed to in writing, software
    8.14 - * distributed under the License is distributed on an "AS IS" BASIS,
    8.15 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    8.16 - * See the License for the specific language governing permissions and
    8.17 - * limitations under the License.
    8.18 - */
    8.19 -
    8.20 -#ifndef ANDROID_EGLNATIVES_H
    8.21 -#define ANDROID_EGLNATIVES_H
    8.22 -
    8.23 -#include <sys/types.h>
    8.24 -
    8.25 -#ifdef __cplusplus
    8.26 -extern "C" {
    8.27 -#endif
    8.28 -/*****************************************************************************/
    8.29 -
    8.30 -struct egl_native_window_t;
    8.31 -struct egl_native_pixmap_t;
    8.32 -
    8.33 -
    8.34 -typedef struct egl_native_window_t*     NativeWindowType;
    8.35 -typedef struct egl_native_pixmap_t*     NativePixmapType;
    8.36 -typedef void*                           NativeDisplayType;
    8.37 -
    8.38 -/* 
    8.39 - * This a conveniance function to create a NativeWindowType surface
    8.40 - * that maps to the whole screen
    8.41 - * This function is actually implemented in libui.so
    8.42 - */
    8.43 -
    8.44 -NativeWindowType android_createDisplaySurface();
    8.45 -
    8.46 -/* flags returned from swapBuffer */
    8.47 -#define EGL_NATIVES_FLAG_SIZE_CHANGED       0x00000001
    8.48 -
    8.49 -/* surface flags */
    8.50 -#define EGL_NATIVES_FLAG_DESTROY_BACKBUFFER 0x00000001
    8.51 -
    8.52 -enum native_pixel_format_t
    8.53 -{
    8.54 -    NATIVE_PIXEL_FORMAT_RGBA_8888   = 1,
    8.55 -    NATIVE_PIXEL_FORMAT_RGB_565     = 4,
    8.56 -    NATIVE_PIXEL_FORMAT_RGBA_5551   = 6,
    8.57 -    NATIVE_PIXEL_FORMAT_RGBA_4444   = 7,
    8.58 -    NATIVE_PIXEL_FORMAT_YCbCr_422_SP= 0x10,
    8.59 -    NATIVE_PIXEL_FORMAT_YCbCr_420_SP= 0x11,
    8.60 -};
    8.61 -
    8.62 -enum native_memory_type_t
    8.63 -{
    8.64 -    NATIVE_MEMORY_TYPE_PMEM         = 0,
    8.65 -    NATIVE_MEMORY_TYPE_GPU          = 1,
    8.66 -    NATIVE_MEMORY_TYPE_FB           = 2,
    8.67 -    NATIVE_MEMORY_TYPE_HEAP         = 128
    8.68 -};
    8.69 -
    8.70 -
    8.71 -struct egl_native_window_t
    8.72 -{
    8.73 -    /*
    8.74 -     * magic must be set to 0x600913
    8.75 -     */
    8.76 -    uint32_t    magic;
    8.77 -    
    8.78 -    /*
    8.79 -     * must be sizeof(egl_native_window_t)
    8.80 -     */
    8.81 -    uint32_t    version;
    8.82 -
    8.83 -    /*
    8.84 -     * ident is reserved for the Android platform
    8.85 -     */
    8.86 -    uint32_t    ident;
    8.87 -    
    8.88 -    /*
    8.89 -     * width, height and stride of the window in pixels
    8.90 -     * Any of these value can be nul in which case GL commands are
    8.91 -     * accepted and processed as usual, but not rendering occurs.
    8.92 -     */
    8.93 -    int         width;      // w=h=0 is legal
    8.94 -    int         height;
    8.95 -    int         stride;
    8.96 -
    8.97 -    /*
    8.98 -     * format of the native window (see ui/PixelFormat.h)
    8.99 -     */
   8.100 -    int         format;
   8.101 -    
   8.102 -    /*
   8.103 -     * Offset of the bits in the VRAM
   8.104 -     */
   8.105 -    intptr_t    offset;
   8.106 -    
   8.107 -    /*
   8.108 -     * flags describing some attributes of this surface
   8.109 -     * EGL_NATIVES_FLAG_DESTROY_BACKBUFFER: backbuffer not preserved after 
   8.110 -     * eglSwapBuffers
   8.111 -     */
   8.112 -    uint32_t    flags;
   8.113 -    
   8.114 -    /*
   8.115 -     * horizontal and vertical resolution in DPI
   8.116 -     */
   8.117 -    float       xdpi;
   8.118 -    float       ydpi;
   8.119 -    
   8.120 -    /*
   8.121 -     * refresh rate in frames per second (Hz)
   8.122 -     */
   8.123 -    float       fps;
   8.124 -    
   8.125 -    
   8.126 -    /*
   8.127 -     *  Base memory virtual address of the surface in the CPU side
   8.128 -     */
   8.129 -    intptr_t    base;
   8.130 -    
   8.131 -    /*
   8.132 -     *  Heap the offset above is based from
   8.133 -     */
   8.134 -    int         fd;
   8.135 -    
   8.136 -    /*
   8.137 -     *  Memory type the surface resides into
   8.138 -     */
   8.139 -    uint8_t     memory_type;
   8.140 -    
   8.141 -    /*
   8.142 -     * Reserved for future use. MUST BE ZERO.
   8.143 -     */
   8.144 -    uint8_t     reserved_pad[3];
   8.145 -    int         reserved[8];
   8.146 -    
   8.147 -    /*
   8.148 -     * Vertical stride (only relevant with planar formats) 
   8.149 -     */
   8.150 -    
   8.151 -    int         vstride;
   8.152 -
   8.153 -    /*
   8.154 -     * Hook called by EGL to hold a reference on this structure
   8.155 -     */
   8.156 -    void        (*incRef)(NativeWindowType window);
   8.157 -
   8.158 -    /*
   8.159 -     * Hook called by EGL to release a reference on this structure
   8.160 -     */
   8.161 -    void        (*decRef)(NativeWindowType window);
   8.162 -
   8.163 -    /*
   8.164 -     * Hook called by EGL to perform a page flip. This function
   8.165 -     * may update the size attributes above, in which case it returns
   8.166 -     * the EGL_NATIVES_FLAG_SIZE_CHANGED bit set.
   8.167 -     */
   8.168 -    uint32_t    (*swapBuffers)(NativeWindowType window);
   8.169 -    
   8.170 -    /*
   8.171 -     * Hook called by EGL to set the swap rectangle. this hook can be 
   8.172 -     * null (operation not supported) 
   8.173 -     */
   8.174 -    void        (*setSwapRectangle)(NativeWindowType window, int l, int t, int w, int h);
   8.175 -
   8.176 -    /*
   8.177 -     * Reserved for future use. MUST BE ZERO.
   8.178 -     */
   8.179 -    void        (*reserved_proc_0)(void);
   8.180 -    
   8.181 -    
   8.182 -    /*
   8.183 -     * Hook called by EGL to retrieve the next buffer to render into. 
   8.184 -     * This call updates this structure.
   8.185 -     */
   8.186 -    uint32_t    (*nextBuffer)(NativeWindowType window);
   8.187 -
   8.188 -    /*
   8.189 -     * Hook called by EGL when the native surface is associated to EGL
   8.190 -     * (eglCreateWindowSurface). Can be NULL.
   8.191 -     */
   8.192 -    void        (*connect)(NativeWindowType window);
   8.193 -
   8.194 -    /*
   8.195 -     * Hook called by EGL when eglDestroySurface is called.  Can be NULL.
   8.196 -     */
   8.197 -    void        (*disconnect)(NativeWindowType window);
   8.198 -    
   8.199 -    /*
   8.200 -     * Reserved for future use. MUST BE ZERO.
   8.201 -     */
   8.202 -    void        (*reserved_proc[11])(void);
   8.203 -    
   8.204 -    /*
   8.205 -     *  Some storage reserved for the oem driver.
   8.206 -     */
   8.207 -    intptr_t    oem[4];
   8.208 -};
   8.209 -
   8.210 -
   8.211 -struct egl_native_pixmap_t
   8.212 -{
   8.213 -    int32_t     version;    /* must be 32 */
   8.214 -    int32_t     width;
   8.215 -    int32_t     height;
   8.216 -    int32_t     stride;
   8.217 -    uint8_t*    data;
   8.218 -    uint8_t     format;
   8.219 -    uint8_t     rfu[3];
   8.220 -    union {
   8.221 -        uint32_t    compressedFormat;
   8.222 -        int32_t     vstride;
   8.223 -    };
   8.224 -    int32_t     reserved;
   8.225 -};
   8.226 -
   8.227 -/*****************************************************************************/
   8.228 -
   8.229 -/*
   8.230 - * OEM's egl's library (libhgl.so) must imlement these hooks to allocate
   8.231 - * the GPU memory they need  
   8.232 - */
   8.233 -
   8.234 -
   8.235 -typedef struct
   8.236 -{
   8.237 -    // for internal use
   8.238 -    void*   user;
   8.239 -    // virtual address of this area
   8.240 -    void*   base;
   8.241 -    // size of this area in bytes
   8.242 -    size_t  size;
   8.243 -    // physical address of this area
   8.244 -    void*   phys;
   8.245 -    // offset in this area available to the GPU
   8.246 -    size_t  offset;
   8.247 -    // fd of this area
   8.248 -    int     fd;
   8.249 -} gpu_area_t;
   8.250 -
   8.251 -typedef struct
   8.252 -{
   8.253 -    // area where GPU registers are mapped
   8.254 -    gpu_area_t regs;
   8.255 -    // number of extra areas (currently limited to 2)
   8.256 -    int32_t count;
   8.257 -    // extra GPU areas (currently limited to 2)
   8.258 -    gpu_area_t gpu[2];
   8.259 -} request_gpu_t;
   8.260 -
   8.261 -
   8.262 -typedef request_gpu_t* (*OEM_EGL_acquire_gpu_t)(void* user);
   8.263 -typedef int (*OEM_EGL_release_gpu_t)(void* user, request_gpu_t* handle);
   8.264 -typedef void (*register_gpu_t)
   8.265 -        (void* user, OEM_EGL_acquire_gpu_t, OEM_EGL_release_gpu_t);
   8.266 -
   8.267 -void oem_register_gpu(
   8.268 -        void* user,
   8.269 -        OEM_EGL_acquire_gpu_t acquire,
   8.270 -        OEM_EGL_release_gpu_t release);
   8.271 -
   8.272 -
   8.273 -/*****************************************************************************/
   8.274 -
   8.275 -#ifdef __cplusplus
   8.276 -}
   8.277 -#endif
   8.278 -
   8.279 -#endif /* ANDROID_EGLNATIVES_H */
   8.280 -
     9.1 --- a/android/testproject/jni/egltypes.h	Tue Aug 17 17:28:14 2010 +1200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,48 +0,0 @@
     9.4 -/*
     9.5 - * Copyright (C) 2007 The Android Open Source Project
     9.6 - *
     9.7 - * Licensed under the Apache License, Version 2.0 (the "License");
     9.8 - * you may not use this file except in compliance with the License.
     9.9 - * You may obtain a copy of the License at
    9.10 - *
    9.11 - *      http://www.apache.org/licenses/LICENSE-2.0
    9.12 - *
    9.13 - * Unless required by applicable law or agreed to in writing, software
    9.14 - * distributed under the License is distributed on an "AS IS" BASIS,
    9.15 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    9.16 - * See the License for the specific language governing permissions and
    9.17 - * limitations under the License.
    9.18 - */
    9.19 -
    9.20 -#ifndef ANDROID_EGL_TYPES_H
    9.21 -#define ANDROID_EGL_TYPES_H
    9.22 -
    9.23 -#include <sys/types.h>
    9.24 -
    9.25 -#ifdef __cplusplus
    9.26 -extern "C" {
    9.27 -#endif
    9.28 -
    9.29 -typedef unsigned int EGLBoolean;
    9.30 -typedef int32_t EGLint;
    9.31 -typedef int EGLenum;
    9.32 -typedef void *EGLDisplay;
    9.33 -typedef void *EGLConfig;
    9.34 -typedef void *EGLSurface;
    9.35 -typedef void *EGLContext;
    9.36 -typedef void *EGLClientBuffer;
    9.37 -
    9.38 -#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
    9.39 -
    9.40 -#define EGL_NO_CONTEXT      ((EGLContext)0)
    9.41 -#define EGL_NO_DISPLAY      ((EGLDisplay)0)
    9.42 -#define EGL_NO_SURFACE      ((EGLSurface)0)
    9.43 -
    9.44 -
    9.45 -#ifdef __cplusplus
    9.46 -}
    9.47 -#endif
    9.48 -
    9.49 -
    9.50 -#endif /* ANDROID_EGL_TYPES_H */
    9.51 -
    10.1 --- a/android/testproject/jni/importgl.cpp	Tue Aug 17 17:28:14 2010 +1200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,168 +0,0 @@
    10.4 -/* San Angeles Observation OpenGL ES version example
    10.5 - * Copyright 2004-2005 Jetro Lauha
    10.6 - * All rights reserved.
    10.7 - * Web: http://iki.fi/jetro/
    10.8 - *
    10.9 - * This source is free software; you can redistribute it and/or
   10.10 - * modify it under the terms of EITHER:
   10.11 - *   (1) The GNU Lesser General Public License as published by the Free
   10.12 - *       Software Foundation; either version 2.1 of the License, or (at
   10.13 - *       your option) any later version. The text of the GNU Lesser
   10.14 - *       General Public License is included with this source in the
   10.15 - *       file LICENSE-LGPL.txt.
   10.16 - *   (2) The BSD-style license that is included with this source in
   10.17 - *       the file LICENSE-BSD.txt.
   10.18 - *
   10.19 - * This source is distributed in the hope that it will be useful,
   10.20 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.21 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
   10.22 - * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
   10.23 - *
   10.24 - * $Id: importgl.c,v 1.4 2005/02/08 18:42:55 tonic Exp $
   10.25 - * $Revision: 1.4 $
   10.26 - */
   10.27 -
   10.28 -#undef WIN32
   10.29 -#undef LINUX
   10.30 -#ifdef _MSC_VER
   10.31 -// Desktop or mobile Win32 environment:
   10.32 -#define WIN32
   10.33 -#else
   10.34 -// Linux environment:
   10.35 -#define LINUX
   10.36 -#endif
   10.37 -
   10.38 -#ifndef DISABLE_IMPORTGL
   10.39 -
   10.40 -#if defined(WIN32)
   10.41 -#define WIN32_LEAN_AND_MEAN
   10.42 -#include <windows.h>
   10.43 -#include <tchar.h>
   10.44 -static HMODULE sGLESDLL = NULL;
   10.45 -#endif // WIN32
   10.46 -
   10.47 -#ifdef LINUX
   10.48 -#include <stdlib.h>
   10.49 -#include <dlfcn.h>
   10.50 -static void *sGLESSO = NULL;
   10.51 -#endif // LINUX
   10.52 -
   10.53 -#endif /* DISABLE_IMPORTGL */
   10.54 -
   10.55 -#define IMPORTGL_NO_FNPTR_DEFS
   10.56 -#define IMPORTGL_API
   10.57 -#define IMPORTGL_FNPTRINIT = NULL
   10.58 -#include "importgl.h"
   10.59 -
   10.60 -
   10.61 -/* Imports function pointers to selected function calls in OpenGL ES Common
   10.62 - * or Common Lite profile DLL or shared object. The function pointers are
   10.63 - * stored as global symbols with equivalent function name but prefixed with
   10.64 - * "funcPtr_". Standard gl/egl calls are redirected to the function pointers
   10.65 - * with preprocessor macros (see importgl.h).
   10.66 - */
   10.67 -int importGLInit()
   10.68 -{
   10.69 -    int result = 1;
   10.70 -
   10.71 -#ifndef DISABLE_IMPORTGL
   10.72 -
   10.73 -#undef IMPORT_FUNC
   10.74 -
   10.75 -#ifdef WIN32
   10.76 -    sGLESDLL = LoadLibrary(_T("libGLES_CM.dll"));
   10.77 -    if (sGLESDLL == NULL)
   10.78 -        sGLESDLL = LoadLibrary(_T("libGLES_CL.dll"));
   10.79 -    if (sGLESDLL == NULL)
   10.80 -        return 0;   // Cannot find OpenGL ES Common or Common Lite DLL.
   10.81 -
   10.82 -    /* The following fetches address to each egl & gl function call
   10.83 -     * and stores it to the related function pointer. Casting through
   10.84 -     * void * results in warnings with VC warning level 4, which
   10.85 -     * could be fixed by casting to the true type for each fetch.
   10.86 -     */
   10.87 -#define IMPORT_FUNC(funcName) do { \
   10.88 -        void *procAddress = (void *)GetProcAddress(sGLESDLL, _T(#funcName)); \
   10.89 -        if (procAddress == NULL) result = 0; \
   10.90 -        *((void **)&FNPTR(funcName)) = procAddress; } while (0)
   10.91 -#endif // WIN32
   10.92 -
   10.93 -#ifdef LINUX
   10.94 -#ifdef ANDROID_NDK
   10.95 -    sGLESSO = dlopen("libGLESv1_CM.so", RTLD_NOW);
   10.96 -#else /* !ANDROID_NDK */
   10.97 -    sGLESSO = dlopen("libGLES_CM.so", RTLD_NOW);
   10.98 -    if (sGLESSO == NULL)
   10.99 -        sGLESSO = dlopen("libGLES_CL.so", RTLD_NOW);
  10.100 -#endif /* !ANDROID_NDK */
  10.101 -    if (sGLESSO == NULL)
  10.102 -        return 0;   // Cannot find OpenGL ES Common or Common Lite SO.
  10.103 -
  10.104 -#define IMPORT_FUNC(funcName) do { \
  10.105 -        void *procAddress = (void *)dlsym(sGLESSO, #funcName); \
  10.106 -        if (procAddress == NULL) result = 0; \
  10.107 -        *((void **)&FNPTR(funcName)) = procAddress; } while (0)
  10.108 -#endif // LINUX
  10.109 -
  10.110 -#ifndef ANDROID_NDK
  10.111 -    IMPORT_FUNC(eglChooseConfig);
  10.112 -    IMPORT_FUNC(eglCreateContext);
  10.113 -    IMPORT_FUNC(eglCreateWindowSurface);
  10.114 -    IMPORT_FUNC(eglDestroyContext);
  10.115 -    IMPORT_FUNC(eglDestroySurface);
  10.116 -    IMPORT_FUNC(eglGetConfigAttrib);
  10.117 -    IMPORT_FUNC(eglGetConfigs);
  10.118 -    IMPORT_FUNC(eglGetDisplay);
  10.119 -    IMPORT_FUNC(eglGetError);
  10.120 -    IMPORT_FUNC(eglInitialize);
  10.121 -    IMPORT_FUNC(eglMakeCurrent);
  10.122 -    IMPORT_FUNC(eglSwapBuffers);
  10.123 -    IMPORT_FUNC(eglTerminate);
  10.124 -#endif /* !ANDROID_NDK */
  10.125 -
  10.126 -    IMPORT_FUNC(glBlendFunc);
  10.127 -    IMPORT_FUNC(glClear);
  10.128 -    IMPORT_FUNC(glClearColorx);
  10.129 -    IMPORT_FUNC(glColor4x);
  10.130 -    IMPORT_FUNC(glColorPointer);
  10.131 -    IMPORT_FUNC(glDisable);
  10.132 -    IMPORT_FUNC(glDisableClientState);
  10.133 -    IMPORT_FUNC(glDrawArrays);
  10.134 -    IMPORT_FUNC(glEnable);
  10.135 -    IMPORT_FUNC(glEnableClientState);
  10.136 -    IMPORT_FUNC(glFrustumx);
  10.137 -    IMPORT_FUNC(glGetError);
  10.138 -    IMPORT_FUNC(glLightxv);
  10.139 -    IMPORT_FUNC(glLoadIdentity);
  10.140 -    IMPORT_FUNC(glMaterialx);
  10.141 -    IMPORT_FUNC(glMaterialxv);
  10.142 -    IMPORT_FUNC(glMatrixMode);
  10.143 -    IMPORT_FUNC(glMultMatrixx);
  10.144 -    IMPORT_FUNC(glNormalPointer);
  10.145 -    IMPORT_FUNC(glPopMatrix);
  10.146 -    IMPORT_FUNC(glPushMatrix);
  10.147 -    IMPORT_FUNC(glRotatex);
  10.148 -    IMPORT_FUNC(glScalex);
  10.149 -    IMPORT_FUNC(glShadeModel);
  10.150 -    IMPORT_FUNC(glTranslatex);
  10.151 -    IMPORT_FUNC(glVertexPointer);
  10.152 -    IMPORT_FUNC(glViewport);
  10.153 -
  10.154 -#endif /* DISABLE_IMPORTGL */
  10.155 -
  10.156 -    return result;
  10.157 -}
  10.158 -
  10.159 -
  10.160 -void importGLDeinit()
  10.161 -{
  10.162 -#ifndef DISABLE_IMPORTGL
  10.163 -#ifdef WIN32
  10.164 -    FreeLibrary(sGLESDLL);
  10.165 -#endif
  10.166 -
  10.167 -#ifdef LINUX
  10.168 -    dlclose(sGLESSO);
  10.169 -#endif
  10.170 -#endif /* DISABLE_IMPORTGL */
  10.171 -}
    11.1 --- a/android/testproject/jni/importgl.h	Tue Aug 17 17:28:14 2010 +1200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,172 +0,0 @@
    11.4 -/* San Angeles Observation OpenGL ES version example
    11.5 - * Copyright 2004-2005 Jetro Lauha
    11.6 - * All rights reserved.
    11.7 - * Web: http://iki.fi/jetro/
    11.8 - *
    11.9 - * This source is free software; you can redistribute it and/or
   11.10 - * modify it under the terms of EITHER:
   11.11 - *   (1) The GNU Lesser General Public License as published by the Free
   11.12 - *       Software Foundation; either version 2.1 of the License, or (at
   11.13 - *       your option) any later version. The text of the GNU Lesser
   11.14 - *       General Public License is included with this source in the
   11.15 - *       file LICENSE-LGPL.txt.
   11.16 - *   (2) The BSD-style license that is included with this source in
   11.17 - *       the file LICENSE-BSD.txt.
   11.18 - *
   11.19 - * This source is distributed in the hope that it will be useful,
   11.20 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.21 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
   11.22 - * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
   11.23 - *
   11.24 - * $Id: importgl.h,v 1.4 2005/02/24 20:29:33 tonic Exp $
   11.25 - * $Revision: 1.4 $
   11.26 - */
   11.27 -
   11.28 -#ifndef IMPORTGL_H_INCLUDED
   11.29 -#define IMPORTGL_H_INCLUDED
   11.30 -
   11.31 -
   11.32 -#ifdef __cplusplus
   11.33 -extern "C" {
   11.34 -#endif
   11.35 -
   11.36 -
   11.37 -#include <GLES/gl.h>
   11.38 -#ifndef ANDROID_NDK
   11.39 -#include <GLES/egl.h>
   11.40 -#endif /* !ANDROID_NDK */
   11.41 -
   11.42 -/* Use DISABLE_IMPORTGL if you want to link the OpenGL ES at
   11.43 - * compile/link time and not import it dynamically runtime.
   11.44 - */
   11.45 -#ifndef DISABLE_IMPORTGL
   11.46 -
   11.47 -
   11.48 -/* Dynamically fetches pointers to the egl & gl functions.
   11.49 - * Should be called once on application initialization.
   11.50 - * Returns non-zero on success and 0 on failure.
   11.51 - */
   11.52 -extern int importGLInit();
   11.53 -
   11.54 -/* Frees the handle to egl & gl functions library.
   11.55 - */
   11.56 -extern void importGLDeinit();
   11.57 -
   11.58 -
   11.59 -#ifndef IMPORTGL_API
   11.60 -#define IMPORTGL_API extern
   11.61 -#endif
   11.62 -#ifndef IMPORTGL_FNPTRINIT
   11.63 -#define IMPORTGL_FNPTRINIT
   11.64 -#endif
   11.65 -
   11.66 -#define FNDEF(retType, funcName, args) IMPORTGL_API retType (*funcPtr_##funcName) args IMPORTGL_FNPTRINIT
   11.67 -
   11.68 -#ifndef ANDROID_NDK
   11.69 -FNDEF(EGLBoolean, eglChooseConfig, (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config));
   11.70 -FNDEF(EGLContext, eglCreateContext, (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list));
   11.71 -FNDEF(EGLSurface, eglCreateWindowSurface, (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list));
   11.72 -FNDEF(EGLBoolean, eglDestroyContext, (EGLDisplay dpy, EGLContext ctx));
   11.73 -FNDEF(EGLBoolean, eglDestroySurface, (EGLDisplay dpy, EGLSurface surface));
   11.74 -FNDEF(EGLBoolean, eglGetConfigAttrib, (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value));
   11.75 -FNDEF(EGLBoolean, eglGetConfigs, (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config));
   11.76 -FNDEF(EGLDisplay, eglGetDisplay, (NativeDisplayType display));
   11.77 -FNDEF(EGLint, eglGetError, (void));
   11.78 -FNDEF(EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint *major, EGLint *minor));
   11.79 -FNDEF(EGLBoolean, eglMakeCurrent, (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx));
   11.80 -FNDEF(EGLBoolean, eglSwapBuffers, (EGLDisplay dpy, EGLSurface draw));
   11.81 -FNDEF(EGLBoolean, eglTerminate, (EGLDisplay dpy));
   11.82 -#endif /* !ANDROID_NDK */
   11.83 -
   11.84 -FNDEF(void, glBlendFunc, (GLenum sfactor, GLenum dfactor));
   11.85 -FNDEF(void, glClear, (GLbitfield mask));
   11.86 -FNDEF(void, glClearColorx, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha));
   11.87 -FNDEF(void, glColor4x, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha));
   11.88 -FNDEF(void, glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
   11.89 -FNDEF(void, glDisable, (GLenum cap));
   11.90 -FNDEF(void, glDisableClientState, (GLenum array));
   11.91 -FNDEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count));
   11.92 -FNDEF(void, glEnable, (GLenum cap));
   11.93 -FNDEF(void, glEnableClientState, (GLenum array));
   11.94 -FNDEF(void, glFrustumx, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar));
   11.95 -FNDEF(GLenum, glGetError, (void));
   11.96 -FNDEF(void, glLightxv, (GLenum light, GLenum pname, const GLfixed *params));
   11.97 -FNDEF(void, glLoadIdentity, (void));
   11.98 -FNDEF(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param));
   11.99 -FNDEF(void, glMaterialxv, (GLenum face, GLenum pname, const GLfixed *params));
  11.100 -FNDEF(void, glMatrixMode, (GLenum mode));
  11.101 -FNDEF(void, glMultMatrixx, (const GLfixed *m));
  11.102 -FNDEF(void, glNormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer));
  11.103 -FNDEF(void, glPopMatrix, (void));
  11.104 -FNDEF(void, glPushMatrix, (void));
  11.105 -FNDEF(void, glRotatex, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z));
  11.106 -FNDEF(void, glScalex, (GLfixed x, GLfixed y, GLfixed z));
  11.107 -FNDEF(void, glShadeModel, (GLenum mode));
  11.108 -FNDEF(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z));
  11.109 -FNDEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
  11.110 -FNDEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height));
  11.111 -
  11.112 -
  11.113 -#undef FN
  11.114 -#define FNPTR(name) funcPtr_##name
  11.115 -
  11.116 -#ifndef IMPORTGL_NO_FNPTR_DEFS
  11.117 -
  11.118 -// Redirect egl* and gl* function calls to funcPtr_egl* and funcPtr_gl*.
  11.119 -
  11.120 -#ifndef ANDROID_NDK
  11.121 -#define eglChooseConfig         FNPTR(eglChooseConfig)
  11.122 -#define eglCreateContext        FNPTR(eglCreateContext)
  11.123 -#define eglCreateWindowSurface  FNPTR(eglCreateWindowSurface)
  11.124 -#define eglDestroyContext       FNPTR(eglDestroyContext)
  11.125 -#define eglDestroySurface       FNPTR(eglDestroySurface)
  11.126 -#define eglGetConfigAttrib      FNPTR(eglGetConfigAttrib)
  11.127 -#define eglGetConfigs           FNPTR(eglGetConfigs)
  11.128 -#define eglGetDisplay           FNPTR(eglGetDisplay)
  11.129 -#define eglGetError             FNPTR(eglGetError)
  11.130 -#define eglInitialize           FNPTR(eglInitialize)
  11.131 -#define eglMakeCurrent          FNPTR(eglMakeCurrent)
  11.132 -#define eglSwapBuffers          FNPTR(eglSwapBuffers)
  11.133 -#define eglTerminate            FNPTR(eglTerminate)
  11.134 -#endif /* !ANDROID_NDK */
  11.135 -
  11.136 -#define glBlendFunc             FNPTR(glBlendFunc)
  11.137 -#define glClear                 FNPTR(glClear)
  11.138 -#define glClearColorx           FNPTR(glClearColorx)
  11.139 -#define glColor4x               FNPTR(glColor4x)
  11.140 -#define glColorPointer          FNPTR(glColorPointer)
  11.141 -#define glDisable               FNPTR(glDisable)
  11.142 -#define glDisableClientState    FNPTR(glDisableClientState)
  11.143 -#define glDrawArrays            FNPTR(glDrawArrays)
  11.144 -#define glEnable                FNPTR(glEnable)
  11.145 -#define glEnableClientState     FNPTR(glEnableClientState)
  11.146 -#define glFrustumx              FNPTR(glFrustumx)
  11.147 -#define glGetError              FNPTR(glGetError)
  11.148 -#define glLightxv               FNPTR(glLightxv)
  11.149 -#define glLoadIdentity          FNPTR(glLoadIdentity)
  11.150 -#define glMaterialx             FNPTR(glMaterialx)
  11.151 -#define glMaterialxv            FNPTR(glMaterialxv)
  11.152 -#define glMatrixMode            FNPTR(glMatrixMode)
  11.153 -#define glMultMatrixx           FNPTR(glMultMatrixx)
  11.154 -#define glNormalPointer         FNPTR(glNormalPointer)
  11.155 -#define glPopMatrix             FNPTR(glPopMatrix)
  11.156 -#define glPushMatrix            FNPTR(glPushMatrix)
  11.157 -#define glRotatex               FNPTR(glRotatex)
  11.158 -#define glScalex                FNPTR(glScalex)
  11.159 -#define glShadeModel            FNPTR(glShadeModel)
  11.160 -#define glTranslatex            FNPTR(glTranslatex)
  11.161 -#define glVertexPointer         FNPTR(glVertexPointer)
  11.162 -#define glViewport              FNPTR(glViewport)
  11.163 -
  11.164 -#endif // !IMPORTGL_NO_FNPTR_DEFS
  11.165 -
  11.166 -
  11.167 -#endif // !DISABLE_IMPORTGL
  11.168 -
  11.169 -
  11.170 -#ifdef __cplusplus
  11.171 -}
  11.172 -#endif
  11.173 -
  11.174 -
  11.175 -#endif // !IMPORTGL_H_INCLUDED
    12.1 --- a/android/testproject/jni/lesson05.c	Tue Aug 17 17:28:14 2010 +1200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,574 +0,0 @@
    12.4 -/*
    12.5 - * This code was created by Jeff Molofee '99 
    12.6 - * (ported to Linux/SDL by Ti Leggett '01)
    12.7 - *
    12.8 - * If you've found this code useful, please let me know.
    12.9 - *
   12.10 - * Visit Jeff at http://nehe.gamedev.net/
   12.11 - * 
   12.12 - * or for port-specific comments, questions, bugreports etc. 
   12.13 - * email to leggett@eecs.tulane.edu
   12.14 - */
   12.15 - 
   12.16 -#include <stdio.h>
   12.17 -#include <stdlib.h>
   12.18 -#include <math.h>
   12.19 -
   12.20 -#include <signal.h>
   12.21 -
   12.22 -#include <android/log.h>
   12.23 -
   12.24 -
   12.25 -#ifdef ANDROID
   12.26 -#include <GLES/gl.h>
   12.27 -#else
   12.28 -#include <GL/gl.h>
   12.29 -#include <GL/glu.h>
   12.30 -#endif
   12.31 -#include "SDL.h"
   12.32 -
   12.33 -/* screen width, height, and bit depth */
   12.34 -#define SCREEN_WIDTH  320
   12.35 -#define SCREEN_HEIGHT 430
   12.36 -#define SCREEN_BPP     16
   12.37 -
   12.38 -/* Define our booleans */
   12.39 -#define TRUE  1
   12.40 -#define FALSE 0
   12.41 -
   12.42 -/* This is our SDL surface */
   12.43 -SDL_Surface *surface;
   12.44 -
   12.45 -int rotation = 0;
   12.46 -
   12.47 -
   12.48 -/**************************************
   12.49 -	gluperspective implementation
   12.50 -**************************************/
   12.51 -void gluPerspective(double fovy, double aspect, double zNear, double zFar){
   12.52 -	glMatrixMode(GL_PROJECTION);
   12.53 -	glLoadIdentity();
   12.54 -	double xmin, xmax, ymin, ymax;
   12.55 -	ymax = zNear * tan(fovy * M_PI / 360.0);
   12.56 -	ymin = -ymax;
   12.57 -	xmin = ymin * aspect;
   12.58 -	xmax = ymax * aspect;
   12.59 -	glFrustumf(xmin, xmax, ymin, ymax, zNear, zFar);
   12.60 -}
   12.61 -
   12.62 -
   12.63 -/**************************************
   12.64 -	  glulookat implementation
   12.65 -**************************************/
   12.66 -void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
   12.67 -          GLfloat centerx, GLfloat centery, GLfloat centerz,
   12.68 -          GLfloat upx, GLfloat upy, GLfloat upz)
   12.69 -{
   12.70 -    GLfloat m[16];
   12.71 -    GLfloat x[3], y[3], z[3];
   12.72 -    GLfloat mag;
   12.73 -    
   12.74 -    /* Make rotation matrix */
   12.75 -    
   12.76 -    /* Z vector */
   12.77 -    z[0] = eyex - centerx;
   12.78 -    z[1] = eyey - centery;
   12.79 -    z[2] = eyez - centerz;
   12.80 -    mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
   12.81 -    if (mag) {          /* mpichler, 19950515 */
   12.82 -        z[0] /= mag;
   12.83 -        z[1] /= mag;
   12.84 -        z[2] /= mag;
   12.85 -    }
   12.86 -    
   12.87 -    /* Y vector */
   12.88 -    y[0] = upx;
   12.89 -    y[1] = upy;
   12.90 -    y[2] = upz;
   12.91 -    
   12.92 -    /* X vector = Y cross Z */
   12.93 -    x[0] = y[1] * z[2] - y[2] * z[1];
   12.94 -    x[1] = -y[0] * z[2] + y[2] * z[0];
   12.95 -    x[2] = y[0] * z[1] - y[1] * z[0];
   12.96 -    
   12.97 -    /* Recompute Y = Z cross X */
   12.98 -    y[0] = z[1] * x[2] - z[2] * x[1];
   12.99 -    y[1] = -z[0] * x[2] + z[2] * x[0];
  12.100 -    y[2] = z[0] * x[1] - z[1] * x[0];
  12.101 -    
  12.102 -    /* mpichler, 19950515 */
  12.103 -    /* cross product gives area of parallelogram, which is < 1.0 for
  12.104 -     * non-perpendicular unit-length vectors; so normalize x, y here
  12.105 -     */
  12.106 -    
  12.107 -    mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
  12.108 -    if (mag) {
  12.109 -        x[0] /= mag;
  12.110 -        x[1] /= mag;
  12.111 -        x[2] /= mag;
  12.112 -    }
  12.113 -    
  12.114 -    mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
  12.115 -    if (mag) {
  12.116 -        y[0] /= mag;
  12.117 -        y[1] /= mag;
  12.118 -        y[2] /= mag;
  12.119 -    }
  12.120 -    
  12.121 -#define M(row,col)  m[col*4+row]
  12.122 -    M(0, 0) = x[0];
  12.123 -    M(0, 1) = x[1];
  12.124 -    M(0, 2) = x[2];
  12.125 -    M(0, 3) = 0.0;
  12.126 -    M(1, 0) = y[0];
  12.127 -    M(1, 1) = y[1];
  12.128 -    M(1, 2) = y[2];
  12.129 -    M(1, 3) = 0.0;
  12.130 -    M(2, 0) = z[0];
  12.131 -    M(2, 1) = z[1];
  12.132 -    M(2, 2) = z[2];
  12.133 -    M(2, 3) = 0.0;
  12.134 -    M(3, 0) = 0.0;
  12.135 -    M(3, 1) = 0.0;
  12.136 -    M(3, 2) = 0.0;
  12.137 -    M(3, 3) = 1.0;
  12.138 -#undef M
  12.139 -    glMultMatrixf(m);
  12.140 -    
  12.141 -    /* Translate Eye to Origin */
  12.142 -    glTranslatef(-eyex, -eyey, -eyez);
  12.143 -    
  12.144 -}
  12.145 -
  12.146 -
  12.147 -
  12.148 -
  12.149 -
  12.150 -/* function to release/destroy our resources and restoring the old desktop */
  12.151 -void Quit( int returnCode )
  12.152 -{
  12.153 -    /* clean up the window */
  12.154 -    SDL_Quit( );
  12.155 -
  12.156 -    /* and exit appropriately */
  12.157 -    exit( returnCode );
  12.158 -}
  12.159 -
  12.160 -/* function to reset our viewport after a window resize */
  12.161 -int resizeWindow( int width, int height )
  12.162 -{
  12.163 -    /* Height / width ration */
  12.164 -    GLfloat ratio;
  12.165 - 
  12.166 -    /* Protect against a divide by zero */
  12.167 -   if ( height == 0 )
  12.168 -	height = 1;
  12.169 -
  12.170 -    ratio = ( GLfloat )width / ( GLfloat )height;
  12.171 -
  12.172 -    /* Setup our viewport. */
  12.173 -    glViewport( 0, 0, ( GLsizei )width, ( GLsizei )height );
  12.174 -
  12.175 -    /* change to the projection matrix and set our viewing volume. */
  12.176 -    glMatrixMode( GL_PROJECTION );
  12.177 -    glLoadIdentity( );
  12.178 -
  12.179 -    /* Set our perspective */
  12.180 -    gluPerspective( 45.0f, ratio, 0.1f, 100.0f );
  12.181 -
  12.182 -    /* Make sure we're chaning the model view and not the projection */
  12.183 -    glMatrixMode( GL_MODELVIEW );
  12.184 -
  12.185 -    /* Reset The View */
  12.186 -    glLoadIdentity( );
  12.187 -
  12.188 -    return( TRUE );
  12.189 -}
  12.190 -
  12.191 -/* function to handle key press events */
  12.192 -void handleKeyPress( SDL_keysym *keysym )
  12.193 -{
  12.194 -    switch ( keysym->sym )
  12.195 -	{
  12.196 -	case SDLK_ESCAPE:
  12.197 -	    /* ESC key was pressed */
  12.198 -	    Quit( 0 );
  12.199 -	    break;
  12.200 -	case SDLK_F1:
  12.201 -	    /* F1 key was pressed
  12.202 -	     * this toggles fullscreen mode
  12.203 -	     */
  12.204 -	    SDL_WM_ToggleFullScreen( surface );
  12.205 -	    break;
  12.206 -    case SDLK_LEFT:
  12.207 -        rotation -= 30;
  12.208 -        break;
  12.209 -
  12.210 -    case SDLK_RIGHT:
  12.211 -        rotation += 30;
  12.212 -        break;
  12.213 -        
  12.214 -	default:
  12.215 -	    break;
  12.216 -	}
  12.217 -
  12.218 -    __android_log_print(ANDROID_LOG_INFO, "SDL","Keycode: %d, %d, %d\n", keysym->sym, SDLK_LEFT, SDLK_RIGHT);
  12.219 -
  12.220 -    return;
  12.221 -}
  12.222 -
  12.223 -/* general OpenGL initialization function */
  12.224 -int initGL( GLvoid )
  12.225 -{
  12.226 -
  12.227 -    /* Enable smooth shading */
  12.228 -    glShadeModel( GL_SMOOTH );
  12.229 -
  12.230 -    /* Set the background black */
  12.231 -    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
  12.232 -
  12.233 -    /* Depth buffer setup */
  12.234 -    //glClearDepth( 1.0f );
  12.235 -
  12.236 -    /* Enables Depth Testing */
  12.237 -    glEnable( GL_DEPTH_TEST );
  12.238 -
  12.239 -    /* The Type Of Depth Test To Do */
  12.240 -    glDepthFunc( GL_LEQUAL );
  12.241 -
  12.242 -    /* Really Nice Perspective Calculations */
  12.243 -    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
  12.244 -
  12.245 -    return( TRUE );
  12.246 -}
  12.247 -
  12.248 -/* Here goes our drawing code */
  12.249 -int drawGLScene( GLvoid )
  12.250 -{
  12.251 -      
  12.252 -	static int Frames = 0;
  12.253 -	static int T0 = 0;
  12.254 -	
  12.255 -    glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
  12.256 -
  12.257 -    glClearColorx(0,0,0,255);
  12.258 -    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
  12.259 -
  12.260 -    glMatrixMode(GL_PROJECTION);
  12.261 -    glLoadIdentity();
  12.262 -    gluPerspective(45, (float)SCREEN_WIDTH / SCREEN_HEIGHT, 0.5f, 150);
  12.263 -
  12.264 -    glMatrixMode(GL_MODELVIEW);
  12.265 -
  12.266 -    glLoadIdentity();
  12.267 -
  12.268 -	//Camera
  12.269 -	gluLookAt(0,0,5, 0,0,0, 0,1,0);
  12.270 -			
  12.271 -	//Draw a triangle
  12.272 -	//glRotatef(iRot, 0, 1, 0);
  12.273 -
  12.274 -	glRotatef( rotation, 0.0f, 1.0f, 0.0f );
  12.275 -
  12.276 -
  12.277 -	glEnableClientState (GL_VERTEX_ARRAY);
  12.278 -	glEnableClientState (GL_COLOR_ARRAY);
  12.279 -	
  12.280 -	/* Rotate The Triangle On The Y axis ( NEW ) */
  12.281 -    //glRotatef( Frames % 360, 0.0f, 1.0f, 0.0f );
  12.282 -
  12.283 -    /* GLES variant of drawing a triangle */
  12.284 -    const GLfloat triVertices[][9] = {
  12.285 -      {     /* Front Triangle */
  12.286 -	 0.0f,  1.0f,  0.0f,               /* Top Of Triangle               */
  12.287 -	-1.0f, -1.0f,  1.0f,               /* Left Of Triangle              */
  12.288 -	 1.0f, -1.0f,  1.0f                /* Right Of Triangle             */
  12.289 -      }, {  /* Right Triangle */
  12.290 -	 0.0f,  1.0f,  0.0f,               /* Top Of Triangle               */
  12.291 -	 1.0f, -1.0f,  1.0f,               /* Left Of Triangle              */
  12.292 -	 1.0f, -1.0f, -1.0f                /* Right Of Triangle             */
  12.293 -      }, {  /* Back Triangle */
  12.294 -	 0.0f,  1.0f,  0.0f,               /* Top Of Triangle               */
  12.295 -	 1.0f, -1.0f, -1.0f,               /* Left Of Triangle              */
  12.296 -	-1.0f, -1.0f, -1.0f                /* Right Of Triangle             */
  12.297 -      }, {  /* Left Triangle */
  12.298 -	 0.0f,  1.0f,  0.0f,               /* Top Of Triangle               */
  12.299 -	-1.0f, -1.0f, -1.0f,               /* Left Of Triangle              */
  12.300 -	-1.0f, -1.0f,  1.0f                /* Right Of Triangle             */
  12.301 -      }
  12.302 -    };
  12.303 -
  12.304 -    /* unlike GL, GLES does not support RGB. We have to use RGBA instead */
  12.305 -    const GLfloat triColors[][12] = {
  12.306 -      {     /* Front triangle */
  12.307 -        1.0f, 0.0f, 0.0f, 1.0f,            /* Red                           */
  12.308 -	0.0f, 1.0f, 0.0f, 1.0f,            /* Green                         */
  12.309 -	0.0f, 0.0f, 1.0f, 1.0f             /* Blue                          */
  12.310 -      }, {  /* Right triangle */
  12.311 -        1.0f, 0.0f, 0.0f, 1.0f,            /* Red                           */
  12.312 -	0.0f, 0.0f, 1.0f, 1.0f,            /* Blue                          */
  12.313 -	0.0f, 1.0f, 0.0f, 1.0f             /* Green                         */
  12.314 -      }, {  /* Back triangle */
  12.315 -        1.0f, 0.0f, 0.0f, 1.0f,            /* Red                           */
  12.316 -	0.0f, 1.0f, 0.0f, 1.0f,            /* Green                         */
  12.317 -	0.0f, 0.0f, 1.0f, 1.0f             /* Blue                          */
  12.318 -      }, {  /* Left triangle */
  12.319 -        1.0f, 0.0f, 0.0f, 1.0f,            /* Red                           */
  12.320 -	0.0f, 0.0f, 1.0f, 1.0f,            /* Blue                          */
  12.321 -	0.0f, 1.0f, 0.0f, 1.0f             /* Green                         */
  12.322 -      }
  12.323 -    };
  12.324 -
  12.325 -    glEnableClientState(GL_COLOR_ARRAY);
  12.326 -
  12.327 -    int tri=0;
  12.328 -
  12.329 -    /* Loop through all Triangles */
  12.330 -    for(tri=0;tri<sizeof(triVertices)/(9*sizeof(GLfloat));tri++) 
  12.331 -    {
  12.332 -      glVertexPointer(3, GL_FLOAT, 0, triVertices[tri]);
  12.333 -      glColorPointer(4, GL_FLOAT, 0, triColors[tri]);
  12.334 -      
  12.335 -      glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
  12.336 -    }
  12.337 -		
  12.338 -    //__android_log_print(ANDROID_LOG_INFO, "SDL", "render %d", Frames++);
  12.339 -
  12.340 -    /* Draw it to the screen */
  12.341 -    SDL_GL_SwapBuffers( );
  12.342 -
  12.343 -    /* Gather our frames per second */
  12.344 -    Frames++;
  12.345 -    {
  12.346 -	GLint t = SDL_GetTicks();
  12.347 -	if (t - T0 >= 5000) {
  12.348 -	    GLfloat seconds = (t - T0) / 1000.0;
  12.349 -	    GLfloat fps = Frames / seconds;
  12.350 -	    __android_log_print(ANDROID_LOG_INFO, "SDL","%d frames in %g seconds = %g FPS\n", Frames, seconds, fps);
  12.351 -	    T0 = t;
  12.352 -	    Frames = 0;
  12.353 -	}
  12.354 -    }
  12.355 -
  12.356 -    rotation++;
  12.357 -
  12.358 -    return( TRUE );
  12.359 -}
  12.360 -
  12.361 -
  12.362 -struct
  12.363 -{
  12.364 -    SDL_AudioSpec spec;
  12.365 -    Uint8 *sound;               /* Pointer to wave data */
  12.366 -    Uint32 soundlen;            /* Length of wave data */
  12.367 -    int soundpos;               /* Current play position */
  12.368 -} wave;
  12.369 -
  12.370 -void SDLCALL
  12.371 -fillerup(void *unused, Uint8 * stream, int len)
  12.372 -{
  12.373 -    __android_log_print(ANDROID_LOG_INFO, "SDL","FILLERUP\n");
  12.374 -    
  12.375 -    Uint8 *waveptr;
  12.376 -    int waveleft;
  12.377 -
  12.378 -    /* Set up the pointers */
  12.379 -    waveptr = wave.sound + wave.soundpos;
  12.380 -    waveleft = wave.soundlen - wave.soundpos;
  12.381 -
  12.382 -    /* Go! */
  12.383 -    while (waveleft <= len) {
  12.384 -        SDL_memcpy(stream, waveptr, waveleft);
  12.385 -        stream += waveleft;
  12.386 -        len -= waveleft;
  12.387 -        waveptr = wave.sound;
  12.388 -        waveleft = wave.soundlen;
  12.389 -        wave.soundpos = 0;
  12.390 -    }
  12.391 -    SDL_memcpy(stream, waveptr, len);
  12.392 -    wave.soundpos += len;
  12.393 -}
  12.394 -
  12.395 -void testAudio(){
  12.396 -
  12.397 -    const char *file = "/sdcard/sample.wav";
  12.398 -
  12.399 -    /* Load the SDL library */
  12.400 -    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
  12.401 -        __android_log_print(ANDROID_LOG_INFO, "SDL","Couldn't initialize SDL Audio: %s\n", SDL_GetError());
  12.402 -        return;
  12.403 -    }else{
  12.404 -        __android_log_print(ANDROID_LOG_INFO, "SDL","Init audio ok\n");
  12.405 -    }
  12.406 -
  12.407 -    /* Load the wave file into memory */
  12.408 -    if (SDL_LoadWAV(file, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
  12.409 -        __android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't load %s: %s\n", file, SDL_GetError());
  12.410 -        return;
  12.411 -    }
  12.412 -
  12.413 -    wave.spec.callback = fillerup;
  12.414 -
  12.415 -    __android_log_print(ANDROID_LOG_INFO, "SDL","Loaded: %d\n", wave.soundlen);
  12.416 -
  12.417 -
  12.418 -    /* Initialize fillerup() variables */
  12.419 -    if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
  12.420 -        __android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't open audio: %s\n", SDL_GetError());
  12.421 -        SDL_FreeWAV(wave.sound);
  12.422 -        return;
  12.423 -    }
  12.424 -
  12.425 -     __android_log_print(ANDROID_LOG_INFO, "SDL","Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
  12.426 -
  12.427 -    /* Let the audio run */
  12.428 -    SDL_PauseAudio(0);
  12.429 -
  12.430 -     __android_log_print(ANDROID_LOG_INFO, "SDL","Playing\n");
  12.431 -    
  12.432 -    while (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING){
  12.433 -         //__android_log_print(ANDROID_LOG_INFO, "SDL","Still playing\n");
  12.434 -        SDL_Delay(100);
  12.435 -    }
  12.436 -
  12.437 -     __android_log_print(ANDROID_LOG_INFO, "SDL","Closing down\n");
  12.438 -
  12.439 -    /* Clean up on signal */
  12.440 -    SDL_CloseAudio();
  12.441 -    SDL_FreeWAV(wave.sound);
  12.442 -}
  12.443 -
  12.444 -int SDL_main( int argc, char **argv )
  12.445 -{
  12.446 -
  12.447 -	__android_log_print(ANDROID_LOG_INFO, "SDL","entry\n");
  12.448 -
  12.449 -    /* Flags to pass to SDL_SetVideoMode */
  12.450 -    int videoFlags;
  12.451 -    /* main loop variable */
  12.452 -    int done = FALSE;
  12.453 -    /* used to collect events */
  12.454 -    SDL_Event event;
  12.455 -    /* this holds some info about our display */
  12.456 -    const SDL_VideoInfo *videoInfo;
  12.457 -    /* whether or not the window is active */
  12.458 -    int isActive = TRUE;
  12.459 -
  12.460 -    /* initialize SDL */
  12.461 -    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  12.462 -	{
  12.463 -	    __android_log_print(ANDROID_LOG_INFO, "SDL", "Video initialization failed: %s\n",
  12.464 -		     SDL_GetError( ) );
  12.465 -	    Quit( 1 );
  12.466 -	}
  12.467 -
  12.468 -    /* Fetch the video info */
  12.469 -    videoInfo = SDL_GetVideoInfo( );
  12.470 -
  12.471 -    if ( !videoInfo )
  12.472 -	{
  12.473 -	    __android_log_print(ANDROID_LOG_INFO, "SDL", "Video query failed: %s\n",
  12.474 -		     SDL_GetError( ) );
  12.475 -	    Quit( 1 );
  12.476 -	}
  12.477 -
  12.478 -    /* the flags to pass to SDL_SetVideoMode */
  12.479 -    videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
  12.480 -    videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
  12.481 -    videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
  12.482 -    videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
  12.483 -
  12.484 -    /* This checks to see if surfaces can be stored in memory */
  12.485 -    if ( videoInfo->hw_available )
  12.486 -	videoFlags |= SDL_HWSURFACE;
  12.487 -    else
  12.488 -	videoFlags |= SDL_SWSURFACE;
  12.489 -
  12.490 -    /* This checks if hardware blits can be done */
  12.491 -    if ( videoInfo->blit_hw )
  12.492 -	videoFlags |= SDL_HWACCEL;
  12.493 -
  12.494 -    /* Sets up OpenGL double buffering */
  12.495 -    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
  12.496 -
  12.497 -    /* get a SDL surface */
  12.498 -    surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,
  12.499 -				videoFlags );
  12.500 -
  12.501 -    /* Verify there is a surface */
  12.502 -    if ( !surface )
  12.503 -	{
  12.504 -	    __android_log_print(ANDROID_LOG_INFO, "SDL",  "Video mode set failed: %s\n", SDL_GetError( ) );
  12.505 -	    Quit( 1 );
  12.506 -	}
  12.507 -
  12.508 -	__android_log_print(ANDROID_LOG_INFO, "SDL","Made a video mode!\n");
  12.509 -
  12.510 -    /* initialize OpenGL */
  12.511 -    initGL( );
  12.512 -
  12.513 -    /* resize the initial window */
  12.514 -    resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
  12.515 -
  12.516 -
  12.517 -    testAudio();
  12.518 -
  12.519 -
  12.520 -    /* wait for events */ 
  12.521 -    while ( !done )
  12.522 -	{
  12.523 -	    /* handle the events in the queue */
  12.524 -
  12.525 -	    while ( SDL_PollEvent( &event ) )
  12.526 -		{
  12.527 -		    switch( event.type )
  12.528 -			{
  12.529 -			case SDL_ACTIVEEVENT:
  12.530 -			    /* Something's happend with our focus
  12.531 -			     * If we lost focus or we are iconified, we
  12.532 -			     * shouldn't draw the screen
  12.533 -			     */
  12.534 -			    if ( event.active.gain == 0 )
  12.535 -				isActive = FALSE;
  12.536 -			    else
  12.537 -				isActive = TRUE;
  12.538 -			    break;			    
  12.539 -			case SDL_VIDEORESIZE:
  12.540 -			    /* handle resize event */
  12.541 -			    surface = SDL_SetVideoMode( event.resize.w,
  12.542 -							event.resize.h,
  12.543 -							16, videoFlags );
  12.544 -			    if ( !surface )
  12.545 -				{
  12.546 -				    __android_log_print(ANDROID_LOG_INFO, "SDL","Could not get a surface after resize: %s\n", SDL_GetError( ) );
  12.547 -				    Quit( 1 );
  12.548 -				}
  12.549 -			    resizeWindow( event.resize.w, event.resize.h );
  12.550 -			    break;
  12.551 -			case SDL_KEYDOWN:
  12.552 -			    /* handle key presses */
  12.553 -			    handleKeyPress( &event.key.keysym );
  12.554 -			    break;
  12.555 -			case SDL_QUIT:
  12.556 -			    /* handle quit requests */
  12.557 -			    done = TRUE;
  12.558 -			    __android_log_print(ANDROID_LOG_INFO, "SDL","App is shutting down\n");
  12.559 -			    break;
  12.560 -			default:
  12.561 -			    break;
  12.562 -			}
  12.563 -		}
  12.564 -
  12.565 -	    /* draw the scene */
  12.566 -	    if ( isActive )
  12.567 -		drawGLScene( );
  12.568 -	}
  12.569 -
  12.570 -    /* clean ourselves up and exit */
  12.571 -    Quit( 0 );
  12.572 -
  12.573 -    /* Should never get here */
  12.574 -    return( 0 );
  12.575 -}
  12.576 -
  12.577 -
    13.1 --- a/android/testproject/local.properties	Tue Aug 17 17:28:14 2010 +1200
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,10 +0,0 @@
    13.4 -# This file is automatically generated by Android Tools.
    13.5 -# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
    13.6 -# 
    13.7 -# This file must *NOT* be checked in Version Control Systems,
    13.8 -# as it contains information specific to your local configuration.
    13.9 -
   13.10 -# location of the SDK. This is only used by Ant
   13.11 -# For customization when using a Version Control System, please read the
   13.12 -# header note.
   13.13 -sdk.dir=/home/paul/Projects/gsoc/sdk/android-sdk-linux_86
    14.1 Binary file android/testproject/res/drawable-hdpi/icon.png has changed
    15.1 Binary file android/testproject/res/drawable-ldpi/icon.png has changed
    16.1 Binary file android/testproject/res/drawable-mdpi/icon.png has changed
    17.1 --- a/android/testproject/res/layout/main.xml	Tue Aug 17 17:28:14 2010 +1200
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,13 +0,0 @@
    17.4 -<?xml version="1.0" encoding="utf-8"?>
    17.5 -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    17.6 -    android:orientation="vertical"
    17.7 -    android:layout_width="fill_parent"
    17.8 -    android:layout_height="fill_parent"
    17.9 -    >
   17.10 -<TextView  
   17.11 -    android:layout_width="fill_parent" 
   17.12 -    android:layout_height="wrap_content" 
   17.13 -    android:text="Hello World, TestActivity"
   17.14 -    />
   17.15 -</LinearLayout>
   17.16 -
    18.1 --- a/android/testproject/res/values/strings.xml	Tue Aug 17 17:28:14 2010 +1200
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,4 +0,0 @@
    18.4 -<?xml version="1.0" encoding="utf-8"?>
    18.5 -<resources>
    18.6 -    <string name="app_name">TestActivity</string>
    18.7 -</resources>
    19.1 --- a/android/testproject/src/org/libsdl/android/SDLActivity.java	Tue Aug 17 17:28:14 2010 +1200
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,388 +0,0 @@
    19.4 -package org.libsdl.android;
    19.5 -
    19.6 -import javax.microedition.khronos.egl.EGLConfig;
    19.7 -import javax.microedition.khronos.opengles.GL10;
    19.8 -import javax.microedition.khronos.egl.*;
    19.9 -
   19.10 -import android.app.*;
   19.11 -import android.content.*;
   19.12 -import android.view.*;
   19.13 -import android.os.*;
   19.14 -import android.util.Log;
   19.15 -import android.graphics.*;
   19.16 -import android.text.method.*;
   19.17 -import android.text.*;
   19.18 -import android.media.*;
   19.19 -import android.hardware.*;
   19.20 -import android.content.*;
   19.21 -
   19.22 -import java.lang.*;
   19.23 -
   19.24 -
   19.25 -/**
   19.26 -    SDL Activity
   19.27 -*/
   19.28 -public class SDLActivity extends Activity {
   19.29 -
   19.30 -    //Main components
   19.31 -    private static SDLActivity mSingleton;
   19.32 -    private static SDLSurface mSurface;
   19.33 -
   19.34 -    //Audio
   19.35 -    private static AudioTrack mAudioTrack;
   19.36 -    private static boolean bAudioIsEnabled;
   19.37 -
   19.38 -    //Sensors
   19.39 -    private static boolean bAccelIsEnabled;
   19.40 -
   19.41 -    //feature IDs. Must match up on the C side as well.
   19.42 -    private static int FEATURE_AUDIO = 1;
   19.43 -    private static int FEATURE_ACCEL = 2;
   19.44 -
   19.45 -    //Load the .so
   19.46 -    static {
   19.47 -        System.loadLibrary("sdltest");
   19.48 -    }
   19.49 -
   19.50 -    //Setup
   19.51 -    protected void onCreate(Bundle savedInstanceState) {
   19.52 -        super.onCreate(savedInstanceState);
   19.53 -        
   19.54 -        //So we can call stuff from static callbacks
   19.55 -        mSingleton = this;
   19.56 -
   19.57 -        //Set up the surface
   19.58 -        mSurface = new SDLSurface(getApplication());
   19.59 -        setContentView(mSurface);
   19.60 -        SurfaceHolder holder = mSurface.getHolder();
   19.61 -        holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
   19.62 -        
   19.63 -    }
   19.64 -
   19.65 -    //Audio
   19.66 -    public static boolean initAudio(){        
   19.67 -
   19.68 -        //blah. Hardcoded things are bad. FIXME when we have more sound stuff
   19.69 -        //working properly. 
   19.70 -        mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
   19.71 -                    11025,
   19.72 -                    AudioFormat.CHANNEL_CONFIGURATION_MONO,
   19.73 -                    AudioFormat.ENCODING_PCM_8BIT,
   19.74 -                    2048,
   19.75 -                    AudioTrack.MODE_STREAM);   
   19.76 -        bAudioIsEnabled = true;     
   19.77 -        return true;
   19.78 -    }
   19.79 -
   19.80 -    //Accel
   19.81 -    public static boolean initAccel(){
   19.82 -        mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   19.83 -        bAccelIsEnabled = true;
   19.84 -        return true;
   19.85 -    }
   19.86 -    
   19.87 -    public static boolean closeAccel(){
   19.88 -        mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, false);
   19.89 -        bAccelIsEnabled = false;
   19.90 -        return true;
   19.91 -    }
   19.92 -    
   19.93 -
   19.94 -    //Events
   19.95 -    protected void onPause() {
   19.96 -        super.onPause();
   19.97 -    }
   19.98 -
   19.99 -    protected void onResume() {
  19.100 -        super.onResume();
  19.101 -    }
  19.102 -
  19.103 -    
  19.104 -
  19.105 -
  19.106 -
  19.107 -    //C functions we call
  19.108 -    public static native void nativeInit();
  19.109 -    public static native void nativeQuit();
  19.110 -    public static native void nativeSetScreenSize(int width, int height);
  19.111 -    public static native void onNativeKeyDown(int keycode);
  19.112 -    public static native void onNativeKeyUp(int keycode);
  19.113 -    public static native void onNativeTouch(int action, float x, 
  19.114 -                                            float y, float p);
  19.115 -    public static native void onNativeResize(int x, int y, int format);
  19.116 -    public static native void onNativeAccel(float x, float y, float z);
  19.117 -
  19.118 -
  19.119 -
  19.120 -    //Java functions called from C
  19.121 -    private static void createGLContext(){
  19.122 -        mSurface.initEGL();
  19.123 -    }
  19.124 -
  19.125 -    public static void flipBuffers(){
  19.126 -        mSurface.flipEGL();
  19.127 -    }
  19.128 -
  19.129 -    public static void updateAudio(byte [] buf){
  19.130 -    
  19.131 -        if(mAudioTrack == null){
  19.132 -            return;
  19.133 -        }
  19.134 -        
  19.135 -        mAudioTrack.write(buf, 0, buf.length);
  19.136 -        mAudioTrack.play();
  19.137 -        
  19.138 -        Log.v("SDL","Played some audio");
  19.139 -    }
  19.140 -
  19.141 -    public static void enableFeature(int featureid, int enabled){
  19.142 -         Log.v("SDL","Feature " + featureid + " = " + enabled);
  19.143 -
  19.144 -        //Yuck. This is all horribly inelegent. If it gets to more than a few
  19.145 -        //'features' I'll rip this out and make something nicer, I promise :)
  19.146 -        if(featureid == FEATURE_AUDIO){
  19.147 -            if(enabled == 1){
  19.148 -                initAudio();
  19.149 -            }else{
  19.150 -                //We don't have one of these yet...
  19.151 -                //closeAudio(); 
  19.152 -            }
  19.153 -        }
  19.154 -
  19.155 -        else if(featureid == FEATURE_ACCEL){
  19.156 -            if(enabled == 1){
  19.157 -                initAccel();
  19.158 -            }else{
  19.159 -                closeAccel();
  19.160 -            }
  19.161 -        }
  19.162 -    }
  19.163 -
  19.164 -
  19.165 -
  19.166 -
  19.167 -
  19.168 -    
  19.169 -    
  19.170 -}
  19.171 -
  19.172 -/**
  19.173 -    Simple nativeInit() runnable
  19.174 -*/
  19.175 -class SDLRunner implements Runnable{
  19.176 -    public void run(){
  19.177 -        //SDLActivity.initAudio();
  19.178 -        
  19.179 -        //Runs SDL_main()
  19.180 -        SDLActivity.nativeInit();
  19.181 -
  19.182 -        Log.v("SDL","SDL thread terminated");
  19.183 -    }
  19.184 -}
  19.185 -
  19.186 -
  19.187 -/**
  19.188 -    SDLSurface. This is what we draw on, so we need to know when it's created
  19.189 -    in order to do anything useful. 
  19.190 -
  19.191 -    Because of this, that's where we set up the SDL thread
  19.192 -*/
  19.193 -class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, 
  19.194 -    View.OnKeyListener, View.OnTouchListener, SensorEventListener  {
  19.195 -
  19.196 -    //This is what SDL runs in. It invokes SDL_main(), eventually
  19.197 -    private Thread mSDLThread;    
  19.198 -    
  19.199 -    //EGL private objects
  19.200 -    private EGLContext  mEGLContext;
  19.201 -    private EGLSurface  mEGLSurface;
  19.202 -    private EGLDisplay  mEGLDisplay;
  19.203 -
  19.204 -    //Sensors
  19.205 -    private static SensorManager mSensorManager;
  19.206 -
  19.207 -    //Startup    
  19.208 -    public SDLSurface(Context context) {
  19.209 -        super(context);
  19.210 -        getHolder().addCallback(this); 
  19.211 -    
  19.212 -        setFocusable(true);
  19.213 -        setFocusableInTouchMode(true);
  19.214 -        requestFocus();
  19.215 -        setOnKeyListener(this); 
  19.216 -        setOnTouchListener(this);   
  19.217 -        
  19.218 -        mSensorManager = (SensorManager)context.getSystemService("sensor");  
  19.219 -    }
  19.220 -
  19.221 -    //Called when we have a valid drawing surface
  19.222 -    public void surfaceCreated(SurfaceHolder holder) {
  19.223 -        Log.v("SDL","Surface created"); 
  19.224 -
  19.225 -        int width = getWidth();
  19.226 -        int height = getHeight();
  19.227 -
  19.228 -        //Set the width and height variables in C before we start SDL so we have
  19.229 -        //it available on init
  19.230 -        SDLActivity.nativeSetScreenSize(width, height);
  19.231 -
  19.232 -        //Now start up the C app thread
  19.233 -        mSDLThread = new Thread(new SDLRunner(), "SDLThread"); 
  19.234 -		mSDLThread.start();       
  19.235 -    }
  19.236 -
  19.237 -    //Called when we lose the surface
  19.238 -    public void surfaceDestroyed(SurfaceHolder holder) {
  19.239 -        Log.v("SDL","Surface destroyed");
  19.240 -        
  19.241 -        SDLActivity.nativeQuit();
  19.242 -
  19.243 -        //Now wait for the SDL thread to quit
  19.244 -        try{
  19.245 -            mSDLThread.wait();
  19.246 -        }catch(Exception e){
  19.247 -            Log.v("SDL","Problem stopping thread: " + e);
  19.248 -        }
  19.249 -    }
  19.250 -
  19.251 -    //Called when the surface is resized
  19.252 -    public void surfaceChanged(SurfaceHolder holder, int format, 
  19.253 -                                int width, int height) {
  19.254 -        Log.v("SDL","Surface resized");
  19.255 -        
  19.256 -        SDLActivity.onNativeResize(width, height, format);
  19.257 -    }
  19.258 -
  19.259 -    //unused
  19.260 -    public void onDraw(Canvas canvas) {}
  19.261 -
  19.262 -    
  19.263 -    //EGL functions
  19.264 -    public boolean initEGL(){
  19.265 -        Log.v("SDL","Starting up");
  19.266 -
  19.267 -        try{
  19.268 -
  19.269 -            EGL10 egl = (EGL10)EGLContext.getEGL();
  19.270 -
  19.271 -            EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
  19.272 -
  19.273 -            int[] version = new int[2];
  19.274 -            egl.eglInitialize(dpy, version);
  19.275 -
  19.276 -            int[] configSpec = {
  19.277 -                    //EGL10.EGL_DEPTH_SIZE,   16,
  19.278 -                    EGL10.EGL_NONE
  19.279 -            };
  19.280 -            EGLConfig[] configs = new EGLConfig[1];
  19.281 -            int[] num_config = new int[1];
  19.282 -            egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config);
  19.283 -            EGLConfig config = configs[0];
  19.284 -
  19.285 -            EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, null);
  19.286 -
  19.287 -            EGLSurface surface = egl.eglCreateWindowSurface(dpy, config, this, null);
  19.288 -
  19.289 -            egl.eglMakeCurrent(dpy, surface, surface, ctx);
  19.290 -
  19.291 -            mEGLContext = ctx;
  19.292 -            mEGLDisplay = dpy;
  19.293 -            mEGLSurface = surface;
  19.294 -            
  19.295 -            
  19.296 -        }catch(Exception e){
  19.297 -            Log.v("SDL", e + "");
  19.298 -            for(StackTraceElement s : e.getStackTrace()){
  19.299 -                Log.v("SDL", s.toString());
  19.300 -            }
  19.301 -        }
  19.302 -        Log.v("SDL","Done making!");
  19.303 -
  19.304 -        return true;
  19.305 -    }
  19.306 -
  19.307 -    //EGL buffer flip
  19.308 -    public void flipEGL(){      
  19.309 -        try{
  19.310 -        
  19.311 -            EGL10 egl = (EGL10)EGLContext.getEGL();
  19.312 -            GL10 gl = (GL10)mEGLContext.getGL();
  19.313 -
  19.314 -            egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);
  19.315 -
  19.316 -            //drawing here
  19.317 -
  19.318 -            egl.eglWaitGL();
  19.319 -
  19.320 -            egl.eglSwapBuffers(mEGLDisplay, mEGLSurface);
  19.321 -
  19.322 -            
  19.323 -        }catch(Exception e){
  19.324 -            Log.v("SDL", "flipEGL(): " + e);
  19.325 -
  19.326 -            for(StackTraceElement s : e.getStackTrace()){
  19.327 -                Log.v("SDL", s.toString());
  19.328 -            }
  19.329 -        }
  19.330 -    }
  19.331 -
  19.332 -
  19.333 -  
  19.334 -    //Key events
  19.335 -    public boolean onKey(View  v, int keyCode, KeyEvent event){
  19.336 -
  19.337 -        if(event.getAction() == KeyEvent.ACTION_DOWN){
  19.338 -            SDLActivity.onNativeKeyDown(keyCode);
  19.339 -            return true;
  19.340 -        }
  19.341 -        
  19.342 -        else if(event.getAction() == KeyEvent.ACTION_UP){
  19.343 -            SDLActivity.onNativeKeyUp(keyCode);
  19.344 -            return true;
  19.345 -        }
  19.346 -        
  19.347 -        return false;
  19.348 -    }
  19.349 -
  19.350 -    //Touch events
  19.351 -    public boolean onTouch(View v, MotionEvent event){
  19.352 -    
  19.353 -        int action = event.getAction();
  19.354 -        float x = event.getX();
  19.355 -        float y = event.getY();
  19.356 -        float p = event.getPressure();
  19.357 -
  19.358 -        //TODO: Anything else we need to pass?        
  19.359 -        SDLActivity.onNativeTouch(action, x, y, p);
  19.360 -        return true;
  19.361 -    }
  19.362 -
  19.363 -    //Sensor events
  19.364 -    public void enableSensor(int sensortype, boolean enabled){
  19.365 -        //TODO: This uses getDefaultSensor - what if we have >1 accels?
  19.366 -        if(enabled){
  19.367 -            mSensorManager.registerListener(this, 
  19.368 -                            mSensorManager.getDefaultSensor(sensortype), 
  19.369 -                            SensorManager.SENSOR_DELAY_GAME, null);
  19.370 -        }else{
  19.371 -            mSensorManager.unregisterListener(this, 
  19.372 -                            mSensorManager.getDefaultSensor(sensortype));
  19.373 -        }
  19.374 -    }
  19.375 -    
  19.376 -    public void onAccuracyChanged(Sensor sensor, int accuracy){
  19.377 -        //TODO
  19.378 -    }
  19.379 -
  19.380 -    public void onSensorChanged(SensorEvent event){
  19.381 -        if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
  19.382 -            SDLActivity.onNativeAccel(  event.values[0],
  19.383 -                                        event.values[1],
  19.384 -                                        event.values[2] );
  19.385 -        }
  19.386 -    }
  19.387 -
  19.388 -
  19.389 -}
  19.390 -
  19.391 -