Project

General

Profile

« Previous | Next » 

Revision 55c14a19

Added by Leszek Koltunski over 7 years ago

Minor reorganization.

View differences:

src/main/java/org/distorted/library/MeshObject.java
21 21

  
22 22
import java.nio.FloatBuffer;
23 23

  
24
import android.opengl.GLES20;
25

  
26 24
///////////////////////////////////////////////////////////////////////////////////////////////////
27 25
/**
28 26
 * Abstract class which represents a Mesh, ie 3 arrays of Vertex attributes: 1) positions
......
33 31
 */
34 32
public abstract class MeshObject
35 33
   {
36
   protected static final int BYTES_PER_FLOAT   = 4; //
37
   protected static final int POSITION_DATA_SIZE= 3; // Size of the position data in elements
38
   protected static final int NORMAL_DATA_SIZE  = 3; // Size of the normal data in elements.
39
   protected static final int TEX_DATA_SIZE     = 2; // Size of the texture coordinate data in elements. 
34
   static final int BYTES_PER_FLOAT   = 4; //
35
   static final int POSITION_DATA_SIZE= 3; // Size of the position data in elements
36
   static final int NORMAL_DATA_SIZE  = 3; // Size of the normal data in elements.
37
   static final int TEX_DATA_SIZE     = 2; // Size of the texture coordinate data in elements.
40 38

  
41
   protected int dataLength;
42
   protected FloatBuffer mMeshPositions, mMeshNormals, mMeshTexture;
39
   int dataLength;
40
   FloatBuffer mMeshPositions, mMeshNormals, mMeshTexture;
43 41

  
44 42
   final float zFactor; // strange workaround for the fact that we need to somehow store the 'depth'
45 43
                        // of the Mesh. Used in DistortedEffects. See DistortedTexture.getDepth().
......
50 48
     {
51 49
     zFactor = factor;
52 50
     }
53

  
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

  
56
   void draw()
57
     { 
58
     GLES20.glVertexAttribPointer(Distorted.mMainProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mMeshPositions);
59
     GLES20.glVertexAttribPointer(Distorted.mMainProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mMeshNormals);
60
     GLES20.glVertexAttribPointer(Distorted.mMainProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mMeshTexture);
61

  
62
     GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, dataLength); 
63
     }
64 51
   }
65

  
66
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff