Page 1 of 1

C++ misery and GapiDraw

PostPosted: May 30, 2003 @ 3:29pm
by Guest
I've been a games programmer for several years, but using C rather than C++. I know this question is due to lack of C++ knowledge rather than anything wrong with GapiDraw, but it's driving me mad:

I have a drawing function/method (PlotCard) for a game. It needs to go inside the CMyApplication class so as to have access to protected variables and methods. However, I can't access that function from outside the class directly from my C code (because it's not a member of the global name space)and I can't call it by a call to myapp.PlotCard because myapp isn't a global variable (and I don't see how you *can* have a global instance of an object because it has to be constructed at runtime).

I suppose I *could* dump all my game code into the CMyApplication object (or make a dummy 'friend' object)... but that seems really over the top. All I want is some way for my C functions to access the GapiDraw drawing functions from outside the CMyApplication object, or of calling a method within that object.

I know my problem comes from lack of C++ knowledge. But I would appreciate any help.

Cheers,
Tom

PostPosted: May 30, 2003 @ 4:54pm
by Guest
eek... I've now found a disgusting workaround:

declare a global...
CMyApplication* g_myapp = NULL;

put this line in the constructor...
g_myapp = this;

and extern it elsewhere...
extern CMyApplication* g_myapp;

I'd still like it if someone could supply me with a *proper* solution though :)

PostPosted: May 30, 2003 @ 6:47pm
by InexorableTash

PostPosted: May 31, 2003 @ 3:51pm
by Guest

to c++ or not to C++

PostPosted: Jun 2, 2003 @ 10:46pm
by Conan

PostPosted: Jun 3, 2003 @ 3:52am
by golan trevize x