4 Sep 03:38
alien attacks SDL
From: Martin <wtxnh-lua <at> yahoo.com.au>
Subject: alien attacks SDL
Newsgroups: gmane.comp.lang.lua.general
Date: 2008-09-04 01:41:33 GMT
Subject: alien attacks SDL
Newsgroups: gmane.comp.lang.lua.general
Date: 2008-09-04 01:41:33 GMT
I liked Michal Kolodziejczyk demonstration of using SDL library with
alien module so I have changed and extend it a little and here is my
creation attached.
One thing that bother me is that I can not find why game always end
with segmentation fault when I am closing it! What is strange it
segfault after last command in the game is executed. I strongly
suspect it has to do something with memory management but can not
figure out a cure. Any suggestion?
While working with alien there was several questions I could not
answer. When defining prototype how do I indicate unsigned integers
of all kind:
SDL.SDL_FillRect:types("int", "pointer", "pointer", "unsigned int")
Also while trying struct.unpack I missed a possibility to unpack
pointer as light userdata, I resolved this with buff:get(5, "pointer").
And lastly when I allocate a buffer with alien.buffer() how do I free
it? I guess this can be reason why my program ends with segmentation
fault, because I allocate buffers on several places but never free any
of them. Or does garbage collector take care of them?
Martin
Though a
proper SDL api would use alien.wrap and wrapper functions to add some
type safety. See aio.lua inside this tarball, for example:
RSS Feed