[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: Virtual methods?
On Sat, 23 Aug 2003, Jan Ekholm wrote:
> >I think you are beeing a bit harsh here. Depending on how you approach
> >things, some people (not me) will argue that virtual methods have an
> >overhead. Personally I would never hesitate, but what if you want to call
> >10000 rendering objects pr. frame? Would it be worth the hassle to store a
> >pointer to the functions instead of relying on virtual methods?
>
> Sure, but can you prove the contrary? That open source game developers
> that micromanage optimizations before the game has even been started have
> a chance of actually getting something out? The Linux world has 10000
> games, of which 100 can be considered complete. I've added a few games to
> the 9900 dead ones in my days.
I understand your point completely, and agree. But, I do not think that
was what the original poster had in mind. Rather he was unsure of the
actual cost of using virtual method calls.
At some point in time, I didn't know that sorting your calls to opengl
after texture attributes was a good thing to do. My situation was the
opposite: ignorance about something that actually was quite expensive. I
had read two (bad) books on OpenGL - none of the mentioned that this was a
problem (well, none of them really used textures at all...). Some books
about C++ migth very well mention that there is an overhead in using
virtual methods. Until you figure out that it is neglible, how would you
know?
> Well, do a little test. Create a class hierarchy of som classes classes
> that inherit a common class, maybe a few other ones inheriting those too,
> and time it all. Then redo it using some other way. Should take an hour or
> so to setup, compile, test and draw conclusions.
Again, I agree.
Mads
--
Mads Bondo Dydensborg. madsdyd@challenge.dk
Unix is here to stay. The Internet is Unix, all network administrators cut
their teeth on Unix, and many of them say they'll give up Unix when you pry
it from their cold, dead fingers.