login

local ffi = require "ffi"

local here = debug.getinfo(1).source:match("@?(.*/)")
local cdefs = io.open(here.."cdef_sdl2.h", "r"):read("*a")
ffi.cdef(cdefs)
local sdl = ffi.load("SDL2")

return setmetatable({}, {
    __index = function (t, k)
        local ok, obj = pcall(function () return sdl["SDL_"..k] end)
        if not ok then
            obj = sdl[k]
        end
        return obj
    end
})