PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

PocketFrog Suggestions Thread

Well, judging by the response to the previous thread about the new torch-bearer, it seems that I will in fact wind up being the guy that maintains PF from here on out. There's still the possibility of someone else stepping up, but I'm going to start thinking as if it's me and go from here.

As soon as Gersen completes 0.2.4 of PocketFrogPlus, that will be our starting point. A few days after he delivers that, I'll package it up, adding the appropriate new documentation and whatever else might be needed, and make it available to all as PocketFrog v1.0.

To start, I'd like to open this thread up to suggestions on what we'd like to see done with PF.

Once I have a list of wishes I can start to prioritize them and hopefully get others to take portions of the work to do. I'll even try and post a very rough and loose project plan so we can all have a clear picture of timelines, when that is appropriate (and possible!)

At this point, the following things come to my mind:

(1) I'd like to add some of the functions I myself have previously posted here including:

* VGA font function for drawing text using standard 8x16 VGA non-proportional fonts

* Filled polygon function

* Flood fill, for filling arbitrary non-rectangular areas with a solid color

(2) I think I've seen people asking for a polygon function, even though it's somewhat pointless given that you can simply use the line functions now on your own, but what the hell, it should be fairly trivial to do, so why not?

(3) I forget who, but someone posted here that they had written a rotating & stretching blitter that they would be willing to integrate. I'd like to see that get added.

(4) I'd like to include as many custom pixel shaders as possible, if not directly as part of PF and always available, than at least included with the distribution. I currently have a fade shader and a greyscale shader I can include, the infrared shader has of course been posted here and can be included. If anyone has others, that would be cool.

(5) I notice that when you draw a rectangle using the current rectangle functions, the bottom right-hand corner pixel does not get blitted. Minor thing, but it should probably get resolved. I think this is the only "bug" I'm aware of.

(6) Thierry has left a couple of to-do's in the code (three I think I found). They should probably get, umm... done! :)

(7) I'd like to put together an all-encompassing tester sample app. My thought is that this app should exercise every capability of PF in something like a benchmark format (although it's not really meant for testing speed, it could be used that way). This would allow us to compile a list of devices that PF might have trouble on and perhaps even, contrary to what I just said!, benchmark information. This could help us determine what we need to do in the future to make PF better and keep it compatible with as many devices as possible. I think such a database would help all of us when releasing software as well in terms of supporting our users.

Please post anything else you guys can think of and we'll get some things moving.
Dave Johnston · 25 Feb 2003, 19:58 UTC
Would it be too much to ask (incidentally, yes, yes it would) for a PC version of PF - like GapiDraw? We would have less people asking for PC conversions that way :)

Can't think of anything else but that right now. Depends really if PF is to remain a basic (graphics) API for game development or if it eventually spans out to encompass many other things too. Personally I think it's fine as it is covering just graphics and sound (via Plus) - anything more (like integrated network functions etc) would turn it into bloatware. IMO, the focus should remain on what PF was first made for.
Kzinti · 25 Feb 2003, 20:04 UTC — PocketFrog Suggestions Thread
fzammetti wrote:
(3) I forget who, but someone posted here that they had written a rotating & stretching blitter that they would be willing to integrate. I'd like to see that get added.


It's already in PocketFrog v0.6.0. Why do you want to replace it? Not sure the API to do both at the same time is exposed, but the rastererizer code sure supports it. In fact, you can provide any transform matrix you want to the rasterizer. It is simply a matter of properly filling the matrix. See BlitRotated() and BlitStretched() for more info.


fzammetti wrote:
(5) I notice that when you draw a rectangle using the current rectangle functions, the bottom right-hand corner pixel does not get blitted. Minor thing, but it should probably get resolved. I think this is the only "bug" I'm aware of.


Not a bug, it's a feature. The Windows/DirectX convention for rects is that the last row and column of a rectangle are always excluded. It only make sense: if you are filling a rectangle with a width of 0 and a height of 0, nothing should be drawn. I kept the same convention. Not only is this more efficient, it is simpler to work with. I would strongly advise against breaking a well known convention such as this one.
I agree completely, I don't really see it growing much beyond what it is.

I can only speak for myself, but one of the biggest selling points of PF is that it really is simple to use and generally to understand. Adding a lot of other stuff would probably betray that, and I suspect most people would rather that not happen.

I'm not familiar with GapiDraw so I can't really comment on a PC version of PF. If it means what I think it does (which is to be able to use PF to write PC games), then yes, that's too much to ask! :) At least for me, if someone else wants to do it I certainly have no objection.

