Is there any performance difference between using drawanim with just one fixed frame or a simple drawsprite?
Thanks in advance.
Hmm... i think DRAWSPRITE are a littlebit faster... but POLYVECTOR are much faster :)
I can image that drawanim is slower because has to handle the animation but I don´t get the difference between drawsprite and polyvector altought I´ve read several times that is faster.
Can you explain the differences a little deeper?
I ask you this because coding an iPhone app I tried to use polyvector instead of drawsprite on a simple scroll algorithm and got better results with drawsprite.
on the iPhone a POLYVECTOR is much faster _if_ you draw a lot of triangles in between STARTPOLY and ENDPOLY. That's because the calls to glDrawArrays should be limited on the iPhone chip.
What about not on an iPhone - should I create a custom "drawanim" function that creates a polyvector instead and use it in place of any "drawanim" commands?
Quote from: Kitty Hello on 2009-Oct-28
on the iPhone a POLYVECTOR is much faster _if_ you draw a lot of triangles in between STARTPOLY and ENDPOLY. That's because the calls to glDrawArrays should be limited on the iPhone chip.
Now I think I get it:
We use POLYVECTOR to define sort of "planar 3D object" with certain texture, and then draw parts of that object with start/end poly.
So if I'm drawing a 2d platformer with lots of tiles (ground, sky, stairs, player, enemies, coins, whatever) and if I put all those tiles on a single texture, and then draw it all inside one POLYVECTOR command it would be treated as ONE draw-call?
So, my dream of having 16-bit style rpg/platformer with lots of tiles would indeed be possible on iPhone...
Oh man, I HAVE to buy myself a Mac finally... oh priorities in life, oh the fate... :'(
Sorry but I don´t get the point.
How could I draw the entire screen composed with several tiles using just one startpoly-endpoly call?
How should I asign the different textures?
I have tried to do it using one call for each tile but don´t know how to draw the full tile screen with just one call.
Maybe colud you post some example?
The same as you would do with DRAWANIM. Just put several tiles on one image. Here's what I use for Wumbo:
STARTPOLY sprite_id%, TRUE
FOR x=0 to 100
FOR y=0 to 100 ...
pQuad(hit[x][y], x*32, y*32)
NEXT
NEXT
FUNCTION pQuad%: i%, x,y
IF g_polydraw%=FALSE; DRAWANIM 0, i, x,y; RETURN; ENDIF
LOCAL tx, ty
tx = MOD(i, 20)*32
ty = (i/20)*32
LOCAL txh=tx+32
LOCAL tyh=ty+32
LOCAL xw=x+32, yw=y+32
POLYVECTOR x, y, tx, ty, 0xffffff
POLYVECTOR x, yw, tx, tyh,0xffffff
POLYVECTOR xw, yw, txh,tyh,0xffffff
POLYVECTOR xw, yw, txh,tyh,0xffffff
POLYVECTOR xw, y, txh,ty, 0xffffff
POLYVECTOR x, y, tx ,ty, 0xffffff
ENDFUNCTION
Thanks for the code, Gernot.
Don´t know why but I didn´t understand the polyvector tx, ty textures coordinates.
I have modified my code using polyvectors and my frame speed is near the same as with drawsprite. Is not faster. :'(
I´m drawing between 110 and 150 tiles per frame (using 2 startpolys calls, because I have 2 scroll layers), each tile is 32x32.
With such a quantity of triangles, shouldn´t I see some perfomance improvement with polyvector?
I have no idea. My game came a bit faster this way.
Quote from: kaotiklabs on 2009-Oct-28
I have modified my code using polyvectors and my frame speed is near the same as with drawsprite. Is not faster. :'(
I´m drawing between 110 and 150 tiles per frame (using 2 startpolys calls, because I have 2 scroll layers), each tile is 32x32.
You have to draw only visible tiles on the screen!
Thats much faster, i made a map with 3 layers and > 1 mio. tiles on it ;)
My tile engine draws 2400 tiles on the screen in eight layers with 60 FPS on a GP2X :-) Sounds like the iPhone is more tricky to program for?
Quote from: Moru on 2009-Oct-29
My tile engine draws 2400 tiles on the screen in eight layers with 60 FPS on a GP2X :-) Sounds like the iPhone is more tricky to program for?
Yes ,you are right, is not as fast as I thought.
Quote from: Schranz0r on 2009-Oct-29
You have to draw only visible tiles on the screen!
Thats much faster, i made a map with 3 layers and > 1 mio. tiles on it ;)
Schranz0r I´m not sure if I understand you.
I´m not drawing total transparent tiles but I´m drawing tiles on the background that are overlaped but tiles on the foreground. If you are refering to the second option, I don´t imagine how to calculate and avoid this drawing. any idea?
I also have tried to use alphamode with a startpoly-endpoly but divides the performance per 2 :'( Using drawsprite was quite fast.
I think he means that you don't need to draw tiles that are outside the screen at the moment but I'm sure you don't do that anyway.
Of course I´m not doing that way, I promise I read scroll lesson 1 =D
If it helps, I´m posting here one of the scroll loops.
With this code I´m only getting a very jumpy framerate of 32-46 fps, using two scroll layers.
Its a 32x32 tile based system, 16 files , 8 columns
As I´m using a background image, tile 0 is used for not drawing the tile in order to show the background image and save transparency calculations.
//=============================================================================
SUB LayerDRAW:
//=============================================================================
LOCAL x%,y%,dx%,dy%,p%
p=INTEGER(scrollx / 32 /2)*8
dx=0-(bAND(scrollx,63) /2)
STARTPOLY imglevel00, TRUE
FOR x=0 TO 15
dy=0
FOR y=0 TO 7
IF Layer.Map[p] <> 0 then PolyQuad(Layer.Map[p], dx, dy)
INC dy,32
INC p,1
NEXT
INC dx,32
NEXT
ENDSUB
Quote from: Moru on 2009-Oct-29
My tile engine draws 2400 tiles on the screen in eight layers with 60 FPS on a GP2X :-)
Moru, maybe are you talking about your published tilemap engine? If it is, I will take a look to the code...
Yes, I was unable to get a single background quad underneath the scrolling playfield as well.
Did anyone manage to get 2 layers at 60 FPS? I'd be really interested if it's possible at all.
Hmm
I was looking at code by KH and Kaoti..
I noticed ENDPOLY is missing from both codes.
Perhaps this is the thorn in your paw.
Sorry, I forgot to type it in the post, but is in my app code.
Unluckily, it seems is not as simple as a silly mistake.
I don´t really know if is a performance problem related with the platform or with GLBasic.
I have played some games not related with GLBasic that scrolled so smooth.
You can try for example the lite version of Knights Onrush by chillingo. the smoothness is awesome.
So must be something related with GL.
Knights Onrush has much bigger thus less sprites. iPhone programming seems a lot of tweaking.
Quote from: Kitty Hello on 2009-Oct-29
Knights Onrush has much bigger thus less sprites. iPhone programming seems a lot of tweaking.
Yes, I agree, the iTouch needs care and lots of optimising. But its all possible, GLBASIC has more than enough horsepower to do most things on this little gadget (my 2 cents) . =D
Just for information.
I´ve tried severals ways of drawing a 3 layers scroll, tiles 32x32, 16 files, 8 columns.
I only apply alpha textures to one of my layers.
The two layers without alpha can be drawn using polys. Using one poly for each layer or one for all makes no difference even it has more polys to draw in one call and should be a litle faster.
The layer with alpha has to be drawn separetly because alpha with polyvector is performing horrible. So I use drawanim there.
Using 2 layers with polyvector and the other with drawanim I reach 41-43 fps without moving the scroll.
When the scroll is moved, the fps falls to 36.
Drawing the 3 layers with drawanim I reach 40-43 fps without moving the scroll.
When the scroll is moved, the fps falls to 35.
So, at least in my case, don´t mind wich method to use.
As KH said, maybe to reach a good performance, the tile size should be generously increased.
Maybe 64x64 tiles would be a better option.
I also agree, 64 x 64 tile sizes will most probably work well. After the release of my game (soon now) I have an idea for a sideway scroller so this is something I will also be looking at. :'(
Hi, I´ve modified the thread name because is more representative and easy to find.
I have found some interesting posts that expose a bit the performance problems that opengl developers are facing with tilemaps ont the iphone.
I hope this can help to improve the performance on glbasic. Forgive me if I´m posting something you allready know...
I was reading the comments of this interesting thread talking about iphone drawing speed (http://abepralle.wordpress.com/2009/05/06/iphone-drawing-speed/ (http://abepralle.wordpress.com/2009/05/06/iphone-drawing-speed/)) when I found those comnents...
"This guy has a tutorial and is claming 310,000 polys per second, or over 5,100 per frame. Is he taking a totally different approach?"
So I follow the link and it seems very interesting. Don´t know if this could help, eitherway hope it helps...
Here the links:
Improving OpenGL performance on iPhone
http://www.sunsetlakesoftware.com/2008/08/05/lessons-molecules-opengl-es (http://www.sunsetlakesoftware.com/2008/08/05/lessons-molecules-opengl-es)
http://www.sunsetlakesoftware.com/2009/01/13/opengl-es-catransform3d (http://www.sunsetlakesoftware.com/2009/01/13/opengl-es-catransform3d)