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

GapiDraw Book


GapiDraw Book

Postby ppcStudios » Jan 15, 2003 @ 5:41pm

Hi everyone, my name is G.R.Moore from PocketPC Studios. Some of you may already know me from my postings on this forum and the GapiDraw tutorials on the ppcstudios website.

I've begun working on a book covering game development on pocket pc devices using GapiDraw. I have a working table of contents for the book, but I would like to hear from you, the developers, what topics should be covered.

GapiDraw is easily the most popular toolkit for pocket pc game development, and it deserves a text that explains the basics as well as advanced topics in a clear and easy to understand manner. With your input and support, I think I can provide just such a book.

-- GR
User avatar
ppcStudios
pm Insider
 
Posts: 744
Joined: Aug 23, 2002 @ 3:53pm
Location: Canfield, Ohio


Sound!

Postby InexorableTash » Jan 16, 2003 @ 9:57am

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


Postby tedson » Jan 16, 2003 @ 6:01pm

tedson
pm Member
 
Posts: 85
Joined: May 29, 2002 @ 8:22pm


Postby efortier » Jan 17, 2003 @ 7:33am

User avatar
efortier
pm Insider
 
Posts: 373
Joined: May 15, 2002 @ 10:32pm


Hiding implementation

Postby InexorableTash » Jan 17, 2003 @ 6:43pm

There are several design patterns for this:

- Export only an interface

This is what Microsoft's COM does. The header file for your DLL contains only abstract base classes (interfaces) such as ISoundMixer, ISoundBuffer, etc. and a factory for creating them in a function, such as CreateSoundMixer().

This is the pattern I tend to follow since I "grew up" with it. I also use IUnknown-style refcounting since smart pointers and a good leak tracker (VC provides this free) make it transparent and easy once you have the religion.

Down side - all of your objects are referenced with pointers. This clashes with GapiDraw's simpler style. You also can't allocate on the stack.

- Get a PIMPL

This design pattern - short for Private IMPLemenetation, defines a public class definition like this in the .H you distribute:

CSoundBuffer
{
public:
// constructor, methods, etc, but no storage or anything private
private:
void* _pimpl;
}

You have a private definition for the same class when you are building the DLL which is mostly identical but has one small change:

CSoundBuffer
{
public:
// constructor, methods, etc, but no storage or anything private
private:
CSoundBufferImpl* _pimpl;
}

The constructor creates a CSoundBufferImpl and saves the pointer in _pimpl. The destructor destroys it. All of your other methods (e.g. LoadWave) simply call the real implementation on the implementation class (e.g. _pimpl->LoadWave() ).

The user will just see a normal class they can instantiate with x = new CBlahBlah() or even CBlahBlah x() for stack allocations. (If you don't know about stack allocations in C++ you're really missing out!)

Down side: Maintaining two real class implementations plus two headers is heavier weight than just maintaining an interface plus a class definition plus an implementation.

...

There are other design patterns, and a lot of references on the web about them. Google search on "hiding implementation" and "design pattern".

Note that in either of these design patterns you're going to suffer a speed hit calling the methods - in the interface method you're hitting a VTable, and in the PIMPL method there's the un-optimizable second call. So you shouldn't expect callers to use these in tight loops -- but you shouldn't be making function calls in tight loops anyway. This is one reason you have Lock()-type methods that give a caller all the data they need to do the work without calling any other methods.
User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Postby efortier » Jan 21, 2003 @ 11:15pm

I believe I will use the PIMPL, as this will allow users to use classes more easily.

Thanks for taking the time to explain these concepts. I appreciate it alot.

--Eric
User avatar
efortier
pm Insider
 
Posts: 373
Joined: May 15, 2002 @ 10:32pm


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

cron