One object - one bitmap?
FenzaFenz

I'm sorry if this is a stupid question, but are Bitmaps supposed to represent one (game) object, and I should modify them as rarely as possible, working with their coordinates, sizes, ect?

Edgar Reynaldo

First, try to narrow down what it is you're asking for. What kind of game are you making? What do you need to represent an object in that game? Do you need a sprite (bitmap image), do you need position, dimensions, other attributes, etc...

A bitmap is just an image. You can do whatever you want with it.

FenzaFenz

Well, my exact question would sound like: "Is modifying bitmap (for example, when I use al_set_target_bitmap(bitmap) and add some primitives to it) expensive?"

And is it good practise to nest bitmaps?

Edgar Reynaldo

Modifying a bitmap is not terribly expensive. You're prematurely optimizing a problem that doesn't exist yet.

What do you want to do with your bitmaps? Just draw on them? Don't worry about it until it becomes a problem. In all likelihood it will never be a problem.

What do you mean 'nest' bitmaps? Use a sub-bitmap? Using a bitmap atlas is a good idea because it allows you to avoid texture switches when drawing a batch of bitmaps using al_hold_bitmap_drawing.

FenzaFenz

Thank you, that fully answers my question :)

Edgar Reynaldo

That said, al_set_target_bitmap does take a small amount of time to switch the active texture, but you don't need to worry about it until it becomes a problem. It's still a good idea to pre-draw your sprites though, and keep them cached.

Thread #616546. Printed from Allegro.cc