I'm writing a UI for my program using opengl with SDL in a combination of Lua and C++
What I need now is some library that will allow me to call a function that presents the user with a file select dialog for opening/saving a file. But if the OS offers native functionality for such a dialog, then I want to use that dialog (eg Window's GetOpenFileName).
The only platforms I need to support are Windows and Linux, but I want to be able to still use most of the SDL & openGL code I've already written.
What options are available?
tinyfiledialogs offers many modal dialogs and popup notifications (both for graphic and console modes). It is a cross-platform C file (with a header) to add to your C or C++ project. It aims to be extremely easy to use, has no init, no main loop, and no external dependencies. It is used by hundreds of projects on GitHub and of course, I am the author. Get it here: http://tinyfiledialogs.sourceforge.net
Usage example:
char const * selection = tinyfd_openFileDialog( // there is also a wchar_t version "Select file", // title "C:\\", // optional initial directory 2, // number of filter patterns lFilterPatterns, // char const * lFilterPatterns[2] = { "*.txt", "*.jpg" }; NULL, // optional filter description 0 // forbid multiple selections );
You should take a good look at Native File Dialog. It is a small, portable C library that lets you use load and save dialogs in a cross platform manner without linking huge dependencies like qt or wxWidgets.
I am the author, and I use it with SDL2 and OpenGL on Linux, Mac and Windows.
https://github.com/mlabbe/nativefiledialog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With