Reputation: 147
I'm creating small engine/framework for making games. It's kind of simple question but I haven't found an answer so I'd like to consult you.
There are some class
es derived from Graphic
with the Draw(...)
function. Draw()
will be called dozens or maybe even hundreds of times (if there are many sprites to render). Draw()
is too big to be inline (10-20 lines).
virtual
(sometimes but rather rarely I'll be using polymorphism*). I think it shouldn't affect greatly on performance but do you think it should be virtual
?The most important question is 2.
*ex. with animations
Upvotes: 1
Views: 107
Reputation: 18431
First you should choose in-memory, double-buffer drawing using BitBlt
, StretchBlt
functions.
Upvotes: 0
Reputation: 308206
Any object which needs to be drawn will be affecting a large number of pixels; it is likely that drawing itself will take much more time than calling the drawing function, so the calling overhead will be negligible. Don't worry about it until profiling shows it to be a bottleneck.
Upvotes: 2