My shaders look like this:
Fragment shader:
precision lowp float;
uniform sampler2D texture;
varying vec4 outColor;
varying vec2 outTexCoords;
varying vec3 outNormal;
void main()
{
vec4 color = texture2D(texture, outTexCoords) * outColor;
gl_FragColor = vec4(color.r,color.g,color.b,color.a);
}
Vertex shader:
uniform mat4 MVPMatrix; // model-view-projection matrix
uniform mat4 projectionMatrix;
attribute vec4 position;
attribute vec2 textureCoords;
attribute vec4 color;
attribute vec3 normal;
varying vec4 outColor;
varying vec2 outTexCoords;
varying vec3 outNormal;
void main()
{
outNormal = normal;
outTexCoords = textureCoords;
outColor = color;
gl_Position = MVPMatrix * position;
}
My rendering code:
public void bind(){
int stride = (2 + 3 + 4) * 4;
vertexBuffer.put(vertexArray, 0, vertexCount);
indexBuffer.put(indexArray, 0, indexCount);
this.vertexBuffer.position(0);
this.indexBuffer.position(0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexBytesAdded,
vertexBuffer, GLES20.GL_STATIC_DRAW);
ShaderAttributes attributes = graphicsSystem.getShader().getAttributes();
GLES20.glVertexAttribPointer(attributes.getAttributeID(Attribute.Position), dimensions, GLES20.GL_FLOAT, false, stride, 0);
attributes.enableAttribute(Attribute.Position);
GLES20.glVertexAttribPointer(attributes.getAttributeID(Attribute.Color), 4, GLES20.GL_FLOAT, false, stride, 3 * 4);
attributes.enableAttribute(Attribute.Color);
GLES20.glVertexAttribPointer(attributes.getAttributeID(Attribute.TextureCoords), 2, GLES20.GL_FLOAT, false, stride, (4 + 3) * 4);
attributes.enableAttribute(Attribute.TextureCoords);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexBytesAdded,
indexBuffer, GLES20.GL_STATIC_DRAW);
vertexBytesAdded = 0;
indexBytesAdded = 0;
vertexCount = 0;
indexCount = 0;
}
public void draw(int mode, int count){
if(hasIndices){
GLES20.glDrawElements(GLES20.GL_TRIANGLES, count, GLES20.GL_UNSIGNED_SHORT, 0);
}else{
GLES20.glDrawArrays(mode, 0, count);
}
}
Is there anything I can improve to increase the framerate? I'm really out of ideas here, it seems like I tried everything and I still can't get past 3000 triangles without the framerate dropping below 60. I read somewhere that MALI-400 is capable of 30 million polygons per second and I am getting only around 500,000.