adonthell-devel
[Top][All Lists]
Advanced

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

[Adonthell-devel] On source code structure and backends


From: Alexandre Courbot
Subject: [Adonthell-devel] On source code structure and backends
Date: 06 Mar 2003 13:35:47 +0100

I've just done further tests to see how we could integrate backends to
the engine. I'll concentrate on the gfx backend for this mail, hopefully
it should be the same for all backends (input, audio, etc.)

The backends should be organized as subdirectories inside the module
they belong to:
gfx/
    sdl/
    wx/
    opengl/
    clanlib/
    ....

They produce a library, named libadonthell_gfx_<backend>.so, say
libadonthell_gfx_sdl.so or libadonthell_gfx_wx.so. They will be placed
in a special adonthell backends directory.

The libgfx by itself will only define the interface of the surface class
(and possibly some elements of screen). The different backends all
implements this interface, plus a global C function named, say,
getnewsurface(arguments), which basically just does a return new
surface(arguments). This function is the *only* exported thing in this
library.

At init time, libgfx will then be passed the name of a backend to use,
and will use dlopen() and its brothers to get a reference to
getnewsurface(). And *every* time we want to create a new surface, we'll
call this function. That way, we'll be using the surface of the selected
backend.

This adds some contraints to our programming, but brings a lot of
flexibility - backends could then be distributed separately from the
engine, and will be selectable at runtime.

Another thing I've tested (which but has failed) was to run python,
import the backend Python wrapper, and then import the libgfx. I thought
that it would be able to find all the symbols it links to as the backend
has been loaded by Python, but it didn't work. Sad, because it would
have been a nice solution.

All of this needs further thoughts and experiments anyway. Comments
welcome! :)

Alex.
-- 
http://www.gnurou.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]