SHARE
TWEET

draw

a guest Dec 4th, 2014 146 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public void draw(float[] mvpMatrix)
  2.         {
  3.                 GLES20.glUseProgram(m_shader.getProgramID());
  4.                 {
  5.                         enableVertexAttrib();
  6.                         for(Map.Entry<String, OBJDatas> entry : m_objDatas.entrySet())
  7.                         {
  8.                                 OBJDatas currentDatas = entry.getValue();
  9.                                 GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, currentDatas.vboID);
  10.                                 {
  11.                                         //Send the vector attribute
  12.                                         int stride = 12;
  13.                                         GLES20.glVertexAttribPointer(m_shaderAttrib.get("vPosition"), 3, GLES20.GL_FLOAT, false, stride, 0);
  14.                                         GLES20.glVertexAttribPointer(m_shaderAttrib.get("vNormal"), 3, GLES20.GL_FLOAT, false, stride, currentDatas.vertexPositionLength*4);
  15.  
  16.                                         int mvpMatrixHandle = GLES20.glGetUniformLocation(m_shader.getProgramID(), "uMVP");
  17.                                         GLES20.glUniformMatrix4fv(mvpMatrixHandle, 1, false, mvpMatrix, 0);
  18.  
  19.                                         int offset = 0;
  20.                                        
  21.                                         //separate call for each material
  22.                                         for(Map.Entry<String, Integer> entryMaterial : currentDatas.materialSerie.entrySet())
  23.                                         {
  24.                                                 //Init the frag shader used by the material
  25.                                                 m_materialWrapper.initFragShader(m_shader, entryMaterial.getKey());
  26.                                                 //Draw
  27.                                                 GLES20.glDrawArrays(GLES20.GL_TRIANGLES, offset, entryMaterial.getValue());
  28.                                                 offset += entryMaterial.getValue();
  29.                                         }
  30.                                 }
  31.                                 GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
  32.                         }
  33.                         disableVertexAttrib();
  34.                 }
  35.                 GLES20.glUseProgram(0);
  36.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top