Reputation: 1660
I am trying to call class function, while Visual Studio throws above error at me. I have been calling another function in constructor and it works there.
What is worth mentioning, is that GameLoop is static. I have a strange feeling that this might be the cause. If it is, how do I make it work?
GameApp::GameApp()
{
winApi.CreateBasicWindow("---===| Test |===---", 1024, 768, WS_OVERLAPPEDWINDOW);
bool err = d3d.BasicInit(winApi.GetWindowHandle(),
winApi.GetInstance(),
1024,
768,
60,
1,
true);
if(!err)
MessageBox(0, "Could not initialize DirectX 10.", "Error!", MB_OK | MB_ICONERROR);
winApi.RunMessageLoop(GameLoop);
}
void GameApp::GameLoop()
{
D3DXCOLOR color(1.0f, 0.0f, 0.0f, 1.0f);
d3d.Redraw(color); // Error here
}
---- edit
Error message
Error 1 error C2228: left of '.Redraw' must have class/struct/union
Upvotes: 0
Views: 100
Reputation: 57555
If GameLoop
is static
, that means it can only access static
fields. d3d
is probably not a static field.
You probably made GameLoop static to keep a single instance of GameApp available throughout the code. To do that properly, read up on the singleton pattern, for it probably is what you are looking for.
Upvotes: 2