🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How do I inherit from DirectX 7 objects

Started by
1 comment, last by GameDev.net 24 years, 8 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
};

Advertisement
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?
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