mirror of
https://github.com/airstruck/luigi.git
synced 2026-02-21 19:36:51 -07:00
add dedicated backend (WIP)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
|
||||
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
|
||||
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
|
||||
Copyright (c) 2011-2013 NYU (Clement Farabet)
|
||||
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
|
||||
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
|
||||
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the names of Deepmind Technologies, NYU, NEC Laboratories America
|
||||
and IDIAP Research Institute nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,32 @@
|
||||
sdl2-ffi
|
||||
========
|
||||
|
||||
A LuaJIT interface to SDL2
|
||||
|
||||
# Installation #
|
||||
|
||||
First, make sure SDL2 is installed on your system. This package only requires the binary shared libraries (.so, .dylib, .dll).
|
||||
Please see your package management system to install SDL2. You can also download yourself binaries on the
|
||||
[SDL2 web page](http://libsdl.org/download-2.0.php)
|
||||
|
||||
```sh
|
||||
luarocks install https://raw.github.com/torch/sdl2-ffi/master/rocks/sdl2-scm-1.rockspec
|
||||
```
|
||||
|
||||
*Note*: this SDL interface supports only SDL2, not SDL 1.2.
|
||||
|
||||
# Usage #
|
||||
|
||||
```lua
|
||||
local sdl = require 'sdl2'
|
||||
sdl.init(sdl.INIT_VIDEO)
|
||||
...
|
||||
```
|
||||
|
||||
All SDL C functions are available in the `sdl` namespace returned by require. The only difference is the naming, which is not prefixed
|
||||
by `SDL_` anymore. The same goes for all C defines (like `SDL_INIT_VIDEO`, which can now be accessed with `sdl.INIT_VIDEO`).
|
||||
|
||||
Although the interface is quite complete, there are still few defines not ported in this package. Fill free to post a message about it,
|
||||
or to request pulls.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
-- Function definitions which were not output by
|
||||
-- the C preprocessor
|
||||
|
||||
local sdl
|
||||
|
||||
local function registerdefines(sdl)
|
||||
|
||||
-- audio
|
||||
|
||||
function sdl.AUDIO_BITSIZE(x)
|
||||
return bit.band(x, sdl.AUDIO_MASK_BITSIZE)
|
||||
end
|
||||
|
||||
function sdl.AUDIO_ISFLOAT(x)
|
||||
return bit.band(x, sdl.AUDIO_MASK_DATATYPE) ~= 0
|
||||
end
|
||||
|
||||
function sdl.AUDIO_ISBIGENDIAN(x)
|
||||
return bit.band(x, sdl.AUDIO_MASK_ENDIAN) ~= 0
|
||||
end
|
||||
|
||||
function sdl.AUDIO_ISSIGNED(x)
|
||||
return bit.band(x, sdl.AUDIO_MASK_SIGNED) ~= 0
|
||||
end
|
||||
|
||||
function sdl.AUDIO_ISINT(x)
|
||||
return not sdl.AUDIO_ISFLOAT(x)
|
||||
end
|
||||
|
||||
function sdl.AUDIO_ISLITTLEENDIAN(x)
|
||||
return not sdl.AUDIO_ISBIGENDIAN(x)
|
||||
end
|
||||
|
||||
function sdl.AUDIO_ISUNSIGNED(x)
|
||||
return not sdl.AUDIO_ISSIGNED(x)
|
||||
end
|
||||
|
||||
function sdl.loadWAV(file, spec, audio_buf, audio_len)
|
||||
return sdl.loadWAV_RW(sdl.RWFromFile(file, "rb"), 1, spec, audio_buf, audio_len)
|
||||
end
|
||||
|
||||
-- surface
|
||||
sdl.blitSurface = sdl.upperBlit
|
||||
|
||||
function sdl.MUSTLOCK(S)
|
||||
return bit.band(S.flags, sdl.RLEACCEL)
|
||||
end
|
||||
|
||||
function sdl.loadBMP(file)
|
||||
return sdl.loadBMP_RW(sdl.RWFromFile(file, 'rb'), 1)
|
||||
end
|
||||
|
||||
function sdl.saveBMP(surface, file)
|
||||
return sdl.saveBMP_RW(surface, sdl.RWFromFile(file, 'wb'), 1)
|
||||
end
|
||||
end
|
||||
|
||||
return registerdefines
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user