-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import san-angeles sample from Android NDK r9
- Loading branch information
0 parents
commit 98f138c
Showing
19 changed files
with
2,816 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.SanAngeles" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<application android:label="@string/app_name"> | ||
<activity android:name=".DemoActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
<uses-sdk android:minSdkVersion="4" /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system use, | ||
# "build.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
|
||
LOCAL_MODULE := sanangeles | ||
|
||
LOCAL_CFLAGS := -DANDROID_NDK \ | ||
-DDISABLE_IMPORTGL | ||
|
||
LOCAL_SRC_FILES := \ | ||
importgl.c \ | ||
demo.c \ | ||
app-android.c \ | ||
|
||
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog | ||
|
||
include $(BUILD_SHARED_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
------------------------------------------------------------------------ | ||
San Angeles Observation OpenGL ES version example | ||
Copyright 2004-2005 Jetro Lauha | ||
Web: http://iki.fi/jetro/ | ||
See file license.txt for licensing information. | ||
------------------------------------------------------------------------ | ||
|
||
This is an OpenGL ES port of the small self-running demonstration | ||
called "San Angeles Observation", which was first presented in the | ||
Assembly'2004 event. It won the first place in the 4 KB intro | ||
competition category. | ||
|
||
The demonstration features a sightseeing of a futuristic city | ||
having many different kind of buildings and items. Everything is | ||
flat shaded with three different lights. | ||
|
||
The original version was made for desktop with OpenGL. It was | ||
naturally heavily size optimized in order to fit it in the size | ||
limit. For this OpenGL ES version example much of the code is | ||
cleaned up and the sound is removed. Also detail level is lowered, | ||
although it still contains over 60000 faces. | ||
|
||
The Win32 (2000/XP) binary package of original version is | ||
available from this address: http://jet.ro/files/angeles.zip | ||
|
||
First version of this OpenGL ES port was submitted to the Khronos | ||
OpenGL ES Coding Challenge held in 2004-2005. | ||
|
||
As a code example, this source shows the following: | ||
* How to create a minimal and portable ad hoc framework | ||
for small testing/demonstration programs. This framework | ||
compiles for both desktop and PocketPC Win32 environment, | ||
and a separate source is included for Linux with X11. | ||
* How to dynamically find and use the OpenGL ES DLL or | ||
shared object, so that the library is not needed at | ||
the compile/link stage. | ||
* How to use the basic features of OpenGL ES 1.0/1.1 | ||
Common Lite, such as vertex arrays, color arrays and | ||
lighting. | ||
* How to create a self contained small demonstration | ||
application with objects generated using procedural | ||
algorithms. | ||
|
||
As the original version was optimized for size instead of | ||
performance, that holds true for this OpenGL ES version as | ||
well. Thus the performance could be significantly increased, | ||
for example by changing the code to use glDrawElements | ||
instead of glDrawArrays. The code uses only OpenGL ES 1.0 | ||
Common Lite -level function calls without any extensions. | ||
|
||
The reference OpenGL ES implementations used for this application: | ||
* Hybrid's OpenGL ES API Implementation (Gerbera) version 2.0.4 | ||
Prebuilt Win32 PC executable: SanOGLES-Gerbera.exe | ||
* PowerVR MBX SDK, OpenGL ES Windows PC Emulation version 1.04.14.0170 | ||
Prebuilt Win32 PC executable: SanOGLES-PVRSDK.exe | ||
|
||
Note that DISABLE_IMPORTGL preprocessor macro can be used | ||
to specify not to use dynamic runtime binding of the library. | ||
You also need to define preprocessor macro PVRSDK to compile | ||
the source with PowerVR OpenGL ES SDK. | ||
|
||
The demo application is briefly tested with a few other OpenGL ES | ||
implementations as well (e.g. Vincent, GLESonGL on Linux, Dell | ||
Axim X50v). Most of these other implementations rendered the demo | ||
erroneously in some aspect. This may indicate that the demo source | ||
could still have some work to do with compatibility and correct | ||
API usage, although the non-conforming implementations are most | ||
probably unfinished as well. | ||
|
||
Thanks and Acknowledgements: | ||
|
||
* Toni L�nnberg (!Cube) created the music for original version, which | ||
is not featured in this OpenGL ES port. | ||
* Sara Kapli (st Rana) for additional camera work. | ||
* Paul Bourke for information about the supershapes. | ||
|
||
------------------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* San Angeles Observation OpenGL ES version example | ||
* Copyright 2009 The Android Open Source Project | ||
* All rights reserved. | ||
* | ||
* This source is free software; you can redistribute it and/or | ||
* modify it under the terms of EITHER: | ||
* (1) The GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at | ||
* your option) any later version. The text of the GNU Lesser | ||
* General Public License is included with this source in the | ||
* file LICENSE-LGPL.txt. | ||
* (2) The BSD-style license that is included with this source in | ||
* the file LICENSE-BSD.txt. | ||
* | ||
* This source is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files | ||
* LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. | ||
*/ | ||
#include <jni.h> | ||
#include <sys/time.h> | ||
#include <time.h> | ||
#include <android/log.h> | ||
#include <stdint.h> | ||
#include "importgl.h" | ||
#include "app.h" | ||
|
||
int gAppAlive = 1; | ||
|
||
static int sWindowWidth = 320; | ||
static int sWindowHeight = 480; | ||
static int sDemoStopped = 0; | ||
static long sTimeOffset = 0; | ||
static int sTimeOffsetInit = 0; | ||
static long sTimeStopped = 0; | ||
|
||
static long | ||
_getTime(void) | ||
{ | ||
struct timeval now; | ||
|
||
gettimeofday(&now, NULL); | ||
return (long)(now.tv_sec*1000 + now.tv_usec/1000); | ||
} | ||
|
||
/* Call to initialize the graphics state */ | ||
void | ||
Java_com_example_SanAngeles_DemoRenderer_nativeInit( JNIEnv* env ) | ||
{ | ||
importGLInit(); | ||
appInit(); | ||
gAppAlive = 1; | ||
} | ||
|
||
void | ||
Java_com_example_SanAngeles_DemoRenderer_nativeResize( JNIEnv* env, jobject thiz, jint w, jint h ) | ||
{ | ||
sWindowWidth = w; | ||
sWindowHeight = h; | ||
__android_log_print(ANDROID_LOG_INFO, "SanAngeles", "resize w=%d h=%d", w, h); | ||
} | ||
|
||
/* Call to finalize the graphics state */ | ||
void | ||
Java_com_example_SanAngeles_DemoRenderer_nativeDone( JNIEnv* env ) | ||
{ | ||
appDeinit(); | ||
importGLDeinit(); | ||
} | ||
|
||
/* This is called to indicate to the render loop that it should | ||
* stop as soon as possible. | ||
*/ | ||
|
||
void _pause() | ||
{ | ||
/* we paused the animation, so store the current | ||
* time in sTimeStopped for future nativeRender calls */ | ||
sDemoStopped = 1; | ||
sTimeStopped = _getTime(); | ||
} | ||
|
||
void _resume() | ||
{ | ||
/* we resumed the animation, so adjust the time offset | ||
* to take care of the pause interval. */ | ||
sDemoStopped = 0; | ||
sTimeOffset -= _getTime() - sTimeStopped; | ||
} | ||
|
||
|
||
void | ||
Java_com_example_SanAngeles_DemoGLSurfaceView_nativeTogglePauseResume( JNIEnv* env ) | ||
{ | ||
sDemoStopped = !sDemoStopped; | ||
if (sDemoStopped) | ||
_pause(); | ||
else | ||
_resume(); | ||
} | ||
|
||
void | ||
Java_com_example_SanAngeles_DemoGLSurfaceView_nativePause( JNIEnv* env ) | ||
{ | ||
_pause(); | ||
} | ||
|
||
void | ||
Java_com_example_SanAngeles_DemoGLSurfaceView_nativeResume( JNIEnv* env ) | ||
{ | ||
_resume(); | ||
} | ||
|
||
/* Call to render the next GL frame */ | ||
void | ||
Java_com_example_SanAngeles_DemoRenderer_nativeRender( JNIEnv* env ) | ||
{ | ||
long curTime; | ||
|
||
/* NOTE: if sDemoStopped is TRUE, then we re-render the same frame | ||
* on each iteration. | ||
*/ | ||
if (sDemoStopped) { | ||
curTime = sTimeStopped + sTimeOffset; | ||
} else { | ||
curTime = _getTime() + sTimeOffset; | ||
if (sTimeOffsetInit == 0) { | ||
sTimeOffsetInit = 1; | ||
sTimeOffset = -curTime; | ||
curTime = 0; | ||
} | ||
} | ||
|
||
//__android_log_print(ANDROID_LOG_INFO, "SanAngeles", "curTime=%ld", curTime); | ||
|
||
appRender(curTime, sWindowWidth, sWindowHeight); | ||
} |
Oops, something went wrong.