Frame Listener in QMLOgre Lib Freeze Window

167 views Asked by At

I'm newbie in using ogre3D and I need help on a certain point!

I'm trying a library mixing ogre3D engine and qtml :

http://advancingusability.wordpress.com/2013/08/14/qmlogre-is-now-a-library/

this library works fine when you want to draw some object and rotate or translate these objects already initialise in a first step.

 void initialize(){

// we only want to initialize once
disconnect(this, &ExampleApp::beforeRendering, this, &ExampleApp::initializeOgre);


// start up Ogre
m_ogreEngine = new OgreEngine(this);
m_root = m_ogreEngine->startEngine();
m_ogreEngine->setupResources();


 m_ogreEngine->activateOgreContext();


 //draw a small cube
 new DebugDrawer(m_sceneManager, 0.5f);
 DrawCube(100,100,100);
 DebugDrawer::getSingleton().build();



m_ogreEngine->doneOgreContext();
emit(ogreInitialized());

}

but If you want to draw or change the scene after this initialisation step it is problematic! In fact in Ogre3D only (without the qtogre library), you have to use a frameListener which will connect the rendering thread and allow a repaint of your scene. But here, we have two ContextOpengl: one for qt and the other one for Ogre. So If you try to put the common part of code :

createScene();
createFrameListener();

// La Boucle de rendu
m_root->startRendering();

//createScene();
while(true)
{
   Ogre::WindowEventUtilities::messagePump();

   if(pRenderWindow->isClosed())
       std::cout<<"pRenderWindow close"<<std::endl;

   if(!m_root->renderOneFrame())
       std::cout<<"root renderOneFrame"<<std::endl;
}

the app will freeze! I know that startRendering is a render loop itself, so the loop below never gets executed. But I don't know where to put those line or how to correct this part!

I've also try to add a background buffer and to swap them :

void OgreEngine::updateOgreContext()
{
glPopAttrib();
glPopClientAttrib();

m_qtContext->functions()->glUseProgram(0);
m_qtContext->doneCurrent();

delete m_qtContext;


m_BackgroundContext= QOpenGLContext::currentContext();


// create a new shared OpenGL context to be used exclusively by Ogre
m_BackgroundContext = new QOpenGLContext();
m_BackgroundContext->setFormat(m_quickWindow->requestedFormat());
m_BackgroundContext->setShareContext(m_qtContext);
m_BackgroundContext->create();

 m_BackgroundContext->swapBuffers(m_quickWindow);


//m_ogreContext->makeCurrent(m_quickWindow);



}

but i've also the same error:

OGRE EXCEPTION(7:InternalErrorException): Cannot create GL vertex buffer in GLHardwareVertexBuffer::GLHardwareVertexBuffer at Bureau/bibliotheques/ogre_src_v1-8-1/RenderSystems/GL/src/OgreGLHardwareVertexBuffer.cpp (line 46)

I'm very stuck! I don't know what to do?

Thanks!

0

There are 0 answers