Commits

Anonymous committed c3d2b5f

Fixed png DLL detection for Win32.
Renamed ColorFromObj -> SDLColorFromObj
Added generic ColorFromObj C API method in base module.
Added basic OpenAL Context class.
Added ARGB/RGBA conversion macros.
Minor sdlgfx.primitives color handling fixes (incomplete).
Added some sdl.wm unit tests.

  • Participants
  • Parent commits 7cdaf68
  • Branches pgreloaded

Comments (0)

Files changed (35)

 * alpha1 (rev. 2176)
 * alpha2 (rev. 2430)
 * alpha3 (rev. 2707)
+
+ 
     ('smpeg', r'(lib){0,1}smpeg\.dll$', ['SDL']),
     ('tiff', r'(lib){0,1}tiff(-3){0,1}\.dll$',  ['jpeg', 'z']),
     ('jpeg', r'(lib){0,1}jpeg\.dll$', []),
-    ('png', r'(lib){0,1}png(1[23])(-0){0,1}\.dll$', ['z']),
+    ('png', r'(lib){0,1}png(1[23]){0,1}(-0){0,1}\.dll$', ['z']),
     ('z', r'zlib1\.dll$', []),
     ('portmidi', r'portmidi\.dll$', []),
     ('openal', r'OpenAL32\.dll$', []),

doc/capi/base.rst

   stored in *convobj* and needs to be freed by the caller, once *text* is not
   required anymore. This returns 1 on success and 0 on failure.
 
+.. cfunction:: int ColorFromObj (PyObject *obj, pguint32 *val)
+
+  Converts the passed object to a 32-bit unsigned integer color value
+  using a RGBA layout and stores the result in *val*. This returns 1 on
+  success and 0 on failure.
+
 .. cfunction:: int IsReadableStreamObj (PyObject *obj)
 
   Checks, whether the passed object supports the most important stream

doc/capi/sdlvideo.rst

 
 Functions
 ---------
-.. cfunction:: int ColorFromObj (PyObject *obj, SDL_PixelFormat *format, Uint32 *val)
+.. cfunction:: int SDLColorFromObj (PyObject *obj, SDL_PixelFormat *format, Uint32 *val)
 
-  Converts the passed object to a 32-bit integer color value and stores the
-  result in *val*. This returns 1 on success and 0 on failure.
+  Converts the passed object to a 32-bit integer color value matching
+  the passed *format* and stores the result in *val*. This returns 1 on
+  success and 0 on failure.
 
 PyPixelFormat
 -------------

doc/src/sdlwm.xml

   <desc>Pygame SDL window manager wrapper module.</desc>
 
   <func name="get_caption">
-    <call>get_caption () -> str</call>
-    <desc>Gets the caption of the current SDL window.</desc>
+    <call>get_caption () -> str, str</call>
+    <desc>Gets the caption of the current SDL window.
+    
+      Gets the title-bar caption and icon name (if any) of the display
+      window. If not set, any of the values might be None.
+    </desc>
   </func>
   <func name="get_info">
     <call>get_info () -> dict</call>
     </desc>
   </func>
   <func name="set_caption">
-    <call>set_caption (str) -> None</call>
-    <desc>Sets the caption of the current SDL window.</desc>
+    <call>set_caption (title[, iconname]) -> None</call>
+    <desc>Sets the caption of the current SDL window.
+    
+      Sets the title-bar caption and optional icon name (or description)
+      of the display window.
+    </desc>
   </func>
   <func name="set_icon">
     <call>set_icon (surface[, mask]) -> None</call>
     
     Module ("openal.base",
         sources = [ "src/openal/openalmod.c",
+                    "src/openal/context.c",
                     "src/openal/device.c" ],
         depends = [ 'openal' ]),
     ]
         else:
             buildsystem = "win"
             builddefines.append (("IS_WIN32", None))
+            builddefines.append (("WIN32", None))
     elif sys.platform == "darwin":
         buildsystem = "darwin"
         builddefines.append (("IS_DARWIN", None))

src/base/basemod.c

     return 1;
 }
 
+int
+ColorFromObj (PyObject *obj, pguint32 *val)
+{
+    if (!obj || !val)
+    {
+        PyErr_SetString (PyExc_TypeError, "argument is NULL");
+        return 0;
+    }
+    
+    if (PyColor_Check (obj))
+    {
+        PyColor *color = (PyColor*) obj;
+        *val = ((pguint32) color->r << 24) | ((pguint32) color->g << 16) |
+            ((pguint32) color->b << 8) | ((pguint32) color->a);
+        return 1;
+    }
+    else if (PyLong_Check (obj))
+    {
+        unsigned long longval = PyLong_AsUnsignedLong (obj);
+        if (PyErr_Occurred ())
+        {
+            PyErr_Clear ();
+            PyErr_SetString(PyExc_ValueError, "invalid color argument");
+            return 0;
+        }
+        *val = (pguint32) longval;
+        return 1;
+    }
+    else if (PyInt_Check (obj))
+    {
+        long intval = PyInt_AsLong (obj);
+        if (intval == -1 && PyErr_Occurred ())
+        {
+            PyErr_Clear ();
+            PyErr_SetString (PyExc_ValueError, "invalid color argument");
+            return 0;
+        }
+        *val = (pguint32) intval;
+        return 1;
+    }
+    else
+        PyErr_SetString (PyExc_TypeError, "invalid color argument");
+    return 0;
+}
+
 static int
 _base_traverse (PyObject *mod, visitproc visit, void *arg)
 {
     c_api[PYGAME_BASE_FIRSTSLOT+12] = UTF8FromObject;
     c_api[PYGAME_BASE_FIRSTSLOT+13] = UlongFromObj;
     c_api[PYGAME_BASE_FIRSTSLOT+14] = LongFromObj;
+    c_api[PYGAME_BASE_FIRSTSLOT+15] = ColorFromObj;
 
     streamwrapper_export_capi (c_api);
     color_export_capi (c_api);
         return 0;
     }
 
-    tmp = ((pguint32) c->a << 24) + ((pguint32) c->r << 16) +
-        ((pguint32) c->g << 8) + (pguint32) c->b;
+    tmp = ((pguint32) c->a << 24) | ((pguint32) c->r << 16) |
+        ((pguint32) c->g << 8) | (pguint32) c->b;
     return tmp;
 }
 

