What order to use for rendering? Drawable -> Texture -> Model?

Hi,

I’m currently developing a minor game for android. THe thing is that when I have more than 100 objects out rendering goes super slow. Now I’m guessing I have to many calls binding the position arrays.

my render code is as follows:

for my drawable:

Object.render(camera)
{
     // Extracts modelview and projection matrix
     model.render(modelView, modelViewProjection, texture.getHandle());
}

for my model:


void render(Matrix4f viewMatrix, Matrix4f projectionMatrix,int textureDataHandle)
{
	if(ready)
	{
		GLES20.glUseProgram(programHandle);
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0);						//Aktiverar den textur vi ska skriva till
                GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureDataHandle);	//Binder vår texturdata till den slotten
                GLES20.glUniform1i(mTextureUniformHandle, 0); 					//Passar in texturen som en uniform till programet

        
		 //Verticies
                 mPackedBuffer.position(mPositionOffset);
                 GLES20.glVertexAttribPointer(positionShaderHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, STRIDE*BYTES_PER_FLOAT, mPackedBuffer);
		
	         //Normal
                 mPackedBuffer.position(mNormalOffset);
                 GLES20.glVertexAttribPointer(normalShaderHandle, NORMAL_DATA_SIZE, GLES20.GL_FLOAT, false,STRIDE*BYTES_PER_FLOAT, mPackedBuffer);        
		
	         //Texture
                 mPackedBuffer.position(mTextureCoordinateOffset);
                 GLES20.glVertexAttribPointer(textureShaderHandle, TEXTURE_DATA_SIZE, GLES20.GL_FLOAT, false,STRIDE*BYTES_PER_FLOAT, mPackedBuffer);

                 GLES20.glEnableVertexAttribArray(positionShaderHandle);
                 GLES20.glEnableVertexAttribArray(normalShaderHandle);
                 GLES20.glEnableVertexAttribArray(textureShaderHandle);
	
                 GLES20.glUniformMatrix4fv(MVMatrixHandle, 1, false, viewMatrix.getFloats(), 0);
                 GLES20.glUniformMatrix4fv(MVPMatrixHandle, 1, false, projectionMatrix.getFloats(), 0);
        
                 GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, mPolyCount);
		}
	}

So for every object I bind the texture and then render the model.
The model is static so many objects could have the same model. This is what got me wondering if I should turn the system upside down.

Ex.

My scene with objects has a renderfunction calling all the models.render(camera)
the model binds all attributes and then
for every texture the model has it binds it and calls texture.render(camera)
the texture now calls all the objects possessing that texture with .render wich binds the modelview and modelviewprojection Matrixes and draws the object.

As a rule of thumb the more render calls the slower you will run. Try combining your textures into texture atlas; group you render calls by texture; group your objects into larger arrays so you can draw more objects per

glDrawArrays call.