I'm bored with the build system so it is time to have some fun: Felix now has a builtin GUI. Well .. its work in progress! Requirements:
* SDL2 * SDL_ttf * SDL_image must be installed. You will have to set up the Felix *.fpc database files sdl2.fpc sdl2_ttf.fpc sdl2_image.fpc Please see src/config/macosx for how to do this. They should be setup for the Mac automatically. Linux will be supported when someone using Linux commits the appropriate changes. Please remember any *.fpc files in $HOME/.felix/config will be installed during the build process so if you rebuild Felix your work is not lost. SDL has many limitations. It is not designed as a GUI but as a way to write portable games. So the GUI will be a bit basic. One major deficiency is that there is no way to properly capture the mouse. The SDL function that does this is bugged and they won't fix it. More precisely it was designed for full screen operation to stop the mouse going out of a particular pane. The implementation on OSX is extremely bad, and the functionality is useless for a GUI where you want to allow the mouse OUT of the window but remain owned by the window. Another problem is that to do advanced graphics you need OpenGL which is very badly designed (non-reentrant) and has become a nightmare of spaghetti options and changing API. Its hard to know what works and what doesn't, and since shaders got introduced the standard changed in an incompatible way .. my Mac only runs version 1.2 I think it is of shaders, which is not compatible with 1.3 due to a trivial syntax change. Here is a working program: /////////////////////////////////////////////////////////////////////////// include "gui/__init__"; open FlxGui; FlxGui::init(); var w : window_t = create_window("My Window",50,50,400,400); var font : font_t = get_font(OSX_dflt_font()); var lineskip = get_lineskip font; var red = RBG(255,0,0); var green = RBG (0,0,255); clear_window(w,green); write (w, 100,100,font,red,"HELLO"); write (w, 100,100+lineskip,font,red,"WORLD"); var clock = Faio::mk_alarm_clock(); Faio::sleep(clock,10.0); destroy_window w; ////////////////////////////////////////////////////////////////////// The "hard bit" will be text input. I already have a text editor written in Felix using SDL (run "make sdltest" or see demos/sdl), so I have some working editing code that can be adapted. Please note the interface will probably change! I'm just hacking something simple together to start. Two major features of Felix will be leveraged with this system. The first is fthread/schannels. This will be used to handle SDL events. We will also leverage it later to implement actors, that is, sprites that move about the screen of their own accord. The other feature we will need a bit later is embedding. The reason we need this is that most GUI systems and also OpenGL are utter crap. Stuff like threading, event polling, and drawing the mix modestly OK on Linux with X don't work with other OS GUIs and don't work with threads. because games are real time systems, some threading is useful to ensure, for example, you get a fixed video framerate and response to keyboard or other control devices. this is particularly important if you have a garbage collector :) Most games around are crap, because they do not do this. Don't blame the game writers. Blame the idiots that designed the GUI systems and OpenGL. In any case we may be forced to embed some code inside foreign event loops. In particular it would be nice if events could be monitored in a pthread and dispatched like ordinary Felix async events. Unfortunately this doesn't work on Windows because the event queue is "per thread". It does work with X-Windows. I don't know about OSX. Similarly it would be nice to do simultaneous drawing: sometimes drawing has to be abandoned in favour of retaining a constant frame rate. Unfortunately if you're using OpenGL to talk to a GPU to do rendering, the only way to do this is to use a mutex to swap contexts across threads. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language