src/base/internals.h

 int UTF8FromObject (PyObject *obj, char **text, PyObject **freeme);
 int LongFromObj (PyObject* obj, long* val);
 unsigned long UlongFromObj (PyObject* obj, long* val);
+int ColorFromObj (PyObject *obj, pguint32 *val);
 
 extern PyTypeObject PyColor_Type;
 #define PyColor_Check(x) (PyObject_TypeCheck(x, &PyColor_Type))

src/base/pgbase.h

 /* Stream handling */
 
 #define PYGAME_BASE_FIRSTSLOT 0
-#define PYGAME_BASE_NUMSLOTS 15
+#define PYGAME_BASE_NUMSLOTS 16
 #ifndef PYGAME_BASE_INTERNAL
 #define PyExc_PyGameError ((PyObject*)PyGameBase_C_API[PYGAME_BASE_FIRSTSLOT])
 #define DoubleFromObj                                                   \
     (*(int(*)(PyObject*, char**, PyObject**))PyGameBase_C_API[PYGAME_BASE_FIRSTSLOT+12])
 #define UlongFromObj                                                    \
     (*(int(*)(PyObject*, unsigned long*))PyGameBase_C_API[PYGAME_BASE_FIRSTSLOT+13])
-#define LongFromObj                                                    \
+#define LongFromObj                                                     \
     (*(int(*)(PyObject*, long*))PyGameBase_C_API[PYGAME_BASE_FIRSTSLOT+14])
+#define ColorFromObj                                                    \
+    (*(int(*)(PyObject*, pguint32*))PyGameBase_C_API[PYGAME_BASE_FIRSTSLOT+15])
 #endif /* PYGAME_BASE_INTERNAL */
 
 /*
     (*(int(*)(PyObject*))PyGameBase_C_API[PYGAME_STREAMWRAPPER_FIRSTSLOT+14])
 #endif /* PYGAME_STREAMWRAPPER_INTERNAL */
 
