I've been using SDL for a long while now. The newest version of SDL 3 will require migrating from SDL 2 versions. Like the switch from 1.2.15 to 2, it will once again break backward compatibility. It will remove support for several older platforms and change the API. The good news is that SDL 3 will have a compatibility layer much sooner than SDL 2 did. I'm still patching some of the SDL 1.2.15 programs I use so that they'll work with either SDL 2 or SDL 1.2.15. In my experiences with it so far, patching seems to work better than using the compatibility layer for SDL 1.2 support. SDL 3 will make more use of the GPU and modern graphics libraries and drivers. From what I've read, it'll introduce a new, portable shader language. So, you may now need more than just a C compiler to write programs. I prefer working with a minimal number of languages and compilers and am not looking forward to some of the new changes SDL 3 may bring. This leaves me wondering if I should seek another graphics/GUI library for more of my development.

I've looked into GUIs, TUIs and graphics libraries in the past and I really wasn't thrilled with most of the options out there. Besides SDL, Raylib seems very promising. It doesn't have the variety of FLOSS applications SDL seems to though. Using OpenGL directly can be just as problematic as SDL because its API keeps changing as well. So, GLFW may not be a great strategy either if the OpenGL compatibility it makes accessible has a changing API. Nano-X seems fairly stable and works on a variety of operating systems. Allegro is often used for applications similar to those created by SDL. However, differences between the versions it supports and what platforms those versions offer is also noticeable. I often use pdcurses with an SDL backend, but pdcursesmod works very well on Windows using Win32 and can also support console mode in Windows and BSD-curses and ncurses offers some benefits over pdcurses on POSIX systems. So, while I've found pdcurses built with SDL highly portable and useful (I even added SDL 2 and SDL2_ttf support), programs that build with pdcurses should port easily to other libraries that don't require SDL.

There are some platforms that only work with SDL 1.2.x and are not supported by later versions of SDL. The same will most likely be true for SDL 2 compared to the latest version of SDL 3. I'm wondering if I should keep using and patching the current SDL 2 and 1.2.15 libraries I've been working with or just make the switch to a new library. I'm also wondering if other developers are in the same situation, trying to determine whether to continue with what they have or port what they can to yet another graphics library or a later version of SDL. If there's interest from other developers in continuing to use older versions of SDL because of platforms they supported or portability issues, it would be nice to collaborate in continuing to maintain these libraries. It's easier to find security issues and bugs when there are a group of users rather than just one programmer using it.

I am currently working on backporting the latest SDL 2 helper libraries so that as many as possible work with SDL 1.2.15. That way SDL 1.2.15 can make use of newer features like loading and rendering SVG images, better utf-8 support, etc. I have a patched version of SDL2_ttf that adds functionality needed for sdl_unifontview to work properly. I've also been adding an alternative build system that doesn't require GNU autotools or cmake. It instead uses CDetect and make.

As one of the earlier contributors to MinGW, I use the original MinGW port to Windows and try to avoid the hostile fork of MinGW whenever possible. Unfortunately, many libraries do not maintain compatibility with the original MinGW compiler. The newer the libraries are, the less compatible they typically are. So, while SDL 1.2.15 is no problem to build with MinGW. SDL 2.26.5 is a nightmare. I'm currently looking into some issues related to building it with the original MinGW now. I maintain my own version of w32api based on the last public domain release and have been trying to add enough functionality to it to compile many of the more modern standard FLOSS libraries. I also built SDL 2 on AIX at one point to experiment with running SDL applications on AIX via X-forwarding. So, I have patches for that as well.

I've started a thread on Mastodon:
https://fosstodon.org/@lmemsm/110413981373101611
Would be very interested to hear how others are dealing with the SDL upgrade path and whether they will be upgrading, staying with what they have or seeking other libraries. If anyone's considering the route of maintaining older libraries, I'd be very interested in sharing resources and patches.

sixel

Apr. 19th, 2022 12:52 pm
I've been investigating using sixel and a terminal program in place of options like X Windows and Wayland. Thought I'd share my research results so far.

The library libsixel is available at:
https://github.com/saitoha/libsixel
An SDL library modified to work with sixel is at:
https://github.com/saitoha/SDL1.2-SIXEL
There's a later fork of the sixel library here:
https://github.com/libsixel/libsixel
However, other projects like sixel support for SDL were not forked.

I started with the older libsixel and SDL1.2-SIXEL projects. The newer project uses Meson for building and I don't intend to get Meson or its dependencies up and running at this time. I was able to get libsixel to build on Windows and AIX. It needs some minor modifications to build on AIX. SDL with sixel support will not build on Windows. It was designed to work on a POSIX machine and would need to be ported to Windows (with a major rewrite) to work. I was able to get SDL with sixel support to build on AIX. That also needed some modifications. The patches at Perlz.org ( https://www.perzl.org/aix/index.php?n=Main.SDL ) were very helpful. Needed some other modifications as well and to configure it to build with sixel and not X Windows.

