Sign in to follow this  
Thors1982

Problem calling functions inside BeginScene()

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this