Archived

This topic is now archived and is closed to further replies.

Making function return LPDIRECT3DDEVICE9 , need to cleanup?

This topic is 5149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ive got a function in a class that returns LPDIRECT3DDEVICE9, for the lp_Device. Im wondering if i need to clean it up somehow? eg
LPDIRECT3DDEVICE9 lp_Device;
//whatever

//whatever

LPDIRECT3DDEVICE9 getDevice()
{
    return lp_Device;
}

Share this post


Link to post
Share on other sites
Making it inline and const would make sense.

Past that, for a function that''s so simple there isn''t much more you could do to the actual function.

If that function isn''t ever meant to be called unless a device has been set up, you might want to put an assert in there to warn about that.


Perhaps a greater question is why you need to return a device pointer from a class in the first place - it might indicate you''re trying to wrap a D3D device too tightly/closely or a poorly thought out class hierarchy/design with dependencies which need access to such low level things.

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
i wanted to make other classes that create things like textures etc

eg

Texture myTexture("filename.bmp");

which requries the device to load...

with the main d3d class being singleton i wanted it to return a value instead of directly accessing it

Share this post


Link to post
Share on other sites