SDL-ctypes: rest of video
Things that work:
* I've ported test/testvidinfo.c to Python with only minor changes and it
works perfectly, and fast.
* I've changed the signature of some functions so that instead of passing by
reference, they return the value directly; for example, see SDL_GetClipRect.
* Functions that take or return an array, I've modified to take or return a
* RWops work both as an opaque type (e.g., as a value to pass from SDL_Load*
to SDL_CreateSurface*), and as a wrapper around any Python file-type object (only
tested reading a bitmap so far).
* There's a couple of unit tests written also, but not many.
Things that don't work yet:
* Haven't wrapped any of the enums yet -- I will do these the same as
constants for now, unless someone has a better idea.
* SDL_VideoInfo has bitfields... these are problematic, since compilers are
allowed to do anything they like with them. At the moment I have them reading
correctly for my AMD64/gcc system, but there's no guarantee it will work for any
* The GL_* constants should probably be stripped out (there is a script that
generates these constants)
Things that need thinking about:
* I'm not doing anything useful with SDL_Surface.pixels yet, which is a void
*. There are also a couple of functions that take arrays of ints that I'm
ignoring for now. I guess here is where we think about doing conversions to/from
strings, lists, numarray, numpy, numeric etc a la PyOpenGL-ctypes.
* I want to be able to autogenerate documentation. Epydoc doesn't pick up the
docstrings on most of my wrapper functions though... does anyone know of a tool
that might work, or an easy way to patch epydoc? Otherwise I'm willing to spend
a couple of days writing/modifying something with docutils to do it, rather than
writing all the documentation by hand.
SDL-ctypes: half of video
At Richard's urging, committed everything to a local SVN repository while I wait
fo the official one. So no-one but me can see anything yet :-)
Have made it halfway through wrapping SDL_video.h (up to line 422). About half
the functions are straightforward wraps: just defining the argument and return
types. Any that take or return an array I've treat specially to conver to/from
Python lists. For the functions I've encountered so far it won't be a speed
problem, but later on I will need to think about also supporting different
sequence types like numarray and friends.
Testing is a bit ad-hoc at the moment; the functions I can test I am testing
through the console, but most will have to wait until a bit more is wrapped. I
suspect that the examples in the SDL/test directory don't give complete coverage,
and I'm going to have to invent some tests.
Marked all 51 3D graphics assignments in two days, surely a record!
Started work on my Google SoC project: writing SDL ctypes bindings. Constants
(minus enums), init functions, version functions and RWops functions are all
done. RWops works fine as an opaque type; I have also tried writing a function
to make any Python file-type object behave as RWops, but cannot test it yet (need
to wrap some bitmap functions first).
Still no CVS or SVN repository for the work, will set up a temporary home if
Peter doesn't get back to me soon.
I've made a 0.1 release of Pyglyph
: text rendering library for Pygame/PyOpenGL.
Still lots of bugs and unimplemented features, but probably useful in its current
state. I chose to release now as there'll be a big break in development while I
finish a semester of uni, start my Google SOC project (link to come), and feel
guilty for not doing my honours thesis.
Text rendering in Pygame + OpenGL
Have spent the last couple of nights putting together a text rendering library
for Pygame/PyOpenGL. The initial code base was pulled out of Nelly, but bears
little resemblance any more.
One of the goals is to make the library require only libraries most Pygame users
ordinarily use -- for most gamers, text rendering is not a critical enough
feature to bloat a package with another dependency. The current version of
Pygame does not expose enough font metrics, so these arrays are pulled directly
out of the Truetype file. Freetype could have been used, but I can't imagine
gamers having the patience to download and install it for a game.
So far, rendering does correct character advance and pairwise kerning. Before
the first release I'd like to add
* style character runs (marked-up text),
* first-fit line breaking,
* left, right and center alignment taking into account left/right-side bearing,
and for possibly for later:
* common temporal effects (transitions),
* text-editing cursor management,
* Knuth/Plass optimal line-breaking (and hyphenation?),
* ligature substitution.
I would just like to add that the Truetype format-4 character encoding table is
the most obfuscated, badly-documented file format in the world, and that the
people responsible for its existence should beg eternal forgiveness.