Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stetre/moonsoil
Lua bindings for SOIL
https://github.com/stetre/moonsoil
Last synced: about 2 months ago
JSON representation
Lua bindings for SOIL
- Host: GitHub
- URL: https://github.com/stetre/moonsoil
- Owner: stetre
- License: other
- Archived: true
- Created: 2016-04-18T10:08:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-25T10:22:21.000Z (almost 4 years ago)
- Last Synced: 2024-08-02T15:37:43.282Z (5 months ago)
- Language: C
- Size: 357 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## MoonSOIL: Lua bindings for SOIL
_*** This project is discontinued, superseded by
[MoonImage](https://github.com/stetre/moonimage). ***_---
MoonSOIL is a Lua binding library for
the
[Simple OpenGL Image Library (SOIL)](http://www.lonesock.net/soil.html).It runs on GNU/Linux and on Windows (MSYS2/MinGW) and requires
[Lua](http://www.lua.org/) (>=5.3).SOIL itself is not required because MoonSOIL includes its sources.
_Authored by:_ _[Stefano Trettel](https://www.linkedin.com/in/stetre)_
[![Lua logo](./doc/powered-by-lua.gif)](http://www.lua.org/)
#### License
MIT/X11 license (same as Lua). See [LICENSE](./LICENSE).
#### Documentation, Getting and installing, etc.
See the [Reference Manual](https://stetre.github.io/moonsoil/doc/index.html).
#### Getting and installing
Setup the build environment as described [here](https://github.com/stetre/moonlibs), then:
```sh
$ git clone https://github.com/stetre/moonsoil
$ cd moonsoil
moonsoil$ make
moonsoil$ make install # or 'sudo make install' (Ubuntu)
```#### Examples
The script below loads an image from file.
```lua
-- MoonSOIL example: load_image.luasoil = require("moonsoil")
-- Load an image from a file. The image is returned as a binary string.
data, w, h, channels = soil.load_image("dice6.png", 'rgb')
-- Check if an error occurred:
assert(data, soil.last_result())print(string.format("Loaded %dx%d %s image (%d bytes)", w, h, channels, #data))
```The script can be executed at the shell prompt with the standard Lua interpreter:
```shell
$ lua load_image.lua
```The script below loads an image from file directly into an OpenGL texture.
Since SOIL uses OpenGL functions for this purpose, the script also uses
[MoonGLFW](https://github.com/stetre/moonglfw) and
[MoonGL](https://github.com/stetre/moongl) to create a GL context and
properly initialize it.```lua
-- MoonSOIL example: load_texture.luagl = require("moongl")
glfw = require("moonglfw")
soil = require("moonsoil")-- SOIL functions create OpenGL textures using OpenGL functions, so
-- prior to use them we need to ensure that OpenGL is initialized.
-- For this purpose, we use MoonGLFW to create a window and make its
-- GL context current. Then we call MoonGL's gl.Init() - which is
-- essentially glewInit() - to initialize OpenGL.
window = glfw.create_window(100, 100)
glfw.make_context_current(window)
gl.init() -- i.e. glewInit()-- Now OpenGL's function pointers should be properly initialized, and
-- SOIL can use them without causing segmentation faults.-- Load an image file directly as a new OpenGL texture:
texid, errmsg = soil.load_texture("dice6.png", 'auto', nil,
'mipmaps', 'invert y', 'ntsc safe rgb', 'compress to dxt');
assert(texid, errmsg)
print(string.format("Loaded texture %d (should be 1)", texid))
```Other examples can be found in the **examples/** directory.
#### See also
* [MoonLibs - Graphics and Audio Lua Libraries](https://github.com/stetre/moonlibs).