Reputation: 448
I'm currently writing an emulator in C which runs entirely off of SDL using SDL surfaces for rendering and SDL events. However now I've finished the emulation part, I wish to add a menu to the top of the window like the "File, Edit, Help" menu found on windows. So I can add options for settings, load rom, etc.
I have seen a few implementations but they ether require c++ (I know c++, but never used it combined with c), or interacting with the windows API. Ideally what I'm after is to use a multi-platform GUI such as GTK+ instead (as I've some experience using this already, and this program be run on linux and windows).
I've also read about being able to parent an SDL surface to a GTK widget, however this doesn't seem to allow me to use SDL events as well.
Does anyone know of a way to achieve this?
okay so I decided to rethink a few things and work on one thing at a time. At the moment i'm trying to get the SDL Surface to display inside a GTK Widget, however it doesn't seem to be making any difference at the moment as SDL is staying in its window, and not going to the gtk one.
GtkWidget *sdlsock;
gui.sdlsock = gtk_event_box_new();
gtk_widget_set_size_request(gui.sdlsock, 500, 300);
char winhack[1024];
sprintf( winhack, "SDL_WINDOWID=%ld", gtk_widget_get_window(sdlsock));
SDL_putenv( winhack );
screen = SDL_SetVideoMode(500, 300, 16, SDL_SWSURFACE);
im using GTK+ 3.0 for Windows in this code
Upvotes: 2
Views: 1434
Reputation: 5683
It seems, that according to this answer: Embedding SDL into GTK that you need to do some hacks to inject the gtk events into SDL. Other than that, it doesn't look overly possible.
Upvotes: 0