PageRenderTime 16ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Research/Example projects/Android OGL/AndroidGL/src/edu/union/GLTutorialTwo.java

https://bitbucket.org/DeveloperUX/behaviortree
Java | 44 lines | 29 code | 9 blank | 6 comment | 0 complexity | b697886c5316cf80cc49181785aeca21 MD5 | raw file
 1package edu.union;
 2
 3import java.nio.FloatBuffer;
 4
 5import javax.microedition.khronos.opengles.GL10;
 6
 7import android.content.Context;
 8import android.opengl.GLU;
 9
10/**
11 * http://www.zeuscmd.com/tutorials/opengles/07-OrthographicProjection.php
12 * @author bburns
13 */
14public class GLTutorialTwo extends GLTutorialBase { 
15	// Coordinates for a 2D square
16	float[] square = new float[] { 	-0.25f, -0.25f, 0.0f,
17									0.25f, -0.25f, 0.0f,
18									-0.25f, 0.25f, 0.0f,
19									0.25f, 0.25f, 0.0f };
20	// NIO Buffer for the square
21	FloatBuffer squareBuff;
22	
23	public GLTutorialTwo(Context c) {
24		super(c);
25		squareBuff = makeFloatBuffer(square);
26	}
27
28	protected void init(GL10 gl) {		
29		gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
30	}
31	
32	public void onDrawFrame(GL10 gl) {
33		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
34		
35		gl.glMatrixMode(GL10.GL_MODELVIEW);
36		gl.glLoadIdentity();
37		gl.glTranslatef(0,0,-1);
38		
39		gl.glColor4f(1, 0, 0, 0.5f);
40		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, squareBuff);
41		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
42		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
43	}
44}