There are still some functions that could be considered primitives, or maybe just slightly above primitives, that make sense to add I think, but not much more. Even the sound stuff I almost wish could be decoupled from it, but that doesn't sound feasible from what Gersen has explained, so it's an exception rather than a rule. (I do have in my head to see if I can separate them though, perhaps with an abstraction layer between PF and the sound engine, that way you can plug in whatever sound engine you want... I think that is ultimately better, but I don't know that I'm going to get around to that or be able to accomplish it anyway).
A bunch of good suggestions Fzammetti. You have my full support as "the new torch bearer". And once I'm done with my thesis, I'll help you out.

(3) I forget who, but someone posted here that they had written a rotating & stretching blitter that they would be willing to integrate. I'd like to see that get added.


I think that was me. It's just a function that combines the two other blitting functions (so it is actually two blits and not a single rotate/stretch blit). The code has been posted here on PF but I intend to mail it to you (along with a rewritten version of your polyfill function) as soon as I get some time left over to double check everything.

It should be possible to write a new blit/stretch function that only blits the source ONCE. I havn't given it that much thought, but both BlitStretch() and BlitRotated() uses a transformation matrix and then calls BlitTransform(). So basicly, one should only have to multiply the two matrixes and voila! Unfortunately the two functions work a bit different so a bit more thought is required to make it work.
adde · 25 Feb 2003, 20:27 UTC — PocketFrog Suggestions Thread
Thierry wrote:
In fact, you can provide any transform matrix you want to the rasterizer. It is simply a matter of properly filling the matrix. See BlitRotated() and BlitStretched() for more info.


Heh... Thierry beat me to it.. I'm a slow writer I guess =)
Here's an idea.. Instead of rewriting PocketFrog to incorporate more features, why not build a PocketFrogExtentions library that works (seamlessly) together with PF.

As Dave J said earlier, it's important to keep the library clean and simple.
adde wrote:
A bunch of good suggestions Fzammetti. You have my full support as "the new torch bearer".


I second that support. I'm willing to help out where I can.

I'd like to see a FillRect() function that takes x and y values and a DrawRect() function that takes a Rect value.

Pam
Frank,

I think, based on what I've seen so far, you're an excellent person for the job. You've got my support, and hopefully I'll be able to make some meaningful contributions.

The one thing I'd love to see in PF is 3D functionality, even at a rudimentary level. (Perhaps using Frank's fill-poly function, where the poly's are all triangles wouldn't be too complex.) Hopefully I can get around to doing something after I finish up my next couple of projects.

Pam, I think those two functions could easily be written to just call the existing functions.

PS. Thanks for the review on PocketGamer Frank! I totally didn't expect it, and truly appreciate it.

-John
Dave Johnston wrote:
Would it be too much to ask (incidentally, yes, yes it would) for a PC version of PF - like GapiDraw? We would have less people asking for PC conversions that way :)


That's a really interesting comment, because PocketFrog first goal was to allow development on the PC. I can guarantee you that it works perfectly on the desktop PC. Although it is not using DirectX, PF on the PC outperforms PF on the PPC...
Ok, let me see if I can reply to everyone...

Thierry:
The thing about sretch & blit, we were basically just talking about exposing the functionality in the API I think. I haven't looked at it at all, so I'm going by what adde mentioned in his original post on the subject. What I was thinking is that we can do a simultaneous stretch & blit now for sure, but a combined API function would probably just make life easier. All the behind-the-scenes stuff that adde brought up I can't comment on because I haven't looked into it at all. I'm going to leave this to him in any case :)

About the rectangle thing, I was unaware of that convention, I certainly bow to your wisdom on the issue. Given that information, my thought would be an optional argument to draw that pixel or not. I know in my current project I had a lot of DrawRect functions followed by SetPixel, which is certainly not any big deal, but again as a matter of convenience it might be nice to make it an option. Thank you for the explanation though, I was unaware of it.

adde:
Finish that thesis soon, I'll probably bust your chops until your available to help :) Thank you very much for the vote of confidence as well!

As for the extensions idea, that's actually EXACTLY what I've been doing on my own. The reason I was thinking of integrating directly though is for performance reasons. Although I have nothing to support it, my suspicion is that there is a slight performance hit of not being directly part of PF (the overhead of method calls for instance). For instance, my font drawing routine would probably be more efficient if it wasn't constantly calling SetPixel. However, I noticed today that many of the internal PF functions actually do just that!, so I may have to chaneg my thinking here anyway :)

If everyone votes for an extensions library instead, I'm all for it, it's certainly easier to add to PF (gee, copy the header to the distribution?!?) and certainly easier to get direct contributions from others.

