-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70f1d63
commit 562cfd8
Showing
10 changed files
with
1,327 additions
and
49 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 |
---|---|---|
@@ -1,52 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.learnopengles.android" | ||
android:versionCode="10" android:versionName="1.0.7.1"> | ||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:targetSdkVersion="15"/> | ||
<!-- We require OpenGL ES 2.0 --> | ||
<uses-feature | ||
android:glEsVersion="0x00020000" | ||
android:required="true" /> | ||
<application | ||
android:icon="@drawable/icon" | ||
android:label="@string/app_name"> | ||
<!-- Don't override application title. See http://stackoverflow.com/questions/3462431/how-to-name-android-application | ||
We will set this in code instead. --> | ||
<activity | ||
android:name="TableOfContents"> | ||
<intent-filter> | ||
<action | ||
android:name="android.intent.action.MAIN" /> | ||
<category | ||
android:name="android.intent.category.LAUNCHER" /> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.learnopengles.android" | ||
android:versionCode="11" | ||
android:versionName="1.0.8.1" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:targetSdkVersion="15" /> | ||
<!-- We require OpenGL ES 2.0 --> | ||
<uses-feature | ||
android:glEsVersion="0x00020000" | ||
android:required="true" /> | ||
|
||
<application | ||
android:icon="@drawable/icon" | ||
android:label="@string/app_name" > | ||
|
||
<!-- | ||
Don't override application title. See http://stackoverflow.com/questions/3462431/how-to-name-android-application | ||
We will set this in code instead. | ||
--> | ||
<activity android:name="TableOfContents" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:label="@string/lesson_one" | ||
android:name=".lesson1.LessonOneActivity"/> | ||
<activity | ||
android:label="@string/lesson_two" | ||
android:name=".lesson2.LessonTwoActivity"/> | ||
<activity | ||
android:label="@string/lesson_three" | ||
android:name=".lesson3.LessonThreeActivity"/> | ||
<activity | ||
android:label="@string/lesson_four" | ||
android:name=".lesson4.LessonFourActivity"/> | ||
<activity | ||
android:label="@string/lesson_five" | ||
android:name=".lesson5.LessonFiveActivity"/> | ||
<activity | ||
android:label="@string/lesson_six" | ||
android:name=".lesson6.LessonSixActivity"/> | ||
<activity | ||
android:label="@string/lesson_seven" | ||
android:name=".lesson7.LessonSevenActivity"/> | ||
<activity | ||
android:label="@string/lesson_eight" | ||
android:name=".lesson8.LessonEightActivity"/> | ||
</application> | ||
</activity> | ||
<activity | ||
android:name=".lesson1.LessonOneActivity" | ||
android:label="@string/lesson_one" /> | ||
<activity | ||
android:name=".lesson2.LessonTwoActivity" | ||
android:label="@string/lesson_two" /> | ||
<activity | ||
android:name=".lesson3.LessonThreeActivity" | ||
android:label="@string/lesson_three" /> | ||
<activity | ||
android:name=".lesson4.LessonFourActivity" | ||
android:label="@string/lesson_four" /> | ||
<activity | ||
android:name=".lesson5.LessonFiveActivity" | ||
android:label="@string/lesson_five" /> | ||
<activity | ||
android:name=".lesson6.LessonSixActivity" | ||
android:label="@string/lesson_six" /> | ||
<activity | ||
android:name=".lesson7.LessonSevenActivity" | ||
android:label="@string/lesson_seven" /> | ||
<activity | ||
android:name=".lesson8.LessonEightActivity" | ||
android:label="@string/lesson_eight" /> | ||
|
||
<service | ||
android:name=".livewallpaper.LessonThreeWallpaperService" | ||
android:label="@string/lesson_three_wallpaper_1" | ||
android:permission="android.permission.BIND_WALLPAPER" > | ||
<intent-filter> | ||
<action android:name="android.service.wallpaper.WallpaperService" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.service.wallpaper" | ||
android:resource="@xml/wallpaper" /> | ||
</service> | ||
<service | ||
android:name=".rbgrnlivewallpaper.LessonThreeWallpaperService" | ||
android:label="@string/lesson_three_wallpaper_2" | ||
android:permission="android.permission.BIND_WALLPAPER" > | ||
<intent-filter> | ||
<action android:name="android.service.wallpaper.WallpaperService" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.service.wallpaper" | ||
android:resource="@xml/wallpaper" /> | ||
</service> | ||
</application> | ||
|
||
</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
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,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:thumbnail="@drawable/ic_lesson_three" /> |
106 changes: 106 additions & 0 deletions
106
...ndroidOpenGLESLessons/src/com/learnopengles/android/livewallpaper/GLWallpaperService.java
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,106 @@ | ||
package com.learnopengles.android.livewallpaper; | ||
|
||
import android.content.Context; | ||
import android.opengl.GLSurfaceView; | ||
import android.opengl.GLSurfaceView.Renderer; | ||
import android.service.wallpaper.WallpaperService; | ||
import android.util.Log; | ||
import android.view.SurfaceHolder; | ||
|
||
import com.learnopengles.android.util.LoggerConfig; | ||
|
||
public abstract class GLWallpaperService extends WallpaperService { | ||
|
||
public class GLEngine extends Engine { | ||
class WallpaperGLSurfaceView extends GLSurfaceView { | ||
private static final String TAG = "WallpaperGLSurfaceView"; | ||
|
||
WallpaperGLSurfaceView(Context context) { | ||
super(context); | ||
|
||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "WallpaperGLSurfaceView(" + context + ")"); | ||
} | ||
} | ||
|
||
@Override | ||
public SurfaceHolder getHolder() { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "getHolder(): returning " + getSurfaceHolder()); | ||
} | ||
|
||
return getSurfaceHolder(); | ||
} | ||
|
||
public void onDestroy() { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "onDestroy()"); | ||
} | ||
|
||
super.onDetachedFromWindow(); | ||
} | ||
} | ||
|
||
private static final String TAG = "GLEngine"; | ||
|
||
private WallpaperGLSurfaceView glSurfaceView; | ||
private boolean rendererHasBeenSet; | ||
|
||
@Override | ||
public void onCreate(SurfaceHolder surfaceHolder) { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "onCreate(" + surfaceHolder + ")"); | ||
} | ||
|
||
super.onCreate(surfaceHolder); | ||
|
||
glSurfaceView = new WallpaperGLSurfaceView(GLWallpaperService.this); | ||
} | ||
|
||
@Override | ||
public void onVisibilityChanged(boolean visible) { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "onVisibilityChanged(" + visible + ")"); | ||
} | ||
|
||
super.onVisibilityChanged(visible); | ||
|
||
if (rendererHasBeenSet) { | ||
if (visible) { | ||
glSurfaceView.onResume(); | ||
} else { | ||
if (!isPreview()) { | ||
glSurfaceView.onPause(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "onDestroy()"); | ||
} | ||
|
||
super.onDestroy(); | ||
glSurfaceView.onDestroy(); | ||
} | ||
|
||
protected void setRenderer(Renderer renderer) { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "setRenderer(" + renderer + ")"); | ||
} | ||
|
||
glSurfaceView.setRenderer(renderer); | ||
rendererHasBeenSet = true; | ||
} | ||
|
||
protected void setEGLContextClientVersion(int version) { | ||
if (LoggerConfig.ON) { | ||
Log.d(TAG, "setEGLContextClientVersion(" + version + ")"); | ||
} | ||
|
||
glSurfaceView.setEGLContextClientVersion(version); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...nGLESLessons/src/com/learnopengles/android/livewallpaper/LessonThreeWallpaperService.java
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,12 @@ | ||
package com.learnopengles.android.livewallpaper; | ||
|
||
import android.opengl.GLSurfaceView.Renderer; | ||
|
||
import com.learnopengles.android.lesson3.LessonThreeRenderer; | ||
|
||
public class LessonThreeWallpaperService extends OpenGLES2WallpaperService { | ||
@Override | ||
Renderer getNewRenderer() { | ||
return new LessonThreeRenderer(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...penGLESLessons/src/com/learnopengles/android/livewallpaper/OpenGLES2WallpaperService.java
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,44 @@ | ||
package com.learnopengles.android.livewallpaper; | ||
|
||
import android.app.ActivityManager; | ||
import android.content.Context; | ||
import android.content.pm.ConfigurationInfo; | ||
import android.opengl.GLSurfaceView.Renderer; | ||
import android.view.SurfaceHolder; | ||
|
||
public abstract class OpenGLES2WallpaperService extends GLWallpaperService { | ||
@Override | ||
public Engine onCreateEngine() { | ||
return new OpenGLES2Engine(); | ||
} | ||
|
||
class OpenGLES2Engine extends GLWallpaperService.GLEngine { | ||
|
||
@Override | ||
public void onCreate(SurfaceHolder surfaceHolder) { | ||
super.onCreate(surfaceHolder); | ||
|
||
// Check if the system supports OpenGL ES 2.0. | ||
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | ||
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); | ||
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; | ||
|
||
if (supportsEs2) | ||
{ | ||
// Request an OpenGL ES 2.0 compatible context. | ||
setEGLContextClientVersion(2); | ||
|
||
// Set the renderer to our user-defined renderer. | ||
setRenderer(getNewRenderer()); | ||
} | ||
else | ||
{ | ||
// This is where you could create an OpenGL ES 1.x compatible | ||
// renderer if you wanted to support both ES 1 and ES 2. | ||
return; | ||
} | ||
} | ||
} | ||
|
||
abstract Renderer getNewRenderer(); | ||
} |
Oops, something went wrong.