+/**
+ * PyColor values are using a ARGB layout - provide some simple
+ * RGBA->ARGB and ARGB->RGBA conversion macros.
+ */
+#define ARGB_2_RGBA(x)                          \
+    (((((x) & 0x00ff0000) >> 16) << 24) |       \
+     ((((x) & 0x0000ff00) >>  8) << 16) |       \
+      (((x) & 0x000000ff)        <<  8) |       \
+      (((x) & 0xff000000) >> 24))
+
+#define RGBA_2_ARGB(x)                          \
+    (((((x) & 0xff000000) >> 24) << 16) |       \
+     ((((x) & 0x00ff0000) >> 16) <<  8) |       \
+      (((x) & 0x0000ff00) >>  8)        |       \
+      (((x) & 0x000000ff)        << 24))
+
 typedef struct
 {
     PyObject_HEAD
     (*(pguint32(*)(PyObject*)) PyGameBase_C_API[PYGAME_COLOR_FIRSTSLOT+4])
 #endif /* PYGAME_COLOR_INTERNAL */
 
+
 typedef struct
 {
     PyObject_HEAD

src/mask/maskmod.c

     if (surfobj2)
         surf2 = PySDLSurface_AsSDLSurface (surfobj2);
 
-    if (!ColorFromObj (rgba_obj_color, surf->format, &color))
+    if (!SDLColorFromObj (rgba_obj_color, surf->format, &color))
         return NULL;
 
     if (rgba_obj_threshold)
     {
-        if (!ColorFromObj (rgba_obj_threshold, surf->format, &color_threshold))
+        if (!SDLColorFromObj (rgba_obj_threshold, surf->format,
+                &color_threshold))
             return NULL;
     }
     else

src/math/mathmod.h

 
 #include <Python.h>
 
+#ifdef IS_WIN32
+#include <float.h>
+#define isnan(x) _isnan(x)
+#endif
+
 #define PYGAME_MATH_INTERNAL
 #define PYGAME_MATHVECTOR_INTERNAL
 #define PYGAME_MATHVECTOR2_INTERNAL

src/openal/constantsmod.c

 */
 #define PYGAME_OPENALCONSTANTS_INTERNAL
 
-#ifdef IS_MSYS
+#if defined(IS_MSYS) || defined(IS_WIN32)
 #include <al.h>
 #include <alc.h>
 #include <alext.h>

src/openal/context.c

+/*
+  pygame - Python Game Library
+  Copyright (C) 2010 Marcus von Appen
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public
+  License along with this library; if not, write to the Free
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+#define PYGAME_OPENALCONTEXT_INTERNAL
+
+#include "pgbase.h"
+#include "openalmod.h"
+#include "pgopenal.h"
+
+
+static int _context_init (PyObject *self, PyObject *args, PyObject *kwds);
+static void _context_dealloc (PyContext *self);
+static PyObject* _context_repr (PyObject *self);
+
+static PyObject* _context_makecurrent (PyObject *self);
+
+/**
+ */
+static PyMethodDef _context_methods[] = {
+    { "make_current", (PyCFunction)_context_makecurrent, METH_NOARGS, "" },
+    { NULL, NULL, 0, NULL }
+};
+
+/**
+ */
+static PyGetSetDef _context_getsets[] = {
+    { NULL, NULL, NULL, NULL, NULL }
+};
+
+/**
+ */
+PyTypeObject PyContext_Type =
+{
+    TYPE_HEAD(NULL, 0)
+    "base.Context",             /* tp_name */
+    sizeof (PyContext),         /* tp_basicsize */
+    0,                          /* tp_itemsize */
+    (destructor) _context_dealloc, /* tp_dealloc */
+    0,                          /* tp_print */
+    0,                          /* tp_getattr */
+    0,                          /* tp_setattr */
+    0,                          /* tp_compare */
+    (reprfunc)_context_repr,    /* tp_repr */
+    0,                          /* tp_as_number */
+    0,                          /* tp_as_sequence */
+    0,                          /* tp_as_mapping */
+    0,                          /* tp_hash */
+    0,                          /* tp_call */
+    0,                          /* tp_str */
+    0,                          /* tp_getattro */
+    0,                          /* tp_setattro */
+    0,                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    0/*DOC_BASE_CONTEXT*/,
+    0,                          /* tp_traverse */
+    0,                          /* tp_clear */
+    0,                          /* tp_richcompare */
+    0,                          /* tp_weaklistoffset */
+    0,                          /* tp_iter */
+    0,                          /* tp_iternext */
+    _context_methods,           /* tp_methods */
+    0,                          /* tp_members */
+    _context_getsets,           /* tp_getset */
+    0,                          /* tp_base */
+    0,                          /* tp_dict */
+    0,                          /* tp_descr_get */
+    0,                          /* tp_descr_set */
+    0,                          /* tp_dictoffset */
+    (initproc) _context_init,   /* tp_init */
+    0,                          /* tp_alloc */
+    0,                          /* tp_new */
+    0,                          /* tp_free */
+    0,                          /* tp_is_gc */
+    0,                          /* tp_bases */
+    0,                          /* tp_mro */
+    0,                          /* tp_cache */
+    0,                          /* tp_subclasses */
+    0,                          /* tp_weaklist */
+    0,                          /* tp_del */
+#if PY_VERSION_HEX >= 0x02060000
+    0                           /* tp_version_tag */
+#endif
+};
+
+
+static void
+_context_dealloc (PyContext *self)
+{
+    if (self->context)
+    {
+        ALCcontext *ctxt = alcGetCurrentContext ();
+        
+        /* Make sure, the context is not current. */
+        if (ctxt == self->context)
+            alcMakeContextCurrent (NULL);
+        alcDestroyContext (self->context);
+    }
+    self->context = NULL;
+    ((PyObject*)self)->ob_type->tp_free ((PyObject *) self);
+}
+
+static int
+_context_init (PyObject *self, PyObject *args, PyObject *kwds)
+{
+    PyObject *device;
+    PyObject *attrlist = NULL;
+    ALCint *attrs = NULL;
+    
+    if (!PyArg_ParseTuple (args, "O|O", &device, &attrlist))
+        return -1;
+
+    if (!PyDevice_Check (device))
+    {
+        PyErr_SetString (PyExc_TypeError, "device must be a Device");
+        return -1;
+    }
+    
+    if (attrlist)
+    {
+        ALCint attr;
+        if (PySequence_Check (attrlist))
+        {
+            PyObject *item;
+            Py_ssize_t i;
+            Py_ssize_t count = PySequence_Size (attrlist);
+            if (count == -1)
+                return -1;
+            if (count > 0)
+                attrs = PyMem_New (ALCint, (count * 2) + 1);
+            else
+                attrs = NULL;
+            for (i = 0; i < (count * 2); i += 2)
+            {
+                item = PySequence_ITEM (attrlist, i);
+                if (!item)
+                {
+                    PyMem_Free (attrs);
+                    return -1;
+                }
+
+                if (!IntFromSeqIndex (item, (Py_ssize_t)0, (int*)&attr))
+                {
+                    PyMem_Free (attrs);
+                    return -1;
+                }
+                attrs[i] = attr;
+                if (!IntFromSeqIndex (item, (Py_ssize_t)1, (int*)&attr))
+                {
+                    PyMem_Free (attrs);
+                    return -1;
+                }
+                attrs[i+1] = attr;
+            }
+            attrs[(count*2)] = 0;
+        }
+        else
+        {
+            PyErr_Clear ();
+            PyErr_SetString (PyExc_TypeError,
+                "attrs must be a sequence of attibute/value pairs");
+            return -1;
+        }
+    }
+
+    ((PyContext*)self)->context = alcCreateContext (PyDevice_AsDevice (device),
+        attrs);
+    if (attrs)
+        PyMem_Free (attrs);
+    if (((PyContext*)self)->context == NULL)
+    {
+        SetALErrorException (alGetError ());
+        return -1;
+    }
+    return 0;
+}
+
+static PyObject*
+_context_repr (PyObject *self)
+{
+    /* TODO */
+    return Text_FromUTF8 ("<alcContext>");
+}
+
+/* Context methods */
+static PyObject*
+_context_makecurrent (PyObject *self)
+{
+    if (alcMakeContextCurrent (PyContext_AsContext (self)) == AL_TRUE)
+        Py_RETURN_TRUE;
+    Py_RETURN_FALSE;
+}
+
+void
+context_export_capi (void **capi)
+{
+    capi[PYGAME_OPENALCONTEXT_FIRSTSLOT] = &PyContext_Type;
+}

src/openal/device.c

 static PyObject* _device_repr (PyObject *self);
 
 static PyObject* _device_hasextension (PyObject *self, PyObject *args);
+static PyObject* _device_geterror (PyObject* self);
 
 static PyObject* _device_getname (PyObject* self, void *closure);
+static PyObject* _device_getextensions (PyObject *self, void *closure);
 /**
  */
 static PyMethodDef _device_methods[] = {
     { "has_extension", _device_hasextension, METH_VARARGS, NULL },
+    { "get_error", (PyCFunction)_device_geterror, METH_NOARGS, NULL },
     { NULL, NULL, 0, NULL }
 };
 
  */
 static PyGetSetDef _device_getsets[] = {
     { "name", _device_getname, NULL, NULL/*DOC_BASEDEVICE_NAME*/, NULL },
+    { "extensions", _device_getextensions, NULL, NULL, NULL },
     { NULL, NULL, NULL, NULL, NULL }
 };
 
         SetALErrorException (alGetError ());
         return -1;
     }
+    ((PyDevice*)self)->device = device;
     return 0;
 }
 
 static PyObject*
 _device_repr (PyObject *self)
 {
-    return Text_FromUTF8 ("<alcDevice>");
+    PyObject *retval;
+    const ALCchar *name = alcGetString (PyDevice_AsDevice (self),
+        ALC_DEVICE_SPECIFIER);
+    /* <Device ('')> == 13 */
+    size_t len = strlen ((const char*) name) + 14;
+    char *str = malloc (len);
+    if (!str)
+        return NULL;
+
+    snprintf (str, len, "<Device ('%s')>", (const char*) name);
+    retval = Text_FromUTF8 (str);
+    free (str);
+    return retval;
 }
 
 /* Device getters/setters */
     return Text_FromUTF8 ((const char*)name);
 }
 
