1

Hey all, i was re-working my android app to use OpenGL instead of canvas (as it is ungodly slow) and i was wondering, since i'm using a tile sheet (atlas texture) would it be faster to use VBO's or draw_texture with the crop set like so:

// Crop our texture
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, cropRect[cropIndex], 0);
gl.glColor4f(1, 1, 1, 1);

After listening a while to Chris Pruett I gathered that draw_texture is undoubtably the fastest for an individual sprite but if i am cropping an atlas is this still true?

j0k
  • 22,600
  • 28
  • 79
  • 90
Smanger
  • 107
  • 1
  • 7

1 Answers1

2

would it be faster to use VBO's or draw_texture

Draw using atlas texture

Note that he is using a "tiled world" which explains why he is using this technique. If you're not using a tiled world you should probably go with draw_texture.

After listening a while to Chris Pruett I gathered that draw_texture is undoubtably the fastest for an individual sprite but if i am cropping an atlas is this still true?

Not always. If you're using a big atlas texture with many sprites the glTexParameteriv() function will be too expensive. If you're just using a lower amount of sprites it will probably be faster, which also depends on number of calls to the glTexParameteriv() function.

Wroclai
  • 26,835
  • 7
  • 76
  • 67
  • Well to give you an idea my atlas is 1024x1024 and at most i have about 12 sprites on screen (non static) And they do not make up a world, the "world" is a simple background image. Thanks so much for the great reply btw! – Smanger Apr 01 '11 at 21:34
  • @Alex: Then you're probably good with using `draw_texture` and `glTexParameteriv()`. – Wroclai Apr 01 '11 at 21:40
  • Thanks! But if i wanted to implement say, a particle system would that be best with a vbo setup? – Smanger Apr 01 '11 at 21:41
  • @Alex: You can go with `draw_texture`. I don't see a performance reason if I should go the VBO way. – Wroclai Apr 01 '11 at 21:44
  • Thanks for all your help really! Just for future reference, when would i want to go with the VBO approach? I mean these particle systems would be spawning 20-30 particles, but still draw texture with crop? – Smanger Apr 02 '11 at 03:18
  • @Alex: You should go with the VBO approach when `draw_texture` isn't available. – Wroclai Apr 02 '11 at 08:21
  • Okay, how needed is this would you say? Is draw_texture standard in openGL 2.0? I mean 2.0+ is nearly 90% of the market, and lower phones usually support it as well... – Smanger Apr 02 '11 at 08:23
  • @Alex: I don't know about standardizations in 2.0, but in 1.0 it's not always guaranteed to be available. With some logic thinking it should be standard in 2.0, but I don't know for sure. – Wroclai Apr 02 '11 at 08:26
  • Alright perhaps i'll start another question for that. Thank you so much! – Smanger Apr 02 '11 at 19:42