You're right, it got fixed, so now icons appear.
The FrameBuffer device only supports the software drivers, but it would be nice to have OpenGL, which I believe GTK can do.
I decided to see if I could get the necessary info from gtk for rendering with OpenGL. Unfortunately it's been a major headache trying to track down the info!!
Here's what I came up with thus far:
Code: Select all
#include <cstdio>
#include <irrlicht.h>
#include <glibmm/ustring.h>
//#include <glibmm/main.h> // For SignalIdle/signal_idle()
#include <glibmm.h>
#include <gtkmm/application.h>
#include <gtkmm/window.h>
//#include <gtk-3.0/gdk/gdkx.h> // (Must be after glibmm, gdkmm, and gtkmm headers) For gdk_x11_display_get_xdisplay()
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> // for GDK_WINDOW_XID
#endif
#ifdef GDK_WINDOWING_WIN32
#include <gdk/gdkwin32.h> // for GDK_WINDOW_HWND
#endif
#include "HelloWorld.h" // Just contains an empty class that inherits Gtk::Window
HelloWorld* helloWorld;
class IrrSideEventReceiver : public irr::IEventReceiver
{
public:
bool OnEvent(const irr::SEvent& event)
{
std::printf("\nIrrlicht Event");
// TODO: Pass mouse-click events to GTK side
return false;
}
};
class IrrMain {
irr::IrrlichtDevice* irrDevice;
irr::SIrrlichtCreationParameters irrParams;
irr::video::SExposedVideoData irrVideoData;
public:
IrrMain( irr::SIrrlichtCreationParameters& params, irr::video::SExposedVideoData& vdata )
: irrDevice()
, irrParams(params)
, irrVideoData(vdata)
{}
void init()
{
irrDevice = irr::createDeviceEx(irrParams);
if (!irrDevice) throw;
irr::scene::ILightSceneNode* irrLight = irrDevice->getSceneManager()->addLightSceneNode(
0, irr::core::vector3df(1,10,2), irr::video::SColor(0xffffffff), 20, 0);
irr::scene::ICameraSceneNode* irrCam = irrDevice->getSceneManager()->addCameraSceneNode(
0, irr::core::vector3df(0,5,5), irr::core::vector3df(0,0,0), 1, true);
irr::scene::ISceneNode* irrCube = irrDevice->getSceneManager()->addCubeSceneNode(
1, 0, 2, irr::core::vector3df(0,0,0), irr::core::vector3df(0.3,0,0), irr::core::vector3df(1,1,1),
irr::scene::ECMT_1BUF_12VTX_NA);
irrDevice->run();
//while(irrDevice->run()) {
irrDevice->getVideoDriver()->beginScene(
true, true, irr::video::SColor(0xff0000ff),
irrVideoData, 0);
/*
irrDevice->getVideoDriver()->beginScene(
true, true, irr::video::SColor(0xff000000),
irr::video::SExposedVideoData(), 0);
irrDevice->getVideoDriver()->endScene();
*/
//}
}
} *irrMain;
void init() {
irr::SIrrlichtCreationParameters irrParams;
irr::video::SExposedVideoData irrVideoData;
GdkWindow* gdk_window = helloWorld->get_window()->gobj();
if (!gdk_window) throw;
gulong xid = GDK_WINDOW_XID(gdk_window);
//irrParams.WindowId = (void*)xid; // Does nothing on Linux
irrParams.AntiAlias = false;
irrParams.Bits = 32;
irrParams.DeviceType = irr::EIDT_X11;
//irrParams.DeviceType = irr::EIDT_FRAMEBUFFER;
irrParams.DriverType = irr::video::EDT_OPENGL; // Should test with Burnings first
//irrParams.DriverType = irr::video::EDT_BURNINGSVIDEO;
//irrParams.EventReceiver = &iEventReceiver;
irrParams.Fullscreen = false;
irrParams.IgnoreInput = true; // TODO: Test without this too
irrParams.Stencilbuffer = true;
irrParams.Vsync = false;
irrParams.WithAlphaChannel = false; // TODO: Test with alpha channel
gint windowWidth=0, windowHeight=0;
helloWorld->get_size(windowWidth, windowHeight); // Won't work. Window not initialized
irrParams.WindowSize = irr::core::dimension2du(windowWidth,windowHeight);
auto xdisplay = gdk_x11_display_get_xdisplay(helloWorld->get_screen()->get_display()->gobj());
irrVideoData.OpenGLLinux.X11Display = xdisplay;
irrVideoData.OpenGLLinux.X11Window = xid;
irrMain = new IrrMain(irrParams, irrVideoData);
irrMain->init();
}
int main (int argc, char *argv[])
{
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example"); // @suppress("Invalid arguments")
helloWorld = new HelloWorld();
helloWorld->set_size_request(900, 600);
Glib::signal_idle().connect_once(sigc::slot<void>(&init));
//Shows the window and returns when it is closed.
return app->run(*helloWorld);
}
It doesn't work, of course. I get an X BadMatch.
I looked at the implementation of CIrrDeviceLinux::createDriver() and discovered for GL it just assigns the initial window and display to 0 (see line 624). Initial SExposedVideoData are ignored. lol. The result is that a separate window for OpenGL is created even if you are intending to house it in a different one. And I found in CGLXManager::activateContext() that I need an X11Context, which I don't know how to get from GTK, and no one seems to have the answer. Years and years ago, someone created a
GLArea class, but it's so outdated and there's little reference for how to use it.
BurningsVideo doesn't complain... but it doesn't render anything either.
At this point, I think the easiest thing is either 1) test if the Frame Buffer option will work (if I'm happy with just the software renderer) or 2) run Irrlicht in a separate window (if I want OpenGL).
Unless someone can figure out what I did wrong...