www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/19/02:42:38

From: Jeff Weeks <pweeks AT execulink DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Style AND speed in C++? How? Please, I need some radical ideas on this one!
Date: 18 Apr 1997 23:00:16 GMT
Organization: Code X Software
Lines: 61
Message-ID: <5j8ue0$8gg@nr1.toronto.istar.net>
NNTP-Posting-Host: ppp7.tellus.execulink.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi everybody.

  I am currently in the works of making my own graphics library.  I've
become very interested in the inner workings of the VGA card (thank you
Mr. Abrash!) and so I've decided to dive right in.  But, I've already
reached a problem.  I'll try to explain what I'm trying to do, and I'd
like some suggests on how I should accomplish this.

I want to have the code very upgradeable.  For instance, I'd like to be
able to just include another class to add support for a new video
card/colour depth.  But I also want all this hidden from the user.  In
other words, the user uses a single class, which could be any one of the
drivers available.  I hope that makes since.  Here's what I'm sortof
looking at:

Video_Template *video;
video = new S3_driver;
video.setmode();
video.putpixel(100,100,15);

Now, I've already done this.  I've created a Video_Template class and
then all my drivers inherit from it (Video_Template defines basic
behavior... the drivers have more specific stuff).  However, this system
requires every function to be a virtual function to work correctly. 
I've tested this and the virtual functions seem to be exactly 2 times
slower!  While style is a big concern, so is speed... so virtual
functions are a no go I think.

So, does anybody know how I would go about creating a simple library
style like the above, but still retain the speed of regular C/C++?

I should also mention that in time, Video_Template will have a static
function called "autodetect" which will return a pointer to one of the
drivers detected.  Is it then possible to do something like this:

Video_Template *video;
video = new Video_Template::AutoDetect();

???  THAT is what I'm really striving for!  This would be the ideal
solution because then I could have one simple class to use, but that
class will actually be, say, an S3 driver... but the programmer doesn't
have to know that.  He/She just continues programming the same way for
every driver/video mode.


I hope I've decribed myself good enough.  If there's anything that's
unclear, PLEASE don't hesitiate to ask.  I'm really interested in this,
and I'd love to get this thing working.  Any ideas are gladly welcomed. 
Any type of critisizm is accepted (even non-constructive! :).  I'm
looking for the best style/speed combonation, and I can't do that
without other people's input.  Please, help me out here!

Jeff Weeks

--------------------------------------------
            - Code X Software -
       Programming to a Higher Power
  
  email: mailto:pweeks AT execulink DOT com
  web:	 http://www.execulink.com/~pweeks/
--------------------------------------------

- Raw text -


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