+static PyObject*
+_device_getextensions (PyObject *self, void *closure)
+{
+    ALCchar tmp[4096] = { '\0' };
+    int i = 0;
+    const ALCchar *dptr, *start;
+    PyObject *list, *item;
+    const ALCchar *devices = alcGetString (PyDevice_AsDevice (self),
+        ALC_CAPTURE_DEVICE_SPECIFIER);
+    
+    if (SetALErrorException (alGetError ()))
+        return NULL;
+    list = PyList_New (0);
+    start = dptr = devices;
+    while (*dptr)
+    {
+        if (*dptr == ' ') /* list entry end */
+        {
+            item = Text_FromUTF8 ((const char*) tmp);
+            if (!item)
+            {
+                Py_DECREF (list);
+                return NULL;
+            }
+            if (PyList_Append (list, item) == -1)
+            {
+                Py_DECREF (item);
+                Py_DECREF (list);
+                return NULL;
+            }
+            Py_DECREF (item);
+            memset (tmp, '\0', (size_t)4096);
+            i = 0;
+        }
+        else if (i < 4096)
+        {
+            tmp[i] = *dptr;
+        }
+        dptr++;
+        i++;
+    }
+    /* Sentinel append */
+    if (i != 0)
+    {
+        item = Text_FromUTF8 ((const char*) tmp);
+        if (!item)
+        {
+            Py_DECREF (list);
+            return NULL;
+        }
+        if (PyList_Append (list, item) == -1)
+        {
+            Py_DECREF (item);
+            Py_DECREF (list);
+            return NULL;
+        }
+        Py_DECREF (item);
+    }
+    return list;
+}
+
 /* Device methods */
 static PyObject*
 _device_hasextension (PyObject *self, PyObject *args)
     Py_RETURN_TRUE;
 }
 
+static PyObject*
+_device_geterror (PyObject* self)
+{
+    ALenum error = alcGetError (PyDevice_AsDevice (self));
+    switch (error)
+    {
+    case AL_INVALID_ENUM:
+        return Text_FromUTF8 ("invalid enumeration value");
+    case AL_INVALID_VALUE:
+        return Text_FromUTF8 ("invalid value");
+    case AL_INVALID_OPERATION:
+        return Text_FromUTF8 ("invalid operation request");
+    case AL_OUT_OF_MEMORY:
+        return Text_FromUTF8 ("insufficient memory");
+    default:
+        Py_RETURN_NONE;
+    }
+}
+
 /* C API */
 PyObject*
 PyDevice_New (const char* name)

src/openal/openalmod.c

 static PyObject* _openal_init (PyObject *self);
 static PyObject* _openal_quit (PyObject *self);
 static PyObject* _openal_geterror (PyObject *self);
+static PyObject* _openal_algetstring (PyObject *self, PyObject *args);
 static PyObject* _openal_isextensionpresent (PyObject *self, PyObject *args);
+static PyObject* _openal_setcurrentcontext (PyObject *self, PyObject *args);
+static PyObject* _openal_listoutputdevices (PyObject *self);
+static PyObject* _openal_listcapturedevices (PyObject *self);
+static PyObject* _openal_getdefaultoutputdevicename (PyObject *self);
+static PyObject* _openal_getdefaultcapturedevicename (PyObject *self);
 
 static PyMethodDef _openal_methods[] = {
     { "init", (PyCFunction)_openal_init, METH_NOARGS, ""/*DOC_BASE_INIT*/ },
     { "quit", (PyCFunction)_openal_quit, METH_NOARGS, ""/*DOC_BASE_QUIT*/ },
-    { "get_error", (PyCFunction)_openal_geterror, METH_NOARGS, ""/*DOC_BASE_GETERROR*/ },
+    { "get_error", (PyCFunction)_openal_geterror, METH_NOARGS,
+      ""/*DOC_BASE_GETERROR*/ },
     { "is_extension_present", _openal_isextensionpresent, METH_VARARGS, "" },
+    { "list_output_devices", (PyCFunction)_openal_listoutputdevices,
+      METH_NOARGS, "" },
+    { "list_capture_devices", (PyCFunction)_openal_listcapturedevices,
+      METH_NOARGS, "" },
+    { "al_get_string", (PyCFunction)_openal_algetstring, METH_O, "" },
+    { "set_current_context", (PyCFunction)_openal_setcurrentcontext,
+      METH_O, "" },
+    { "get_default_output_device_name",
+      (PyCFunction) _openal_getdefaultoutputdevicename, METH_NOARGS, ""},
+    { "get_default_capture_device_name",
+      (PyCFunction) _openal_getdefaultcapturedevicename, METH_NOARGS, ""},
+
     { NULL, NULL, 0, NULL },
 };
 
 }
 
 static PyObject*
+_openal_algetstring (PyObject *self, PyObject *args)
+{
+    ALenum val;
+    const ALchar* retval;
+    if (!IntFromObj (args, (int*) &val))
+        return NULL;
+    CLEAR_ERROR_STATE ();
+
+    if (alcGetCurrentContext () == NULL)
+    {
+        PyErr_SetString (PyExc_PyGameError, "no context is currently used");
+        return NULL;
+    }
+
+    retval = alGetString (val);
+    if (!retval)
+    {
+        SetALErrorException (alGetError ());
+        return NULL;
+    }
+    return Text_FromUTF8 ((const char*)retval);
+}
+
+static PyObject*
 _openal_isextensionpresent (PyObject *self, PyObject *args)
 {
     char *extname = NULL;
         return NULL;
     }
     
+    CLEAR_ERROR_STATE ();
     if (device)
         present = alcIsExtensionPresent (PyDevice_AsDevice (device),
             (const ALchar*) extname);
     Py_RETURN_TRUE;
 }
 
