wrap_sdl
is an Eiffel binding of SDL API
using WrapC tool.
Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.
- WrapC tool.
- SDL API
- SDL Image API -- Extension
Check the following link to learn more about SDL installation https://wiki.libsdl.org/Installation
Download the release-2.0.12 https://hg.libsdl.org/SDL
tar -xvf SDL-355a4f94a782.tar.gz
cd SDL-355a4f94a782
mkdir build
cd build
../configure
make
sudo make install
Rebuild the ldconfig cache using
sudo ldconfig
Download the release-2.0.12 https://hg.libsdl.org/SDL_image/
tar -xvf SDL_image-59a4c1ea96f3.tar.gz
cd SDL_image-59a4c1ea96f3
mkdir build
cd build
../configure
make
sudo make install
Rebuild the ldconfig cache using
sudo ldconfig
Optionally you can use vckpg, a C++ Library Manager for Windows, Linux, and MacOS.
Using vcpkg (https://github.com/microsoft/vcpkg) tool, you can install lib sdl2 library
vcpkg install sdl2:x64-windows
vcpkg install sdl2-image:x64-windows
On windows you will need to copy SDL2.lib
to PROJECT_PATH\sdl\C\lib
and SDL2_image.lib
to PROJECT_PATH\sdl_image\C\lib
Be sure to have the dll's on th PATH before to run the example.
At the moment there is no support for static linking with wrap_sdl project.
Work in progress
It's recommended to generate the code yourself instead of use the generated code. To do that just run the following script. Before to run it, double check you have the required dependencies.
install.bat
./install.sh
This script will generate the wrapper and also will compile the C library glue code, required to execute the examples.
The examples are based on the following SDL tutorial http://lazyfoo.net/tutorials/SDL/index.php
- Hello sdl
Shows how to create a window
. - Getting an image on the screen
Shows how to gets an image on the screen
. - Event Driven Programming
Shows how to handling user input by allowing the user to X out the window
. - Key presses
Shows different images appear depending on which key you press
. - Optimized Surface Loading and Soft Stretching
Shows Optimized Surface Loading and Soft Stretching
. - Extension loading PNG's images
Shows how to load PNGs images with SDL_image
. - Texture Loading and Rendering
Shows how to texture loading and rendering
. - Geometry Rendering
Shows SDL2 new feature, hardware accelerated primitive rendering
. - Viewport
SDL 2.0 also lets you control where you render on the screen using the viewport
. - Color Keying
Shows how to use color keying to give textures transparent backgrounds.
.
Before to use the examples you will need to compile the C glue code, go to
sld/generated_wrapper/c/src
and
sld_image/generated_wrapper/c/src
and run
finish_freezing --library
It will copy the C lib eif_sdl.a
to $ECF_CONFIG_PATH/C/spec/$(ISE_PLATFORM)/lib/
or eif_sdl.lib
to $ECF_CONFIG_PATH/C/spec/$ISE_C_COMPILER/$ISE_PLATFORM/lib