Problem calling functions inside BeginScene()

Started by
4 comments, last by Shadx 17 years, 10 months ago
I originally had: if(SUCCEEDED(g_pd3dDevice->BeginScene())) { Transformations(); . . worked fine... all I did was add a StateManage and move most of my functions into a class instead of everything in winmain.cpp file. Now I get an error.... if I call the Transformations(); Transformations is just a private function in the same calss. error C2352: 'application::Transformations' : illegal call of non-static member function application.h(35) : see declaration of 'application::Transformations' If this is not enough information I can post my code on a website. Since its multiple files. I hate posting errors, i like to try to figure them out but I think I just don't understand something.
Advertisement
How about you drop the "application::" ? (you're calling that method from within the same class, if I understand correctly)
The problems seems related to the fact that your calling function (the one with the code you posted) is static, and the Transformation method isn't.

A static function cannot call a non-static function. You probably don't want to make that calling function static anyway.

Cheers,
Shadx
Ahhh Shadx is completely right

I made it static to get my StateManager to work.
I am having issues with that right now :-p

thanks a lot

edit:
Actually the reason I made it static was because the person I got my StateManager (idea from) has his static. And I don't think mine will work without them being static.
I may just start from scratch...

By the way I am using the StateManager out of "Programming Role Playing Games with DirectX"
Quote:Original post by Shadx
A static function cannot call a non-static function. You probably don't want to make that calling function static anyway.


Mainly because there is no implicit 'this' for the non static function to be called on. I just thought your sentence could mislead one into thinking that non static funcs were strictly unusable in static ones. It is indeed possible to call, in your static funcion: g_pManager->Transformations(), provided you have the g_pManager instance.

Thor,

Maybe the author never intended for multiple instance of the StateManager to exist, which is why he went with static functions on a class. If that's the intent, then I would encourage you to look at either the singleton or MonoState patterns. They both achieve this in their own way, check the plus and con of each to see which one is better for you.

Good luck,
Shadx

This topic is closed to new replies.

Advertisement