+static PyObject*
+_openal_setcurrentcontext (PyObject *self, PyObject *args)
+{
+    if (PyContext_Check (args))
+    {
+        PyErr_SetString (PyExc_TypeError, "argument must be a Context");
+        return NULL;
+    }
+    if (alcMakeContextCurrent (PyContext_AsContext (args)) == AL_TRUE)
+        Py_RETURN_TRUE;
+    Py_RETURN_FALSE;
+}
+
+static PyObject*
+_openal_listoutputdevices (PyObject *self)
+{
+    PyObject *list, *item;
+    const ALCchar *dptr;
+    const ALCchar *devices;
+
+    CLEAR_ERROR_STATE ();
+    if (alcIsExtensionPresent (NULL, "ALC_ENUMERATION_EXT") == AL_FALSE)
+    {
+        PyErr_SetString (PyExc_PyGameError, "device listing not supported");
+        return NULL;
+    }
+
+    if (alcIsExtensionPresent (NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE)
+        devices = alcGetString (NULL, ALC_ALL_DEVICES_SPECIFIER);
+    else
+        devices = alcGetString (NULL, ALC_DEVICE_SPECIFIER);
+
+    if (!devices)
+    {
+        SetALErrorException (alGetError ());
+        return NULL;
+    }
+
+    list = PyList_New (0);
+    if (!list)
+        return NULL;
+    dptr = devices;
+    /* According to the docs, devices will be a list of strings, seperated
+     * by NULL, with two consequtive NULL bytes to mark the end */
+    while (devices && *dptr)
+    {
+        item = Text_FromUTF8 ((const char*) dptr);
+        if (!item)
+        {
+            Py_DECREF (list);
+            return NULL;
+        }
+        if (PyList_Append (list, item) == -1)
+        {
+            Py_DECREF (item);
+            Py_DECREF (list);
+            return NULL;
+        }
+        Py_DECREF (item);
+        dptr += strlen (dptr) + 1;
+    }
+    return list;
+}
+
+static PyObject*
+_openal_listcapturedevices (PyObject *self)
+{
+    PyObject *list, *item;
+    const ALCchar *dptr;
+    const ALCchar *devices;
+
+    CLEAR_ERROR_STATE ();
+    if (alcIsExtensionPresent (NULL, "ALC_ENUMERATION_EXT") == AL_FALSE)
+    {
+        PyErr_SetString (PyExc_PyGameError, "device listing not supported");
+        return NULL;
+    }
+
+    devices = alcGetString (NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
+    if (!devices)
+    {
+        SetALErrorException (alGetError ());
+        return NULL;
+    }
+    list = PyList_New (0);
+    if (!list)
+        return NULL;
+    dptr = devices;
+    /* According to the docs, devices will be a list of strings, seperated
+     * by NULL, with two consequtive NULL bytes to mark the end */
+    while (devices && *dptr)
+    {
+        item = Text_FromUTF8 ((const char*) dptr);
+        if (!item)
+        {
+            Py_DECREF (list);
+            return NULL;
+        }
+        if (PyList_Append (list, item) == -1)
+        {
+            Py_DECREF (item);
+            Py_DECREF (list);
+            return NULL;
+        }
+        Py_DECREF (item);
+        dptr += strlen (dptr) + 1;
+    }
+    return list;
+}
+
+static PyObject*
+_openal_getdefaultoutputdevicename (PyObject *self)
+{
+    const ALCchar *name;
+    CLEAR_ERROR_STATE ();
+    name = alcGetString (NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
+    if (name)
+        return Text_FromUTF8 ((const char*)name);
+    SetALErrorException (alGetError ());
+    return NULL;
+}
+
+static PyObject*
+_openal_getdefaultcapturedevicename (PyObject *self)
+{
+    const ALCchar *name;
+    CLEAR_ERROR_STATE ();
+    name = alcGetString (NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
+    if (name)
+        return Text_FromUTF8 ((const char*)name);
+    SetALErrorException (alGetError ());
+    return NULL;
+}
+
 /* C API */
 int
 SetALErrorException (ALenum error)
     PyDevice_Type.tp_new = PyType_GenericNew;
     if (PyType_Ready (&PyDevice_Type) < 0)
         goto fail;
+    PyContext_Type.tp_new = PyType_GenericNew;
+    if (PyType_Ready (&PyContext_Type) < 0)
+        goto fail;
     
     ADD_OBJ_OR_FAIL (mod, "Device", PyDevice_Type, fail);
+    ADD_OBJ_OR_FAIL (mod, "Context", PyContext_Type, fail);
     MODINIT_RETURN(mod);
 fail:
     Py_XDECREF (mod);

src/openal/openalmod.h

 
 #define PYGAME_OPENAL_INTERNAL
 #define PYGAME_OPENALDEVICE_INTERNAL
+#define PYGAME_OPENALCONTEXT_INTERNAL
 
-#ifdef IS_MSYS
+#if defined(IS_MSYS) || defined(IS_WIN32)
 #include <al.h>
 #else
 #include <AL/al.h>
 #define PyDevice_Check(x) (PyObject_TypeCheck (x, &PyDevice_Type))
 PyObject* PyDevice_New (const char *name);
 
+extern PyTypeObject PyContext_Type;
+#define PyContext_Check(x) (PyObject_TypeCheck (x, &PyContext_Type))
+
 int SetALErrorException (ALenum error);
+#define CLEAR_ERROR_STATE() alGetError()
 
 void device_export_capi (void **capi);
 

src/openal/pgopenal.h

 #ifndef _PYGAME_OPENAL_H_
 #define _PYGAME_OPENAL_H_
 
-#ifdef IS_MSYS
+#if defined(IS_MSYS) || defined(IS_WIN32)
 #include <al.h>
 #include <alc.h>
 #include <alext.h>
     (*(PyObject*(*)(const char*))PyGameOpenAL_C_API[PYGAME_OPENALDEVICE_FIRSTSLOT+1])
 #endif /* PYGAME_OPENALDEVICE_INTERNAL */
 
+typedef struct
+{
+    PyObject_HEAD
+    ALCcontext *context;
+} PyContext;
+#define PyContext_AsContext(x) (((PyContext*)x)->context)
+#define PYGAME_OPENALCONTEXT_FIRSTSLOT \
+    (PYGAME_OPENALDEVICE_FIRSTSLOT + PYGAME_OPENALDEVICE_NUMSLOTS)
+#define PYGAME_OPENALCONTEXT_NUMSLOTS 1
+#ifndef PYGAME_OPENALCONTEXT_INTERNAL
+#define PyContext_Type                                             \
+    (*(PyTypeObject*)PyGameOpenAL_C_API[PYGAME_OPENALCONTEXT_FIRSTSLOT+0])
+#define PyContext_Check(x)                                                 \
+    (PyObject_TypeCheck(x,                                              \
+        (PyTypeObject*)PyGameOpenAL_C_API[PYGAME_OPENALCONTEXT_FIRSTSLOT+0]))
+#endif /* PYGAME_OPENALDEVICE_INTERNAL */
+
 /**
  * C API export.
  */
 #define PYGAME_SDLVIDEO_FIRSTSLOT 0
 #define PYGAME_SDLVIDEO_NUMSLOTS 1
 #ifndef PYGAME_SDLVIDEO_INTERNAL
-#define ColorFromObj                                                    \
+#define SDLColorFromObj                                                    \
     (*(int(*)(PyObject*,SDL_PixelFormat*,Uint32*))PyGameSDLVideo_C_API[PYGAME_SDLVIDEO_FIRSTSLOT+0])
 #endif /* PYGAME_SDLVIDEO_INTERNAL */
 

src/sdl/rwopsmod.c

         if (!ops)
             PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return ops;
-
     }
 
     /* No text object, so its a buffer or something like that. Try to get the
 static int IsValidRect (PyObject* rect);
 static int SDLRect_FromRect (PyObject* rect, SDL_Rect *sdlrect);
 
-static int _sdl_traverse (PyObject *mod, visitproc visit, void *arg);
-static int _sdl_clear (PyObject *mod);
-
 typedef struct {
     int initialized : 1;
 } _SDLState;

src/sdl/surface.h

         _g = (Uint8) (((argb) & 0x0000ff00) >> 8);                      \
         _b = (Uint8)  ((argb) & 0x000000ff);                            \
         (argb) = (_r >> (format)->Rloss) << (format)->Rshift |          \
-            (_g >> (format)->Gloss) << (format)->Gshift |               \
-            (_b >> (format)->Bloss) << (format)->Bshift |               \
-            ((_a >> (format)->Aloss) << (format)->Ashift & (format)->Amask); \
+                 (_g >> (format)->Gloss) << (format)->Gshift |          \
+                 (_b >> (format)->Bloss) << (format)->Bshift;           \
+        if ((format)->Amask)                                            \
+        {                                                               \
+            (argb) = (argb) |                                           \
+                ((_a >> (format)->Aloss) << (format)->Ashift);          \
+        }                                                               \
+        else                                                            \
+            (argb) |= 255;                                              \
     }                                                                   \
     else                                                                \
     {                                                                   \

src/sdl/videomod.c

 
 /* C API */
 int
-ColorFromObj (PyObject *value, SDL_PixelFormat *format, Uint32 *color)
+SDLColorFromObj (PyObject *value, SDL_PixelFormat *format, Uint32 *color)
 {
     Uint8 rgba[4];
 
         rgba[2] = ((PyColor*)value)->b;
         rgba[3] = ((PyColor*)value)->a;
 
-        *color = (Uint32) SDL_MapRGBA
-            (format, rgba[0], rgba[1], rgba[2], rgba[3]);
+        if (format->Amask != 0)
+            *color = (Uint32) SDL_MapRGBA
+                (format, rgba[0], rgba[1], rgba[2], rgba[3]);
+        else
+            *color = (Uint32) SDL_MapRGB (format, rgba[0], rgba[1], rgba[2]);
+        return 1;
+    }
+    else if (PyLong_Check (value))
+    {
+        unsigned long longval = PyLong_AsUnsignedLong (value);
+        if (PyErr_Occurred ())
+        {
+            PyErr_Clear ();
+            PyErr_SetString(PyExc_ValueError, "invalid color argument");
+            return 0;
+        }
+        *color = (Uint32) longval;
         return 1;
     }
     else if (PyInt_Check (value))
         *color = (Uint32) intval;
         return 1;
     }
-    else if (PyLong_Check (value))
-    {
-        unsigned long longval = PyLong_AsUnsignedLong (value);
-        if (PyErr_Occurred ())
-        {
-            PyErr_Clear ();
-            PyErr_SetString(PyExc_ValueError, "invalid color argument");
-            return 0;
-        }
-        *color = (Uint32) longval;
-        return 1;
-    }
     else
         PyErr_SetString (PyExc_TypeError, "invalid color argument");
     return 0;
     ADD_OBJ_OR_FAIL (mod, "Surface", PySDLSurface_Type, fail);
     ADD_OBJ_OR_FAIL (mod, "Overlay", PyOverlay_Type, fail);
     
-    c_api[PYGAME_SDLVIDEO_FIRSTSLOT+0] = ColorFromObj;
+    c_api[PYGAME_SDLVIDEO_FIRSTSLOT+0] = SDLColorFromObj;
 
     pixelformat_export_capi (c_api);
     surface_export_capi (c_api);

src/sdl/videomod.h

 PyObject* PyPixelFormat_New (void);
 PyObject* PyPixelFormat_NewFromSDLPixelFormat (SDL_PixelFormat *fmt);
 
-int ColorFromObj (PyObject *value, SDL_PixelFormat *format, Uint32 *color);
+int SDLColorFromObj (PyObject *value, SDL_PixelFormat *format, Uint32 *color);
 
 void surface_export_capi (void **capi);
 void overlay_export_capi (void **capi);
 
     if (!PyArg_ParseTuple (args, "s|s:set_caption", &title, &icon))
         return NULL;
-
+/*
     if (!icon)
         icon = title;
-
+*/
     SDL_WM_SetCaption (title, icon);
     Py_RETURN_NONE;
 }

src/sdlext/drawmod.c

     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
     
     if (surface->format->BytesPerPixel != 3 &&
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
     
     if (width < 1)
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
     
     if (!PySequence_Check (list))
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
     
     if (!PySequence_Check (list))
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
 
     if (!SDLRect_FromRect (rectobj, &rect))
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
 
     if (!SDLRect_FromRect (rectobj, &rect))
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
 
     if (radius < 0)
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
 
     if (!PySequence_Check (list))
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format, &color))
+    if (!SDLColorFromObj (colorobj, surface->format, &color))
         return NULL;
     
     if (!PySequence_Check (list))
     }
     surface = ((PySDLSurface*)surfobj)->surface;
     
