[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nel] Drivers interface pb

From: Vincent Caron
Subject: [Nel] Drivers interface pb
Date: Tue, 27 Aug 2002 20:24:49 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826


I just implemented a portable class to portably manipulate DLLs at runtime (bad and non portable code is duplicated in several places of NeL). It's called CModule, goes in 'misc', and is straightforward.

I tried to port 3D/DRU, but ran in a design pb. There's currently no mean to properly unload/free a driver. And there's a curious 'OpenGL' tying interface countering your efforts to make a portable 3D driver interface. In more details :

- There should not but such a CDRU::createGlDriver()

- There should be a :

    static IDriver* IDriver::createDriver(const std::string& module);

  We would currently load NL3D_DLL_NAME, of course ...

- And if you want to be able to release the module handle by destroying the IDriver instance, you'll have to give the module ownership to the driver:
  * pass it to the instance at init time
  * store it (use a CModule IDriver::_module member)
  * destroy it when needed (in ~IDriver())


It would be a little less ackward to have a CDriverHost class, holding the module reference, loading/instanciating/unloading the real driver. Example :

class CDriverHost
    _module = NULL;
    _driver = NULL;

  virtual ~CDriverHost()
    if (_driver) delete _driver;
    if (_module) delete _module;

  bool load(const std::string& moduleName)
    if (_module) return false;
    nlassert(_driver == NULL);

    CModule* module = new CModule(moduleName);
    if (module->load() && onLoad(module))
      _module = module;
      delete module;

  IDriver* getDriver() const { return _driver; }

  void setDriver(IDriver* driver) { _driver = driver; }

  virtual bool onLoad(CModule* module) = 0;

  CModule* _module;
  IDriver* _driver;

You can easily implement a 3D driver host by overloading the onLoad() method and doing the specific DLL and entry point discovery here.

I'd be interested in implementing the last solution, at least for the 3D and audio drivers.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]