1
|
package org.distorted.library;
|
2
|
|
3
|
import java.nio.FloatBuffer;
|
4
|
|
5
|
import android.opengl.GLES20;
|
6
|
|
7
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
8
|
|
9
|
abstract class GridObject
|
10
|
{
|
11
|
protected static final int BYTES_PER_FLOAT = 4; //
|
12
|
protected static final int POSITION_DATA_SIZE= 3; // Size of the position data in elements
|
13
|
protected static final int COLOR_DATA_SIZE = 4; // Size of the color data in elements
|
14
|
protected static final int NORMAL_DATA_SIZE = 3; // Size of the normal data in elements.
|
15
|
protected static final int TEX_DATA_SIZE = 2; // Size of the texture coordinate data in elements.
|
16
|
|
17
|
protected int dataLength;
|
18
|
|
19
|
protected FloatBuffer mGridPositions,mGridColors,mGridNormals,mGridTexture;
|
20
|
|
21
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
22
|
|
23
|
void draw()
|
24
|
{
|
25
|
GLES20.glVertexAttribPointer(Distorted.mPositionH , POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mGridPositions);
|
26
|
GLES20.glVertexAttribPointer(Distorted.mColorH , COLOR_DATA_SIZE , GLES20.GL_FLOAT, false, 0, mGridColors );
|
27
|
GLES20.glVertexAttribPointer(Distorted.mNormalH , NORMAL_DATA_SIZE , GLES20.GL_FLOAT, false, 0, mGridNormals );
|
28
|
GLES20.glVertexAttribPointer(Distorted.mTextureCoordH, TEX_DATA_SIZE , GLES20.GL_FLOAT, false, 0, mGridTexture );
|
29
|
|
30
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, dataLength);
|
31
|
}
|
32
|
}
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|