-    if (!ColorFromObj (colorobj, surface->format,  &color))
+    if (!SDLColorFromObj (colorobj, surface->format,  &color))
         return NULL;
 
     if (!SDLRect_FromRect (rectobj, &rect))

src/sdlext/pixelarray.c

     for (offset = 0; offset < seqsize; offset++)
     {
         item = PySequence_ITEM (val, offset);
-        if (!ColorFromObj (item, surface->format, &color))
+        if (!SDLColorFromObj (item, surface->format, &color))
         {
             Py_XDECREF (item);
             PyMem_Free (colorvals);
     bpp = surface->format->BytesPerPixel;
     pixels = (Uint8 *) surface->pixels;
 
-    if (!ColorFromObj (value, surface->format, &color))
+    if (!SDLColorFromObj (value, surface->format, &color))
     {
         if (PyPixelArray_Check (value))
         {
-            PyErr_Clear (); /* ColorFromObj */
+            PyErr_Clear (); /* SDLColorFromObj */
             return _array_assign_array (array, _index, _index + 1,
                 (PyPixelArray *) value);
         }
         else if (PySequence_Check (value))
         {
-            PyErr_Clear (); /* ColorFromObj */
+            PyErr_Clear (); /* SDLColorFromObj */
             return _array_assign_sequence (array, _index, _index + 1, value);
         }
-        else /* Error already set by ColorFromObj(). */
+        else /* Error already set by SDLColorFromObj(). */
             return -1;
     }
 
     {
         return _array_assign_array (array, low, high, (PyPixelArray *) value);
     }
-    else if (ColorFromObj (value, surface->format, &color))
+    else if (SDLColorFromObj (value, surface->format, &color))
     {
         return _array_assign_slice (array, low, high, color);
     }
     else if (PySequence_Check (value))
     {
-        PyErr_Clear (); /* In case ColorFromObj set it */
+        PyErr_Clear (); /* In case SDLColorFromObj set it */
         return _array_assign_sequence (array, low, high, value);
     }
     return 0;
     bpp = surface->format->BytesPerPixel;
     pixels = (Uint8 *) surface->pixels;
 
-    if (!ColorFromObj (value, surface->format, &color))
+    if (!SDLColorFromObj (value, surface->format, &color))
         return -1;
 
     absxstep = ABS (array->xstep);
             return 0;
         }
     }
