www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/22/16:16:22

From: Shawn Hargreaves <shawn AT talula DOT demon DOT co DOT uk>
To: djgpp AT delorie DOT com
MMDF-Warning: Parse error in original version of preceding line at relay-7.mail.demon.net
Subject: RE: Style AND speed in C++? How? Please, I need some radical ideas on this one!
Date: Tue, 22 Apr 1997 14:48:17 +0100
MIME-Version: 1.0
Message-ID: <861717941.0523452.0@[194.129.18.166]>

Doug Eleveld writes:
> I'm pretty sure that the overhead of a virtual function call could cause 
> you some problems.  It's OK to use virtual function for setup or 
> something but don't use it for putpixel or linedraw.  The fastest and 
> neatest way that I can think of is to keep function pointers for all the 
> fast drawing functions, and fill them in in the constructor of whatever 
> video card.

You seem to be missing the point here: virtual functions _are_ function
pointers! That's all the virtual keyword means: it just tells the C++ 
compiler to allocate some space in the structure, fill it in with a pointer
to the code, and use this pointer whenever you call the function rather
than branching directly to it. That's exactly the same thing as using
function pointers directly in C, as I did in Allegro, but easier because
most of the hassle is taken care of by the compiler...

	Shawn Hargreaves.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019