Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2003:
[Freeciv-Dev] (PR#7124) [FS] Drawing abstraction layer
Home

[Freeciv-Dev] (PR#7124) [FS] Drawing abstraction layer

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7124) [FS] Drawing abstraction layer
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sat, 20 Dec 2003 10:53:20 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7124 >


FS should (only one implemented so far, so this isn't an "does")
support multiple backends. A backend here is something which performs
primitive drawing operations and basic event handling. The interface
here is defined in backend.h (attached). The basic structe is OSDA
(off screen drawing area). An OSDA is always rectangular (a sprite on
the other side isn't because it may have a mask). Again a clean
interface because the users of the backend don't know the implemention
of the OSDA. For X11 it is simply a Pixmap.

The following points are abstracted in a backend:
 - creation and destruction of off-screen-drawing-area (short OSDA)
 - drawing onto OSDAs (transparency is a function parameter here)
 - copy part of an OSDA on the screen
 - implementation of a font
 - implementation of a sprite (required by common client code)
 - query the screen size
 - query the size of a string
 - query the size of a sprite
 - add/remove a network input
 - wait for the next event and return it

I have finished an implementation of the backend for X11 consisting of
1200 lines. This is all which is needed to port FS to other backends
like SDL, Win32 or Amiga's graphics.library. The 2000 lines for the
widget set aren't needed to be ported.

So why was not SDL used as an abstraction? IMHO SDL has serveral
shortcoming which make it not my first choice. Please read the
archives for the details.

The abstraction is small. So the extra effort to provide a universal
target is minimal and already done.

Open points:
 - use ucs-2 for the string data instead of latin1 and friends
   pro: 
      - support all spoken languages
   con:
      - need lib for converting to/from unicode (iconv)
      - need support at drawing these chars
      - slightly larger memory usage (minor point)

   I think that ucs-2 should be used. Now I have to figure out how to
   control X11 in this regard.

For the first other backend we need some switch at conf-time to choose
the correct backend. Otherwise new backends are welcome.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Are you saying that you actually used the Classpath Java AWT classes in 
  addition to the GTK peers and got them to display something?
  Wow.  That's way better than I did and I wrote the code!"
    -- Aaron M. Renn in the classpath mailing list




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7124) [FS] Drawing abstraction layer, Raimar Falke <=