Newbie Q: What to use ...



Hi,

I am working on restructuring an application, it's called "the Warring Ants".

If you don't know it, it's a programming game: Different people implement a standard behaviour of individual ants in an ant tribe, and several different tribes then compete for survival.

The game is visualized in a pixel map; each ant is just a colored 1x1 pixel dot. While the game runs, all ants (there might be 1000s of them) take turns in making a move - a move is one pixel up/down/left/right. A game might involve up to a few dozen ant tribes.

Currently, the ants and everything are drawn right into an X window using XLib primitives. Performs great. The backing buffer is a home made design.

There is no GUI per se, only graphical output. All game parameters and results are I/Oed in the console.

Now I wan to add some nice menus etc, preferrably using GTK, and also a debugger utility that will visualize many more details about some selected ants.

This means that I will have ant imaging and GUI widgets exist in the same windows.

I have very little experience in programming GTK, but, hey, after this project I will have some.

My problem here is that I am not sure whether I should, or even need to reimplement the ant visualization in something else than raw XLib.

In one view, I want to have something like this:

--------------------------------------------------------------
| MyDebuggerWindow                                        |
--------------------------------------------------------------
|  Enlarged                |  GTK widgets                    |
|  image                     | displaying debugging        |
|  of part                    | info on seleced  ant(s)       |
|  of ant                     |                                           |
|  battlefield               |                                           |
|  w/ selection            |                                           |
|  cursor                     |                                           |
| | |
--------------------------------------------------------------

(yes, I know ... debugging ants !?!? )

Question: How should I put this together ?

1) Stick with Xlib primitives for displaying ants ? OK, but I can't see which kind of widget that will allow me to use XLib drawing primitives on it, or how to somehow extract an XWindow from a widget

2) Use Gnome canvas ? Might be fine for the debugger, but isn't it much slower than XLib for the main
   battlefield view ?

3) Use GDK primitives ? But I need to be able to control the color of the ants directly. Can I somehow set the drawing foreground color in RGB directly ? Seems to me that GDK was made for drawing
   widgets, not much more.

4) Use GDKRGB ? I can see how to use that for displaying a static image :) But I also need to be able to manipulate individual pixels, or rectangles in the image dynamically, and preferably fast :)

I hope someone can help me out. Basically, the question is, what should I use for maintaining a dynamically updated image in a GTK or Gnome application ?

Thanx

Soren



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]