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

Re: [pygame] SDL-ctypes progress



On Tue, 2006-06-06 at 01:29 +1000, Alex Holkner wrote:
> I've uploaded a new snapshot of my work:  
> http://pygame.org/ctypes/SDL-ctypes-0.02.tar.gz

Progress is looking strong. Having the documentation is a big bonus, far
more than I was expecting for SoC. I've got a couple notes, but nothing
urgent.

I'd drop SDL_opengl.h from the constant. The only constant we are
getting from it is WIN32_LEAN_AND_MEAN. I found all the keysyms in their
own .py file, at first I thought they were not included.

I'd agree that SDL_syswm is useful from Python. The best solution may be
to create three versions of the class and select one based on
"sys.platform".

It might be nice if the unicode attribute on SDL_keysym was already
mapped to a single or zero character unicode string. I don't know if
having the unicode ordinal number ever helps from Python.

I thought the PyOpenGL ctypes could take arguments from any of the array
modules, but always returned a new array with a globally registered
type. If this is true, it would be good if the SDL code could accept
arrays from any type of array.

I couldn't find the right package for numpy on my Dapper system. (Tried
all manner of scipy and friends). It seems like numpy is the most
hopeful number array package out there. Unfortunately it's also the
newest and not as widely distributed. I'm eager for the other SoC
project to build a base generic array type into the standard libs.

I'm wondering if we can just always have SDL functions return new
"ctypes" style arrays. Then provide convenience functions for wrapping
those into array types for other libraries.
    pal = mysurf.format.palette
    palette = SDL.numpy.Convert(pal.ncolors, pal, colors)

Then again, we may prefer more specific array building functions.
    palette_array = SDL.numeric.PaletteArray(mysurf.format.palette)
    pixel_array = SDL.numeric.PixelsArray(mysurf)
    
We probably want to support 8bit arrays for the 24bit and 32bit Surfaces
(the "3d" array types in pygame.surfarray). This would work well for
palette arrays too.

In current Pygame, when building an array that references the pixel data
of a Surface, a pair of SDL_LockSurface and SDL_UnlockSurface are tied
to the lifetime of the array. If there is an easy way to implement this,
that may help prevent segfault locking problems. I'm not sure how much
bullet proofing we want to worry about at this SDL level of the binding.

I also couldn't import the package because of SDL_GetKeyRepeat on my SDL
version 1.2.9. We need to make sure we avoid the import time exceptions
like this in our version handling scheme.