Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Objects;
- import java.nio.ByteBuffer;
- import java.nio.ByteOrder;
- import java.nio.FloatBuffer;
- import javax.microedition.khronos.opengles.GL10;
- import Physics.Physics;
- import android.opengl.GLES10;
- import android.util.Log;
- public class Player
- {
- // Physics Variables //
- public double v = 0.0;
- // // // // // // // //
- Physics phy = new Physics();
- private FloatBuffer vertexBuffer;
- private float vertices[] = {
- -0.15f, 1.0f, 0.0f, // V1 - bottom left
- -0.15f, 0.85f, 0.0f, // V2 - top left
- 0.15f, 1.0f, 0.0f, // V3 - bottom right
- 0.15f, 0.85f, 0.0f // V4 - top right
- };
- public Player()
- {
- }
- public void getVertex()
- {
- // a float has 4 bytes so we allocate for each coordinate 4 bytes
- ByteBuffer vertexByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
- vertexByteBuffer.order(ByteOrder.nativeOrder());
- // allocates the memory from the byte buffer
- vertexBuffer = vertexByteBuffer.asFloatBuffer();
- // fill the vertexBuffer with the vertices
- vertexBuffer.put(vertices);
- // set the cursor position to the beginning of the buffer
- vertexBuffer.position(0);
- }
- /** The draw method for the square with the GL context */
- public void draw(GL10 gl)
- {
- //move();
- getVertex();
- Log.i("DRAWING", "0 : DRAWING SQUARE");
- gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
- // set the colour for the square
- //gl.glColor4f(0.0f, 1.0f, 0.0f, 0.5f);
- gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- // Point to our vertex buffer
- gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
- // Draw the vertices as triangle strip
- gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
- //Disable the client state before leaving
- //gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
- Log.i("1 : DRAWING", "DRAWING SQUARE");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement