lua-users home
lua-l archive

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


I'm assuming SDL 1.2 (maybe SDL 1.2.4) - because the size of the event's type changed from uint8 to uint32

Is this 32-bit or 64-bit?

SDL has this nasty thing where it force packing of structures only for certain compilers, check in your SDL distribution include/begin_code.h for pragma pack(push,4) and similar.

Now the packing is done only for Microsoft, Metrowerks and Borland (Inprise) compilers, but I'm not sure what was the default packing for luajit.

I recompile SDL myself (but whatever latest 1.3 dev) and I remove all pragma packs, etc. I even asked on the their mailing list why these are over there, but no response.

Too much talking, can you print resize.w, resize.h, before resizing...
and it could be something else.

If I have some free time (crunching right now at work), I'll see whether I can get it to run under my testbed (I also keep some ffi bindings for luajit).

On 10/17/2011 9:33 AM, Duncan Cross wrote:
Hi,

I am trying to put together a proof-of-concept program for LuaJIT-FFI
that uses an OpenVG[1] implementation called ShivaVG[2] to render
graphics.

The test uses SDL[3] to handle the window and OpenGL initialization
(ShivaVG's own tests use GLUT, but that requires callbacks).

The problem is that, on Ubuntu 11.04, calling ShivaVG's initialization
function via FFI is consistently causing me an immediate segmentation
fault. The function has a simple signature:

   typedef int VGint;
   typedef enum { VG_FALSE=0, VG_TRUE=1 } VGboolean;

   VGboolean vgCreateContextSH(VGint width, VGint height);

I have an equivalent C program, and that runs fine. I also tried it
(the Lua version) on Windows 7, and it works there too. All the
program actually does, when it works, is present a blank blue window.
Close the window or press Esc to quit.

Here is the code. I have bundled minimal FFI declarations for SDL and
ShivaVG (only the functions/constants I am using) into the one Lua
script:

   Lua: http://pastebin.com/w5FX0eGp
   C:   http://pastebin.com/kExMvhMa

Any help would be much appreciated! I am not much of a Linux expert so
to be honest I wouldn't be surprised if it's something I'm doing
wrong. But I have tried various other experimental FFI bindings with
great success so far.

-Duncan

[1] http://www.khronos.org/openvg/
[2] http://shivavg.sourceforge.net/
[3] http://www.libsdl.org/