SHARE
TWEET
draw
a guest
Dec 4th, 2014
146
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- public void draw(float[] mvpMatrix)
- {
- GLES20.glUseProgram(m_shader.getProgramID());
- {
- enableVertexAttrib();
- for(Map.Entry<String, OBJDatas> entry : m_objDatas.entrySet())
- {
- OBJDatas currentDatas = entry.getValue();
- GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, currentDatas.vboID);
- {
- //Send the vector attribute
- int stride = 12;
- GLES20.glVertexAttribPointer(m_shaderAttrib.get("vPosition"), 3, GLES20.GL_FLOAT, false, stride, 0);
- GLES20.glVertexAttribPointer(m_shaderAttrib.get("vNormal"), 3, GLES20.GL_FLOAT, false, stride, currentDatas.vertexPositionLength*4);
- int mvpMatrixHandle = GLES20.glGetUniformLocation(m_shader.getProgramID(), "uMVP");
- GLES20.glUniformMatrix4fv(mvpMatrixHandle, 1, false, mvpMatrix, 0);
- int offset = 0;
- //separate call for each material
- for(Map.Entry<String, Integer> entryMaterial : currentDatas.materialSerie.entrySet())
- {
- //Init the frag shader used by the material
- m_materialWrapper.initFragShader(m_shader, entryMaterial.getKey());
- //Draw
- GLES20.glDrawArrays(GLES20.GL_TRIANGLES, offset, entryMaterial.getValue());
- offset += entryMaterial.getValue();
- }
- }
- GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
- }
- disableVertexAttrib();
- }
- GLES20.glUseProgram(0);
- }
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.

