0

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 
James M
  • 18,506
  • 3
  • 48
  • 56
Neomex
  • 1,650
  • 6
  • 24
  • 38

1 Answers1

2

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.

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149