Once I got the libraries built, I needed a way to test it. mlterm ( http://mlterm.sourceforge.net/ ) has sixel support and it builds on a variety of platforms. So, I ran my tests through mlterm.

I built the SDL demo program fire because it didn't require a lot of support libraries and it has enough color to let me test if colors on an Endian system were being handled properly.

Here's what I found out. For a small example program, it seemed to run incredibly slow. Not sure how they ran the Doom program mentioned at the sixel site at a decent rate. The colors were reversed because it was an Endian system. I've been wanting to test some of the SDL programs I typically work with to see if I've coded for Endian systems properly or not. Hopefully, I'll be able to do that in the future.

Note: As a follow-up, I tested some of my SDL programs using X forwarding. Some of the programs I tried did have a problem with color when tested on a Big Endian system. However, the ones I specifically coded to handle colors on different systems appear to be displaying properly. So, my assumptions on how to work with color palettes on Big Endian systems appear to be validated. I built the fire demo using SDL with X Windows support and ran it using X forwarding. It is actually even slower than the sixel solution was. So, using X Windows with X forwarding to run GUI programs on another machine does not appear to be a good solution either.

I've been looking at various methods to replace X Windows and Wayland. There's nano-x, directfb which works with SDL and now I can add sixel to the list of options I've tried. Nano-x works great, but it was slower than X Windows on my computers. You can run more than one application at once and display them in windows on your screen. Using framebuffer or directfb works in some cases, but when I tried to run more than one application using a terminal splitting program, it was a mess. It's not slow. However, less programs can be built this way. SDL applications typically need to be set to use fullscreen options. As mentioned, similar to nano-x, sixel seems to be slow as well. I'm not sure how it will work with a terminal splitter program, but I assume it will do better than the framebuffer/directfb options. nano-x provides the greatest compatibility as far as number of programs that work with it. Since both it and sixel are slower options, I'm not sure sixel provides enough advantages over nano-x beyond the fact that it'll run in a terminal so you can access it by ssh on another system. You'd be very limited in what terminals you could successfully use though. One advantage of sixel is that you could run GUI programs in a terminal on Android using a method similar to what Termux uses. You could also run GUI programs on Windows using WSL without requiring an X Windows server. There's now a better solution for using GUI programs on later versions of Windows that doesn't require a separate X Windows installation. So, it may not be that useful to run GUI programs in a terminal using sixel on WSL, especially if the speed is much better using the other methods.

So, at this point, I'm wondering if I'm back to square one as to finding GUI options that will allow for quickly and easily building and for sharing applications. I'm still finding it easier to build and share applications targeted to Windows using Win32. They run on Windows operating systems (several versions) and many run on ReactOS and on Linux via Wine. There are other solutions for running Windows compatible programs as well. BoxedWine allows porting of Windows programs to other operating systems. Winebox creates an alternative operating system to Windows based on Android. I'd like to find some alternative solutions to using Win32 that are just as portable. I've also investigated building programs for DOS systems and using options like DOSBox and DOSemu. Was not thrilled with that alternative for various reasons. As Termux demonstrates, porting console programs often works well. One can build a console program statically and not have to worry about what libraries are available on another POSIX system. However, once a GUI is involved, it can be much more challenging (as the effort to get GUI programs working with WSL illustrates). Would be interested to hear from others who are looking into alternatives to X Windows and Wayland.

Gem games

Jul. 16th, 2020 02:11 pm
I've been looking for a decent Open Source jewel or gem game where you try to line up three or more gems in a row.

Was able to find a few written in C:
https://sourceforge.net/projects/bejeweled/
https://sourceforge.net/projects/gemz/

I also ran across OpenGemmy on the Google Play Store. The source code for it is available here:
https://bitbucket.org/vjaka/match3/
It's built using lua and a library called love2d.

I thought it would be really interested to be able to play the match3 game on my PC instead of an Android. One reason, the screen's easier to view. So, I tried downloading an executable of love2d for Windows. With the latest version of love2d and a couple of patches to the match3 code, I'm able to get it working on a Windows 10 machine. However, I really wanted to see if I could get this running on an old Windows XP machine. Later versions of love2d are written in C++, but I found an older version of love2d written in C ( https://github.com/love2d/love-old ). It's probably going to take a while to debug and get building against the latest version of lua. So, in the meantime, I downloaded love-0.6.2-win-x86.zip from https://bitbucket.org/rude/love/downloads/ With a little more patching I was able to get match3 to come up using that version of love2d. To run, specify the directory where love is installed and the executable along with the directory where match3 is installed. For instance, on my system it's:
\bin\lua\love2d\love \bin\lua\match3
Needed to do some debugging on match3 to get it to run without any bugs on Windows XP, but it appears to be working fine now. It's nice being able to see it on a large screen.

If you run across any other cross platform implementations of this type of game in C, please let me know. I'd really like to find out what other versions of this game are out there.

LM Ports

May. 19th, 2020 09:00 am
I've mentioned my build system before. I've been trying to find a good way to share the programs I've compiled for Windows, Linux, AIX, Android, etc. However, I still haven't found a good method to do so. Rather than continuing to wait until I find the perfect solution, I've decided to try a temporary solution that's very basic.

I've already been uploading the build scripts to the archive link at my LM Ports page ( http://www.distasis.com/cpp/lmports.htm ). I'm going to start adding some executables and libraries for Windows. I don't have an automated installation program at this point, so some manual work needs to be done to get programs to run. In order to run a program, you will need all the dependencies. So, you need to download the tarball (has txz extension) with the program you're interested in plus the tarballs with the dependency libraries aka dlls. The bldepend.txt file in the build script has a list of what dependencies are needed to build a program or library. The depends.txt file in the tarball package has a list of all the dlls needed for the program to run. Pick a directory on your system. ( I use \mingw\msys\ ) Unpack the required tarballs to the same directory (holding the executable program and libraries/dlls). ( This puts the programs and dlls in \mingw\msys\opt\bin ) Programs like 7zip, 7za, gzip, bsdtar can be used to unpack tarballs. You can run them from the command line or the msys bash shell. If it's a program with a GUI, you can also create a shortcut or run from the file explorer.

I use some tricks to make programs more portable including a couple of specialized libraries and some patches so that the programs don't have to run from the directory they're built for. I don't have those libraries uploaded and ready to share yet. For now, I'm using the standard libintl instead of my modified version. So, internationalization probably won't work well until I can switch to my libraries.

While I'm not interested in changing package managers/build systems, I'm open to suggestions on better/easier ways to make the programs available/accessible to people. The plan was to eventually put together an ISO with several programs and a GUI front-end plus more documentation on how the programs work, but I'm not far enough along in the project to do so yet.

It's a lot of work to try to port programs and keep the build scripts up-to-date. I've just been doing this for myself. So, don't expect any official support on the project. However, I would like to share some of the results with others in the chance that it might be useful to someone besides myself now. If you'd like to encourage the project or get more involved, you're welcome to do so from the CppDesign mailing list ( http://www.distasis.com/connect.htm ). I have Windows builds for several command line utilities, SDL, FLTK and pdcurses based programs and even an X Windows port.
Was looking for a cross-platform open file dialog for SDL that I could use to select files if one isn't provided via command line. There are lots of options but finding a solution isn't as easy as I would like.

There are SDL programs like Bard and Milkytracker that have this sort of functionality. The code for the file dialog functionality is integrated with the programs, so it would be hard to remove it and use it as a library for other programs.

One could integrate SDL with other GUI toolkits. There are some interesting articles on how to do just that. However, I'd like to avoid the overhead of the heavier toolkits.

Nuklear has a file browser example. The basic Nuklear backend uses OpenGL instead of SDL. One would need SDL_gpu or a similar solution to use Nuklear with a SDL backend.

otk has a file browser example ( http://otk.sourceforge.net/tutorials.html ). It also uses OpenGL instead of SDL, but it needs less dependencies than Nuklear to build. It's worth considering, but it's not quite as ergonomic as other options.

The dialog program which can be built with ncurses, pdcurses or other versions of curses has a directory selection dialog. Applications built with pdcurses can use a SDL backend. However, that would mean adding a pdcurses dependency to projects. Plus, dialog is a program and it's not really designed to be called as a library. There are other options that will build with pdcurses and are designed to be called as a library such as CDK.

A similar option to the dialog solution would be to use BSD libform and pdcurses. One would need to write the rest of the dialog functionality though.

Some small projects use tiny file dialogs ( https://sourceforge.net/projects/tinyfiledialogs/ ). It can use native Windows or conio options on Windows. However, on Linux systems it would need some help from tools like dialog or zenity or similar tools.

When searching for SDL file browsers, I ran across this code:
https://www.omnimaga.org/ti-nspire-projects/sdl-file-browser/
It has a GNU GPL 3 license. It's written for SDL 1.2.

There's also the Jlime project's fileselector code. It works well enough and it's fairly readable. It has a GNU GPL 2 license. It's written for SDL 1.2. So, a port for SDL 2.x would be needed. Plus, I needed to add some support on Windows to use the GetCurrentDirectory in place of getcwd in order to build it successfully.

Those are the options I've found so far. I'd love to track down some other possibilities. Have any other SDL based suggestions? Please share them.
There are still lots of great programs that only work with SDL 1.2.x and haven't been ported to SDL 2.x yet. There are also some operating systems that have not yet added a port of SDL 2.x and are still using SDL 1.2.x. SDL 1.2.x has support for Linux framebuffer which SDL 2.x does not offer. So, I've been finding myself supporting both SDL 1.2.x and SDL 2.x development environments. I am porting SDL 1.2.x programs that I commonly use so that they'll work with SDL 2.x as well. I have more than a half dozen converted but have a long way to go. A list of the SDL applications I use most frequently is here: https://lmemsm.dreamwidth.org/1855.html If you know of other ports of these programs to SDL 2.x, please share the information. A list of some of what I've already added SDL 2.x support to is available from here: http://www.distasis.com/cpp/lmports.htm

There are several helper libraries, I consistently use when working with SDL. I've been trying to pare it down to a minimum, but there are some I can't do without. These include sdl_ttf/sdl2_ttf, sdl_gfx/sdl2_gfx, sdl_image/sdl2_image and sdl_mixer/sdl2_mixer. I've been able to replace sdl_draw (which I did port to SDL 2 at one point) with sdl2_gfx in all the applications that used it as a dependency. I don't really use sdl_net. I tend to prefer to use programs offline and not be connected to the Internet just to have a program work. I haven't found a real need for sdl_audio. sdl_mixer seems to be good enough for most programs that provide audio.

Still, four libraries for SDL 1.2.15 and four for SDL 2.x can be a lot to keep up with. Also, the SDL 2 versions of these libraries have added some nice features like better Unicode/UTF-8 support for sdl2_ttf and support for newer image formats like svg in sdl2_image. They'd be nice to have in SDL 1.2.x.

When I was porting unicodeview to SDL 2.x, I needed to make some patches to sdl2_ttf similar to the ones needed for sdl_ttf just to get the unicodeview program to work. Neither sdl_ttf or sdl2_ttf has great support for UTF-32. sdl2_ttf does have better support for UTF-8 than sdl_ttf. So, I wanted to use the UTF-8 improvements in sdl2_ttf to improve Unicode and UTF-32 support in sdl_ttf. When I looked at the sdl2_ttf code and compared it to sdl_ttf, I realized they were similar enough one could still use sdl2_ttf with SDL 1.2.x. So, I decided to start using sdl2_ttf for both SDL 2.x and SDL 1.2.x builds.

sdl_gfx is an interesting case. sdl2_gfx only works with SDL 2.x. However, the developer has patches for sdl_gfx to get it work with SDL 2.x as well. I actually found one of my SDL 2.x programs worked faster using sdl_gfx instead of sdl2_gfx. So, I have versions of sdl_gfx for both SDL 1.2.15 and 2.x along with the option to use sdl2_gfx with SDL 2.x applications. The programs I've been patching that require one or the other or that used to need sdl_draw can now use any of those 3 options.

Since I've added support for both versions of SDL to other libraries, I decided it was time to look at the code of all the support libraries I use for SDL and see if I could combine the rest of them. I just completed patching SDL2_image so it will still work with SDL 1.2.x. I tried it with a build of picaxo and I can now view svg in the SDL 1.2.x build of picaxo not just the SDL 2.x build. Will also be looking at sdl_mixer.

I could just patch the programs to make these changes, but I find it easier to use my own build tools when trying to make modifications. So, I've ported all the libraries I'm working on to build with CDetect, GNU make, pkgconf and a shell (usually bash) build script. I no longer need the entire GNU autotools toolchain to build them. I don't need cmake either. I find it really easy using my own build system to switch between the SDL 1.x and SDL 2.x builds. I just need to change one define and generate the appropriate build script. I also find it easier to build these libraries for more unusual systems like Android using my own build tools.

I know there are still some systems out there that are using SDL 1.x in place of SDL 2.x especially those that do not have a SDL 2.x library port readily available. Most of the SDL 1.x helper libraries haven't been updated or had features added since development switched to a newer version of SDL. Would think updated versions of these libraries would be nice for systems still using SDL 1.x. If you're working on a system like that or are interested in porting software so that it works with different versions of SDL, contact me. It would be nice to combine efforts on a project like this.

If anyone wants to try some of these changes out, I will be uploading my patches and build scripts to:
http://www.distasis.com/cpp/lmports.htm
For a long time now, I've been wanting to put together an ISO with Free, Libre and Open Source software similar to the kind our Linux Users Group gave out on Software Freedom Day. I'd like to gear it specifically toward educational software so that groups like Schoolforge may make use of it. If you'd like to help, I would love to have suggestions for lightweight, portable software that can run in console or framebuffer mode. I'm specifically interested in educational, hobby-related, utility, information/organizing and/or word processing programs. Have any recommendations? Please let me know ( http://www.distasis.com/connect.htm ).

Since I'm creating this to promote FLOSS software, I thought it would be great if I could distribute the software on a remastered Linux ISO that could be run from VirtualBox or Qemu or that might boot from a DVD or flash drive. I'd like to try to stick with a console based distribution so that it's lightweight and runs well on older computers with low resources. That means all programs need to be command line, console based (ncurses/pdcurses) or work in framebuffer mode (using SDL 1.x, nano-x, nx11, FLTK, etc.) in order to run on the system without X Windows or Wayland. For efficiency, I'd prefer compiled programs (such as those written in C) to ones that require an interpreter to run. I'd also like to make it as accessible as possible as far as internationalization and for users that may have disabilities. I'm using internationalized language support when possible via gettext. There are utilities like flite and espeak for text-to-speech support. My goal is to put together a lightweight, low resource distribution that will work well for users with older computers and users with no or limited Internet access. There are plenty of things you can do with a computer even if you can't get access to the Internet. Why not make some of those options more readily available?

I'll list some of the software I'm currently considering for the distribution. I'm still missing functionality in several areas, so if you have any recommendations for programs that would fit the criteria I've mentioned, please let me know.


Graphics applications

grafx2 - graphics editor
lodepaint - graphics editor
graphicsmagick - command line graphics editor
picaxo - graphics viewer
perigee slideshow - slideshow viewer
gifsicle - command line tool to create animated GIF files
GLE - command line tool to produce charts
nanosvg - includes lightweight SVG viewer


Music creation/audio applications

I'm still looking for a good Karaoke program (written in C or C++). TiMidity++ does some lyrics display, but I've yet to see it display lyrics created by abc2midi using the console version of TiMidity++. Some educators have found Karaoke to be a good way to help students improve their reading skills.

abc2midi - create your own music using music notation and convert to midi format (command line)
abcm2ps - creates sheet music (command line)
sox - sound exchange, audio file converter and player (command line)
milkytracker - create and play music
TiMidity++ - plays midi files


Readers

Still need several suggestions in this area. I'm currently looking for lightweight PDF and Postscript viewers. Was thinking of using mupdf but I'd still need a decent front-end for it that will work in framebuffer mode. Xpost might make an interesting alternative for Postscript display, but it's still in the works. I found a cbr/cbz library, but don't have a good framebuffer based front end for that yet either. It could be integrated with mupdf or used standalone. Would be nice to include some educational public domain ebooks with the distribution too.

bard - epub reader with text-to-speech capability
pdftxt - converts PDF to text using libmupdf (Can be used with search tools such as grep.)
qpdf - command line PDF transformation tool
sdlbook - SDL front end for libmupdf (Recently found this and it may fill my needs for a PDF viewer.)


Audio/video players

flxplay - plays flx movies
theoraplay - plays ogg theora videos and ogg vorbis


Astronomy

nightsky - displays stars
pngphoon - graphically shows moon phase (command line)
lcal - command line based lunar calendar that outputs to PostScript


Word processing

I'm thinking of using one or more of the following editors as an alternative to the popular vi/vim and emacs editors. Other suggestions welcome.

nano - ncurses/pdcurses editor
textadept - programming editor that uses scintilla editor widget has ncurses/pdcurses front-end
wordgrinder - ncurses word processor
mp (maximum profit) - editor with ncurses/pdcurses front-end


Other text related utilities

I have a few dictionaries in stardict format that are Open Source. (Created one from the Mobi project.) I'm looking for other Open Source dictionaries in the stardict format or easily converted to that format. Also still looking for a good grammar checker program.

hunspell - command line spell checker
sdcv - command line version of stardict dictionary tool
style - readability tool
diction - readability tool


Information managers/organizational tools

This section needs some additions. Anyone know a good SDL based calculator? I'd love to find a decent command line utility to avoid repetitive stress injury. There are some great desktop ones such as (workrave and prevrsi).

pcal - command line calendar that outputs to PostScript
ckpass - possible command line keepass replacement
sc - spreadsheet calculator


Hobby related

Don't have much in this category yet. There are several good HAM radio programs available. Maybe some of them that will work in console or command line mode could be added. Other hobby suggestions welcome. Also, maybe some public domain ebooks on hobbies could be useful.

nut - nutritional analysis


Educational entertainment

If you have other recommendations, please let me know.

lpairs - memory game
dual-n-back - memory tool
anagramarama - anagram language game
scramble - anagram language game
hangman - language game
concentration - memory game
tuxmath - game for improving math skills
starlanes - interstellar commerce game


That's all I have so far. I still have to look into remastering a Linux distribution. If you have tips for a simple remastering tool to use or know of some good documentation on how to remaster a Linux distribution via command line, please let me know. Would also appreciate other suggestions for lightweight, portable, useful or educational software (preferably in C). I'm also looking for Creative Commons, public domain or Open licensed educational media (ebooks, videos, etc.). Know of a Linux distribution that's already doing a similar project and would like another volunteer? Please let me know. If you'd like to discuss this project further or help out in some way, feel free to contact me ( http://www.distasis.com/connect.htm ). Thanks.
Along the lines of investigating portable C GUI libraries, I started looking at cross-platform library options for font rendering in C. This area is particularly useful if you're investigating creating your own GUI library or game library. I was most interested in the TrueType font rendering libraries and techniques. It was rather surprising to read just how difficult it is to get simple internationalized text to the screen especially using graphics libraries like OpenGL.

Here's what I've located. If you have other recommendations for C font rendering libraries, please let me know.


GUI library options like nuklear and nanovg use stb_truetype.h:
https://github.com/nothings/stb
They also use some kind of font stash, such as this one used with nanovg:
https://github.com/memononen/fontstash


Other GUI libraries use FreeType2.
https://www.freetype.org/

For instance, SDL2_ttf uses FreeType2.
https://www.libsdl.org/projects/SDL_ttf/

Allegro also has font libraries available that are based on FreeType2.
http://opensnc.sourceforge.net/alfont/mirror/

Here's one that works with Allegro or SDL:
http://kirill-kryukov.com/glyph-keeper/files.shtml


There are several font libraries for OpenGL, but there aren't many options written in C. Some are for older versions of OpenGL and some only work with later versions. Here's what I found so far:

https://github.com/rougier/freetype-gl
https://github.com/jtsiomb/libdrawtext
http://quesoglc.sourceforge.net/


Here's another C option that works with FreeType2 and embeds fonts in C programs:
https://github.com/chrisy/fontem


The most recommended technique used by OpenGL developers seems to be texture mapping. A texture can be used like a hash table to store various characters and other pixmaps that need to be rendered. An OpenGL function can draw a piece of the texture or update/change parts of it in memory without affecting performance too much. While software renderers have no real trouble copying or blending a bitmap graphic or pixmap, the newer OpenGL versions send the textures to the GPU for rendering. So utilizing a texture instead of bitmaps/pixmaps and minimizing the number of textures one is working with can improve performance.

I personally find it easier to render text with SDL. It handles copying and blending bitmaps (as an SDL_Surface) and offers a useful library (SDL_ttf) to do most of the work. SDL 2.x does use OpenGL underneath on some platforms, so some of the texture concepts used by OpenGL programmers might improve font rendering performance on some versions of SDL as well.

Freetype seems to be the library for working with TrueType fonts. SDL_ttf uses freetype to interpret the Truetype font format and create bitmaps/pixmaps to represent characters (converting them from vector format to bitmap/pixmap format). I found working with SDL_ttf a lot more user-friendly than trying to use Freetype directly.

Another viable option is stb_truetype.h. The license for this software is definitely an advantage. However, from what I've read the rendering still isn't quite as good as Freetype. I look forward to testing this out on my own at some point.

At this point, I'm still investigating SDL_ttf, stb_truetype.h and OpenGL texture mapping. A combination of these might be just what's needed in a font rendering design for a cross-platform GUI library.

Know of some other font rendering options that work well for Truetype fonts or have a better way to get fonts to the screen, I'd love to hear about it?
Some of the C graphics libraries are great, but I've yet to find a simple GUI that makes it easy to port some older BASIC programs that I want to be able to keep working with. I've created several iterations of my own GUI library, but have never been satisfied with the results. That's the main reason I keep investigating cross-platform GUIs, to see if someone's found a better way to do it. Of the various designs, the ideas behind the immediate mode GUIs seem the most useful for the type of programs I'm targeting. However, I can't seem to find one GUI library that provides a simple way to do what I want. So, I've decided to revisit my old GUI library designs but eliminate some of the framework constraints and some of the object oriented elements. Instead, I'm looking at a more procedural approach that uses concepts from immediate mode GUIs.

Even though I'm avoiding popular C/C++ GUI libraries, I'm not starting completely from scratch and writing everything myself. There are plenty of good graphics libraries that are very portable and make a great basic starting point for a GUI. One of the libraries I've been very impressed with is SDL. It makes a great base for porting software. I've also done a lot of work with PicoGL (a TinyGL fork). It's a convenient way to make OpenGL more portable and avoid some of the version issues. It works on low resource platforms such as handheld devices that don't have high performance video driver support. I've often found OpenGL and Mesa slow on older computers and low resource systems. PicoGL provides very good performance on these types of systems. While using Win32 is not as portable as I would like, it's not that hard to get an OpenGL window up and running on Win32. That easily allows switching between Win32/OpenGL and SDL (1.2.15 or SDL 2.x)/PicoGL. SDL can work on a variety of platforms and PicoGL can work with SDL or with other options such as nano-x, X11 or vesa framebuffer. It shouldn't be too hard to take the output from PicoGL to use with the Android bitmap API either. Another possible option for a backend is Allegro. Like SDL, it works on a variety of platforms. It would be nice to switch between SDL and Allegro as backends depending on which works best for a particular platform without needing to redesign an entire application.

The PDCurses/ncurses API provides a standard way to create console based programs that work well on a variety of platforms from DOS to Windows to FreeBSD to Linux. However, it provides only text support and no real graphics support. While it's great for porting programs written to work with it, I don't think it's the best option to use as a GUI backend. I recently came across TinyCurses which provides a subset of the API and uses SDL as a backend. PDCurses also offers SDL as a backend option. I couldn't help thinking, once a decent GUI design was finalized, it wouldn't be too hard to provide a subset of functionality similar to PDCurses/ncurses. That would allow for easy porting of some PDCurses/ncurses based applications to any platform the GUI library works on.

So, why not just use OpenGL as the backend to design a GUI library? After considering the pros and cons, I decided I don't want to be tied specifically to OpenGL as an API for 2D graphics. While it's very popular and available on several platforms, the changes from a fixed function pipeline to a programmable pipeline with its own shading language make it hard to port programs from one version to another. PicoGL makes use of old fixed function pipeline concepts. Windows OpenGL also uses the older design. Mobile devices and WebGL make use of the newer concepts and the ability to harness the GPU to do more processing. Many developers seem to be abandoning the older concepts and embracing the new programmable pipeline design. However, that leaves some nice older applications that were designed for earlier versions of OpenGL that won't port easily to the newer versions. They might require a complete redesign and rewrite. Using PicoGL is one way to make it easier to port such applications. It can do software rendering to a bitmap which can then use more modern methods (including later versions of OpenGL or SDL 2.x) to transfer the bitmap to the screen. While the idea of using OpenGL as the portable backend for a GUI library sounds good, dealing with version differences and what versions may be available on which platforms does not make it the best option for a complete cross-platform portable solution. Instead, I prefer the concept of being able to switch out backends to use what works well on a particular platform. The GUI library should encapsulate the rendering as much as possible to avoid needing to rewrite applications in order to switch to another backend.

On the other hand, many GUI libraries and some other rendering libraries (such as SDL) offer ways to interoperate with a graphics library like OpenGL. While I want my GUI library code to be cross-platform, I don't want to limit a developer to using just that API. If a programmer wants to use OpenGL or SDL2_gfx or some other library to handle 2D/3D graphics, I'd like the GUI to be able to interoperate with that choice. It would mean that the resulting application would be less portable. However, if an application is already designed to utilize SDL2_gfx, OpenGL or some other library that could work compatibly with the GUI library, it could make adding some GUI functionality to an existing application much easier.

I definitely know what I'm looking for in a cross-platform GUI. I want a simple, portable way to get text, menus, forms, file/directory picker dialog functionality to the screen. I'd like to make use of Freetype fonts. I want an internationalized way to display text and for users to input text. The text strings will probably involve a library such as gettext. I want the options to use keyboard input for those of us who prefer keyboard commands to get their work done and mouse/touchscreen input for devices such as mobile phones where a real keyboard may not be available. I need to be able to access graphics and audio information from a file system or from a zipped file (such as .apk file on Android). I don't care if the look and feel matches what's in style for a particular device or operating system. I just want it to be user-friendly and ergonomically designed.

If you're interested in GUI design or working on a GUI or gaming library of your own, I'd love to compare notes on the subject. Have an idea for what C library might make a good backend for a portable, cross-platform C based GUI? Let me know. Feel free to discuss design issues or other C/C++ topics on the CppDesign mailing list or contact me to compare design notes and share ideas ( http://www.distasis.com/connect.htm ).
I'm always on the look-out for a simple to use, lightweight, portable GUI library. I've put together several lists of available C/C++ GUI libraries. (For instance: http://www.distasis.com/cpp/scrlib.htm ) I've also tried out and experimented with several GUI and text user interface libraries. It's difficult to find one that will let you get a new application up and running or an old one ported to C/C++ quickly. Most GUIs seem to get in the way of development or complicate it.

I still keep debating whether to create my own GUI library in projects or use what's currently available. There's no point in creating your own if there's something better out there. That's the main reason I continue to look for interesting GUI libraries. However, I've yet to find that "something better" that I really enjoy working with.

With that in mind, here's another list of GUI libraries. This time I've limited the field to C only libraries that are highly portable. Since many lighter GUIs use various graphics libraries and other frameworks as backends, I'm including information on graphics libraries that can be used for GUI development as well.


Graphics libraries often used with GUIs:


Some lightweight GUI libraries use graphics libraries as backends to improve portability and decrease library code size. Popular graphics backends written in C include SDL (Simple DirectMedia Layer) and Allegro.

SDL

https://www.libsdl.org/
SDL2_ttf provides TrueType text support for SDL.
https://www.libsdl.org/projects/SDL_ttf/
SDL2_ttf provides internationalization support using a UCS-2 character set. I have patches to support the UTF-32 character set.
http://www.distasis.com/cpp/lmports.htm

Allegro

https://www.allegro.cc/about

AGG

Anti-Grain Geometry library is also used as a graphics backend. Some projects stick with the older version of AGG 2.4 which has a BSD license.
https://en.wikipedia.org/wiki/Anti-Grain_Geometry

Nano-X/Microwindows

Nano-X is highly portable and can work on a wide variety of platforms including DOS and embedded systems. It makes it easier to port X11 and Win32 applications by providing a subset of those APIs (with nano-x/NX11 or microwindows).
https://github.com/ghaerr/microwindows
https://github.com/georgp24/microwindows-android-bin
https://github.com/ghaerr/nxlib

OpenGL

I've seen several lightweight GUI and screen libraries designed for OpenGL. However there are issues with portability to different versions of OpenGL or OpenGLES. Projects like freeglut and GLFW try to make OpenGL easier to use for cross-platform development. There are also several libraries that work with the freetype library and add TrueType font support including ftgl, ftgles, GLTT, freetype-gl, OGFLT
http://freeglut.sourceforge.net/
https://www.glfw.org/

PicoGL

I like PicoGL (a fork of tinyGL) for OpenGL development. It's a subset of OpenGL. It supports several backends including SDL, nano-x, X11 and vesa framebuffer. Since it's software based, it ports well to hand-held devices and other systems that may not have rich hardware support for graphics.
http://people.openmoko.org/jserv/graphics/

I've made several updates and additions to PicoGL including adding some missing OpenGL functionality, SDL 2.x support, bug fixes including a fix for lighting bug in the gears demo. It includes enough OpenGL support to port Emilia pinball. I haven't uploaded my changes to the Internet yet, but if anyone's interested, feel free to contact me about it.


GUI and text user interface options:


PDCurses with SDL backend

This is an option I really like. I've been experimenting with using this for development. I have BSD libmenu and libform working with it too. PDCurses can be used to create a text user interface and SDL can add graphics capabilities.
https://github.com/wmcbrine/PDCurses

TinyWidgets

Lightweight GUI with graphical screen designer. Uses nano-x as a backend. While the original project is dated, there's been some recent development by some of the nano-x developers.
http://tinywidgets.sourceforge.net/
https://github.com/ghaerr/microwindows/tree/master/src/contrib/TinyWidgets

nuklear

This looks promising. Has several backends including GLFW, SDL, Win32, X11, SFML, allegro, nanovg.
https://github.com/Immediate-Mode-UI/Nuklear
https://github.com/vurtun/nuklear
https://github.com/vurtun/nuklear/issues/202
There are also projects that combines nuklear and raylib:
https://github.com/RobLoach/raylib-nuklear
https://github.com/tcfunk/raylib-nuklear

raygui

Another promising cross-platform option. It has support tools to help create layouts. It works on a variety of systems including mobile devices. There's also raylib (a graphics/video game library used by raygui) and raudio (for audio support). The raylib library uses OpenGL/GLFW for graphics support.
https://github.com/raysan5/raygui

c_ugui

Immediate mode GUI using Raylib.
https://github.com/Aurumaker72/c_ugui

nanovg

nanovg is a 2D vector drawing library by the developer of nanosvg (popular svg parsing library). The examples show GUI elements. Other GUI libraries (including nuklear and oui-blendish) also use this as a backend option.
https://github.com/memononen/nanovg
https://bitbucket.org/duangle/oui-blendish/src

GTK+

GTK+ is one of the more popular GUI libraries. However, while each new major version came with added features, it also came with a lot of added complexity. Some distributions use older versions of GTK+ (no longer in development) in order to cut down on complexity. While there were several applications written with this library, it's hard to find up-to-date, supported applications that still use an older version of GTK+.

Amigo Linux is still using GTK 1.2 and has patched some applications to keep them working.
ftp://distro.ibiblio.org/amigolinux/misc/Amigo%20Linux%20Project.html

I've also seen some patches to GTK 1.2 to keep it more up-to-date.
https://github.com/dimkr/gtk
https://github.com/tindzk/GTK

Another interesting GTK+ based option, there were some ports of GTK+ that use the ncurses backend.
https://atrey.karlin.mff.cuni.cz/~pavel/cursed/cursed.html
https://sourceforge.net/projects/zemljanka/files/

If you're interested in more up-to-date GTK+ versions that try to avoid some of the bloat and unneeded dependencies, check out these forks for GTK 2 and a minimal ATK to use with GTK 3:
https://github.com/stefan11111/gtk2
https://github.com/stefan11111/atk


XForms Toolkit

http://xforms-toolkit.org/

LessTif

https://sourceforge.net/projects/lesstif/

Kiss_sdl

GUI toolkit for SDL.
https://github.com/actsl/kiss_sdl

kiss-nanovg-sdl

Based on kiss-sdl but modified to support svg using nanovg.
https://gitlab.com/Mis012/kiss-nanovg-sdl

KiWi

GUI toolkit for SDL.
https://github.com/mobius3/KiWi

RetroGui

Minimalistic GUI library based on SDL.
https://gitlab.com/Pix3l/RetroGui

rouziclib

Works with SDL and other libraries.
https://github.com/Photosounder/rouziclib

Green-GUI

GUI for SDL 1.2 written in C99.
https://github.com/Laurefinwe/Green-GUI

swk

Minimalist widget kit for SDL.
https://oldgit.suckless.org/swk/files.html

WidgetSDL2

C99/SDL2 Cross-platform GUI using include headers.
https://github.com/nuchida7727/WidgetSDL2

uGI

Micro Graphical User interface. Needs SDL2.
https://github.com/wernsey/uGI

SDL GUI

Simple SDL GUI libraries, mainly targeted toward Windows.
https://github.com/David-H-Bolton/sdlgui

CGUI

GUI toolkit using allegro.
http://cgui.sourceforge.net/index.html

Win32

I've seen several C applications written with the Win32 API. That might not sound very portable for platforms other than Windows. However, keep in mind that X11 users have access to winelib and Microwindows offers some Win32 API compatibility. I have been able to get some programs written using a Win32 backend to port and run fine on Microwindows/nano-x.

Otk (Open Tool Kit)

C and OpenGL GUI.
https://sourceforge.net/projects/otk/

IUP

https://sourceforge.net/projects/iup/

LCUI

https://github.com/lc-soft/LCUI

Clay
https://github.com/nicbarker/clay

sgui

https://github.com/AgentD/sgui

libui

https://github.com/andlabs/libui

libui-ng
https://github.com/libui-ng/libui-ng

GraphApp

http://enchantia.com/software/graphapp/

Microraptor GUI

https://github.com/hodefoting/mrg

Micro-GUI (ugui)

https://github.com/ryankurte/micro-gui

microui

https://github.com/rxi/microui

FTK

https://github.com/xianjimli/ftk

EasyGui for embedded systems

https://github.com/MaJerle/EasyGUI

m2klib

https://github.com/olikraus/m2tklib

Milkymist Gui Toolkit

https://github.com/m-labs/mtk

mGui

http://web.tiscali.it/morello/MGui/index.html

RGFW

https://github.com/ColleagueRiley/RGFW

RSGL

https://github.com/ColleagueRiley/RSGL

Yzone

http://lifesoft.chat.ru/yzone/

GUISlice

https://github.com/ImpulseAdventure/GUIslice

newt

https://pagure.io/newt

notcurses

https://github.com/dankamongmen/notcurses

vtk

https://github.com/vktec/vtk

Agar

GUI toolkit using SDL. I've read several posts about it being buggy and not well supported. I've personally had no luck porting it to certain platforms.

STFL

Use with PDCurses, ncurses or similar libraries to provide common controls and widgets.
http://www.clifford.at/stfl/

CDK

Curses Development Kit.
https://invisible-island.net/cdk/cdk.html

Widget Curses ToolKit

Ncurses TUI widget toolkit library.
https://github.com/stfsux/libwctk



This list is in no way comprehensive. If you know of other highly portable, strictly C GUI or text user interface libraries, please mention them. If you're working on your own GUI library, would like to discuss C/C++ GUI libraries and development or other C/C++ related topics, feel free to continue the conversation on the CppDesign mailing list.
Let's talk about Free and Open Source games. I thought I covered some of these when I discussed programs that work with various GUIs such as SDL and FLTK. However, looks like I left many out of my lists. So, here are some games I've found interesting. They're cross-platform and don't require a ton of resources to build and run. So, they should work fine on low resource or older machines as well as the newer ones. I tend to prefer educational games, but there should still be a good mix of different types of games in the list. If you have other lightweight cross-platform favorites, I would be interested to hear about them. You're welcome to discuss the topic of C/C++ games further on the CPPDesign mailing list ( https://groups.yahoo.com/neo/groups/CppDesign/info ).

I have patches for several of these to fix bugs such as memory leaks and to add support for later versions of libraries. Some of my patches are available online. If you're interested in others that I have not uploaded yet, you can let me know via the CppDesign mailing list.


FLTK BASED GAMES


Checkers and sudoku come with FLTK as examples.


fltkmm

Mastermind game. This is one of the more lightweight versions of Mastermind that I could find that's still intuitive to play. There are some ncurses/PDCurses alternatives and some SDL alternatives, but I haven't found any I like yet.

I have patches to make this work with the latest version of the FLTK library.

https://www.muquit.com/muquit/software/fltkmm/fltkmm.html


wordsearch

I've been able to port this to DOS using DJGPP. It also works fine on Windows, Linux and BSD.

https://web.archive.org/web/20120104214117/http://agtoys.sourceforge.net/wordsearch/wordsearch-2.2.html

qubix

While this ports without modifications to several platforms using Nano-X support for FLTK, I've been experimenting with patches and a port to use OpenGL/PicoGL as an alternative GUI. The program was originally written for a system that had Display Postscript support so it ports very easily to a graphics API like OpenGL.

https://www.fltk.org/links.php?V153+Q


npuzzle

http://jlehtinen.net/agenda/


SDL BASED GAMES


SDL is great toolkit for games and there are several nice games that work with it. Many of the games I've listed were written for SDL 1.2.x. I have patches in various states to get them working with version 2.x as well.


lpairs

http://lgames.sourceforge.net/LPairs/


scramble, hangman, concentration, torrent

These games are by the same author and use a similar back-end. I've made a library out of the shared code and am in the process of debugging ports to SDL 2.x.


pong

A copy of the original source and my SDL 2.x patches are available from the archive link at:
http://www.distasis.com/cpp/lmports.htm
Was also able to get this working for Android, but it requires a tablet with a keyboard.


drac

Basic solitaire card game.

I have patches for porting this to SDL 2.x as well. Was also able to get this working on Android systems.

https://github.com/ricoz/drac/


yahtzee

Works with SDL, ncurses/pdcurses or via command line. I have patches for using this with SDL 2.x.

https://www.muppetlabs.com/~breadbox/software/yahtzee.html


dual-n-back

This is a game, but it's also supposed to help improve memory.

https://sourceforge.net/projects/dualnbacklite/


tuxmath

A copy of the source and my SDL 2.x patches plus several memory and bug fixes and some modificiations for library updates are available from the archive link at:
http://www.distasis.com/cpp/lmports.htm
My patched version runs on Windows as well as Linux/BSD. The original source crashed on Windows.


Emilia pinball

I have patches porting this to SDL 2.x. I also improved Allegro support enough to build on DOS with DJGPP. I have an alternative build that works with SDL and picogl for systems that may not have easy access to an OpenGL library or mesa.

https://sourceforge.net/projects/pinball/


jooleem

I was looking for a bejeweled style game and this was the only one I found so far that I really liked.

https://sourceforge.net/projects/jooleem/


eremit

http://www.murga-linux.com/puppy/viewtopic.php?t=8724


anagramarama

https://github.com/Anagramarama/anagramarama


ReMined

https://sourceforge.net/projects/remined/


sopwith

http://sdl-sopwith.sourceforge.net/


PDCURSES/NCURSES/BSDCURSES GAMES


There should be several good games in this category but so far I just have one on my list. Please feel free to recommend your favorites in this category.


starlanes

This started out as a game written in BASIC with a few variants available. The version mentioned here is a variant that's been ported to C.

https://web.archive.org/web/20191230071944/http://www.barnsdle.demon.co.uk/game/starlanes.html


WIN32 GAMES


To make WIN32 applications work cross-platform, you'll need nano-x or winelib. The win32api is available with Open Source compilers such as MinGW on Windows sytems.


pyramid

This is a public domain solitaire-style card game. I'm currently working on converting this to run with SDL/OpenGL as the backend (instead of Win32) so I can more quickly and easily port it to other systems such as Android. It will make a nice test case for the GUI library I'm working on. If anyone's interested in status of the port, feel free to contact me about it.

http://jdmcox.com/
I've been searching technical books and articles to find out more about writing programs for Android using the native development toolkit (NDK) and C/C++. Finding relevant information is extremely difficult. Most sources just say to use Android Studio (or for older articles, use Eclipse) and do not go into any details as to how things work beyond the IDE or wrapper script. It's extremely difficult to find documentation that explains what's going on underneath.

I'm working on porting some Open Source projects already written in C/C++ to Android. So, I find it extremely frustrating when the typical advice I read is to avoid the NDK and use Java (or Kotlin). References that state that usually go on to say that Java (or Kotlin) really is not that much slower than C/C++, so you would be getting no significant gain in performance by using it. That leads me to believe that there has to be some gain in performance (even if it is not what the authors deem 'significant') or the articles wouldn't be mentioning that C/C++ was considered faster in the first place. Such articles typically go on to state that it's much harder to work with the NDK and one is better off using languages recommended by Google. However, for developers who prefer C/C++ over Java or Kotlin development and who are already aware of potential pitfalls of the C/C++ languages and how best to avoid them, those developers could be far more proficient and productive using C/C++ over other options. So, why recommend avoiding the NDK and C/C++? Why not encourage developers to use the languages and tools they can leverage to their best advantage?

Speaking of using tools that developers are most productive with, I already have a cross-platform build system that greatly reduces the time I spend building and porting Open Source libraries. I wanted to be able to use my build system. However, IDEs (like Android Studio) don't integrate well with automated build systems. It took a lot of digging through articles and books on Android, but I was pleased to find out how to create a standalone tool chain to build Android C/C++ applications.

I was surprised at the lack of support for cross-platform compiling of certain Open Source libraries. It's difficult to find Android builds and patches to common Open Source libraries. Also, based on my experiences porting Open Source projects to Windows, I wonder how many Open Source library developers would welcome adding patches to make builds of their libraries for Android work out of the box. My past experience has proved that many library developers would prefer not to add support for more platforms. That means I'll probably end up adding my patches to my LM BLD scripts ( http://www.distasis.com/cpp/lmbld.htm ) rather than seeing the fixes I've submitted added in to the libraries themselves.

So, as I work my way through porting various Open Source applications to Android, I thought I'd share the few useful resources I found that help clarify how to build and share C/C++ Open Source applications on Android.

The best documentation I've located to date and the one I'd refer anyone interested in C/C++ programming for Android to is this one:
http://www.hanshq.net/command-line-android.html
It explains where to get the NDK and other needed libraries. It walks you through how to create an Android package (apk file) via the command line. It gives a good example of how to build a C application that can get a developer started.

If you're on a Linux system, you can use the package manager to download a version of Java. You'll need it to create Android packages. For Windows users, one option is to download a portable version of Java and make sure it's in your development path.
https://portableapps.com/apps/utilities/jdkportable

The Android developer web site actually has some decent information on how to create a stand-alone C/C++ toolchain. You currently need Python to create the toolchain, but they actually supply a version of Python for operating systems that don't easily offer one.
https://developer.android.com/ndk/guides/standalone_toolchain.html#selecting_your_toolchain
See also:
https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
http://mobilepearls.com/labs/native-android-api/ndk/docs/STANDALONE-TOOLCHAIN.html

When creating the stand-alone toolchain, you'll need to know what API you're targeting. More information on that is provided elsewhere:
https://source.android.com/setup/build-numbers
Typical choices are to target the latest if you want to use all the newest features in Android or target an early enough version that the results will work on a majority of the Android devices out there. Which version is best will change over time as the majority of users buy newer devices and new innovations are added to newer APIs. Even though you mention the API when creating the standalone toolchain, the only place the information seems to be stored is in the llvm wrapper. So, you may need to add -D__ANDROID_API__ and the API you want to support to your compiler flags.

You'll also need to decide whether you want to target 32 or 64 bit platforms. Keep in mind that 32 bit code will work on 64 bit platforms, but the reverse is not true. There seems to be better support for large file access on 64 bit platforms though. Note that Google is pushing for latest API targets and 64 bit support for projects that will submitted to the Google Play Store. You'll need to build your application for each target you wish to support. So, if you want your programs to work on Android devices with arm chips or x86 based chips, you'll need to build libraries and applications for more than one system.

Google is also moving toward unified headers so they don't have to support a version of the C and C++ header files for each API they support. Depending on what version of the NDK you're using, you may want to add --unified-headers when creating your standalone toolchain.

I find it useful to know what native C/C++ functionality/which libraries are supported for various versions/APIs of Android:
https://developer.android.com/ndk/guides/stable_apis

I thought this site had a good series of posts on how to port a SDL based application to Android:
http://blog.stuff-o-matic.com/post/2013/10/20/ASGP-s-Android-Port-Part-IV%3A-building-the-APK

If you're interested in using dynamic libraries, this site had some useful information:
https://www.andriydruk.com/post/introduction-to-c-for-android-developers/

Testing the results you built may be difficult. My experience with using MoSync to build C/C++ Android applications showed how slow testing an application with an emulator could be. If you install Android Studio, it gives the option to install Intel HAXM (hardware accelerated execution manager). This can help speed up Android emulation. You can find HAXM and more information on it at the Intel web site.

You can also use VirtualBox and an Android virtual machine image for testing.
Android-X86 ( http://www.android-x86.org/ ) can provide images that work with targets compiled for x86 machines.

Another option is to use adb (Android Debug Bridge) to test the results on an actual Android device. Now that Windows Subsystem for Android is available, you can also us it to run Android apps and use adb to side load the applications you want to test. Here are a couple of articles that give examples of how to work with adb:
http://nickdesaulniers.github.io/blog/2016/07/01/android-cli/
http://codeblog.vurdalakov.net/2016/12/build-and-run-native-c-cpp-android-apps-with-ndk.html

One thing to keep in mind if you're going to test on your own Android device is that Developer options must be activated on that device first. Here's an article on how to do that:
https://www.embarcadero.com/starthere/xe7/mobdevsetup/android/en/enabling_usb_debugging_on_an_android_device.html

You can also build or access Open Source console applications (even without turning on developer options) when you have a terminal emulator app installed on your system. This gives applications you're running in the terminal emulator (even one's you've built from source) the same rights at the terminal emulator. You can use command line or console based applications (such as those built with pdcurses/ncurses/netbsd-curses) with a terminal emulator. There are several terminal emulators available from the Google Play Store or F-Droid. Try some out and see which you like best.

One of the terminal emulator projects has a github project with information on some common Open Source library packages including commands for building and patches needed to compile. One thing to watch out for is that some of their patches are made directly to the standalone toolchain header files. If you don't have similar patches or add extra patches to the library's build script, you may not be able to compile successfully. One of these fixes is to help work-around 64 bit file handling support on 32 bit systems. Some Open Source projects don't build properly or need major work-arounds to handle this with earlier versions of the Android API for 32 bit systems. More information on how the Termux terminal emulator project builds their Open Source libraries and programs is available at their github site:
https://github.com/termux/termux-packages/tree/master/packages

Another interesting resource if you want to see how various C/C++ projects are built and what patching might be needed is this one:
https://github.com/pelya/commandergenius
It uses SDL 1.2/1.3 ported to Android and includes several Open Source libraries and several popular Open Source applications including DOSBox, Milkytracker, grafx2 and a SDL based X server.

A developer I correspond with wrote his own tutorial on how to build C/C++ applications using Allegro and Nano-X. He covers a lot of useful material about the NDK and C/C++ development including how to call Java functions from C/C++ and vice versa. He also explains how to use Allegro on Android.
https://wiki.allegro.cc/index.php?title=Running_Allegro_applications_on_Android

Libraries such as SDL, Allegro and Nano-X provide support for building GUI applications on Android. Nano-X offers a subset of X11 functions so GUIs like FLTK and WxWidgets will work. PDCurses can be used in conjunction with SDL. Applications built using any of these libraries could potentially be ported to Android. Not all C/C++ applications provide interfaces that are user friendly for Android or for smaller screens and devices that may lack physical keyboards. However, if you create a well designed, portable interface for your program, there's no reason why it shouldn't work well on Android systems as well as PCs (Linux, Windows, BSD, etc.). Here's more information on some GUI libraries that work on Android:
https://github.com/georgp24/microwindows-android-bin
https://wiki.libsdl.org/Android
http://liballeg.org/readme.html

More recently, I ran across Android Apps in C. It uses Android Studio which is a lot of overhead if you just want to build an application. Also seems to use WSL on Windows instead of direct development on Windows. Seems to use the standard android_native_app_glue code. However, there may be other tips and tricks that are useful when creating a C/C++ application for Android. The project is at:
https://github.com/cnlohr/rawdrawandroid

That's pretty much all my searches have turned up as far as resources I've found useful for building C/C++ applications targeted to Android devices. If you have other reference recommendations that explain how things actually work (rather than glossing over the details and using a GUI interface), please let me know. If you'd like to share or compare notes on patches, compiler/linker options for building various Open Source libraries and applications, I'd enjoy hearing from you. You can discuss C/C++ Android development further with me and other interested developers on the CppDesign mailing list.
It's fun to discover new lightweight applications. They work well on newer computer systems as well as older or slower computers and low resource machines like many mobile devices. You can run more of them at once. If they're not well-known, they can actually be more secure sometimes (using the security through obscurity principle). I also personally prefer portable applications. That way, you can use the same programs on any operating system. You don't have to relearn new programs for each system you work with.

It can be quite a challenge to find new lightweight applications. I've read several threads on forums where users post their favorite lightweight applications. Many truly are not lightweight by standards that take into consideration memory usage, lines of code, compilation time and/or number of dependencies (libraries).

One way to find lightweight applications is to look for programs built with lightweight GUIs. I've seen a few comparisons of GUI performance. This one is particularly good because it tests the various GUIs and gives statistics:
https://www.pismotek.com/brainout/content/gui-toolkit-resources.php
I was rather surprised by the SDL2 results. Generally, the time it takes to build a GUI from source is one good indication of complexity. FLTK and SDL both build quickly from source compared to the other GUI frameworks mentioned. So, I was surprised that SDL2 scored so badly on the memory usage tests. I'd be curious to know if SDL 1.2.x (which many systems still use) would show a large improvement. Another surprise was how well Tcl/Tk did in the tests. I typically think interpreted languages have worse performance than compiled ones. It would be interesting to see some statistics on response times for similar applications created with these GUIs.

I often go through various source repositories such as Sourceforge, github, etc. looking for code written using specific user interfaces in order to find new and interesting applications. Standard search engines are another way to search for programs. The user interfaces I'm personally most interested in at this point are FLTK, pdcurses/ncurses, SDL and command line programs. These types of applications are typically more lightweight or designed to do one thing well. Know of any other lightweight GUIs or TUIs (text user interfaces)? Please share your recommendations and why you like them.

There are some nice blogs for finding and discussing minimalistic (or in some cases maximalistic) programs. Unfortunately, many are no longer very active. Some favorites are:
https://kmandla.wordpress.com/
https://inconsolation.wordpress.com/
https://web.archive.org/web/20160304000554/http://www.jaredandcoralee.com/CLIapps.html
http://macrofig.blogspot.com/

If you know of others, I'd love to hear about them.

One can also look for lightweight distributions and see what programs they have in their repositories or read their forums for more suggestions. Some of the interesting distributions to check are TinyCore Linux (uses several FLTK programs), Nanolinux (uses more interesting FLTK programs), Rogue Class Linux (uses several SDL programs), Puppy Linux, AntiX (Debian based), INX ( http://inx.maincontent.net/ ), Absolute Linux (Slackware based), 4MLinux ( https://sourceforge.net/projects/linux4m/ ), OLPC. Typically DSL and Puppy get mentioned when people list lightweight Open Source systems. There's been no active development on DSL in a long time and the forums are very quiet. I also found Puppy a little too resource intensive on one of my older machines. FreeBSD performed much better on that system. Puppy Linux has some interesting discussions in their forums.

Linux systems that work in framebuffer mode using DirectFB, nano-x and other alternatives also typically contain many interesting, unusual and lightweight applications. Nanolinux and Rogue Class Linux are in this category.

One can also look at operating systems and development projects that use more lightweight C libraries (such as uclibc and musl). Those projects typically gravitate to choosing lightweight applications, command line and console based programs and lightweight tools like Busybox and Toybox.

Alternative operating systems often offer interesting lightweight application choices. Syllable and Haiku often use SDL programs and other lightweight applications that are easier to port to those systems. Systems like Minix and ELKS are also interesting to investigate. Minix 3 uses a lot of the programs that BSD systems do, but earlier versions of Minix include some interesting alternatives. XFDOS includes many interesting FLTK applications. Plan 9 is interesting as well, but not many of the programs used on this system have been ported to other systems. Another good place to look for unusual applications is on mobile devices.
Here are some application lists from Syllable and Agenda:
https://sites.google.com/site/syllablesoftware/
http://agtoys.sourceforge.net/

I'd love to find more places to discuss lightweight applications. If you've written an article on the topic, please share it. If you know of a good blog, forum, mailing list or other resource, please let me know ( http://www.distasis.com/connect.htm ). If you'd like to discuss your favorite C/C++ applications further, you're welcome to check out the mailing list: https://groups.io/g/distasis I had a mailing list on Yahoo Groups called CppDesign, but Yahoo is no longer supporting mailing lists. So, the new list on Groups.io replaces my old lists on Yahoo Groups.
While libSDL is typically used for games, there are some applications that can be used to replace common desktop and productivity applications. I'll list the ones I've found here. If you have other alternatives, please let me know.

I've been working on simplifying the applications I typically use on Linux so that they can run in framebuffer mode using DirectFB or Nano-x instead or requiring X Windows. I'm always looking for portable applications, so I can run them on any system I'm using (at home or at work) whether it's Linux or FreeBSD or Windows or something else. I'd love to hear from others with similar goals.

The list just covers libSDL applications. They all built with SDL 1.2.x and I'm creating or locating ports to SDL 2.x as well. I haven't listed SDL based applications that use PDCurses or OpenGL/TinyGL. There are enough of those to warrant their own lists. More information on SDL applications and other screen libraries is available at: http://www.distasis.com/cpp/scrlib.htm#sdl I've posted some of the patches/build scripts for my SDL 2.x ports and will add more over time. You can find them from the archive link at: http://www.distasis.com/cpp/lmbld.htm

URLs are accurate as of when this was posted. However, they can change over time. You can use a search engine or archive.org wayback tool to find pages that have been moved or backups of older versions of pages.

Font viewers:

sfontview
Good for picking what font you want to work with quickly.
http://distro.ibiblio.org/puppylinux/sources/s/

sdl_unifontview
Let's you see all the characters in the font, so you can check if there's support for specific characters needed for internationalization.
https://github.com/mkiever/sdl_unifontview

Epub reader:

Bard
Includes text to speech capabilities using Festival Lite.
http://festvox.org/bard

PDF viewer:

SDLBook
I've been trying to put together a SDL based PDF viewer based on mupdf for a while now. Looks like someone beat me to it. SDLBook is a lightweight reader that can handle any formats mupdf and djvulibre libraries can.
https://github.com/rofl0r/SDLBook
https://codeberg.org/rofl0r/SDLBook

I assume SDLBook is designed for the latest version of mupdf. I backported it to mupdf 1.1 which was the last GNU GPL licensed version of mupdf. The latest versions of mupdf have epub support. While the 1.1 version does not include epub support, I've added cbr support using libunarr from sumatrapdf. The library handles cbr and cbz format. I also use nanosvg for SVG graphics.

Gemini browser:

Nemini
There are a few SDL based Gemini viewers, but I really like this one. It's very portable and fairly easy to build from source.
https://github.com/neonmoe/nemini

There are also SDL based web browsers such as a fork of links that uses SDL as a back end.

Word Processors:

There are a series of SDL based text editors that use a core of common code with some variations in order to port to various handheld devices. Tried building and running, but it's hard to work with since it expects an on screen keyboard rather than a real physical keyboard.
http://texteditors.org/cgi-bin/wiki.pl?search=GameConsoleFamily

Left
Haven't tried it yet, but this looks promising.
https://git.sr.ht/~rabbits/left

File Manager:

fm
Completely SDL based, two pane file manager.
https://www.raspberrypi.org/forums/viewtopic.php?f=9&t=1616

Graphics:

picaxo
Lightweight, fast graphics viewer.
http://gigi.nullneuron.net/comp/picaxo/

perigee
Slideshow viewer.
http://jstanley.pingerthinger.com/slideshow.html

grafx2
Graphics editor.
http://pulkomandy.tk/projects/GrafX2

lodepaint
Painting program and image editor.
https://sourceforge.net/projects/lodepaint/

sdl_svg
Older SVG library. Includes a simple SVG viewer.
http://www.linuxmotors.com/SDL_svg/

nanosvg
Supports SVG rendering and is not tied to a particular screen library. I built a simple SDL SVG viewer with it. If you're looking for SVG support for SDL, this is the best option I've found to date. (Looks like other SDL developers agree since it's been added to SDL2_image.)
https://github.com/memononen/nanosvg

photocrop
http://burningsmell.org/photocrop/

xtopng
http://burningsmell.org/xtopng/

fische
http://26elf.at/category/fische/

Tuxpaint and lunapaint are also SDL options for graphics editors, but I'm not currently using either of them.

Audio:

Milkytracker
Mod player. Can also create music.
http://milkytracker.titandemo.org/

wavetool
The project has a simple, lightweight wave file viewer. I added support so that it works with SDL in place of some of the other graphics options it used.
http://tph.tuwien.ac.at/~oemer/wavetools.html

sdl-widgets
Sample audio applications.
http://members.chello.nl/w.boeke/SDL-widgets/

AV players:

flxplay
https://www.libsdl.org/projects/flxplay/

theoraplay
http://hg.icculus.org/icculus/theoraplay/

webm-player
Unfortunately no one's added sound support yet.
https://github.com/doublec/webm-player

playvpx
http://www.philhassey.com/blog/2012/02/02/how-to-create-and-play-ivf-vp8-webm-libvpx-video-in-opengl/

GPS:

sdlmap
https://github.com/jhawthorn/sdlmap

PSP-Maps
https://github.com/deeice/PSP-Maps

Productivity:

Hyperlist
https://web.archive.org/web/20120630103356/http://www.zahniser.net/software/hyperlist

Astronomy:

nightsky
https://sourceforge.net/projects/nightsky/

Emulators:

DOSBox
http://www.dosbox.com/

8086tiny
http://8086tiny.freeforums.net/
http://jaybertsoftware.weebly.com/8086-tiny-plus.html

XRoar
http://www.6809.org.uk/xroar/

July 2025

S M T W T F S
  12345
67891011 12
13141516171819
20212223242526
2728293031  

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 4th, 2025 08:27 am
Powered by Dreamwidth Studios