Accessing DirectDraw object between classes?

Started by
11 comments, last by Nali 22 years, 3 months ago
BTW I noticed something, if I remember the standard used by windows programers in the line :
LPDIRECTDRAWSURFACE *pLpDDSBuffer
you are creating a pointer to a pointer
so thats why you have the error
you can use either LPDIRECTDRAWSURFACE pLpDDSBuffer or DIRECTDRAWSURFACE *pLpDDSBuffer
humanity will always be slaved by its ignorance
Advertisement
hm... I think I understand the basics of singletons..
but I didnt get the code to work

this is how it looks now:
class C_Game
{
LPDIRECTDRAW m_lpDD;
LPDIRECTDRAWSURFACE m_lpDDsPrimary;
LPDIRECTDRAWSURFACE m_lpDDsBuffer;

C_Game();

public:

LPDIRECTDRAWSURFACE GetBuffer(void) { return(m_lpDDsBuffer); }
LPDIRECTDRAWSURFACE GetPrimary(void) { return(m_lpDDsPrimary); }
LPDIRECTDRAW GetDD(void) {return(m_lpDD);}

static C_Game* GetObj()
{
static C_Game m_pObj;
return &m_pObj;
}
private:
...
};

in C_Menu I added C_Game *m_pGame under the private directive

but I get this error:
error C2352: ''C_Game::GetBuffer'' : illegal call of non-static member function

when I use this code in the C_Menu constructor
m_pGame = C_Game::GetObj();
m_plpDDsBuffer = C_Game::GetBuffer();

m_pGame->GetBuffer();


That should work.

This topic is closed to new replies.

Advertisement