My favorites
▼
|
Sign in
android-gamedev
Android Game Development Tutorial Code
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
src
/
com
/
badlogic
/
gamedev
/
samples
/
PerspectiveSample.java
‹r20
r71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.badlogic.gamedev.samples;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLU;
import android.os.Bundle;
import com.badlogic.gamedev.tools.GameActivity;
import com.badlogic.gamedev.tools.GameListener;
import com.badlogic.gamedev.tools.Mesh;
import com.badlogic.gamedev.tools.Mesh.PrimitiveType;
public class PerspectiveSample extends GameActivity implements GameListener
{
Mesh mesh;
public void onCreate( Bundle savedInstance )
{
super.onCreate( savedInstance );
setGameListener( this );
}
@Override
public void setup(GameActivity activity, GL10 gl)
{
// we create a mesh with 3 vertices having different colors
mesh = new Mesh( gl, 6, true, false, false );
mesh.color( 0, 1, 0, 1 );
mesh.vertex( 0f, -0.5f, -5 );
mesh.color( 0, 1, 0, 1 );
mesh.vertex( 1f, -0.5f, -5 );
mesh.color( 0, 1, 0, 1 );
mesh.vertex( 0.5f, 0.5f, -5 );
mesh.color( 1, 0, 0, 1 );
mesh.vertex( -0.5f, -0.5f, -2 );
mesh.color( 1, 0, 0, 1 );
mesh.vertex( 0.5f, -0.5f, -2 );
mesh.color( 1, 0, 0, 1 );
mesh.vertex( 0, 0.5f, -2);
}
@Override
public void mainLoopIteration(GameActivity activity, GL10 gl)
{
gl.glViewport( 0, 0, activity.getViewportWidth(), activity.getViewportHeight() );
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glMatrixMode( GL10.GL_PROJECTION );
gl.glLoadIdentity();
float aspectRatio = (float)activity.getViewportWidth() / activity.getViewportHeight();
GLU.gluPerspective( gl, 67, aspectRatio, 1, 100 );
mesh.render( PrimitiveType.Triangles );
}
}
Show details
Hide details
Change log
r70
by quantumgame on Mar 10, 2011
Diff
[fixed] a couple of missing glClears...
Go to:
...ev/samples/BackgroundSample.java
...amedev/samples/CameraSample.java
...gamedev/samples/ColorSample.java
...amedev/samples/ColorSample2.java
.../gamedev/samples/MeshSample.java
...gamedev/samples/OrthoSample.java
...v/samples/PerspectiveSample.java
...v/samples/TextureMeshSample.java
...medev/samples/TextureSample.java
...edev/samples/TriangleSample.java
Project members,
sign in
to write a code review
Older revisions
r20
by quantumgame on Jan 8, 2010
Diff
[No log message]
All revisions of this file
File info
Size: 1617 bytes, 57 lines
View raw file
Powered by
Google Project Hosting