How to create a file open dialog with the SDL library?

Asked

Viewed 189 times

1

I’m making a very simple audio player in C (on Ubuntu) for a college job, and I’m using the SDL library to create windows (graphical interface) along with the Sdl_mixer to play the audio.

The problem is: I need a way for the user to point out the music file he wants to play, like a dialog box that would return the directory of the file chosen by the user so that I could pass it to Sdl_mixer and run it.

On the Internet I only found some tutorials in C# for Windows.

Any idea?

  • 1

    Here you won’t find a tutorial. In what part of your code exactly are you facing problem? Maybe Voce could even share this chunk of code that Voce did and is finding a problem, if applicable.

  • 3

    SDL does not have functions to create file open windows. So you will have to create a new one, or use a complementary library.

1 answer

3


You can install the GTK+ (is also in C) and use it to show a File Chooser Dialog, where the user will select the music file. From there on you can do with the SDL even.

Some references:

To install the GTK:

apt-get install libgtk2.0-dev

Browser other questions tagged

You are not signed in. Login or sign up in order to post.