Advertisement

How do I inherit from DirectX 7 objects

Started by October 17, 1999 03:05 PM
1 comment, last by GameDev.net 25 years, 4 months ago
The IDirectDrawSurface7 object(like all DX objects) contains no functionality, whatsoever, it is just an abstract interface. The only people who create descendent classes from it are the implementers of DX. To do what you want, you have to inherit from an internal DirectX object, which is completely unknown to you, the application developer.

To create a wrapper, you'd have to do something like the following:

class CSurface
{
private:
LPDIRECTDRAWSURFACE7 m_pdds;
DDPIXELFORMAT m_ddpf;
. . . // Whatever else
public:

CSurface();
~CSurface();
Create(...);
Blt(...);
. . . // Whatever else
};

Can I inherit an interface from a DirectX object (IDirectDrawSurface), and create a wrapper from that, or do I need to create my own functions for each interface call?
Advertisement
What mhkrause said is true, but you can inherit from the IDirectDrawSurface7 interface and implement your own functions, that redirect the call to a private pointer to an own created DDObject :

class CDrawSurface : public IDirectDrawSurface7
{
private:
LPDIRECTDRAWSURFACE7 m_pDDSurface;
public:
HRESULT Blt(...)
{ return m_pDDSurface->Blt(...); }
...
};

But you must have implementations for every function defined in IDirectDrawSurface7, because these functions are declared pure virtually.

Aidan

This topic is closed to new replies.

Advertisement