Skip to content

Commit

Permalink
Update lessons
Browse files Browse the repository at this point in the history
  • Loading branch information
learnopengles committed Jul 14, 2012
1 parent 70f1d63 commit 562cfd8
Show file tree
Hide file tree
Showing 10 changed files with 1,327 additions and 49 deletions.
127 changes: 78 additions & 49 deletions android/AndroidOpenGLESLessons/AndroidManifest.xml
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>
2 changes: 2 additions & 0 deletions android/AndroidOpenGLESLessons/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<string name="lesson_two_subtitle">Learn about ambient and diffuse lighting in this lesson.</string>
<string name="lesson_three">Lesson Three: Adding Per-Pixel Lighting</string>
<string name="lesson_three_subtitle">This builds on lesson two by adding per-pixel lighting.</string>
<string name="lesson_three_wallpaper_1">Lesson 3: GLSurfaceView</string>
<string name="lesson_three_wallpaper_2">Lesson 3: Re-implementation of GLSurfaceView</string>
<string name="lesson_four">Lesson Four: Basic Texturing</string>
<string name="lesson_four_subtitle">This builds on lesson three by adding basic texturing.</string>
<string name="lesson_five">Lesson Five: An Intro to Blending</string>
Expand Down
3 changes: 3 additions & 0 deletions android/AndroidOpenGLESLessons/res/xml/wallpaper.xml
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" />
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);
}
}
}
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();
}
}
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();
}
Loading

0 comments on commit 562cfd8

Please sign in to comment.