*UPDATE*
BillyQuith has graciously integrated my renderer into GWork
https://github.com/billyquith/GWork
GWEN has been abandoned by the developer and subsequently a fork called GWork has taken it's place.
GWork is in active development providing a more stable version of the original GWEN project.
It holds true to the idea of a "GUI Without Extravagant Nonsense" even more so than previous iterations.
The renderer is complete except for the font related functions which will be written once Irrlicht supports TT-Fonts.
For now it uses the built-in default GUI font and text rendering so you'll need to have Irrlicht compiled with GUI enabled.
Demo code is posted below:
Code: Select all
#include <irrlicht.h>
#include "gwork/gwork.h"
#include "gwork/Skins/Simple.h"
#include "gwork/Skins/TexturedBase.h"
#include "gwork/Test/Test.h"
#include "gwork/Input/Irrlicht.h"
#include "gwork/Renderers/Irrlicht.h"
#include <Gwork/Platform.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class MyEventReceiver : public IEventReceiver {
public:
MyEventReceiver(Gwk::IInputEventListener* el) : input() {
input.Initialize(el);
}
virtual bool OnEvent(const SEvent& event) {
return input.HandleEvents(event);
}
private:
Gwk::Input::Irrlicht input;
};
int main() {
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, dimension2d<u32>(1004, 650), 32, false, false, false, NULL);
if (!device) { return 1; }
device->setWindowCaption(L"Gwork - Irrlicht Sample");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//
// Create a Gwork Irrlicht Renderer
//
Gwk::Platform::RelativeToExecutablePaths paths(GWORK_RESOURCE_DIR);
Gwk::Renderer::IrrlichtResourceLoader loader(driver, paths);
Gwk::Renderer::Irrlicht* pRenderer = new Gwk::Renderer::Irrlicht(device, loader);
//
// Create a Gwork skin
//
Gwk::Skin::TexturedBase* pSkin = new Gwk::Skin::TexturedBase(pRenderer);
pSkin->Init("DefaultSkin.png");
pSkin->SetDefaultFont("OpenSans.ttf", 11);
//
// Create a Canvas (it's root, on which all other Gwork panels are created)
//
Gwk::Controls::Canvas* pCanvas = new Gwk::Controls::Canvas(pSkin);
pCanvas->SetSize(998, 650 - 24);
pCanvas->SetDrawBackground(true);
pCanvas->SetBackgroundColor(Gwk::Color(150, 0, 0, 255));
// Texture caching doesn't seem to work properly.
// Cached textures never get updated.
//pCanvas->EnableCacheToTexture();
//
// Create our unittest control (which is a Window with controls in it)
//
auto pUnit = new TestFrame(pCanvas);
pUnit->SetPos(10, 10);
MyEventReceiver* eventReceiver = new MyEventReceiver(pCanvas);
device->setEventReceiver(eventReceiver);
int lastFPS = -1;
while (device->run()) {
driver->beginScene(true, true, SColor(255, 100, 101, 140));
smgr->drawAll();
//
// Draw the canvas
//
pCanvas->RenderCanvas();
//
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps) {
core::stringw str = L"Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
delete eventReceiver;
delete pCanvas;
delete pSkin;
delete pRenderer;
device->drop();
return 0;
}
Any other issues with GWork can be brought up here: https://github.com/billyquith/GWork/issues