qt + irrlicht : fonts not showing (neither static text).

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

qt + irrlicht : fonts not showing (neither static text).

Post by gabdab »

I am embedding irrlicht in qt trough window id parameter passing.
Everything works excellent, but fonts not showing up.
I managed to have statictext showing a couple of times , but now it is off ..
Do you spot any error in this initialization procedure ?

Code: Select all

    irr::SIrrlichtCreationParameters createParams;
    createParams.DriverType = m_DriverType;
    createParams.WindowSize = irr::core::dimension2d<irr::u32>( size().width(), size().height() );
    createParams.EventReceiver = 0;
    createParams.Stencilbuffer = true;
    createParams.IgnoreInput = true;
 
    // Window ID for creating the native rendering context
    createParams.WindowId = ( void * ) winId();
 
    qDebug() << "   render size           = " << createParams.WindowSize.Width << " x " << createParams.WindowSize.Height;
    qDebug() << "   native window ID      = " << ( irr::u32 ) createParams.WindowId;
 
    if(( m_IrrDevice = irr::createDeviceEx( createParams )) == 0 )
        throw( "failed to create Irrlicht device" );
 
   guienv = getIrrlichtDevice()->getGUIEnvironment();
 
   guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",  irr::core::rect<irr::s32>(10,10,10,10),true);
 
   skin = guienv->getSkin();
 
   font = guienv->getFont("media/fonthaettenschweiler.bmp");
 
   skin->setFont(font);
 
   skin->setColor(gui::EGDC_BUTTON_TEXT,SColor(255,255,255,255));
 
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: qt + irrlicht : fonts not showing (neither static text).

Post by Virion »

did you call

Code: Select all

guienv->DrawAll();
in the main loop?
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: qt + irrlicht : fonts not showing (neither static text).

Post by gerdb »

hi, maybe you forgot to set the new skin

Code: Select all

 
guienv->setSkin(skin);
 
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Re: qt + irrlicht : fonts not showing (neither static text).

Post by gabdab »

guienv->DrawAll();
I call it in paintEvent( QPaintEvent *event ) , so that is excluded from possible causes.
guienv->setSkin(skin);
Just tested and it doesn't solve the problem, excluded.
I guess it might have to do with the Window ID for creating the native rendering context

Code: Select all

    createParams.WindowId = ( void * ) winId();
and irr::gui::IGUIFont maybe lacking a reference to it ?
I guess so because IGUIStaticText does work instead.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: qt + irrlicht : fonts not showing (neither static text).

Post by Radikalizm »

Are you sure you're calling guiEnv->drawAll() in between beginScene() and endScene() ?
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Re: qt + irrlicht : fonts not showing (neither static text).

Post by gabdab »

edit: Now statictext behaves properly , I wonder if I can use

Code: Select all

IGUIStaticText
in place of

Code: Select all

font->draw
?
Are you sure you're calling guiEnv->drawAll() in between beginScene() and endScene() ?
This is all the render loop .

Code: Select all

void QIrrlichtWidget::paintEvent( QPaintEvent *event )
{
    if( m_IrrDevice == 0 )
        return;
    m_IrrDevice->getVideoDriver()->beginScene(true, true, video::SColor(0,39,86,104));
    m_IrrDevice->getSceneManager()->drawAll();
    guienv->drawAll();
    m_IrrDevice->getVideoDriver()->endScene();
    XUpdate();
}
 
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Re: qt + irrlicht : fonts not showing (neither static text).

Post by gabdab »

statictext not a viable alternative.
edit: statictext is working fine.
Problem seems related to how qt deals with initializations.
irr::gui::font gives problems in a qt contest being initialized in a loop (at render time) ?
Anyone ?
Post Reply