Hooking DirectX and inheritance

Started by
2 comments, last by jollyjeffers 16 years, 8 months ago
I've just read the following thread about hooking Direct3D http://www.gamedev.net/community/forums/topic.asp?topic_id=359794 I'm just curious as to why all of the member functions for the appropriate interfaces have to be implemented in order to hook Direct3D like this? I would have thought that inheritance would have took care of the functionality that isn't overloaded? Can anyone explain this for me?
Progress is born from the opportunity to make mistakes.

My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
Advertisement
Quote:Original post by InsaneBoarder234
I've just read the following thread about hooking Direct3D http://www.gamedev.net/community/forums/topic.asp?topic_id=359794

I'm just curious as to why all of the member functions for the appropriate interfaces have to be implemented in order to hook Direct3D like this? I would have thought that inheritance would have took care of the functionality that isn't overloaded?

Can anyone explain this for me?
The IDirect3D9 (or whatever) interface is full of pure virtual functions; they don't have an implementation. When you derive from that class, you need to implement all of the function in it (Even if they do nothing, or just call the real object's members).
Ah of course, hence the I in the class name. In that case, would it not be possible to inherit from an implemented DirectX class? - Although to be honest I'm thinking that such a class would be hidden away so it would take a hack to inherit from such a class.
Progress is born from the opportunity to make mistakes.

My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
Yup, you don't want to be trying that - the whole inheritance thing with interfaces is A Bad Idea™. Last time I tried something clever like that I took a trip to memory leak city via GPF's galore; turned out that my class heirarchy was getting sliced during device/resource creation [headshake]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement