This site is no longer active and is available for archival purposes only. Registration and login is disabled.

C++ misery and GapiDraw


C++ misery and GapiDraw

Postby Guest » May 30, 2003 @ 3:29pm

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
Guest
 


Postby Guest » May 30, 2003 @ 4:54pm

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 :)
Guest
 


Postby InexorableTash » May 30, 2003 @ 6:47pm

User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Postby Guest » May 31, 2003 @ 3:51pm

Guest
 


to c++ or not to C++

Postby Conan » Jun 2, 2003 @ 10:46pm

What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Postby golan trevize x » Jun 3, 2003 @ 3:52am

golan trevize x
 


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum