GNU Modula-2 binding of SDL2 library.
|
|
пре 2 недеља | |
|---|---|---|
| docs | пре 2 недеља | |
| examples | пре 2 недеља | |
| lib | пре 2 недеља | |
| showcases | пре 2 недеља | |
| src | пре 2 недеља | |
| tests | пре 2 недеља | |
| .gitignore | пре 2 недеља | |
| Makefile | пре 2 недеља | |
| README.md | пре 2 недеља |
Thin DEFINITION MODULE FOR "C" bindings of SDL2 for gm2
(GCC 16 / GNU Modula-2), starting with init, video, version,
timer, error and a minimal event pump.
Starter set, verified with gm2 + SDL 2.32.4 on Linux:
| Module | C header | Contents |
|---|---|---|
SDL2 |
<SDL.h>, <SDL_error.h>, <SDL_timer.h> |
init/quit, GetError, Delay, ticks, performance counter |
SDLVersion |
<SDL_version.h> |
SDLVersion record, GetVersion, GetRevision |
SDLVideo |
<SDL_video.h> |
window create/destroy, title, size, show/hide |
SDLEvents |
<SDL_events.h> |
PumpEvents, PollEvent, WaitEvent, PushEvent, quit/key/mouse type ids (opaque buffer for now) |
SDLRect |
<SDL_rect.h> |
pure-M2 SDLPoint/SDLRect + helpers |
SDLRender |
<SDL_render.h> |
window+renderer creation, draw color, clear/present, points/lines/rects |
SDLKey |
<SDL_keycode.h> |
pure-M2 keycode constants (arrows, Q/R, Escape...) |
SDLUtils (lib/) |
— | CStrToM2() + GetErrorString() helpers, DrainEvents() quit pump, PollM2Event() decoded poll |
Full SDL_Event union mapping, renderer, audio and gamepad come next.
m2SDL/
src/ FOR "C" .def bindings (+ pure-M2 SDLRect)
lib/ pure-M2 helpers built on the bindings (SDLUtils)
tests/ gm2 smoke tests + run_tests.sh
examples/ hello_window, version, event_loop
showcases/ ports of SDL-main renderer examples (clear, rectangles, primitives)
build/ generated binaries (git-ignored)
gm2 (tested: 16.0.1 experimental, ~/bin/Modula2/Gm2/bin/gm2)pkg-config --cflags --libs sdl2, tested: 2.32.4)export PATH=$HOME/bin/Modula2/Gm2/bin:$PATH
make # tests + examples + showcases -> build/
./tests/run_tests.sh
SDL_VIDEODRIVER=dummy ./tests/run_tests.sh # headless
./build/examples/hello_window
./build/examples/version
./build/examples/event_loop
./build/showcases/showcase_clear # or rectangles / primitives
make check is make tests + the runner script.
FROM SDL2 IMPORT SDL_Init, SDL_Quit, SDLInitVideo;
FROM SDLVideo IMPORT SDL_CreateWindow, SDL_DestroyWindow,
WindowShown, WindowPosUndefined;
Compile your program with the binding search path and the C library:
gm2 -Isrc -Ilib myprog.mod src/SDLRect.mod lib/SDLUtils.mod -o myprog -lSDL2
Notes:
CARDINAL <-> Uint32, INTEGER <-> int (see gm2 "Elementary data
types" node); opaque SDL_Window * / char * travel as ADDRESS.ARRAY OF CHAR parameters map onto char *: string literals and
CHAR arrays can be passed directly (see gm2 "Interface to C" node).VAR record parameters map onto T *: SDL_GetVersion(v),
SDL_GetWindowSize(win, w, h).SDL_Event variant record + typed poll/wait.../../SDL3-3.2.28, not yet installed).