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
Accessing DirectDraw object between classes?
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();
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();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement