Porblem suporimposing

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

Porblem suporimposing

Post by Guest »

i hava problem because y wanna superposing on my image background a button "jouer" and "quitter"
my code is :

#include <irrlicht.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

IrrlichtDevice *device = 0;
s32 cnt = 0;
IGUIListBox* listbox = 0;

class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();

switch(event.GUIEvent.EventType)
{

case EGET_SCROLL_BAR_CHANGED:
if (id == 104)
{
s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();

for (s32 i=0; i<EGDC_COUNT ; ++i)
{
SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
col.setAlpha(pos);
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
}

}
break;

case EGET_BUTTON_CLICKED:

if (id == 101)
{
device->closeDevice();
return true;
}

if (id == 102)
{
listbox->addItem(L"Window created");
cnt += 30;
if (cnt > 200)
cnt = 0;

IGUIWindow* window = env->addWindow(
rect<s32>(100 + cnt, 100 + cnt, 300 + cnt, 200 + cnt), 0, -1, L"Test window");

env->addStaticText(L"Please close me", true,
rect<s32>(35,35,140,50), window);
return true;
}

if (id == 103)
{
listbox->addItem(L"File open");
env->addFileOpenDialog(L"Please choose a file.");
return true;
}

break;
}
}

return false;
}
};

int main()
{
MyEventReceiver receiver;

device = createDevice(video::DT_OPENGL,
core::dimension2d<s32>(640, 480), 16, false, false, &receiver);

device->setWindowCaption(L"Irrlicht Engine - User Inferface Demo");

video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();


env->addButton(rect<s32>(10,210,100,240), 0, 101, L"Jouer"); // button "jouer" :lol:
env->addButton(rect<s32>(10,300,100,340), 0, 103, L"Quitter"); // button "quiter :lol:

IGUISkin* skin = env->getSkin();
IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
if (font)
skin->setFont(font);

//background image
IGUIEnvironment* guienv = device->getGUIEnvironment();
IGUIImage* img =guienv->addImage(core::rect<int>(0,0,640,480));
img->setImage(driver->getTexture("image2.jpg"));

ISceneManager* smgr = device->getSceneManager();

while(device->run() && driver)
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,100,100,100));
smgr->drawAll();
env->drawAll();

driver->endScene();
}

device->drop();

return 0;
}
Guest

Post by Guest »

nobody answer :cry: ?
Post Reply