Best 2D rendering method

Problems with Canvas, OpenGL, etc...

Best 2D rendering method

Postby Amazing Retardo » Mon Jun 14, 2010 4:43 am

Hi guys,

I'm new to this forum.. but I've been referring to a couple of the tutorials (great stuff). So.. recently I've started developing games for the android platform. Coming from a pretty decent OpenGL background, it wasn't difficult to get used to OpenGL ES (1.0/1.1 is very similar to standard OpenGL).

After reading a couple of articles and watching the videos from Google I/O (Real-Time Games) I learned that VBOs are fast and draw_texture is faster.. So to make sure this was true, I created a simple test program that attempted to render 1000 sprites unto the screen while randomly updating their positions every frame. I started the test with pre-transformed VBOs, matrix transformed VBOs (sharing the same 1 by 1 VBO and transformed with GL matrix functions) and lastly draw_texture (glDrawTexfOES).

I'm not sure if I was doing anything wrong but out of all the tests.. draw_texture performed to worst.. and surprisingly.. matrix transformed VBOs performed slightly better than pre-transformed VBOs.. o_O

I figured that bad frame rate from the VBO method was because I was drawing each image with 1 draw call as opposed to batching them, so I wrote a fourth case using a single VBO and glBufferSubData to update the positions. and true enough this was the fastest rendering method.

I'm working with a Nexus One and I'm not sure if these results are due to some issue with the Nexus One itself.

It'd be cool if someone could verify this... I've added the test program I created. Hopefully the reason why draw_texture is so slow is because of the way I'm using it.. :\
Attachments
QuadGLTest.zip
Test program I created.
(67.13 KiB) Downloaded 181 times
Amazing Retardo
Freshman
Freshman
 
Posts: 4
Joined: Mon Jun 14, 2010 4:32 am

Top

Re: Best 2D rendering method

Postby Amazing Retardo » Mon Jun 14, 2010 1:38 pm

After snooping around the internet some more, I found the SpriteMethodTest application at: http://code.google.com/p/apps-for-android and sure enough my suspicions were proven.. The draw_texture extension when run from the demo produce slightly poorer results compared to the VBO method of rendering. However it seems that canvas produces far superior results compared to its OpenGL counterparts (almost a 2 times increase in speed in most scenarios)

If this is indeed true for most android devices I will begin the conversion of my framework to use the canvas class and its draw methods. A quick question to the community, are there any differences (in terms of functionality) between canvas and OpenGL ES 1.0/1.1 when dealing with 2D graphics?
Amazing Retardo
Freshman
Freshman
 
Posts: 4
Joined: Mon Jun 14, 2010 4:32 am

Re: Best 2D rendering method

Postby ShadowKntSDS » Mon Jun 14, 2010 4:51 pm

From my experience, if you need to draw a lot of different textures to the screen multiple times, an atlas texture and a VBO is the fastest way on most hardware. If you need to draw 1 or 2 sprites, drawTex is very fast, and can be more efficient (less GL calls) than setting up a full VBO for those one or two sprites.

I have heard that the newer phones (droid, N1, etc) have some acceleration for 2d. I get slightly faster results with Canvas on my Droid Incredible, but i do not think this is true for the G1 era phones.
ShadowKntSDS
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 28, 2010 10:29 pm

Re: Best 2D rendering method

Postby impi » Fri Jun 18, 2010 11:33 am

what do you do, if you want Z-ordering with alpha sprites and that with big textures (multiple enemies) ?
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Top

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

Who is online

Users browsing this forum: No registered users and 2 guests