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 trying to implement drawing a line with a finger, similar to a Pencil tool in image editors. From what I've found on AndEngine, it seems like the recommended approach would be to create a line entity on every finger move, from the previous position to the new one. To me it seems rather inefficient to mimic this raster tool by vector graphics: apart from creating tens on objects per simple swipe, I guess that all these objects are repainted on each frame which is bad for speed. So I'm looking for a way to do all the painting on a bitmap canvas and draw it as a single entity. Am I missing something conceptually or did I just overlook some method?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Yes, you are missing something conceptually - AndEngine is based on OpenGL ES. Now OpenGL is very well suited to the following use case:

  1. Load a texture to bitmap memory
  2. Define texture region in the texture
  3. Create transformation (scale, position, ...)
  4. Draw the Region from the texture memory to display

AndEngine exploits this by defining a 2D sprite that is a representation of the region. It uses ortographic projection to show textured quads. It is certainly not suited for drawing on "canvas".

Using Line object is not recommended, because it is up to the OpenGL ES implementer how the line will look like in the end. Each implementation has to follow certain rules, but still the lines can look different.

So your best bet is to:

  1. Use the line and bear the consequences (I do that in my game btw)
  2. Use line texture + sprite
  3. Temporarily show something (draft using 1 or 2), then create a bitmap from it and load it to texture memory as a new texture and then show it.
share|improve this answer
    
Thank you, I've already come to the conclusion that OpenGL doesn't allow what I want, but confirmation from an experienced person is always good :) I chose to switch from OpenGL to CPU graphics. My game is pretty simple, so it should suffice. Currently I'm trying candroidengine. –  Lapis Oct 15 '13 at 13:34
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.