Albert Tomanek
Albert Tomanek

Reputation: 397

How to embed an SDL_Surface into GTK+

I am writing a game using SDL, but would like to use GTK+ for controls. I therefore need to embed an SDL_Surface into GTK+. How should I do this?

Edit

The game would be a tile-based transport simulator (like OpenTTD), but instead of using SDL to display the game UI (screenshot), I would use GTK+.

(I find OpenTTD's SDL-based GUI quite clumsy because it doesn't integrate with the OS and therefore doesn't support things like copy-paste, control with the arrow and tab keys, etc.)

enter image description here

Upvotes: 5

Views: 3251

Answers (1)

Emanuele Aina
Emanuele Aina

Reputation: 382

Not knowing much about what you're currently trying to do I suspect that SDL and GTK+ may be overlapping quite a bit, so I'm not sure how useful would it be to use both at the same time.

When writing a game the purpose of any toolkit is usually to simply talk to the windowing system and to manage inputs as all the drawing is done using GL.

If you also plan to use GTK+ for controls I'd recommend to just use GTK+ and not mix the two.

With GTK+ the best way to use GL is to use the GtkGLArea widget which gives you a canvas where to draw using standard GL calls.

If instead you don't plan to use GL but you just want to draw in software, the right widget for that purpose would be GtkDrawingArea.

By joining the #gnome-games IRC channel on the irc.gnome.org server you may find people more knownledgeable that can guide you better than me. :)

Upvotes: 1

Related Questions