3

im testing the android SpriteMethodTest and on default settings canvas is getting 58fps while open gl is between 50-55fps, and the gap just gets larger with more sprites.

I was under the impression that opengl is faster than canvas so is this wrong? or is their something wrong with my phone (htc desire)?

http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest/

Gray
  • 115,027
  • 24
  • 293
  • 354
MindlessBarber
  • 1,590
  • 6
  • 22
  • 39

6 Answers6

7

It should be noted that SpriteMethodTest is not using OpenGL at maximum efficiency. Each sprite is being rendered with its own set of GL calls, where ideally many sprites should be batched into as few calls to OpenGL as possible.

THere's a sprite-rendering performance shootout happening over at JavaGaming.org right now, and libGDX is the current frontrunner. When handled correctly, OpenGL is the fastest way to draw stuff.

ryanm
  • 2,979
  • 18
  • 22
  • That sounds like the sanest answer. I never checked out the referenced code (SpriteMethodTest), but if it's really drawing each spite with separate set of GL calls, it is way far from efficient. – ognian Mar 25 '11 at 12:01
  • 1
    @ognian I've just had a closer look, not only is every quad being rendered separately, there's a texture bind **per quad**. To put it mildly, _ouch_. – ryanm Mar 25 '11 at 12:07
1

Probably you're not measuring it correct. How many sprites are you using? The FPS will probably be the same with < 10 sprites but as soon you're start increasing the number of sprites the OpenGL system will definitely beat the Canvas system.

For further information about this topic, see this.

Community
  • 1
  • 1
Wroclai
  • 26,835
  • 7
  • 76
  • 67
  • just tried it with 1000 animated sprites canvas: 12fps opengl basic vert quads: 10fps opengl draw texture extension: 11fps opengl vbo extension: 11fps – MindlessBarber Mar 18 '11 at 16:58
  • @ng93: That can't be correct. Regular Vertex Arrays are like the `Canvas` system but the Vertex Buffer Objects and draw_texture should beat the `Canvas` system. Post some screenshots where I can see your actual results. – Wroclai Mar 18 '11 at 17:03
  • GL is not necessarily faster. If you draw a LOT of sprites you will run into fillrate issues. Drawing a sprite in software can be pretty efficient and if you have a lot of memory bandwidth, it can be fast. – Romain Guy Mar 18 '11 at 17:10
  • @Romain Guy: I've heard of that fill limited amount on the high end devices. I've heard Chris Pruett talk about this but as far I understood he said that it's not running slower, its just showing slower. It was something like that, although I can be wrong in this particular subject. – Wroclai Mar 18 '11 at 17:13
  • ok so even if theres no performance benefit would there be any other benefit making it worth using e.g. battery life? – MindlessBarber Mar 18 '11 at 17:20
1

You should probably first profile your code to make sure it is actually rendering where you are taking your time.

hackbod
  • 90,665
  • 16
  • 140
  • 154
  • 1
    What kind of answer is this? OP stated he's using SpriteMethodTest, not his own code. Did you even read the question? – Mark Mar 01 '13 at 12:33
0

I...can't...comment...

That is interesting I had always though OpenGL was faster as well. From my experience with my app I found GL to be much faster than the canvas but I was using all fixed point numbers.

TurqMage
  • 3,321
  • 2
  • 31
  • 52
0

That would be only possible on emulator or device without GPU

ognian
  • 11,451
  • 4
  • 35
  • 33
  • im using a htc desire which has an adreno 200 gpu – MindlessBarber Mar 25 '11 at 11:07
  • As @ryanm stated, the GL code you use to measure performance is drawing spites in the least efficient way. You should modify it to use interleaved VBOs to get real results – ognian Mar 25 '11 at 12:03
0

Just ran SpriteMethodTest on a HTC Tattoo (1.6, probably no GPU) and OpenGL is really bad compared to Canvas. If for 100 sprites I get a bit over 30fps, whereas all 3 OpenGL methods are under 5 fps. Currently I'm using Canvas to draw my game but I was thinking of using OpenGL from now on so I can implement a particle system which might be pretty sprite intensive.

Now I'm confused, if I can't get performance on low end devices with OpenGL why should I use it? Is this not the case on the majority of devices? Or maybe the method used in SpriteMethodTest isn't the best (I haven't looked at the code yet) as some people are saying?

Mihai F
  • 161
  • 2
  • 3