1.1 --- a/android/testproject/jni/Android.mk Fri Jun 18 00:03:09 2010 +1200
1.2 +++ b/android/testproject/jni/Android.mk Fri Jun 18 01:28:39 2010 +1200
1.3 @@ -4,13 +4,17 @@
1.4
1.5 LOCAL_MODULE := sanangeles
1.6
1.7 +SDL := /home/paul/Projects/gsoc/SDL-gsoc2010_android/
1.8 +
1.9 LOCAL_CFLAGS := -DANDROID_NDK \
1.10 - -DDISABLE_IMPORTGL
1.11 + -DDISABLE_IMPORTGL \
1.12 + -I$(SDL)/include
1.13
1.14 LOCAL_SRC_FILES := \
1.15 importgl.c \
1.16 app-android.c \
1.17 + lesson05.c \
1.18
1.19 -LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog
1.20 +LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lSDL -lEGL -lgcc -L$(SDL) -L$(SDL)/build-scripts/android_libs/
1.21
1.22 include $(BUILD_SHARED_LIBRARY)
2.1 --- a/android/testproject/jni/app-android.c Fri Jun 18 00:03:09 2010 +1200
2.2 +++ b/android/testproject/jni/app-android.c Fri Jun 18 01:28:39 2010 +1200
2.3 @@ -14,6 +14,7 @@
2.4 #include <pthread.h>
2.5
2.6 #include "importgl.h"
2.7 +#include "egl.h"
2.8
2.9 /*******************************************************************************
2.10 Globals
2.11 @@ -31,7 +32,17 @@
2.12 }
2.13
2.14
2.15 +/*******************************************************************************
2.16 + Things used by libsdl
2.17 +*******************************************************************************/
2.18 +pthread_mutex_t mSDLRenderMutex;
2.19 +pthread_cond_t mSDLRenderCondition;
2.20
2.21 +EGLContext mContext;
2.22 +EGLDisplay mDisplay;
2.23 +EGLSurface mRead;
2.24 +EGLSurface mDraw;
2.25 +
2.26 /*******************************************************************************
2.27 SDL thread
2.28 *******************************************************************************/
2.29 @@ -39,7 +50,13 @@
2.30
2.31 void* sdlThreadProc(void* args){
2.32 __android_log_print(ANDROID_LOG_INFO, "SDL", "Thread Entry");
2.33 - return 0;
2.34 +
2.35 + if(!eglMakeCurrent(mDisplay, mDraw, mRead, mContext)){
2.36 + __android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't make current: 0x%x", eglGetError());
2.37 + return NULL;
2.38 + }
2.39 +
2.40 + return (void *)SDL_main();
2.41 }
2.42
2.43 /*******************************************************************************
2.44 @@ -54,6 +71,21 @@
2.45
2.46 __android_log_print(ANDROID_LOG_INFO, "SDL", "Entry point");
2.47
2.48 + pthread_mutex_init(&mSDLRenderMutex, NULL);
2.49 + pthread_cond_init (&mSDLRenderCondition, NULL);
2.50 +
2.51 + //Get some egl stuff we need
2.52 + mContext = eglGetCurrentContext();
2.53 + mDisplay = eglGetCurrentDisplay();
2.54 + mRead = eglGetCurrentSurface(EGL_READ);
2.55 + mDraw = eglGetCurrentSurface(EGL_DRAW);
2.56 +
2.57 + //We need to abandon our context so SDL can have it
2.58 + if(!eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)){
2.59 + __android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't abandon context: 0x%x", eglGetError());
2.60 + return NULL;
2.61 + }
2.62 +
2.63 //Spin up the SDL thread
2.64 int r = pthread_create(&mSDLThread, NULL, sdlThreadProc, NULL);
2.65
2.66 @@ -115,4 +147,10 @@
2.67 {
2.68 //TODO: Render here
2.69
2.70 + pthread_mutex_lock(&mSDLRenderMutex);
2.71 + pthread_cond_signal(&mSDLRenderCondition); //wake up the SDL thread
2.72 + pthread_mutex_unlock(&mSDLRenderMutex);
2.73 +
2.74 + //__android_log_print(ANDROID_LOG_INFO, "SDL", "Unlocked");
2.75 +
2.76 }
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/android/testproject/jni/egl.h Fri Jun 18 01:28:39 2010 +1200
3.3 @@ -0,0 +1,269 @@
3.4 +/*
3.5 + * Copyright (C) 2007 The Android Open Source Project
3.6 + *
3.7 + * Licensed under the Apache License, Version 2.0 (the "License");
3.8 + * you may not use this file except in compliance with the License.
3.9 + * You may obtain a copy of the License at
3.10 + *
3.11 + * http://www.apache.org/licenses/LICENSE-2.0
3.12 + *
3.13 + * Unless required by applicable law or agreed to in writing, software
3.14 + * distributed under the License is distributed on an "AS IS" BASIS,
3.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3.16 + * See the License for the specific language governing permissions and
3.17 + * limitations under the License.
3.18 + */
3.19 +
3.20 +#ifndef ANDROID_EGL_H
3.21 +#define ANDROID_EGL_H
3.22 +
3.23 +#include <GLES/gl.h>
3.24 +#include <egltypes.h>
3.25 +#include <eglnatives.h>
3.26 +
3.27 +#ifdef __cplusplus
3.28 +extern "C" {
3.29 +#endif
3.30 +
3.31 +#define EGL_VERSION_1_0 1
3.32 +#define EGL_VERSION_1_1 1
3.33 +#define EGL_VERSION_1_2 1
3.34 +
3.35 +#define EGL_FALSE 0
3.36 +#define EGL_TRUE 1
3.37 +
3.38 +/* Errors */
3.39 +#define EGL_SUCCESS 0x3000
3.40 +#define EGL_NOT_INITIALIZED 0x3001
3.41 +#define EGL_BAD_ACCESS 0x3002
3.42 +#define EGL_BAD_ALLOC 0x3003
3.43 +#define EGL_BAD_ATTRIBUTE 0x3004
3.44 +#define EGL_BAD_CONFIG 0x3005
3.45 +#define EGL_BAD_CONTEXT 0x3006
3.46 +#define EGL_BAD_CURRENT_SURFACE 0x3007
3.47 +#define EGL_BAD_DISPLAY 0x3008
3.48 +#define EGL_BAD_MATCH 0x3009
3.49 +#define EGL_BAD_NATIVE_PIXMAP 0x300A
3.50 +#define EGL_BAD_NATIVE_WINDOW 0x300B
3.51 +#define EGL_BAD_PARAMETER 0x300C
3.52 +#define EGL_BAD_SURFACE 0x300D
3.53 +#define EGL_CONTEXT_LOST 0x300E
3.54 +
3.55 +/* Config attributes */
3.56 +#define EGL_BUFFER_SIZE 0x3020
3.57 +#define EGL_ALPHA_SIZE 0x3021
3.58 +#define EGL_BLUE_SIZE 0x3022
3.59 +#define EGL_GREEN_SIZE 0x3023
3.60 +#define EGL_RED_SIZE 0x3024
3.61 +#define EGL_DEPTH_SIZE 0x3025
3.62 +#define EGL_STENCIL_SIZE 0x3026
3.63 +#define EGL_CONFIG_CAVEAT 0x3027
3.64 +#define EGL_CONFIG_ID 0x3028
3.65 +#define EGL_LEVEL 0x3029
3.66 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A
3.67 +#define EGL_MAX_PBUFFER_PIXELS 0x302B
3.68 +#define EGL_MAX_PBUFFER_WIDTH 0x302C
3.69 +#define EGL_NATIVE_RENDERABLE 0x302D
3.70 +#define EGL_NATIVE_VISUAL_ID 0x302E
3.71 +#define EGL_NATIVE_VISUAL_TYPE 0x302F
3.72 +#define EGL_SAMPLES 0x3031
3.73 +#define EGL_SAMPLE_BUFFERS 0x3032
3.74 +#define EGL_SURFACE_TYPE 0x3033
3.75 +#define EGL_TRANSPARENT_TYPE 0x3034
3.76 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
3.77 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
3.78 +#define EGL_TRANSPARENT_RED_VALUE 0x3037
3.79 +#define EGL_NONE 0x3038
3.80 +#define EGL_BIND_TO_TEXTURE_RGB 0x3039
3.81 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
3.82 +#define EGL_MIN_SWAP_INTERVAL 0x303B
3.83 +#define EGL_MAX_SWAP_INTERVAL 0x303C
3.84 +#define EGL_LUMINANCE_SIZE 0x303D
3.85 +#define EGL_ALPHA_MASK_SIZE 0x303E
3.86 +#define EGL_COLOR_BUFFER_TYPE 0x303F
3.87 +#define EGL_RENDERABLE_TYPE 0x3040
3.88 +
3.89 +/* Config values */
3.90 +#define EGL_DONT_CARE ((EGLint)-1)
3.91 +
3.92 +#define EGL_SLOW_CONFIG 0x3050
3.93 +#define EGL_NON_CONFORMANT_CONFIG 0x3051
3.94 +#define EGL_TRANSPARENT_RGB 0x3052
3.95 +#define EGL_NO_TEXTURE 0x305C
3.96 +#define EGL_TEXTURE_RGB 0x305D
3.97 +#define EGL_TEXTURE_RGBA 0x305E
3.98 +#define EGL_TEXTURE_2D 0x305F
3.99 +#define EGL_RGB_BUFFER 0x308E
3.100 +#define EGL_LUMINANCE_BUFFER 0x308F
3.101 +
3.102 +/* Config attribute mask bits */
3.103 +#define EGL_PBUFFER_BIT 0x01
3.104 +#define EGL_PIXMAP_BIT 0x02
3.105 +#define EGL_WINDOW_BIT 0x04
3.106 +#define EGL_OPENGL_ES_BIT 0x01
3.107 +#define EGL_OPENVG_BIT 0x02
3.108 +
3.109 +/* String names */
3.110 +#define EGL_VENDOR 0x3053
3.111 +#define EGL_VERSION 0x3054
3.112 +#define EGL_EXTENSIONS 0x3055
3.113 +#define EGL_CLIENT_APIS 0x308D
3.114 +
3.115 +/* Surface attributes */
3.116 +#define EGL_HEIGHT 0x3056
3.117 +#define EGL_WIDTH 0x3057
3.118 +#define EGL_LARGEST_PBUFFER 0x3058
3.119 +#define EGL_TEXTURE_FORMAT 0x3080
3.120 +#define EGL_TEXTURE_TARGET 0x3081
3.121 +#define EGL_MIPMAP_TEXTURE 0x3082
3.122 +#define EGL_MIPMAP_LEVEL 0x3083
3.123 +#define EGL_RENDER_BUFFER 0x3086
3.124 +#define EGL_COLORSPACE 0x3087
3.125 +#define EGL_ALPHA_FORMAT 0x3088
3.126 +#define EGL_HORIZONTAL_RESOLUTION 0x3090
3.127 +#define EGL_VERTICAL_RESOLUTION 0x3091
3.128 +#define EGL_PIXEL_ASPECT_RATIO 0x3092
3.129 +#define EGL_SWAP_BEHAVIOR 0x3093
3.130 +
3.131 +#define EGL_BACK_BUFFER 0x3084
3.132 +#define EGL_SINGLE_BUFFER 0x3085
3.133 +
3.134 +#define EGL_DISPLAY_SCALING 10000
3.135 +
3.136 +#define EGL_UNKNOWN ((EGLint)-1)
3.137 +
3.138 +/* Back buffer swap behaviors */
3.139 +#define EGL_BUFFER_PRESERVED 0x3094
3.140 +#define EGL_BUFFER_DESTROYED 0x3095
3.141 +
3.142 +/* CreatePbufferFromClientBuffer buffer types */
3.143 +#define EGL_OPENVG_IMAGE 0x3096
3.144 +
3.145 +/* QueryContext targets */
3.146 +#define EGL_CONTEXT_CLIENT_TYPE 0x3097
3.147 +
3.148 +/* BindAPI/QueryAPI targets */
3.149 +#define EGL_OPENGL_ES_API 0x30A0
3.150 +#define EGL_OPENVG_API 0x30A1
3.151 +
3.152 +/* WaitNative engines */
3.153 +#define EGL_CORE_NATIVE_ENGINE 0x305B
3.154 +
3.155 +/* Current surfaces */
3.156 +#define EGL_DRAW 0x3059
3.157 +#define EGL_READ 0x305A
3.158 +
3.159 +
3.160 +EGLDisplay eglGetDisplay(NativeDisplayType display);
3.161 +EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
3.162 +EGLBoolean eglTerminate(EGLDisplay dpy);
3.163 +
3.164 +EGLBoolean eglGetConfigs( EGLDisplay dpy,
3.165 + EGLConfig *configs,
3.166 + EGLint config_size, EGLint *num_config);
3.167 +
3.168 +EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
3.169 + EGLConfig *configs, EGLint config_size,
3.170 + EGLint *num_config);
3.171 +
3.172 +EGLBoolean eglGetConfigAttrib( EGLDisplay dpy, EGLConfig config,
3.173 + EGLint attribute, EGLint *value);
3.174 +
3.175 +EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
3.176 + NativeWindowType window,
3.177 + const EGLint *attrib_list);
3.178 +
3.179 +EGLSurface eglCreatePixmapSurface( EGLDisplay dpy, EGLConfig config,
3.180 + NativePixmapType pixmap,
3.181 + const EGLint *attrib_list);
3.182 +
3.183 +EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config,
3.184 + const EGLint *attrib_list);
3.185 +
3.186 +EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
3.187 +
3.188 +EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
3.189 + EGLint attribute, EGLint *value);
3.190 +
3.191 +EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
3.192 + EGLContext share_list, const EGLint *attrib_list);
3.193 +
3.194 +EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
3.195 +
3.196 +EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
3.197 + EGLSurface read, EGLContext ctx);
3.198 +
3.199 +EGLContext eglGetCurrentContext(void);
3.200 +EGLSurface eglGetCurrentSurface(EGLint readdraw);
3.201 +EGLDisplay eglGetCurrentDisplay(void);
3.202 +EGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx,
3.203 + EGLint attribute, EGLint *value);
3.204 +
3.205 +EGLBoolean eglWaitGL(void);
3.206 +EGLBoolean eglWaitNative(EGLint engine);
3.207 +EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw);
3.208 +EGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface,
3.209 + NativePixmapType target);
3.210 +
3.211 +EGLint eglGetError(void);
3.212 +const char* eglQueryString(EGLDisplay dpy, EGLint name);
3.213 +void (*eglGetProcAddress (const char *procname))();
3.214 +
3.215 +/* ----------------------------------------------------------------------------
3.216 + * EGL 1.1
3.217 + * ----------------------------------------------------------------------------
3.218 + */
3.219 +
3.220 +EGLBoolean eglSurfaceAttrib(
3.221 + EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
3.222 +EGLBoolean eglBindTexImage(
3.223 + EGLDisplay dpy, EGLSurface surface, EGLint buffer);
3.224 +EGLBoolean eglReleaseTexImage(
3.225 + EGLDisplay dpy, EGLSurface surface, EGLint buffer);
3.226 +
3.227 +EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval);
3.228 +
3.229 +/* ----------------------------------------------------------------------------
3.230 + * EGL 1.2
3.231 + * ----------------------------------------------------------------------------
3.232 + */
3.233 +
3.234 +EGLBoolean eglBindAPI(EGLenum api);
3.235 +EGLenum eglQueryAPI(void);
3.236 +EGLBoolean eglWaitClient(void);
3.237 +EGLBoolean eglReleaseThread(void);
3.238 +EGLSurface eglCreatePbufferFromClientBuffer(
3.239 + EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
3.240 + EGLConfig config, const EGLint *attrib_list);
3.241 +
3.242 +/* ----------------------------------------------------------------------------
3.243 + * Android extentions
3.244 + * ----------------------------------------------------------------------------
3.245 + */
3.246 +
3.247 +EGLBoolean eglSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
3.248 + EGLint l, EGLint t, EGLint w, EGLint h);
3.249 +
3.250 +EGLBoolean eglCopyFrontToBackANDROID(EGLDisplay dpy,
3.251 + EGLSurface surface,
3.252 + EGLint l, EGLint t, EGLint w, EGLint h);
3.253 +
3.254 +const char* eglQueryStringConfigANDROID(
3.255 + EGLDisplay dpy, EGLConfig config, EGLint name);
3.256 +
3.257 +void* eglGetRenderBufferAddressANDROID(EGLDisplay dpy, EGLSurface surface);
3.258 +
3.259 +EGLBoolean eglCopyBitsANDROID(EGLDisplay dpy,
3.260 + NativeWindowType draw, EGLint x, EGLint y,
3.261 + NativeWindowType read,
3.262 + EGLint crop_x, EGLint crop_y, EGLint crop_w, EGLint crop_h,
3.263 + EGLint flags);
3.264 +
3.265 +
3.266 +#ifdef __cplusplus
3.267 +}
3.268 +#endif
3.269 +
3.270 +
3.271 +#endif /*ANDROID_EGL_H*/
3.272 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/android/testproject/jni/eglnatives.h Fri Jun 18 01:28:39 2010 +1200
4.3 @@ -0,0 +1,277 @@
4.4 +/*
4.5 + * Copyright (C) 2007 The Android Open Source Project
4.6 + *
4.7 + * Licensed under the Apache License, Version 2.0 (the "License");
4.8 + * you may not use this file except in compliance with the License.
4.9 + * You may obtain a copy of the License at
4.10 + *
4.11 + * http://www.apache.org/licenses/LICENSE-2.0
4.12 + *
4.13 + * Unless required by applicable law or agreed to in writing, software
4.14 + * distributed under the License is distributed on an "AS IS" BASIS,
4.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4.16 + * See the License for the specific language governing permissions and
4.17 + * limitations under the License.
4.18 + */
4.19 +
4.20 +#ifndef ANDROID_EGLNATIVES_H
4.21 +#define ANDROID_EGLNATIVES_H
4.22 +
4.23 +#include <sys/types.h>
4.24 +
4.25 +#ifdef __cplusplus
4.26 +extern "C" {
4.27 +#endif
4.28 +/*****************************************************************************/
4.29 +
4.30 +struct egl_native_window_t;
4.31 +struct egl_native_pixmap_t;
4.32 +
4.33 +
4.34 +typedef struct egl_native_window_t* NativeWindowType;
4.35 +typedef struct egl_native_pixmap_t* NativePixmapType;
4.36 +typedef void* NativeDisplayType;
4.37 +
4.38 +/*
4.39 + * This a conveniance function to create a NativeWindowType surface
4.40 + * that maps to the whole screen
4.41 + * This function is actually implemented in libui.so
4.42 + */
4.43 +
4.44 +NativeWindowType android_createDisplaySurface();
4.45 +
4.46 +/* flags returned from swapBuffer */
4.47 +#define EGL_NATIVES_FLAG_SIZE_CHANGED 0x00000001
4.48 +
4.49 +/* surface flags */
4.50 +#define EGL_NATIVES_FLAG_DESTROY_BACKBUFFER 0x00000001
4.51 +
4.52 +enum native_pixel_format_t
4.53 +{
4.54 + NATIVE_PIXEL_FORMAT_RGBA_8888 = 1,
4.55 + NATIVE_PIXEL_FORMAT_RGB_565 = 4,
4.56 + NATIVE_PIXEL_FORMAT_RGBA_5551 = 6,
4.57 + NATIVE_PIXEL_FORMAT_RGBA_4444 = 7,
4.58 + NATIVE_PIXEL_FORMAT_YCbCr_422_SP= 0x10,
4.59 + NATIVE_PIXEL_FORMAT_YCbCr_420_SP= 0x11,
4.60 +};
4.61 +
4.62 +enum native_memory_type_t
4.63 +{
4.64 + NATIVE_MEMORY_TYPE_PMEM = 0,
4.65 + NATIVE_MEMORY_TYPE_GPU = 1,
4.66 + NATIVE_MEMORY_TYPE_FB = 2,
4.67 + NATIVE_MEMORY_TYPE_HEAP = 128
4.68 +};
4.69 +
4.70 +
4.71 +struct egl_native_window_t
4.72 +{
4.73 + /*
4.74 + * magic must be set to 0x600913
4.75 + */
4.76 + uint32_t magic;
4.77 +
4.78 + /*
4.79 + * must be sizeof(egl_native_window_t)
4.80 + */
4.81 + uint32_t version;
4.82 +
4.83 + /*
4.84 + * ident is reserved for the Android platform
4.85 + */
4.86 + uint32_t ident;
4.87 +
4.88 + /*
4.89 + * width, height and stride of the window in pixels
4.90 + * Any of these value can be nul in which case GL commands are
4.91 + * accepted and processed as usual, but not rendering occurs.
4.92 + */
4.93 + int width; // w=h=0 is legal
4.94 + int height;
4.95 + int stride;
4.96 +
4.97 + /*
4.98 + * format of the native window (see ui/PixelFormat.h)
4.99 + */
4.100 + int format;
4.101 +
4.102 + /*
4.103 + * Offset of the bits in the VRAM
4.104 + */
4.105 + intptr_t offset;
4.106 +
4.107 + /*
4.108 + * flags describing some attributes of this surface
4.109 + * EGL_NATIVES_FLAG_DESTROY_BACKBUFFER: backbuffer not preserved after
4.110 + * eglSwapBuffers
4.111 + */
4.112 + uint32_t flags;
4.113 +
4.114 + /*
4.115 + * horizontal and vertical resolution in DPI
4.116 + */
4.117 + float xdpi;
4.118 + float ydpi;
4.119 +
4.120 + /*
4.121 + * refresh rate in frames per second (Hz)
4.122 + */
4.123 + float fps;
4.124 +
4.125 +
4.126 + /*
4.127 + * Base memory virtual address of the surface in the CPU side
4.128 + */
4.129 + intptr_t base;
4.130 +
4.131 + /*
4.132 + * Heap the offset above is based from
4.133 + */
4.134 + int fd;
4.135 +
4.136 + /*
4.137 + * Memory type the surface resides into
4.138 + */
4.139 + uint8_t memory_type;
4.140 +
4.141 + /*
4.142 + * Reserved for future use. MUST BE ZERO.
4.143 + */
4.144 + uint8_t reserved_pad[3];
4.145 + int reserved[8];
4.146 +
4.147 + /*
4.148 + * Vertical stride (only relevant with planar formats)
4.149 + */
4.150 +
4.151 + int vstride;
4.152 +
4.153 + /*
4.154 + * Hook called by EGL to hold a reference on this structure
4.155 + */
4.156 + void (*incRef)(NativeWindowType window);
4.157 +
4.158 + /*
4.159 + * Hook called by EGL to release a reference on this structure
4.160 + */
4.161 + void (*decRef)(NativeWindowType window);
4.162 +
4.163 + /*
4.164 + * Hook called by EGL to perform a page flip. This function
4.165 + * may update the size attributes above, in which case it returns
4.166 + * the EGL_NATIVES_FLAG_SIZE_CHANGED bit set.
4.167 + */
4.168 + uint32_t (*swapBuffers)(NativeWindowType window);
4.169 +
4.170 + /*
4.171 + * Hook called by EGL to set the swap rectangle. this hook can be
4.172 + * null (operation not supported)
4.173 + */
4.174 + void (*setSwapRectangle)(NativeWindowType window, int l, int t, int w, int h);
4.175 +
4.176 + /*
4.177 + * Reserved for future use. MUST BE ZERO.
4.178 + */
4.179 + void (*reserved_proc_0)(void);
4.180 +
4.181 +
4.182 + /*
4.183 + * Hook called by EGL to retrieve the next buffer to render into.
4.184 + * This call updates this structure.
4.185 + */
4.186 + uint32_t (*nextBuffer)(NativeWindowType window);
4.187 +
4.188 + /*
4.189 + * Hook called by EGL when the native surface is associated to EGL
4.190 + * (eglCreateWindowSurface). Can be NULL.
4.191 + */
4.192 + void (*connect)(NativeWindowType window);
4.193 +
4.194 + /*
4.195 + * Hook called by EGL when eglDestroySurface is called. Can be NULL.
4.196 + */
4.197 + void (*disconnect)(NativeWindowType window);
4.198 +
4.199 + /*
4.200 + * Reserved for future use. MUST BE ZERO.
4.201 + */
4.202 + void (*reserved_proc[11])(void);
4.203 +
4.204 + /*
4.205 + * Some storage reserved for the oem driver.
4.206 + */
4.207 + intptr_t oem[4];
4.208 +};
4.209 +
4.210 +
4.211 +struct egl_native_pixmap_t
4.212 +{
4.213 + int32_t version; /* must be 32 */
4.214 + int32_t width;
4.215 + int32_t height;
4.216 + int32_t stride;
4.217 + uint8_t* data;
4.218 + uint8_t format;
4.219 + uint8_t rfu[3];
4.220 + union {
4.221 + uint32_t compressedFormat;
4.222 + int32_t vstride;
4.223 + };
4.224 + int32_t reserved;
4.225 +};
4.226 +
4.227 +/*****************************************************************************/
4.228 +
4.229 +/*
4.230 + * OEM's egl's library (libhgl.so) must imlement these hooks to allocate
4.231 + * the GPU memory they need
4.232 + */
4.233 +
4.234 +
4.235 +typedef struct
4.236 +{
4.237 + // for internal use
4.238 + void* user;
4.239 + // virtual address of this area
4.240 + void* base;
4.241 + // size of this area in bytes
4.242 + size_t size;
4.243 + // physical address of this area
4.244 + void* phys;
4.245 + // offset in this area available to the GPU
4.246 + size_t offset;
4.247 + // fd of this area
4.248 + int fd;
4.249 +} gpu_area_t;
4.250 +
4.251 +typedef struct
4.252 +{
4.253 + // area where GPU registers are mapped
4.254 + gpu_area_t regs;
4.255 + // number of extra areas (currently limited to 2)
4.256 + int32_t count;
4.257 + // extra GPU areas (currently limited to 2)
4.258 + gpu_area_t gpu[2];
4.259 +} request_gpu_t;
4.260 +
4.261 +
4.262 +typedef request_gpu_t* (*OEM_EGL_acquire_gpu_t)(void* user);
4.263 +typedef int (*OEM_EGL_release_gpu_t)(void* user, request_gpu_t* handle);
4.264 +typedef void (*register_gpu_t)
4.265 + (void* user, OEM_EGL_acquire_gpu_t, OEM_EGL_release_gpu_t);
4.266 +
4.267 +void oem_register_gpu(
4.268 + void* user,
4.269 + OEM_EGL_acquire_gpu_t acquire,
4.270 + OEM_EGL_release_gpu_t release);
4.271 +
4.272 +
4.273 +/*****************************************************************************/
4.274 +
4.275 +#ifdef __cplusplus
4.276 +}
4.277 +#endif
4.278 +
4.279 +#endif /* ANDROID_EGLNATIVES_H */
4.280 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/android/testproject/jni/egltypes.h Fri Jun 18 01:28:39 2010 +1200
5.3 @@ -0,0 +1,48 @@
5.4 +/*
5.5 + * Copyright (C) 2007 The Android Open Source Project
5.6 + *
5.7 + * Licensed under the Apache License, Version 2.0 (the "License");
5.8 + * you may not use this file except in compliance with the License.
5.9 + * You may obtain a copy of the License at
5.10 + *
5.11 + * http://www.apache.org/licenses/LICENSE-2.0
5.12 + *
5.13 + * Unless required by applicable law or agreed to in writing, software
5.14 + * distributed under the License is distributed on an "AS IS" BASIS,
5.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5.16 + * See the License for the specific language governing permissions and
5.17 + * limitations under the License.
5.18 + */
5.19 +
5.20 +#ifndef ANDROID_EGL_TYPES_H
5.21 +#define ANDROID_EGL_TYPES_H
5.22 +
5.23 +#include <sys/types.h>
5.24 +
5.25 +#ifdef __cplusplus
5.26 +extern "C" {
5.27 +#endif
5.28 +
5.29 +typedef unsigned int EGLBoolean;
5.30 +typedef int32_t EGLint;
5.31 +typedef int EGLenum;
5.32 +typedef void *EGLDisplay;
5.33 +typedef void *EGLConfig;
5.34 +typedef void *EGLSurface;
5.35 +typedef void *EGLContext;
5.36 +typedef void *EGLClientBuffer;
5.37 +
5.38 +#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
5.39 +
5.40 +#define EGL_NO_CONTEXT ((EGLContext)0)
5.41 +#define EGL_NO_DISPLAY ((EGLDisplay)0)
5.42 +#define EGL_NO_SURFACE ((EGLSurface)0)
5.43 +
5.44 +
5.45 +#ifdef __cplusplus
5.46 +}
5.47 +#endif
5.48 +
5.49 +
5.50 +#endif /* ANDROID_EGL_TYPES_H */
5.51 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/android/testproject/jni/lesson05.c Fri Jun 18 01:28:39 2010 +1200
6.3 @@ -0,0 +1,469 @@
6.4 +/*
6.5 + * This code was created by Jeff Molofee '99
6.6 + * (ported to Linux/SDL by Ti Leggett '01)
6.7 + *
6.8 + * If you've found this code useful, please let me know.
6.9 + *
6.10 + * Visit Jeff at http://nehe.gamedev.net/
6.11 + *
6.12 + * or for port-specific comments, questions, bugreports etc.
6.13 + * email to leggett@eecs.tulane.edu
6.14 + */
6.15 +
6.16 +#include <stdio.h>
6.17 +#include <stdlib.h>
6.18 +#include <math.h>
6.19 +
6.20 +#include <android/log.h>
6.21 +
6.22 +
6.23 +#ifdef ANDROID
6.24 +#include <GLES/gl.h>
6.25 +#else
6.26 +#include <GL/gl.h>
6.27 +#include <GL/glu.h>
6.28 +#endif
6.29 +#include "SDL.h"
6.30 +
6.31 +/* screen width, height, and bit depth */
6.32 +#define SCREEN_WIDTH 320
6.33 +#define SCREEN_HEIGHT 480
6.34 +#define SCREEN_BPP 16
6.35 +
6.36 +/* Define our booleans */
6.37 +#define TRUE 1
6.38 +#define FALSE 0
6.39 +
6.40 +/* This is our SDL surface */
6.41 +SDL_Surface *surface;
6.42 +
6.43 +
6.44 +/**************************************
6.45 + gluperspective implementation
6.46 +**************************************/
6.47 +void gluPerspective(double fovy, double aspect, double zNear, double zFar){
6.48 + glMatrixMode(GL_PROJECTION);
6.49 + glLoadIdentity();
6.50 + double xmin, xmax, ymin, ymax;
6.51 + ymax = zNear * tan(fovy * M_PI / 360.0);
6.52 + ymin = -ymax;
6.53 + xmin = ymin * aspect;
6.54 + xmax = ymax * aspect;
6.55 + glFrustumf(xmin, xmax, ymin, ymax, zNear, zFar);
6.56 +}
6.57 +
6.58 +
6.59 +/**************************************
6.60 + glulookat implementation
6.61 +**************************************/
6.62 +void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
6.63 + GLfloat centerx, GLfloat centery, GLfloat centerz,
6.64 + GLfloat upx, GLfloat upy, GLfloat upz)
6.65 +{
6.66 + GLfloat m[16];
6.67 + GLfloat x[3], y[3], z[3];
6.68 + GLfloat mag;
6.69 +
6.70 + /* Make rotation matrix */
6.71 +
6.72 + /* Z vector */
6.73 + z[0] = eyex - centerx;
6.74 + z[1] = eyey - centery;
6.75 + z[2] = eyez - centerz;
6.76 + mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
6.77 + if (mag) { /* mpichler, 19950515 */
6.78 + z[0] /= mag;
6.79 + z[1] /= mag;
6.80 + z[2] /= mag;
6.81 + }
6.82 +
6.83 + /* Y vector */
6.84 + y[0] = upx;
6.85 + y[1] = upy;
6.86 + y[2] = upz;
6.87 +
6.88 + /* X vector = Y cross Z */
6.89 + x[0] = y[1] * z[2] - y[2] * z[1];
6.90 + x[1] = -y[0] * z[2] + y[2] * z[0];
6.91 + x[2] = y[0] * z[1] - y[1] * z[0];
6.92 +
6.93 + /* Recompute Y = Z cross X */
6.94 + y[0] = z[1] * x[2] - z[2] * x[1];
6.95 + y[1] = -z[0] * x[2] + z[2] * x[0];
6.96 + y[2] = z[0] * x[1] - z[1] * x[0];
6.97 +
6.98 + /* mpichler, 19950515 */
6.99 + /* cross product gives area of parallelogram, which is < 1.0 for
6.100 + * non-perpendicular unit-length vectors; so normalize x, y here
6.101 + */
6.102 +
6.103 + mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
6.104 + if (mag) {
6.105 + x[0] /= mag;
6.106 + x[1] /= mag;
6.107 + x[2] /= mag;
6.108 + }
6.109 +
6.110 + mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
6.111 + if (mag) {
6.112 + y[0] /= mag;
6.113 + y[1] /= mag;
6.114 + y[2] /= mag;
6.115 + }
6.116 +
6.117 +#define M(row,col) m[col*4+row]
6.118 + M(0, 0) = x[0];
6.119 + M(0, 1) = x[1];
6.120 + M(0, 2) = x[2];
6.121 + M(0, 3) = 0.0;
6.122 + M(1, 0) = y[0];
6.123 + M(1, 1) = y[1];
6.124 + M(1, 2) = y[2];
6.125 + M(1, 3) = 0.0;
6.126 + M(2, 0) = z[0];
6.127 + M(2, 1) = z[1];
6.128 + M(2, 2) = z[2];
6.129 + M(2, 3) = 0.0;
6.130 + M(3, 0) = 0.0;
6.131 + M(3, 1) = 0.0;
6.132 + M(3, 2) = 0.0;
6.133 + M(3, 3) = 1.0;
6.134 +#undef M
6.135 + glMultMatrixf(m);
6.136 +
6.137 + /* Translate Eye to Origin */
6.138 + glTranslatef(-eyex, -eyey, -eyez);
6.139 +
6.140 +}
6.141 +
6.142 +
6.143 +
6.144 +
6.145 +
6.146 +/* function to release/destroy our resources and restoring the old desktop */
6.147 +void Quit( int returnCode )
6.148 +{
6.149 + /* clean up the window */
6.150 + SDL_Quit( );
6.151 +
6.152 + /* and exit appropriately */
6.153 + exit( returnCode );
6.154 +}
6.155 +
6.156 +/* function to reset our viewport after a window resize */
6.157 +int resizeWindow( int width, int height )
6.158 +{
6.159 + /* Height / width ration */
6.160 + GLfloat ratio;
6.161 +
6.162 + /* Protect against a divide by zero */
6.163 + if ( height == 0 )
6.164 + height = 1;
6.165 +
6.166 + ratio = ( GLfloat )width / ( GLfloat )height;
6.167 +
6.168 + /* Setup our viewport. */
6.169 + glViewport( 0, 0, ( GLsizei )width, ( GLsizei )height );
6.170 +
6.171 + /* change to the projection matrix and set our viewing volume. */
6.172 + glMatrixMode( GL_PROJECTION );
6.173 + glLoadIdentity( );
6.174 +
6.175 + /* Set our perspective */
6.176 + gluPerspective( 45.0f, ratio, 0.1f, 100.0f );
6.177 +
6.178 + /* Make sure we're chaning the model view and not the projection */
6.179 + glMatrixMode( GL_MODELVIEW );
6.180 +
6.181 + /* Reset The View */
6.182 + glLoadIdentity( );
6.183 +
6.184 + return( TRUE );
6.185 +}
6.186 +
6.187 +/* function to handle key press events */
6.188 +void handleKeyPress( SDL_keysym *keysym )
6.189 +{
6.190 + switch ( keysym->sym )
6.191 + {
6.192 + case SDLK_ESCAPE:
6.193 + /* ESC key was pressed */
6.194 + Quit( 0 );
6.195 + break;
6.196 + case SDLK_F1:
6.197 + /* F1 key was pressed
6.198 + * this toggles fullscreen mode
6.199 + */
6.200 + SDL_WM_ToggleFullScreen( surface );
6.201 + break;
6.202 + default:
6.203 + break;
6.204 + }
6.205 +
6.206 + return;
6.207 +}
6.208 +
6.209 +/* general OpenGL initialization function */
6.210 +int initGL( GLvoid )
6.211 +{
6.212 +
6.213 + /* Enable smooth shading */
6.214 + glShadeModel( GL_SMOOTH );
6.215 +
6.216 + /* Set the background black */
6.217 + glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
6.218 +
6.219 + /* Depth buffer setup */
6.220 + //glClearDepth( 1.0f );
6.221 +
6.222 + /* Enables Depth Testing */
6.223 + glEnable( GL_DEPTH_TEST );
6.224 +
6.225 + /* The Type Of Depth Test To Do */
6.226 + glDepthFunc( GL_LEQUAL );
6.227 +
6.228 + /* Really Nice Perspective Calculations */
6.229 + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
6.230 +
6.231 + return( TRUE );
6.232 +}
6.233 +
6.234 +/* Here goes our drawing code */
6.235 +int drawGLScene( GLvoid )
6.236 +{
6.237 + static int Frames = 0;
6.238 + static int T0 = 0;
6.239 +
6.240 + glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
6.241 +
6.242 + glClearColorx(0,0,Frames,255);
6.243 + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
6.244 +
6.245 + glMatrixMode(GL_PROJECTION);
6.246 + glLoadIdentity();
6.247 + gluPerspective(45, (float)SCREEN_WIDTH / SCREEN_HEIGHT, 0.5f, 150);
6.248 +
6.249 + glMatrixMode(GL_MODELVIEW);
6.250 +
6.251 + glLoadIdentity();
6.252 +
6.253 + //Camera
6.254 + gluLookAt(0,0,5, 0,0,0, 0,1,0);
6.255 +
6.256 + //Draw a triangle
6.257 + //glRotatef(iRot, 0, 1, 0);
6.258 +
6.259 + glRotatef( Frames % 360, 0.0f, 1.0f, 0.0f );
6.260 +
6.261 +
6.262 + glEnableClientState (GL_VERTEX_ARRAY);
6.263 + glEnableClientState (GL_COLOR_ARRAY);
6.264 +
6.265 + /* Rotate The Triangle On The Y axis ( NEW ) */
6.266 + glRotatef( Frames % 360, 0.0f, 1.0f, 0.0f );
6.267 +
6.268 + /* GLES variant of drawing a triangle */
6.269 + const GLfloat triVertices[][9] = {
6.270 + { /* Front Triangle */
6.271 + 0.0f, 1.0f, 0.0f, /* Top Of Triangle */
6.272 + -1.0f, -1.0f, 1.0f, /* Left Of Triangle */
6.273 + 1.0f, -1.0f, 1.0f /* Right Of Triangle */
6.274 + }, { /* Right Triangle */
6.275 + 0.0f, 1.0f, 0.0f, /* Top Of Triangle */
6.276 + 1.0f, -1.0f, 1.0f, /* Left Of Triangle */
6.277 + 1.0f, -1.0f, -1.0f /* Right Of Triangle */
6.278 + }, { /* Back Triangle */
6.279 + 0.0f, 1.0f, 0.0f, /* Top Of Triangle */
6.280 + 1.0f, -1.0f, -1.0f, /* Left Of Triangle */
6.281 + -1.0f, -1.0f, -1.0f /* Right Of Triangle */
6.282 + }, { /* Left Triangle */
6.283 + 0.0f, 1.0f, 0.0f, /* Top Of Triangle */
6.284 + -1.0f, -1.0f, -1.0f, /* Left Of Triangle */
6.285 + -1.0f, -1.0f, 1.0f /* Right Of Triangle */
6.286 + }
6.287 + };
6.288 +
6.289 + /* unlike GL, GLES does not support RGB. We have to use RGBA instead */
6.290 + const GLfloat triColors[][12] = {
6.291 + { /* Front triangle */
6.292 + 1.0f, 0.0f, 0.0f, 1.0f, /* Red */
6.293 + 0.0f, 1.0f, 0.0f, 1.0f, /* Green */
6.294 + 0.0f, 0.0f, 1.0f, 1.0f /* Blue */
6.295 + }, { /* Right triangle */
6.296 + 1.0f, 0.0f, 0.0f, 1.0f, /* Red */
6.297 + 0.0f, 0.0f, 1.0f, 1.0f, /* Blue */
6.298 + 0.0f, 1.0f, 0.0f, 1.0f /* Green */
6.299 + }, { /* Back triangle */
6.300 + 1.0f, 0.0f, 0.0f, 1.0f, /* Red */
6.301 + 0.0f, 1.0f, 0.0f, 1.0f, /* Green */
6.302 + 0.0f, 0.0f, 1.0f, 1.0f /* Blue */
6.303 + }, { /* Left triangle */
6.304 + 1.0f, 0.0f, 0.0f, 1.0f, /* Red */
6.305 + 0.0f, 0.0f, 1.0f, 1.0f, /* Blue */
6.306 + 0.0f, 1.0f, 0.0f, 1.0f /* Green */
6.307 + }
6.308 + };
6.309 +
6.310 + glEnableClientState(GL_COLOR_ARRAY);
6.311 +
6.312 + int tri=0;
6.313 +
6.314 + /* Loop through all Triangles */
6.315 + for(tri=0;tri<sizeof(triVertices)/(9*sizeof(GLfloat));tri++)
6.316 + {
6.317 + glVertexPointer(3, GL_FLOAT, 0, triVertices[tri]);
6.318 + glColorPointer(4, GL_FLOAT, 0, triColors[tri]);
6.319 +
6.320 + glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
6.321 + }
6.322 +
6.323 + //__android_log_print(ANDROID_LOG_INFO, "SDL", "render %d", Frames++);
6.324 +
6.325 + /* Draw it to the screen */
6.326 + SDL_GL_SwapBuffers( );
6.327 +
6.328 + /* Gather our frames per second */
6.329 + Frames++;
6.330 + {
6.331 + GLint t = SDL_GetTicks();
6.332 + if (t - T0 >= 5000) {
6.333 + GLfloat seconds = (t - T0) / 1000.0;
6.334 + GLfloat fps = Frames / seconds;
6.335 + __android_log_print(ANDROID_LOG_INFO, "SDL","%d frames in %g seconds = %g FPS\n", Frames, seconds, fps);
6.336 + T0 = t;
6.337 + Frames = 0;
6.338 + }
6.339 + }
6.340 +
6.341 + return( TRUE );
6.342 +}
6.343 +
6.344 +int SDL_main( int argc, char **argv )
6.345 +{
6.346 +
6.347 + __android_log_print(ANDROID_LOG_INFO, "SDL","entry\n");
6.348 +
6.349 + /* Flags to pass to SDL_SetVideoMode */
6.350 + int videoFlags;
6.351 + /* main loop variable */
6.352 + int done = FALSE;
6.353 + /* used to collect events */
6.354 + SDL_Event event;
6.355 + /* this holds some info about our display */
6.356 + const SDL_VideoInfo *videoInfo;
6.357 + /* whether or not the window is active */
6.358 + int isActive = TRUE;
6.359 +
6.360 + /* initialize SDL */
6.361 + if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
6.362 + {
6.363 + __android_log_print(ANDROID_LOG_INFO, "SDL", "Video initialization failed: %s\n",
6.364 + SDL_GetError( ) );
6.365 + Quit( 1 );
6.366 + }
6.367 +
6.368 + /* Fetch the video info */
6.369 + videoInfo = SDL_GetVideoInfo( );
6.370 +
6.371 + if ( !videoInfo )
6.372 + {
6.373 + __android_log_print(ANDROID_LOG_INFO, "SDL", "Video query failed: %s\n",
6.374 + SDL_GetError( ) );
6.375 + Quit( 1 );
6.376 + }
6.377 +
6.378 + /* the flags to pass to SDL_SetVideoMode */
6.379 + videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */
6.380 + videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
6.381 + videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */
6.382 + videoFlags |= SDL_RESIZABLE; /* Enable window resizing */
6.383 +
6.384 + /* This checks to see if surfaces can be stored in memory */
6.385 + if ( videoInfo->hw_available )
6.386 + videoFlags |= SDL_HWSURFACE;
6.387 + else
6.388 + videoFlags |= SDL_SWSURFACE;
6.389 +
6.390 + /* This checks if hardware blits can be done */
6.391 + if ( videoInfo->blit_hw )
6.392 + videoFlags |= SDL_HWACCEL;
6.393 +
6.394 + /* Sets up OpenGL double buffering */
6.395 + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
6.396 +
6.397 + /* get a SDL surface */
6.398 + surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,
6.399 + videoFlags );
6.400 +
6.401 + /* Verify there is a surface */
6.402 + if ( !surface )
6.403 + {
6.404 + __android_log_print(ANDROID_LOG_INFO, "SDL", "Video mode set failed: %s\n", SDL_GetError( ) );
6.405 + Quit( 1 );
6.406 + }
6.407 +
6.408 + __android_log_print(ANDROID_LOG_INFO, "SDL","Made a video mode!\n");
6.409 +
6.410 + /* initialize OpenGL */
6.411 + initGL( );
6.412 +
6.413 + /* resize the initial window */
6.414 + resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
6.415 +
6.416 + /* wait for events */
6.417 + while ( !done )
6.418 + {
6.419 + /* handle the events in the queue */
6.420 +
6.421 + while ( SDL_PollEvent( &event ) )
6.422 + {
6.423 + switch( event.type )
6.424 + {
6.425 + case SDL_ACTIVEEVENT:
6.426 + /* Something's happend with our focus
6.427 + * If we lost focus or we are iconified, we
6.428 + * shouldn't draw the screen
6.429 + */
6.430 + if ( event.active.gain == 0 )
6.431 + isActive = FALSE;
6.432 + else
6.433 + isActive = TRUE;
6.434 + break;
6.435 + case SDL_VIDEORESIZE:
6.436 + /* handle resize event */
6.437 + surface = SDL_SetVideoMode( event.resize.w,
6.438 + event.resize.h,
6.439 + 16, videoFlags );
6.440 + if ( !surface )
6.441 + {
6.442 + __android_log_print(ANDROID_LOG_INFO, "SDL","Could not get a surface after resize: %s\n", SDL_GetError( ) );
6.443 + Quit( 1 );
6.444 + }
6.445 + resizeWindow( event.resize.w, event.resize.h );
6.446 + break;
6.447 + case SDL_KEYDOWN:
6.448 + /* handle key presses */
6.449 + handleKeyPress( &event.key.keysym );
6.450 + break;
6.451 + case SDL_QUIT:
6.452 + /* handle quit requests */
6.453 + done = TRUE;
6.454 + break;
6.455 + default:
6.456 + break;
6.457 + }
6.458 + }
6.459 +
6.460 + /* draw the scene */
6.461 + if ( isActive )
6.462 + drawGLScene( );
6.463 + }
6.464 +
6.465 + /* clean ourselves up and exit */
6.466 + Quit( 0 );
6.467 +
6.468 + /* Should never get here */
6.469 + return( 0 );
6.470 +}
6.471 +
6.472 +