Sign in to follow this  
InsaneBoarder234

Hooking DirectX and inheritance

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this