-    else if (PyInt_Check (op))
-    {
-        /* Plain index: array[x, */
-        *start = PyInt_AsLong (op);
-        if (*start < 0)
-            *start += length;
-        if (*start >= length || *start < 0)
-        {
-            PyErr_SetString(PyExc_IndexError, "invalid index");
-            return 0;
-        }   
-        *stop = (*start) + 1;
-        *step = 1;
-    }
     else if (PyLong_Check (op))
     {
         long long val = -1;
         *stop = (*start) + 1;
         *step = 1;
     }
+    else if (PyInt_Check (op))
+    {
+        /* Plain index: array[x, */
+        *start = PyInt_AsLong (op);
+        if (*start < 0)
+            *start += length;
+        if (*start >= length || *start < 0)
+        {
+            PyErr_SetString(PyExc_IndexError, "invalid index");
+            return 0;
+        }   
+        *stop = (*start) + 1;
+        *step = 1;
+    }
     return 1;
 }
 

src/sdlext/pixelarray_methods.c

     }
 
     surface = ((PySDLSurface*)array->surface)->surface;
-    if (!ColorFromObj (delcolor, surface->format, &dcolor) ||
-        !ColorFromObj (replcolor, surface->format, &rcolor))
+    if (!SDLColorFromObj (delcolor, surface->format, &dcolor) ||
+        !SDLColorFromObj (replcolor, surface->format, &rcolor))
         return NULL;
 
     if (!_get_weights (weights, &wr, &wg, &wb))
         return NULL;
 
     surface = ((PySDLSurface*)array->surface)->surface;
-    if (!ColorFromObj (excolor, surface->format, &color))
+    if (!SDLColorFromObj (excolor, surface->format, &color))
         return NULL;
 
     /* Create the b/w mask surface. */

src/sdlgfx/primitivesmod.c

 
     if (!PyArg_ParseTuple (args, "OOO:pixel", &surface, &pt, &color))
     {
+        PyErr_Clear ();
         if (!PyArg_ParseTuple (args, "OiiO:pixel", &surface, &x, &y, &color))
             return NULL;
     }
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
         return NULL;
     }
