<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">A long time ago (2019) I started an SDL wrapper, then, I found this site:<div class=""><a href="https://github.com/FlyingJester/SDL2.m/blob/master/sdl2.m" class="">https://github.com/FlyingJester/SDL2.m/blob/master/sdl2.m</a></div><div class=""><br class=""></div><div class="">I decided to persevere with my own version as it would both help me to learn and to only write the code that my application needs, but that single file has been an immense source of inspiration and education for sure, thanks to FlyingJester’s efforts.</div><div class=""><br class=""></div><div class="">I find myself now stumbling to see the light on how to convert C world values into corresponding Mercury world values, first, the code:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">:- type button ---> left ; middle ; right.</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><div class=""><font face="Courier" class="">:- pragma foreign_enum("C", button/0, [</font></div><div class=""><font face="Courier" class=""> left - "SDL_BUTTON_LEFT",</font></div><div class=""><font face="Courier" class=""> middle - "SDL_BUTTON_MIDDLE",</font></div><div class=""><font face="Courier" class=""> right - "SDL_BUTTON_RIGHT"</font></div><div class=""><font face="Courier" class="">]).</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">:- pragma foreign_export_enum("C", button/0, [uppercase]).</font></div></div><div class=""><br class=""></div><div class="">…and in my event handling C code…</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier" class="">711 case SDL_MOUSEBUTTONDOWN: {</font></div><div class=""><font face="Courier" class="">712 int buttonType = LEFT;</font></div><div class=""><font face="Courier" class="">713 if (event.button.button == SDL_BUTTON_MIDDLE) {</font></div><div class=""><font face="Courier" class="">714 buttonType = MIDDLE;</font></div><div class=""><font face="Courier" class="">715 } else if (event.button.button == SDL_BUTTON_LEFT) {</font></div><div class=""><font face="Courier" class="">716 buttonType = RIGHT;</font></div><div class=""><font face="Courier" class="">717 }</font></div><div class=""><font face="Courier" class="">718 Event = createYesEvent(</font></div><div class=""><font face="Courier" class="">719 createMouseDownEvent(</font></div><div class=""><font face="Courier" class="">720 buttonType,</font></div><div class=""><font face="Courier" class="">721 event.button.x, event.button.y,</font></div><div class=""><font face="Courier" class="">722 event.button.clicks));</font></div><div class=""><font face="Courier" class="">723 } break</font></div></div><div class=""><br class=""></div><div class="">but I get this when I try to compile it, I thought I had done well to get this far, it’s taken me a while!</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier" class="">mmc -s hlc.gc -O4 -lsdl2 -lSDL2_mixer -lSDL2_image --make main</font></div><div class=""><font face="Courier" class="">Making Mercury/int3s/sdl2.int3</font></div><div class=""><font face="Courier" class="">Making Mercury/ints/sdl2.int</font></div><div class=""><font face="Courier" class="">Making Mercury/cs/sdl2.c</font></div><div class=""><font face="Courier" class="">sdl2.m:289: In clause for function `create_mouse_down_event'/4:</font></div><div class=""><font face="Courier" class="">sdl2.m:289: in function result term of clause head:</font></div><div class=""><font face="Courier" class="">sdl2.m:289: in unification of variable `HeadVar__5'</font></div><div class=""><font face="Courier" class="">sdl2.m:289: and term `mouse_down(Btn, V_10, Clicks)':</font></div><div class=""><font face="Courier" class="">sdl2.m:289: type error in argument of functor `mouse_down'/3.</font></div><div class=""><font face="Courier" class="">sdl2.m:289: Argument 1 (Btn) has type `int',</font></div><div class=""><font face="Courier" class="">sdl2.m:289: expected type was `sdl2.button'.</font></div><div class=""><font face="Courier" class="">sdl2.m:297: In clause for function `create_mouse_up_event'/4:</font></div><div class=""><font face="Courier" class="">sdl2.m:297: in function result term of clause head:</font></div><div class=""><font face="Courier" class="">sdl2.m:297: in unification of variable `HeadVar__5'</font></div><div class=""><font face="Courier" class="">sdl2.m:297: and term `mouse_up(Btn, V_10, Clicks)':</font></div><div class=""><font face="Courier" class="">sdl2.m:297: type error in argument of functor `mouse_up'/3.</font></div><div class=""><font face="Courier" class="">sdl2.m:297: Argument 1 (Btn) has type `int',</font></div><div class=""><font face="Courier" class="">sdl2.m:297: expected type was `sdl2.button’.</font></div></div><div class=""><br class=""></div><div class="">This is something that will come up again and again and again as I make progress towards a graphics framework, possibly based around Queaks’ Morhpic framework which I have always admired since I first got into Squeak two decades ago.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Sean.</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>