Pam:
Thank you for the support as well! Your suggestions are good ones and are on the list. The FillRect thing I think might be redundant if I add the FloodFill function, although FillRect I bet would still be more efficient.

That makes me think of something... It might be nice to have a FilledCircle as well. My thinking is that any primitive function that draws any sort of closed figure should also have a filled version, assuming that floodfill doesn't suffice or is not efficient enough.

Presto:
To you as well I thank you for the support! And your welcome for the review :) 3D functions would probably be a good idea, but that can get very far-reaching in a hurry. Just a highly-optimized triangle blitter might be doable, but going beyond that I know I certainly couldn't do.

However, if we all like the idea of extension libraries, assuming the performance doesn't prove to be a significant problem, then a 3D extension library I'm all for.

The line between what makes sense in the base library and what should be in an extension library is of course a difficult decision. To me, the following new functions make sense in the base library:

* DrawPolygon
* DrawFilledPolygon
* DrawFilledCircle
* FloodFill ... which makes Pam's FillRect(x, y) probably not needed

And the following modified functions:

* DrawRect ... that accepts a Rect and that has the option of drawing the corner pixel
* BlitRotated ... that accepts a source Rect

And then in a couple of extension libraries:

* PFE_Sound ... which would be Gersen's sound engine decoupled from PF, if this is possible. A part of this would be abstracting the sound calls so that you could swap in a different sound engine if you so choose.
* PFE_2D ... including BlitStretchRotated, DrawTextVGA (my VGA font drawing function), DrawTextBMP (text drawing using a source bitmap font, like how the FPS counter is drawn in the blit sample
* PFE_3D ... including an optimized BlitTriangle and whatever else Presto has in mind! :)
* PFE_Shaders ... a collection of pixel shaders

One other wacky idea I've had is this: if anyone remembers the C64 effect FLD (Flexible Line Distance, it was a method basically of putting space between each screen line, or scan line later on), imagine being able to do those things with PF... to do it, I think all we'd have to do is create a table of line distances and make this available to the function that flips the back buffer forward, then just use the table to calculate each line address as it goes. But, I haven't looked at that function so I don't know how it's implemented now, this might not be possible. If it's a blit than this should work fine, if it's a memcpy it obviously won't. In any case, it was just an off-the-wall idea, certainly not a priority. It would allows for crazy full-screen waves and slides and things like that (things you could do now with the library with enough code).
fzammetti wrote:
* DrawRect ... that accepts a Rect and that has the option of drawing the corner pixel


I though you were saying that DrawRect() was not filling the last row and column. If you really said that only the bottom-right corner pixel isn't draw, then this is definitely a bug and should be easy to find.

I am also aware of a clipping bug in the line drawing (Cohen-Sutherland clip routin). Someone reported it a while ago in this forum, it is quite easy to fix. I never released that fix though. It is in all versions, including v0.6.0.
Well, a Rect is left, top, right, bottom (aka x1, y1, x2, y2). So, to implement Pam's idea, we'd simply add:
Code:

// rasterizer.h
void FillRect(int x1, int y1, int x2, int y2, Pixel color);

// rasterizer.cpp
void Rasterizer::FillRect(int x1, int y1, int x2, int y2, Pixel color)
{
FillRect(Rect(x1, y1, x2, y2), color);
}

-John
I might have misunderstood, but I think Pam was asking for a function that accepts a Rect structure. So, we would actually just overload DrawRect:

Code:

// rasterizer.h
void DrawRect(Rect, Pixel);

// rasterier.cpp
void Rasterizer::DrawRect(Rect rect, Pixel color) {
DrawRect(rect.left, rect.top, rect.right, rect.bottom, color);
}

But as I said, I might have completely misunderstood.

Thierry, let me check and make sure I'm not totally imagining things, but I'm pretty sure it's just the bottom right-hand corner pixel that doesn't get drawn. Probably just an off-by-one problem. (Yep, just tried and it is just that corner).
Dave Johnston · 25 Feb 2003, 23:35 UTC
Thierry wrote:
That's a really interesting comment, because PocketFrog first goal was to allow development on the PC. I can guarantee you that it works perfectly on the desktop PC. Although it is not using DirectX, PF on the PC outperforms PF on the PPC...


But it still needs to be compiled for the x86 PPC emulator, does it not? (I do all my dev on the emulator now since a bad experience with EasyCE and messing up the OS somehow...!) I don't know for certain, but I'm 99% sure that GapiDraw allows a x86 executable to be compiled without the need for the PPC emulator to be able to play it - like Mr Minter did with that lawnmowing game... which used GapiDraw.

