performance goes down with only 2552 triangles

Problems with Canvas, OpenGL, etc...

performance goes down with only 2552 triangles

Postby LukasBanana » Tue Mar 22, 2011 6:30 pm

Hi, for my game I'm rendering in a special level 164 objects where the most of them are only simple cubes.
In fact I'm rendering: 164 objects, 4239 vertices and 2552 triangles and the performance goes down dramatically.
I have a Samsung Galaxy S and I think 2552 triangle is not too much for hardware accelerated OpenGL also for a modern mobile device.
So where could my problem be? I process the transformation with my own matrix class and then load the matrix via GLES10.glLoadMatrix ...
But I cannot belive that this is the problem?!
Please help me.
Lukas
LukasBanana
Freshman
Freshman
 
Posts: 7
Joined: Tue Mar 08, 2011 9:01 pm

Top

Re: performance goes down with only 2552 triangles

Postby icerevenant » Tue Mar 22, 2011 11:23 pm

How many transformations do you do on signle frame draw?
My Samsung Galaxy S shows good 30 fps with over 100 000 triangles scene.
What you say is absolutely not normal.
Possible causes may be:
- opengl debugging flag
- too many glBindTexture()s?
- transormations of every vertex? =)
Anyway Galaxy S does a lot better than what you have. At least mine does.
Check everything, there's something terribly wrong, but without sources what can I guess?
icerevenant
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Mar 22, 2011 11:10 pm

Re: performance goes down with only 2552 triangles

Postby LukasBanana » Wed Mar 23, 2011 10:11 am

Is the GL debugging flag on by default?? And where can I switch this flag off?
When I'm home I will post some code of my scene management. I currently use no tree but for this small scene you normally really don't need a tree hierarchy.
LukasBanana
Freshman
Freshman
 
Posts: 7
Joined: Tue Mar 08, 2011 9:01 pm

Re: performance goes down with only 2552 triangles

Postby LukasBanana » Wed Mar 30, 2011 4:47 pm

Now I know were my mistake was: my used the "onDrawFrame" method as the main-loop for the whole game.
Now I try to use an extra Thread for the main loop and in the onDrawFrame function I do OpenGL rendering only.
This is my current code for the Thread:

Code: Select all
new Thread(new Runnable() {
   public void run() {
      while (true) { // main loop
         game.updateScene(); // Update game logic
         sceneManager.transformScene(); // Transform each object to the final GL modelview matrix
         SystemClock.sleep(25); // Wait a few milliseconds, otherwise it's too fast now
      }
   }
}).start();

/* ... */

public void onDrawFrame(GL10 gl) {
   clearBuffers(); // Clear color- and depth buffer
   sceneManager.renderScene(); // render the whole scene
}

But now I have a new problem: I think it's because the program is not thread-safe.
The App crashs relatively fast after starting the thread.

Can anyone help me how to use multi-threading in a game which uses OpenGL|ES??
LukasBanana
Freshman
Freshman
 
Posts: 7
Joined: Tue Mar 08, 2011 9:01 pm

Re: performance goes down with only 2552 triangles

Postby Orabig » Thu Apr 07, 2011 11:24 am

When you use OpenGL, you don't have to handle the GL Thread, as the SurfaceView is supposed to handle it for you.

What you have to do is :
- implement a Renderer, and assign if to your SurfaceView
- Call the SurfaceView.onResume and onPause(), which will start/stop the thread, and call your renderer onDraw(gl) method.
- And that's it. Then, you can have your own thread to call game.updateScene(), or call this method from onDraw if it's fast enough.

Good luck, OpenGl is a difficult friend, but the reward is high !
Orabig
Freshman
Freshman
 
Posts: 4
Joined: Thu Apr 07, 2011 10:37 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 3 guests