Hi,
I needed to use SFML in a gtkmm based GUI and luckily I found some Code-Snippets in the old Wiki:
http://www.sfml-dev.org/wiki/en/sources/gtksfmlwidgetBefore I can upload my Code-Changes to my online git repository I wanted to
- Ask which License the Wiki is using.
- Request a License note in the wiki regarding the Code Snippets (I searched, but couldn't find)
Open Source is about sharing, so I wanted to share the changes I've made to the gtkmm-example code (Tested on Linux Mint 12.04 64Bit, NVidia; SFML 2.0; gtkmm-2.4):
- The Widget was flickering extremely when I resized the window, so I needed to disable the Widgets default double buffering by adding the following line to the end of the on_realize method:
this->set_double_buffered(false);
- On neighbor Widgets, there were strange artifacts when I resized the widgets. The Workaround I used was to suppress the Widgets default drawing Method using a invisible Pattern:
this->get_window()->set_back_pixmap(Glib::RefPtr<Gdk::Pixmap>());
- The on_idle Method presented in the snipped caused my application to crash as returning true caused the application to ignore the main loop. Instead I used the widgets on_expose Method.
- To have the operating system dependend Code in only one place, I used the following Preprocessor Code to do most of the work:
#if defined(SFML_SYSTEM_WINDOWS)
#include <gdk/gdkwin32.h>
#define GET_WINDOW_HANDLE_FROM_GDK GDK_WINDOW_HANDLE
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)
#include <gdk/gdkx.h>
#define GET_WINDOW_HANDLE_FROM_GDK GDK_WINDOW_XID
#elif defined(SFML_SYSTEM_MACOS)
#error Note: You have to figure out an analogue way to access the handle of the widget on a Mac-System
#else
#error Unsupported Operating System
#endif
In order to keep the Window handling Method within the on_realize Method simple:
this->sf::RenderWindow::create(GET_WINDOW_HANDLE_FROM_GDK(m_refGdkWindow->gobj()));
I've attached the whole Code. Be aware that the current Version of gtkmm is 3.0 And The Code I've created is compatible to gtkmm 2.4.
[attachment deleted by admin]