Of course, if PF does already do this, I'd love to know how to do it! :)
Dave Johnston wrote:
But it still needs to be compiled for the x86 PPC emulator, does it not? (I do all my dev on the emulator now since a bad experience with EasyCE and messing up the OS somehow...!)


You don't need to work in the x86 PPC emulator. That's the whole point of PocketFrog. All of PF + samples were written using Microsoft Visual C++ 6.0 under Windows XP. I've never touched the x86 emulator, in fact I never verified that it did work with it. Glad it does!

All you have to do is open the .dsw workspace file inside VC6 or VC7, compile and enjoy. Just like you would do with EVC3.


Dave Johnston wrote:
I don't know for certain, but I'm 99% sure that GapiDraw allows a x86 executable to be compiled without the need for the PPC emulator to be able to play it - like Mr Minter did with that lawnmowing game... which used GapiDraw.

Of course, if PF does already do this, I'd love to know how to do it! :)


Of course PF does this. That's the whole point of the library: developping on the desktop and simply recompiling for the PPC when you are done.
Dave wrote:But it still needs to be compiled for the x86 PPC emulator, does it not? ... I don't know for certain, but I'm 99% sure that GapiDraw allows a x86 executable to be compiled without the need for the PPC emulator to be able to play it... Of course, if PF does already do this, I'd love to know how to do it! :)


PF works perfectly well on any i386+ system running any windows OS system. To find out more, have a look at the following threads here on PocketMatrix:
http://forums.pocketmatrix.com/viewtopic.php?t=9707
http://forums.pocketmatrix.com/viewtopic.php?t=9819

I'm shure there's a few more out there if you look closely. These are the recent ones and contain almost all the information you need.

Basicly, all you have to do is create a new project using VC6 and set up the include and library paths as usual. For info on starting a new project, I wrote a brief note about this on PocketFrog Dev Corner:
http://www.omnytex.com/pf/forums/topic. ... Do+I%3F%85

Start a new thread (here) if you run into problems.
Strike Two!!

Thierry beat me to it again.. Damn I'm slow =)
Dave Johnston · 26 Feb 2003, 00:15 UTC
Well then, guess I've been told!

Thanks guys, can't believe I didn't check that stuff out before. Damn assumptions.
I have to admit I didn't know that either, but I also never had a reason to because my luck with eVC++ and the emulator has always been good.

The question I have is this: is it better to work in Visual C++ over eVC++ and if so, why?
Yes, it's much better IMO.

Why? Well, for starters, you get a full blown debugger. And some people have trouble with the emulator. With a VC6 build you don't have any problems unless your code is making them.
Ok... first of all I would like to appologize for writing this loooooooong note. But once I got started I couldn't stop. Anyways, here goes:

What I meant with an extension library is NOT a bunch of header files with a lot of (global) functions that call existing PF functions to do the job. This will (in some cases) get much to slow. It will be ugly and hard to overview (further down the line). And it will definitely not follow the OOP design scheme.

What I propose is to utilize that Thierry wrote PF in an OOP fashion, and simply extend the existing classes with new classes and wrap those classes in a new namespace. For instance FrogEx.

Ok.. this is just an example. I'm not saying this is the way to do it, but it could be done this way. You also have to use your imagination a bit since it's not complete code. And, since it's getting pretty late, I might have missed some minor important stuff.

Code:
namespace FrogEx {

class GameEx : public Frog::Game
{
protected:
//Here you can add new extensions to the Game class. For example:
BlitRotatedStretch(int destx, int desty, float angle, const Frog::Surface* source, int stretch_xsize, int stretch_ysize, const Frog::Rect* src_rect=0);
...

};

} // end namespace FrogEx

This should work right out of the box. But if you want to extend the Rasterizer object for instance, you need to make some adjustments to the PF structure. I.e. making some functions protected instead of private (so they can be accessed by extended classes) and defining some functions virtual so they can be extended (or polymorphed). This should be done by someone who understands OOP otherwise one might jeopardize the whole PF structure.

As Frank said earlier, the important primitives should be added directly to PF:s rasterizer object. But I think that custom pixelshaders and other custom and highlevel functions should not, to keep PF clean and simple. They should instead be extended somehow. One example is to do it like I did with the GameEx class above. Another to extend the rasterizer object.

You might also have the following class hierarcy:

Code:
namespace FrogEx {

class Game2D : public Frog::Game;
class Game3D : public Game2D;

}; // end namespace FrogEx

because some people might not want all the extra 3D functionality (and size I imagine).

