Jump to content
  • Advertisement
Sign in to follow this  
jagguy2

IDIRECT3DDEVICE9

This topic is 3849 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

I use this pointer in my class and main program. I pass the pointer to my class when needed but do i need to? Can i create several of these types or do i need to just create 1 for my directx project. I dont want to keep passing this pointer if i can create another in the required class. IDIRECT3DDEVICE9 *g_pd3dDevice

Share this post


Link to post
Share on other sites
Advertisement
Obviously, you only have one actual device, but you could have several pointers to it if you wanted.

E.g:


class Sprite
{
private:
IDirect3DDevice9 *Dev;

public:
Sprite(IDirect3DDevice9 *D) : Dev(D) { }

void Draw(){ /* use Dev */ }
};


Then after you init the device and create a sprite, you could pass the device pointer to the sprite's constructor to avoid having to pass around among all of Sprite's methods.

Share this post


Link to post
Share on other sites
passing it to a constructor means i can use it as a global variable or assign another pointer to it to be like a global 'public' for the class?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!