CrazyEddie wrote:I'm not sure what could cause this to be honest. You're saying that if you remove the setText call, but leave everything else as-is - including the CEGUI render call - things are then drawn correctly? As in the scene and the CEGUI window (with no text!) and the CEGUI cursor?
It actually sounds like some kind of rendering state issue. though I've never heard of such things in conjunction with Irrlicht before, and absolutely never due to a simple setText call
CE
Exactly. When I put the setText call inside the while loop, only CEGUI windows will be rendered. When I put the call outside, everything goes fine. I've beening trying hundreds of times...
Here's the code with setText call outside.
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include "CEGUI.h"
#include "CEGUIBase.h"
#include "CEGUISchemeManager.h"
#include "CEGUIDefaultResourceProvider.h"
#include "CEGUIIrrlichtRenderer.h"
using namespace irr;
using namespace std;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace CEGUI;
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "CEGUIBase_d.lib")
#pragma comment(lib, "CEGUIIrrlichtRenderer_d.lib")
int main()
{
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
if (!device)
return 1;
try{
CEGUI::IrrlichtRenderer &CEGUIRenderer = CEGUI::IrrlichtRenderer::bootstrapSystem(*device);
}
catch ( CEGUI::Exception &e)
{
cout << e.getMessage() << endl;
}
CEGUI::DefaultResourceProvider * rp = static_cast<CEGUI::DefaultResourceProvider*>
(CEGUI::System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory("schemes",".\\datafiles\\schemes");
rp->setResourceGroupDirectory("fonts",".\\datafiles\\fonts");
rp->setResourceGroupDirectory("layouts",".\\datafiles\\layouts");
rp->setResourceGroupDirectory("looknfeels",".\\datafiles\\looknfeel");
rp->setResourceGroupDirectory("lua_scripts",".\\datafiles\\lua_scripts");
rp->setResourceGroupDirectory("imagesets",".\\datafiles\\imagesets");
CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
try{
CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
}
catch ( CEGUI::Exception &e)
{
cout << e.getMessage() << endl;
}
WindowManager& wmgr = WindowManager::getSingleton();
Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );
System::getSingleton().setGUISheet( myRoot );
FrameWindow* fWnd = static_cast<FrameWindow*>(
wmgr.createWindow( "TaharezLook/FrameWindow", "testWindow" ));
myRoot->addChildWindow( fWnd );
fWnd->setPosition( UVector2( UDim( 0.25f, 0 ), UDim( 0.25f, 0 ) ) );
fWnd->setSize( UVector2( UDim( 0.5f, 0 ), UDim( 0.5f, 0 ) ) );
fWnd->setText( "Hello World!" );
device->setWindowCaption(L"Hello World!");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
CEGUI::System::getSingleton().renderGUI();
driver->endScene();
}
device->drop();
return 0;
}
Here's the screenshot:
[img]
http://i3.6.cn/cvbnm/51/0f/f0/0a3773155 ... 44f492.png[/img]
Here's the code with setText call outside. Problems occurred
Code: Select all
//omitted for brevity
while(device->run())
{
[color=#FF0000] //here's the problem
fWnd->setText("Hello");[/color]
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
CEGUI::System::getSingleton().renderGUI();
driver->endScene();
}
device->dro
Screenshot:
[img]
http://i3.6.cn/cvbnm/ca/8c/fd/fbaffa473 ... 603ece.png[/img]
--------------------------------------------------------------------
I've tried hunderds of times. One of my friend managed to generate the same error with the code above(Irrlicht 1.7.1 and CEGUI 0.7.1, the same as mine). But those who use OGRE has never come across the same problem. Please help
Many thanks again.