-    if (!PyColor_Check (color))
-    {
-        PyErr_SetString (PyExc_TypeError, "color must be a Color");
+
+    if (!ColorFromObj (color, &c))
         return NULL;
-    }
-
-    c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
 
     if (pixelColor (((PySDLSurface*)surface)->surface, x, y, c) == -1)
     {
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (hlineColor (((PySDLSurface*)surface)->surface, x1, x2, y, c) == -1)
     {
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (vlineColor (((PySDLSurface*)surface)->surface, x, _y1, y2, c) == -1)
     {
     x2 = (Sint16) (sdlrect.x + sdlrect.w);
     y2 = (Sint16) (sdlrect.y + sdlrect.h);
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (rectangleColor (((PySDLSurface*)surface)->surface, x1, x2,_y1, y2, c) ==
         -1)
     x2 = (Sint16) (sdlrect.x + sdlrect.w);
     y2 = (Sint16) (sdlrect.y + sdlrect.h);
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (rectangleColor (((PySDLSurface*)surface)->surface, x1, x2,_y1, y2, c) ==
         -1)
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (lineColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, c) == -1)
     {
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (circleColor (((PySDLSurface*)surface)->surface, x, y, r, c) == -1)
     {
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     if (arcColor (((PySDLSurface*)surface)->surface, x, y, r, start, end, c)
         == -1)
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
         return NULL;
     }
-    if (!PyColor_Check (color))
-    {
-        PyErr_SetString (PyExc_TypeError, "color must be a Color");
-        return NULL;
-    }
-
     c = (Uint32) PyColor_AsNumber (color);
     ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
-
+    printf ("%x\n", c);
+/*    c = (Uint32) PyColor_AsNumber (color);
+      c = ARGB_2_RGBA (c);*/
     if (aacircleColor (((PySDLSurface*)surface)->surface, x, y, r, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         PyErr_SetString (PyExc_TypeError, "color must be a Color");
         return NULL;
     }
-
-    c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
-
+    c = PyColor_AsNumber (color);
+    c = ARGB_2_RGBA (c);
     if (filledCircleColor (((PySDLSurface*)surface)->surface, x, y, r, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());

test/font_test.py

+import sys
 try:
     import pygame2.test.pgunittest as unittest
 except:
         self.assertEqual (type (retval[1]), bool)
         self.assertEqual (type (retval[2]), bool)
 
-    def todo_test_pygame2_font_find_fonts(self):
+    def test_pygame2_font_find_fonts(self):
 
         # __doc__ (as of 2009-12-10) for pygame2.font.find_fonts:
 
         # 
         # All found fonts are returned as list
 
-        self.fail() 
+        retval = font.find_fonts ("invalidfont")
+        self.assertEqual (retval, None)
 
-    def todo_test_pygame2_font_get_families(self):
+        retval = font.find_fonts ("sans")
+        self.assert_ (len (retval) != 0)
+        self.assert_ (type (retval), list)
+
+    def test_pygame2_font_get_families(self):
 
         # __doc__ (as of 2009-12-10) for pygame2.font.get_families:
 
         # get_families () -> [str, str, str, ...]
         # 
         # Gets the list of available font families.
-
-        self.fail() 
-
+        if sys.version in ('win32', 'darwin'):
+            pass
+        else:
+            self.assert_ (len (font.get_families ()) != 0)
+            self.assertEqual (type (font.get_families ()), list)
+    
 if __name__ == '__main__':
     unittest.main()

test/freetype_base_test.py

         # init()
         base.init()
         self.assertEqual(base.was_init(), True)
-
+        
         # quit
         base.quit()
         self.assertEqual(base.was_init(), False)

test/math_vector3_test.py

         self.assertEqual (v.elements[1], 10)
         self.assertEqual (v.elements[2], 33.44)
 
-    def todo_test_pygame2_math_base_Vector3_angle_to(self):
+    def test_pygame2_math_base_Vector3_angle_to(self):
 
         # __doc__ (as of 2010-01-09) for pygame2.math.base.Vector3.angle_to:
 
 
         self.fail() 
 
-    def todo_test_pygame2_math_base_Vector3_cross(self):
+    def test_pygame2_math_base_Vector3_cross(self):
 
         # __doc__ (as of 2010-01-09) for pygame2.math.base.Vector3.cross:
 

test/sdl_video_pixelformat_test.py

             self.assertEqual (format.bytes_per_pixel, i)
             self.assertEqual (format.bits_per_pixel, 0)
 
-    def todo_test_pygame2_sdl_video_PixelFormat_colorkey(self):
+    def test_pygame2_sdl_video_PixelFormat_colorkey(self):
 
         # __doc__ (as of 2009-12-08) for pygame2.sdl.video.PixelFormat.colorkey:
 
         # Gets or sets the RGBA value of transparent pixels.
 
-        self.fail() 
+        def _setcolorkey (fmt, key):
+            fmt.colorkey = key
+        
+        format = video.PixelFormat ()
+        self.assertEqual (format.colorkey, Color (0x00000000))
 
+        self.assertRaises (ValueError, _setcolorkey, format, -200)
+        self.assertRaises (ValueError, _setcolorkey, format, -1)
+        self.assertRaises (ValueError, _setcolorkey, format, 200)
+        self.assertRaises (ValueError, _setcolorkey, format, "hello")
+        self.assertRaises (ValueError, _setcolorkey, format, None)
+
+        # TODO: test assignments
+        
     def todo_test_pygame2_sdl_video_PixelFormat_get_rgba(self):
 
         # __doc__ (as of 2009-12-08) for pygame2.sdl.video.PixelFormat.get_rgba:

test/sdl_wm_test.py

     from pgunittest import doprint, interactive
 
 import pygame2
-import pygame2.sdl.wm as image
+import pygame2.sdl.wm as wm
 import pygame2.sdl.video as video
 import pygame2.sdl.constants as constants
 
 class SDLWMTest (unittest.TestCase):
 
-    @interactive("Is the shown caption on the window title correct?")
-    def todo_test_pygame2_sdl_wm_get_caption(self):
+    def test_pygame2_sdl_wm_get_caption(self):
 
         # __doc__ (as of 2010-01-13) for pygame2.sdl.wm.get_caption:
 
         # get_caption () -> str
         # 
         # Gets the caption of the current SDL window.
-        doprint ("The window title caption should be 'sdl.wm unittest'")
-        self.fail() 
+        self.assertRaises (pygame2.Error, wm.get_caption)
+        video.init ()
+        self.assertRaises (pygame2.Error, wm.get_caption)
+        sf = video.set_mode (10, 10)
+        self.assertEqual (wm.get_caption (), (None, None))
+        wm.set_caption ("test window")
+        self.assertEqual (wm.get_caption (), ("test window", None))
+        wm.set_caption ("", "icon")
+        self.assertEqual (wm.get_caption (), ("", "icon"))
+        wm.set_caption ("test window", "icon")
+        self.assertEqual (wm.get_caption (), ("test window", "icon"))
+        video.quit ()
 
     def todo_test_pygame2_sdl_wm_get_info(self):
 
 
         self.fail() 
 
-    @interactive ("Was the caption set correctly?")
-    def todo_test_pygame2_sdl_wm_set_caption(self):
+    def test_pygame2_sdl_wm_set_caption(self):
 
         # __doc__ (as of 2010-01-13) for pygame2.sdl.wm.set_caption:
 
         # set_caption (str) -> None
         # 
         # Sets the caption of the current SDL window.
-        doprint ("Trying to set the caption to 'sdl.wm set_caption'...")
-        self.fail() 
+
+        # handled in wm_get_caption()
+        self.assertRaises (pygame2.Error, wm.set_caption, "test", "test")
+        video.init ()
+        self.assertRaises (pygame2.Error, wm.set_caption, "test", "test")
+        sf = video.set_mode (10, 10)
+        self.assertEqual (wm.get_caption (), (None, None))
+        self.assert_ (wm.set_caption ("test window") == None)
+        self.assertEqual (wm.get_caption (), ("test window", None))
+        self.assert_ (wm.set_caption ("", "icon") == None)
+        self.assertEqual (wm.get_caption (), ("", "icon"))
+        self.assert_ (wm.set_caption ("test window", "icon") == None)
+        self.assertEqual (wm.get_caption (), ("test window", "icon"))
+        video.quit ()
 
     @interactive ("Was the window icon updated correctly?")
     def todo_test_pygame2_sdl_wm_set_icon(self):