I got curious of how the sound had been implemented and I'm sure it's working (havn't tried it myself yet though), but there really is no reason for it to be implemented the way it is. For those who havn't looked beyond the blit example I can tell you it mimics the DisplayDriver for no apparent reason. But, I totally understand why Gersen did it like this. Simplicity! "If I follow the DisplayDevice and do the same thing with Sound, it should work with minimum job and error."

There are two possible alternatives to how to use the sound extension that make a little more sence. The one I would have used puts the weight on a stand-alone Sound class/object in it's own namespace. And then you use it though aggregation in your extended Game class. So, for instance, in the Blit sample:

Code:
// BlitSample.h

class BlitSample : public Frog::Game
{
private:
Sound::Sound* m_sound;
};

// BlitSample.cpp

bool BlitSample::GameInit()
{
...
m_sound = new Sound(frequency, stereo); //assuming we have modified the constructor of Sound to call open(frequency,stereo).
}

bool BlitSampel::GameEnd()
{
delete m_sound; //assuming we have modified the destructor to call close()
}

The other alternative requires some altering to the Game object. The way I see it, only the following has to be changed/added:

1. Add two virtual callback functions, Suspend() and Resume(), that will be called from the OnActivate() window message callback. This is needed to stop sound, rendering, network, calculation or whatever when the PF window drops focus.

These modification are done directly to the Game class. We don't want to include the Sound just yet. As we ponder upon adding more objects to the Game class, it MUST be rewritten to handle easy extension anyways. Not just Sound.

Sound is added to the extended Game class, or GameEx as I called it above, in the following manner.

Code:
// GameEx.h

class GameEx : public Frog::Game
{
...
protected:
virtual void Suspend(); // called every time the window drops focus
virtual void Resume(); // called every time the window receives focus
const Sound::Sound* GetSound() { return m_sound; };
private:
Sound::Sound* m_sound;
};

// GameEx.cpp

GameEx::GameEx()
{
...
m_sound = new Sound();
m_sound->open(frequency,sound); // call open explicitly.. (we could have modified the constructor as I assumed above)
}
GameEx::~GameEx()
{
m_sound->close(); // call close explicitly.. (we could have modified the destructor to do this)
delete m_sound;
}
void GameEx::Suspend()
{
m_sound->suspend();
Game::Suspend(); // don't forget to call the base class
}
void GameEx::Resume()
{
m_sound->resume();
Game::Resume(); // don't forget to call the base class
}

Now what about those graphical extention objects that needs to have a display pointer to work right. Shouldn't they be initialized in Init (or shortly thereafter)??. Well, there really is no reason for this. They can safely be created in the constructor. Just supply the m_display pointer (provided by the GetDisplay() function) as an argument and by the magic of pointers, it will work if the window is created successfully (and if it isn't, then it doesn't really matter now does it).

All objects could be implemented in either one of these two ways. There is simply a matter of deciding which should be connected to the Game API and which should be standing alone. The sound, since it has no connection to the graphics API what so ever, should be a stand-alone class and added through aggregation IMO.

The benefit of extending PF this way is to keep the core clean. Imagine someone writes a new and better extention. It would be hard to remove an outdated extention and insert a new one if it's to connected to the PF mainframe (so to speak). And, this also enables the extentions to be developed independently, reducing work for Frank.

Just a few sugestions.
I realize now it sounded like I meant just adding some headers with global functions (which is exactly what I do in my own projects for simplicity), but that wasn't what I intended to say. You are right in what you wrote, following the established OO design of PF is what should be done, and it's what I intend to see done.

All of your suggestions sound good from a cursory glance, I'll have to spend more time delving into them ultimately. The underlying theme of keeping the core clean and utilizing OO design properly is the important point, and I couldn't agree more.

Gersen was telling me a while back that the sound stuff has to be intertwined in the game class for the reasons you indicate. Your ideas about how to decouple them make sense on the surface but again, looking into it in more detail is in order. I do think that's the right idea though if it works out.

Perhaps when Gersen is done with 0.2.4 you want to take a stab at it? If you can get it decoupled that would be great.
Naturally, taking on this task (to extend PF) requires a lot of thought. There are several ways to go about it. I mearly suggested a few.

Regarding Gersens sound extension. I looked briefly at his Game.h/Game.cpp files aswell as the Blit.h/Blit.cpp demo file and I saw no evidence against my suggestions. But, before making any changes one has to look more closely on the whole Sound object to see how to make it fit in the best way, as you also pointed out. For instance, should the Sound::open()/close() calls be public (i.e. called by the client/user class) or private (i.e. called by the constructor/destructor).

And, finally: shure I can have a go at it when the 0.2.4 version is finished. It shouldn't be that difficult. I have a clear view of how to do it.
Conan · 26 Feb 2003, 12:46 UTC — 3D with PocketFrog
Just a reminder that anyone wanting 3D now can integrate PocketGL with PocketFrog. It costs $49 of course:(

My game-in-development includes lots of textured meshes in 3D in a 240x240 window running under PocketFrog with PocketGL's 3D engine in the background using PF's rendering for the final screen display. Performance is reasonable.
fzammetti wrote:
I might have misunderstood, but I think Pam was asking for a function that accepts a Rect structure.


Really I was just pointing out that there are two functions that draw rectangles, one filled, one not. The parameters passed to the functions are not consistent, one takes a Rect struct the other takes x,y values. My suggestion is that if we are going to make changes to the base library, one obvious change is to either make the functions consistent, or better, overload the function name to provide the different ways of calling.

Pam
Conan,

When you say "performance is reasonable", what's your definition of reasonable? My other question is, (because I did consider getting PocketGL), how hard was it to use it with PF?

-John
Conan · 26 Feb 2003, 15:12 UTC — PF / PGL performance
The way I'm using PF as the rendering mechanism is to copy the PocketGL buffer into PF as follows:-

Code:
Surface::LockInfo buffer;
CLIP = (FAR_CLIP<<16);// make a long containing [far_clip<<16+far_clip] to make copy faster
CLIP += FAR_CLIP;// add on the 2nd far_clip
offs = 0;// init the counter
PGL->Lock(buffer,true);

memcpy(buffer.pixels,VScreen,96000);//copy 240 x 200 = 48000 ints as bytes = 96000
memset(VScreen,0,96000);// clear the vscreen

for(int y = 0; y < 24000; y++)//copy longs containing [far_clip|far_clip]
{
// set offset to beginning of the next line to draw
ZBuff[offs] = CLIP;
offs++;
}
PGL->Unlock();//back to normal PF


This slows down the frame rate by about half. PGL can get over 60 FPS on my iPaq 3650 (drawing an animated character model) so even half this rate is ok.

As PGL is all integer maths the 3D side is pretty fast so long as I keep the polygon count sensible. The space ships I'm using have about 1000 polygons.

Integrating PGL V1.0 into PF 6 was not very difficult. My main problems are always caused by my novice level of C++ knowledge. I'm now looking at doing the same with PGL 1.2 as it's got transparency, lights, wire frame support & other nice stuff which v1.0 does not have.
Thanks a lot, Conan. That definitely answered my questions. (I'll probably get PocketGL now.) The only line I didn't quite understand was your comment "// set offset to beginning of the next line to draw" Was that a substitution for real code? Otherwise you could just use offs instead of y in the for loop.

Back on topic, it's nice to hear that existing 3D can be incorporated with PF. *and there was much rejoicing* But, of course, PF is free, and PocketGL isn't, so adding some simple functionality to PF would still be neat. =)

I totally agree with the proposed methods for doing extensions to PF. It's essentially like the PowerBuilder Foundation Class (PFC). It comes with both "PFC" and "PFE" classes, where the "PFE" is the extension to the "PFC". One NEVER touches the base class, just the extension. The same methodology would be perfect for PF.

-John
adde:
Ok, when the new version is out I'll come after you and hold you to your offer to look at it :) It sounds like your on the right track with it, might as well run with it.

Conan:
The PGL stuff is very interesting, thanks for the info! I still agree with Presto that some rudimentary 3D functionality as an extension might be nice to add. Frankly, never having done any 3D stuff myself, I don't even know what really qualifies for this. I know a triangle blitter and that's about it.

Pam:
I think I actually did understand what you meant (no one was more surprised than I!). I agree completely, PF is already pretty good in terms of API consistency, what you pointed out is perfectly valid though. Where it makes sense, as with DrawRect, making things more consistent and at the same time flexible is a good goal.

Everyone:
I wanted to point out that I added a chat section to the PF Developer's Corner (http://www.omnytex.com/pf).

My thinking right now is that that site will serve as PF's new home, I'll add a section specifically for downloading PF. Maybe at some point I'll ask Thierry if he would be willing to sell me the pocketfrog.com domain, but that doesn't strike me as a priority right now.

It sounds like the extensions idea has been well-recieved, so it seems we'll go that route. I posted the other day a rough outline of the extension libraries I think make sense. The only question I have at this point is whether to put these in their own namespaces or not. I'm not sure of the implications of doing so (i.e., class access and such), so I'll have to do a little reading.

I'm wondering, in lue of that research, if anyone can think of a good reason to not put all the extensions in the same Frog namespace? It doesn't seem like it would break anything or require touching the base classes to do so, and I'm not sure what the benefits of adding namespaces is. Then the next question is whether to add one namespace (maybe PFExtensions or something) or a couple of new ones (such as PFE2D, PFE3D, PFESound, etc.)
FZammetti wrote:I'm wondering, in lue of that research, if anyone can think of a good reason to not put all the extensions in the same Frog namespace? It doesn't seem like it would break anything or require touching the base classes to do so, and I'm not sure what the benefits of adding namespaces is.


Well, I'm not a wizard on namespaces and there are a lot of conventions out there. But the benefit of adding a new namespace is to clearly separate the core (which is Frog) from the extensions.

Nothing BAD will happen if you put the extensions in the Frog namespace. You don't need to change anything in the core to do this, but it's not clear what is part of the core and what is part of the extension.

FZammetti wrote:Then the next question is whether to add one namespace (maybe PFExtensions or something) or a couple of new ones (such as PFE2D, PFE3D, PFESound, etc.)


Well, PFExtensions is a bad namespace name because it's too long ;) PFE is much better, or FrogEx. Namespaces should be short so they can be used explicitly and not just implicitly by specifying: using namespace really_long_namespace_name; at the beginning of the function (or the file)

Furthermore, namespaces are like objects. They follow a hierarchy (or atleast they should) so PFESound should be PFE::Sound and PFE2D could be PFE::Game2D or PFE::2DFrog or whatever, that is a namespace whithin the namespace.

Which brings us to the question of whether the extension namespace should be inside or outside the Frog namespace. I'll have to get back to you no that one, because right now I can't give you a motivated answer (need to get something to eat and then think about it for a while =)

If you want some examples you can take a look at the existing namespaces used by Thierry inside the Frog namespace. Why are they present? To separate the code.

And finally (sheeeze, get on with it you babbeling fool) I don't think PFE2D (or PFE:2D as I suggested earlier as an example) is a usefull namespace. Namespaces are used to group objects together, and what good will a 2D namespace do us? Isn't Frog a 2D namespace already? Looosly speaking.. The distinction between 2D and 3D could (and maybee should) be made clear by utilizing different objects, not different namespaces.

Oh well.. time to eat =)
Heirarchically, we should wrap Frog in FrogEx, just as Frog wraps Internal.

We can put anything we want in FrogEx. So long as the GameEx class is inherited from Game, and we wrap Frog inside our FrogEx namespace, we should be all set.

Code:
// namespace heirarchy
namespace FrogEx
{
namespace Frog
{
namespace Internal
{
}
}
}

// class derivation
namespace FrogEx
{
using namespace Frog;

class GameEx : public Game
{
};
}

// in our own code
using namespace FrogEx;

class MyGame : public GameEx
{
};

By "using namespace FrogEx;", everything should function perfectly. As someone stated earlier, we might have to make some things "unprivate" in Frog so that our extensions work, but I don't see any other problems. Feel free to correct me.

Also... In pocketpc.cpp, is the second namespace supposed to be namespace Internal? There's a blank namespace in the file.
Well, as far as the actual naming goes, I personally prefer FrogEx over PFE... being as Frog is the current namespace and we're extending that, FrogEx looks more correct in my eyes.

In any case, I think I understand what you guys wrote, although I'm unclear about why we would need a GameEx class... if FrogEx wraps Frog, wouldn't we still be able to use anything in the Frog namespace, specifically Game?

If not, that leads to the question of backwards compatibility because if I have a game currently written using class Game and I want to update the library, I should be able to do so without any changes to my code, assuming the interface hasn't changed, which good OOP design says it shouldn't. So, I'm going to assume you could still use Game just the same, so I don't understand why we would need a GameEx... should just have to change all the "using namespace Frog" lines to "using namespace FrogEx" I would think, no?

As far as the 2D library thing goes, what you say makes sense. What I would think that means is that we would want to have a namespace hierarchy like so:

Frog3D {
FrogEx {
Frog {
Internal {

And inside FrogEx would be the new 2D functions that are deemed not proper to be part of the "base" namespace Frog. Likewise, FrogSound would wrap FrogEx and whatever other clearly delineated grouping there would would also wrap FrogEx. I think you can use multiple namespaces at once, right?

But this is really just a question of organization. I'm more concerned with being able to simply compile existing code with a newer version of PF without having to change anything (or maybe as I said just a namespac specification), so I'm more concerned with the idea of using different objects, because it seems like that is more likely to break existing code.

You know, I hate to say it, but the easiest thing to do is what I've done with my own code, which is just include or not include various extension library header files which add members to the appropriate classes. If this was the case, then you would simply comment out the appropriate includes in PF that you didn't need and recompile the library. I'm not suggesting we do this as I wasn't before, but it IS less taxing on the brain is my point :)
Actually, I think we want everything inside FrogEx, like so:
Code:
namespace FrogEx {
namespace Frog {
namespace Internal { ... }
}
namespace Sound { ... }
namespace ThreeD { ... }
namespace ... { ... }
}

That's assuming that Sound is de-coupled from Frog. Ignore otherwise.

You're right, Frank. We shouldn't need GameEx if our FrogEx::Game class is derived from Frog::Game. And I totally agree that we want to keep the same names and have it 100% backwards compatible. If we can't do that, it's not worth doing. (But I know we can do it. =)
I see your point about the hierarchy you drew... yes, that looks correct as opposed to mine. I had one more level than was really needed. Ah well, better one more than one less I guess.
Presto wrote:Heirarchically, we should wrap Frog in FrogEx, just as Frog wraps Internal.

Yes, you're absolutely right.

Presto wrote:In pocketpc.cpp, is the second namespace supposed to be namespace Internal? There's a blank namespace in the file.

No, this is called an 'unnamed namespace' and is a local namespace sort of like static is local variables. Let me quote Bjarne Stroustrup: "All unnamed namespaces within a compilation unit are treated as one namespace 'the unnamed namespace' and treated as if it had a name that is unique in a program. A name from an unnamed namespace can be accessed without qualification after its point of declaration." I can't, however, think of a good example of why one should use unnamed namespaces.

Fzammetti wrote:Well, as far as the actual naming goes, I personally prefer FrogEx over PFE

I totally agree.

I'm unclear about why we would need a GameEx class... if FrogEx wraps Frog, wouldn't we still be able to use anything in the Frog namespace, specifically Game?

Yes, setting up the namespaces and classes like myself and Presto suggested will enable you to use (and extend) the Game class from the FrogEx namespace. There is no problem here.

But the reason we need a GameEx class is just because we want to ensure that old code will continue to work. Making changes to the Game class could violate this. Extending Game into GameEx allows us to use the GameEx as-if-it-was a Game class (and it is, since GameEx is inherited from Game) and since we havn't changed Game (well, atleast not more than absolutely nesessary) old code that uses the Frog namespace and the Game class will still work.

Fzammetti wrote:I'm more concerned with being able to simply compile existing code with a newer version of PF without having to change anything, so I'm more concerned with the idea of using different objects, because it seems like that is more likely to break existing code.

Well, with a well though out strategy, we won't brake any existing code. This is what I'm trying to point out. Keep the core clean!

Fzammetti wrote:And inside FrogEx would be the new 2D functions that are deemed not proper to be part of the "base" namespace Frog. Likewise, FrogSound would wrap FrogEx and whatever other clearly delineated grouping there would also wrap FrogEx. I think you can use multiple namespaces at once, right?

This sounds like a good disposition. All extensions should be wrapped inside the FrogEx namespace. Whether or not they should have a namespace of their own depends on the content. Imagine, for instance, that we have two sound libraries. One for mods and one for mp3s. To avoid nameclashing they could either
1. Be in different namespaces.
2. Use different names on the classes they define.

And yes, multiple namespaces (unless I totally misunderstood the question) is possible. For example, Game would be in the FrogEx::Frog namespace in the new version. There is also something called namespace-alias which works something like this:
Code:
namespace OldFrog = FrogEx::Frog;
class BlitSample : public OldFrog::Game;
which simply means that OldFrog can be used exactly like Frog was used before the change.
Hmm.. maybee I should stop writing large notes since they seem to say pretty much the same as the small ones that people post while I'm working on the large one =)

Presto, you're absolutely right.

Either we define an extension to Frog::Game and call it the same but put it in the new namespace, like this: FrogEx::Game (as you suggested).

Or, you give it a new name even though it is distinguishable by it's namespace. (i.e. FrogEx::GameEx).

Personally I think a new name (aswell as a new namespace) is the best. Why?
1. For the old projects to work, you still need to change the using namespace Frog to using namespace FrogEx::Frog, or wrap the whole file inside a namespace FrogEx clause. (so I lied earlier when I said they would compile with no problem using the new library) assuming that the PocketFrog.h file has been changed accordingly. So having the same name (or not) doesn't really matter.
2. Having the same name can be confusing even though they have separate namespaces. Well, what do we have namespaces for then, you might ask. I like to think of it as a group. If I see an object with a namespace of say Frog, I know it has something to do with PF. If it has a namespace of say Sound, I know it has something to do with sound. Shure, for simple classes with well though out names, this information could be infered from the class, but this is not always the case.

Blah.. guess this turned out to be a large note after all.