Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm developing an android game, where the enemies are geometrical shapes. Performance is a main goal for me so I was wondering if defining shapes directly in OpenGL would be more efficient than using sprites. Is it really faster or I'm missing something?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I think it also depends on how many shapes you're going to draw and how complex they are. If these are simple rectangles/triangles, you should choose to directly draw the geometry (because you're going to be drawing 2 triangles for each sprite anyway).

An advantage of using sprites (textured quads) is that your "sprite" can be arbitrarily complex and also have anti-aliased edges without much cost (because the edges are in the texture). This approach could potentially use a lot of graphics-memory if all your shapes happen to be different.

When drawing the geometry directly in OpenGL you don't have to care all that much about how many different shapes you have. It also works much better than the texture approach if you plan to scale your entities a lot. But if you want anti-aliased edges, you'll have to enable anti-aliasing which in turn has an impact on performance.

This probably doesn't answer your question directly. But I think the type of shape (how complex, how many different types of shapes) and how you're planning to animate it (will they be scaled, change color?) directly influence the performance of each approach.

share|improve this answer
add comment

With meshes/geometry you can get better precision and look. Performance varies on shape complexity and size.

Every point/vertex is processed by vertex shader. Every face is rasterized to pixels. Every pixel is processed by fragment shader.

So if you are drawing rounded-corner rectangle then you would get better performance with sprite, because there is minimum of transparent pixels. If you are drawing shape like alphabet 'L' then you would probably get better performance with geometry, because of high amount of transparent pixels that are processed by fragment shader.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.