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
Apress
committed
Oct 16, 2016
0 parents
commit 0031717
Showing
99 changed files
with
2,254 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,27 @@ | ||
Freeware License, some rights reserved | ||
|
||
Copyright (c) 2012 Satya Komatineni and Dave MacLean | ||
|
||
Permission is hereby granted, free of charge, to anyone obtaining a copy | ||
of this software and associated documentation files (the "Software"), | ||
to work with the Software within the limits of freeware distribution and fair use. | ||
This includes the rights to use, copy, and modify the Software for personal use. | ||
Users are also allowed and encouraged to submit corrections and modifications | ||
to the Software for the benefit of other users. | ||
|
||
It is not allowed to reuse, modify, or redistribute the Software for | ||
commercial use in any way, or for a user�s educational materials such as books | ||
or blog articles without prior permission from the copyright holder. | ||
|
||
The above copyright notice and this permission notice need to be included | ||
in all copies or substantial portions of the software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
Binary file added
BIN
+1.36 MB
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/Prog3Dgrahics_OpenGL.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/.classpath
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
33 changes: 33 additions & 0 deletions
33
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/.project
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>TestOpenGL</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
5 changes: 5 additions & 0 deletions
5
...302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/.settings/org.eclipse.jdt.core.prefs
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,5 @@ | ||
#Sat Sep 27 12:05:15 EDT 2008 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.source=1.5 |
26 changes: 26 additions & 0 deletions
26
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/AndroidManifest.xml
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,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.androidbook.OpenGL" | ||
android:versionCode="1" | ||
android:versionName="1.0.0"> | ||
<application android:icon="@drawable/icon" | ||
android:label="OpenGL Test Harness" | ||
android:debuggable="true"> | ||
<activity android:name=".TestOpenGLMainDriverActivity" | ||
android:label="OpenGL Test Harness"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name="MultiViewTestHarnessActivity" | ||
android:label="OpenGL MultiView Test Harness"/> | ||
|
||
<activity android:name="OpenGL20MultiViewTestHarnessActivity" | ||
android:label="OpenGL MultiView Test Harness"/> | ||
|
||
<uses-feature android:glEsVersion="0x00020000" /> | ||
</application> | ||
<uses-sdk android:minSdkVersion="3" /> | ||
</manifest> |
Binary file added
BIN
+31.5 KB
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/TestOpenGL.apk
Binary file not shown.
Binary file added
BIN
+30.7 KB
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/classes.dex
Binary file not shown.
Binary file added
BIN
+1.76 KB
...urceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/AbstractRenderer.class
Binary file not shown.
Binary file added
BIN
+2.83 KB
...Chapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/AbstractSingleTexturedRenderer.class
Binary file not shown.
Binary file added
BIN
+2.14 KB
...Chapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/AnimatedSimpleTriangleRenderer.class
Binary file not shown.
Binary file added
BIN
+1.2 KB
.../BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/AnimatedTriangleActivity.class
Binary file not shown.
Binary file added
BIN
+5.26 KB
...Code/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/ES20AbstractRenderer.class
Binary file not shown.
Binary file added
BIN
+1.78 KB
...onusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/ES20SimpleTriangleRenderer.class
Binary file not shown.
Binary file added
BIN
+7.66 KB
...ceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/GLES20TestRenderer.class
Binary file not shown.
Binary file added
BIN
+7.68 KB
...de/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/GLES20TriangleRenderer.class
Binary file not shown.
Binary file added
BIN
+2.38 KB
...usChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/MultiViewTestHarnessActivity.class
Binary file not shown.
Binary file added
BIN
+1.36 KB
...nusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/OpenGL15TestHarnessActivity.class
Binary file not shown.
Binary file added
BIN
+2.22 KB
...r_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/OpenGL20MultiViewTestHarnessActivity.class
Binary file not shown.
Binary file added
BIN
+1.23 KB
...BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/OpenGLTestHarnessActivity.class
Binary file not shown.
Binary file added
BIN
+1.8 KB
...ourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/PolygonRenderer.class
Binary file not shown.
Binary file added
BIN
+352 Bytes
...-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R$attr.class
Binary file not shown.
Binary file added
BIN
+441 Bytes
...0-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R$drawable.class
Binary file not shown.
Binary file added
BIN
+882 Bytes
...02-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R$id.class
Binary file not shown.
Binary file added
BIN
+406 Bytes
...930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R$layout.class
Binary file not shown.
Binary file added
BIN
+405 Bytes
...-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R$menu.class
Binary file not shown.
Binary file added
BIN
+398 Bytes
...2-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R$raw.class
Binary file not shown.
Binary file added
BIN
+603 Bytes
...-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/R.class
Binary file not shown.
Binary file added
BIN
+5.89 KB
...SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/RegularPolygon.class
Binary file not shown.
Binary file added
BIN
+2.02 KB
...e/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/SimpleRectangleRenderer.class
Binary file not shown.
Binary file added
BIN
+1.91 KB
...de/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/SimpleTriangleRenderer.class
Binary file not shown.
Binary file added
BIN
+1.93 KB
...e/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/SimpleTriangleRenderer2.class
Binary file not shown.
Binary file added
BIN
+1.51 KB
...SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/SquareRenderer.class
Binary file not shown.
Binary file added
BIN
+1.85 KB
...usChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/TestOpenGLMainDriverActivity.class
Binary file not shown.
Binary file added
BIN
+2.23 KB
...e/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/TexturedPolygonRenderer.class
Binary file not shown.
Binary file added
BIN
+1.79 KB
...de/BonusChapter_OpenGL/TestOpenGL/bin/com/androidbook/OpenGL/TexturedSquareRenderer.class
Binary file not shown.
Binary file added
BIN
+16.1 KB
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/bin/resources.ap_
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/default.properties
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,14 @@ | ||
# 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. | ||
|
||
# Indicates whether an apk should be generated for each density. | ||
split.density=false | ||
# Project target. | ||
target=Google Inc.:Google APIs:8 | ||
apk-configurations= |
40 changes: 40 additions & 0 deletions
40
...1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/gen/com/androidbook/OpenGL/R.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,40 @@ | ||
/* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
* | ||
* This class was automatically generated by the | ||
* aapt tool from the resource data it found. It | ||
* should not be modified by hand. | ||
*/ | ||
|
||
package com.androidbook.OpenGL; | ||
|
||
public final class R { | ||
public static final class attr { | ||
} | ||
public static final class drawable { | ||
public static final int icon=0x7f020000; | ||
public static final int robot=0x7f020001; | ||
} | ||
public static final class id { | ||
public static final int menuGroup_Main=0x7f060000; | ||
public static final int mid_OpenGL_AnimatedTriangle=0x7f060003; | ||
public static final int mid_OpenGL_Current=0x7f06000a; | ||
public static final int mid_OpenGL_SimpleTriangle=0x7f060001; | ||
public static final int mid_OpenGL_SimpleTriangle2=0x7f060002; | ||
public static final int mid_es20_triangle=0x7f06000b; | ||
public static final int mid_multiple_figures=0x7f060009; | ||
public static final int mid_polygon=0x7f060006; | ||
public static final int mid_rectangle=0x7f060004; | ||
public static final int mid_square_polygon=0x7f060005; | ||
public static final int mid_textured_polygon=0x7f060008; | ||
public static final int mid_textured_square=0x7f060007; | ||
} | ||
public static final class layout { | ||
public static final int main=0x7f030000; | ||
} | ||
public static final class menu { | ||
public static final int main_menu=0x7f050000; | ||
} | ||
public static final class raw { | ||
public static final int robot=0x7f040000; | ||
} | ||
} |
Binary file added
BIN
+3.11 KB
...8-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/res/drawable/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.5 KB
...-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/res/drawable/robot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
ProAndroid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/res/layout/main.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
> | ||
<TextView | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:text="A Simple Main Activity. Click Menu to Proceed" | ||
/> | ||
</LinearLayout> |
38 changes: 38 additions & 0 deletions
38
...droid4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/res/menu/main_menu.xml
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,38 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- This group uses the default category. --> | ||
<group android:id="@+id/menuGroup_Main"> | ||
|
||
<item android:id="@+id/mid_OpenGL_SimpleTriangle" | ||
android:title="Simple Triangle" /> | ||
|
||
<item android:id="@+id/mid_OpenGL_SimpleTriangle2" | ||
android:title="Two Triangles" /> | ||
|
||
<item android:id="@+id/mid_OpenGL_AnimatedTriangle" | ||
android:title="Animated Triangle" /> | ||
|
||
<item android:id="@+id/mid_rectangle" | ||
android:title="Rectangle" /> | ||
|
||
<item android:id="@+id/mid_square_polygon" | ||
android:title="Square polygon" /> | ||
|
||
<item android:id="@+id/mid_polygon" | ||
android:title="Polygon" /> | ||
|
||
<item android:id="@+id/mid_textured_square" | ||
android:title="Textured Square" /> | ||
|
||
<item android:id="@+id/mid_textured_polygon" | ||
android:title="Textured Polygon" /> | ||
|
||
<item android:id="@+id/mid_multiple_figures" | ||
android:title="Multiple Figures" /> | ||
|
||
<item android:id="@+id/mid_OpenGL_Current" | ||
android:title="Current" /> | ||
|
||
<item android:id="@+id/mid_es20_triangle" | ||
android:title="ES20 Triangle" /> | ||
</group> | ||
</menu> |
Binary file added
BIN
+5.5 KB
...4_978-1-4302-3930-7_SourceCode/BonusChapter_OpenGL/TestOpenGL/res/raw/robot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
...ourceCode/BonusChapter_OpenGL/TestOpenGL/src/com/androidbook/OpenGL/AbstractRenderer.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,46 @@ | ||
package com.androidbook.OpenGL; | ||
|
||
import javax.microedition.khronos.egl.EGLConfig; | ||
import javax.microedition.khronos.opengles.GL10; | ||
|
||
import android.opengl.GLSurfaceView.Renderer; | ||
import android.opengl.GLU; | ||
|
||
//filename: AbstractRenderer.java | ||
public abstract class AbstractRenderer implements Renderer | ||
{ | ||
public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) { | ||
gl.glDisable(GL10.GL_DITHER); | ||
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, | ||
GL10.GL_FASTEST); | ||
gl.glClearColor(.5f, .5f, .5f, 1); | ||
gl.glShadeModel(GL10.GL_SMOOTH); | ||
gl.glEnable(GL10.GL_DEPTH_TEST); | ||
} | ||
|
||
public void onSurfaceChanged(GL10 gl, int w, int h) { | ||
gl.glViewport(0, 0, w, h); | ||
float ratio = (float) w / h; | ||
gl.glMatrixMode(GL10.GL_PROJECTION); | ||
gl.glLoadIdentity(); | ||
//Regular frustum | ||
gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7); | ||
//4 times bigger | ||
//gl.glFrustumf(-ratio * 4, ratio * 4, -1 * 4, 1 * 4, 3, 7); | ||
} | ||
|
||
public void onDrawFrame(GL10 gl) | ||
{ | ||
gl.glDisable(GL10.GL_DITHER); | ||
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); | ||
gl.glMatrixMode(GL10.GL_MODELVIEW); | ||
gl.glLoadIdentity(); | ||
//Straight up | ||
GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f); | ||
//Upside down | ||
//GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, -1.0f, 0.0f); | ||
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); | ||
draw(gl); | ||
} | ||
protected abstract void draw(GL10 gl); | ||
} |
99 changes: 99 additions & 0 deletions
99
...sChapter_OpenGL/TestOpenGL/src/com/androidbook/OpenGL/AbstractSingleTexturedRenderer.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,99 @@ | ||
package com.androidbook.OpenGL; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import javax.microedition.khronos.egl.EGLConfig; | ||
import javax.microedition.khronos.opengles.GL10; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.opengl.GLU; | ||
import android.opengl.GLUtils; | ||
|
||
|
||
public abstract class AbstractSingleTexturedRenderer extends AbstractRenderer | ||
{ | ||
int mTextureID; | ||
int mImageResourceId; | ||
Context mContext; | ||
public AbstractSingleTexturedRenderer(Context ctx, | ||
int imageResourceId) | ||
{ | ||
mImageResourceId = imageResourceId; | ||
mContext = ctx; | ||
} | ||
public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) | ||
{ | ||
super.onSurfaceCreated(gl, eglConfig); | ||
gl.glEnable(GL10.GL_TEXTURE_2D); | ||
prepareTexture(gl); | ||
} | ||
private void prepareTexture(GL10 gl) | ||
{ | ||
|
||
int[] textures = new int[1]; | ||
gl.glGenTextures(1, textures, 0); | ||
|
||
mTextureID = textures[0]; | ||
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); | ||
|
||
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, | ||
GL10.GL_NEAREST); | ||
gl.glTexParameterf(GL10.GL_TEXTURE_2D, | ||
GL10.GL_TEXTURE_MAG_FILTER, | ||
GL10.GL_LINEAR); | ||
|
||
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, | ||
GL10.GL_CLAMP_TO_EDGE); | ||
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, | ||
GL10.GL_CLAMP_TO_EDGE); | ||
|
||
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, | ||
GL10.GL_REPLACE); | ||
|
||
InputStream is = mContext.getResources() | ||
.openRawResource(this.mImageResourceId); | ||
Bitmap bitmap; | ||
try { | ||
bitmap = BitmapFactory.decodeStream(is); | ||
} finally { | ||
try { | ||
is.close(); | ||
} catch(IOException e) { | ||
// Ignore. | ||
} | ||
} | ||
|
||
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); | ||
bitmap.recycle(); | ||
} | ||
|
||
public void onDrawFrame(GL10 gl) | ||
{ | ||
gl.glDisable(GL10.GL_DITHER); | ||
gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, | ||
GL10.GL_MODULATE); | ||
|
||
// gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, | ||
// GL10.GL_DECAL); | ||
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); | ||
gl.glMatrixMode(GL10.GL_MODELVIEW); | ||
gl.glLoadIdentity(); | ||
GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f); | ||
|
||
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); | ||
|
||
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); | ||
|
||
gl.glActiveTexture(GL10.GL_TEXTURE0); | ||
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); | ||
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, | ||
GL10.GL_REPEAT); | ||
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, | ||
GL10.GL_REPEAT); | ||
|
||
draw(gl); | ||
} | ||
} |
Oops, something went wrong.