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
/
ColorSample2.java
‹r14
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.badlogic.gamedev.samples;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL10;
import android.os.Bundle;
import com.badlogic.gamedev.tools.GameActivity;
import com.badlogic.gamedev.tools.GameListener;
public class ColorSample2 extends GameActivity implements GameListener
{
private FloatBuffer vertices;
private FloatBuffer colors;
public void onCreate( Bundle savedInstance )
{
super.onCreate( savedInstance );
setGameListener( this );
}
@Override
public void setup(GameActivity activity, GL10 gl)
{
ByteBuffer buffer = ByteBuffer.allocateDirect( 3 * 4 * 3 );
buffer.order(ByteOrder.nativeOrder());
vertices = buffer.asFloatBuffer();
vertices.put( -0.5f );
vertices.put( -0.5f );
vertices.put( 0 );
vertices.put( 0.5f );
vertices.put( -0.5f );
vertices.put( 0 );
vertices.put( 0 );
vertices.put( 0.5f );
vertices.put( 0 );
vertices.rewind();
buffer = ByteBuffer.allocateDirect( 3 * 4 * 4 );
buffer.order(ByteOrder.nativeOrder());
colors = buffer.asFloatBuffer();
colors.put( 1 );
colors.put( 0 );
colors.put( 0 );
colors.put( 1 );
colors.put( 0 );
colors.put( 1 );
colors.put( 0 );
colors.put( 1 );
colors.put( 0 );
colors.put( 0 );
colors.put( 1 );
colors.put( 1 );
colors.rewind();
}
@Override
public void mainLoopIteration(GameActivity activity, GL10 gl)
{
gl.glViewport( 0, 0, activity.getViewportWidth(), activity.getViewportHeight() );
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY );
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertices);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY );
gl.glColorPointer( 4, GL10.GL_FLOAT, 0, colors );
gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
}
}
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
r14
by quantumgame on Jan 8, 2010
Diff
[No log message]
All revisions of this file
File info
Size: 1930 bytes, 80 lines
View raw file
Powered by
Google Project Hosting