CustomGUIelement.h
Code: Select all
#include "irrlicht.h"
using namespace irr;
using namespace gui;
class CustomGUIelement:public IGUIElement
{
public:
CustomGUIelement(IGUIEnvironment*,IGUIElement*, s32, wchar_t*, core::rect<s32>);
virtual ~CustomGUIelement();
virtual bool OnEvent(const SEvent& event);
void draw();
protected:
private:
IGUIEnvironment *gui;
IGUIStaticText *title;
};
Code: Select all
CustomGUIelement::CustomGUIelement(IGUIEnvironment* g,IGUIElement* parent, s32 id, wchar_t* titletext, core::rect<s32> position):IGUIElement(EGUIET_ELEMENT,g,parent,id,position),gui(g)
{
title=gui->addStaticText(titletext,core::rect<s32>(0,0,100,100),false,false,this);
}
CustomGUIelement::~CustomGUIelement()
{
//dtor
}
bool CustomGUIelement::OnEvent(const SEvent& event)
{
return true;
}
void CustomGUIelement::draw()
{
IGUIElement::draw();
}
Code: Select all
#include "irrlicht.h"
#include "CustomGUIelement.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
IrrlichtDevice * device = createDevice(EDT_OPENGL, core::dimension2d<u32>(640, 480));
device->setWindowCaption(L"Irrlicht Engine - User Interface Demo");
device->setResizable(true);
IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
CustomGUIelement* cos=new CustomGUIelement(env,0,-1,L"TEST KONTROLKI",rect<s32>(0,0,640,480));
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
cos->draw();//without this line it wont work :(
driver->endScene();
}
}
device->drop();
return 0;
}