Ogre's viewport wont update in real time
-
I'm not sure why but the viewports of Ogre don't update in realy time, i make a change then i have to resize the widget it's in to see the affect of the command.......Here's the class used for rendering/updating
@#include "stdafx.h"
#include "CRenderer.h"
#include "qwidget.h"void CRenderer::clearViewport()
{
QColor Color2 = QColorDialog::getColor(Color,this);
Ogre::ColourValue cv;
cv.r = Color2.redF();
cv.b = Color2.blueF();
cv.g = Color2.greenF();
cv.a = 1.0;
this->m_pIViewport->setBackgroundColour(cv);
}
QPaintEngine* CRenderer::paintEngine() const
{
return 0;
}void CRenderer::paintEvent(QPaintEvent* evt)
{
Ogre::Timer* time = m_pIRoot->getTimer();
time->reset();
Ogre::FrameEvent event;
event.timeSinceLastFrame += time->getMillisecondsCPU();
if(isInitialized)
{Ogre::Root::getSingleton()._fireFrameStarted();
m_pIRenderWindow->update(true);
for (unsigned int X = 0; X < m_pIRenderWindow->getNumViewports(); ++X)
{
this->m_pIRenderWindow->getViewport(X)->update();
}
Ogre::Root::getSingleton()._fireFrameRenderingQueued();
Ogre::Root::getSingleton()._fireFrameEnded();}
}
void CRenderer::resizeEvent(QResizeEvent* evt)
{
this->resize(this->parentWidget()->width(),this->parentWidget()->height());
if (m_pIRenderWindow)
{m_pIRenderWindow->resize(this->parentWidget()->width(),this->parentWidget()->height());
m_pIRenderWindow->windowMovedOrResized();for (unsigned short X = 0; X < m_pIRenderWindow->getNumViewports(); ++X)
{
Ogre::Viewport* views = m_pIRenderWindow->getViewport(X);
Ogre::Camera* cam = views->getCamera();
cam->setAspectRatio(static_castOgre::Real(views->getActualWidth())/static_castOgre::Real(views->getActualHeight()));
m_pIRenderWindow->_updateViewport(views);}
}}
bool CRenderer::DrawScene()
{return true;
}
void CRenderer::mousePressEvent(QMouseEvent event)
{
Ogre::Entity Cube = m_pSceneMgr->getEntity("Ogre");
Ogre::SceneNode* N = Cube->getParentSceneNode();if(event->buttons() & Qt::LeftButton)
{
m_pIRenderWindow->_beginUpdate();N->pitch(-Ogre::Degree(lastPos.rx()));
N->yaw(-Ogre::Degree(lastPos.ry()));m_pIViewport->update();
m_pIRenderWindow->_endUpdate();
}}
void CRenderer::mouseReleaseEvent(QMouseEvent *event)
{}
void CRenderer::mouseMoveEvent(QMouseEvent *event)
{lastPos = event->pos();
}
void CRenderer::keyPressEvent(QKeyEvent *event)
{if(event->key() == Qt::Key_A)
{
MessageBoxA(NULL,"","",MB_OK);
}}
void CRenderer::keyReleaseEvent(QKeyEvent *event)
{}
void CRenderer::contextMenuEvent(QContextMenuEvent *event)
{}
void CRenderer::focusInEvent(QFocusEvent *fevent)
{
if (fevent->gotFocus() && fevent->reason() == QFocusEvent::ActiveWindow)
{
m_pIRenderWindow->_beginUpdate();
m_pIRenderWindow->setActive(true);
m_pIViewport->update();
m_pIRenderWindow->_endUpdate();
}
}@
Yes, it's long...but if i can figure out how to fix it in this widget then making sure that the viewport updates in real time in all the other windows will be easy
-
Not sure if this helps, yet somewheres in your set up you should call, the startRendering method of the Root object. When and how is up to you. Without it, there is no trigger to repaint anything, unless an event forces a re-paint, i.e. when you change the size of the window screen.
-
I actually tried that and the program was unresponsive....
-
Aha. Then I've have to pass. I just getting into QT as a game engine. I did not see your second control QPaintEngine. One of the QT team should be able to respond. Or delete this thread, and rephrase the question using only QT controls.
Another potential issue I see is that there is no 'visible statement' in your code snippet you posted, to link to QT's OpenGL support; <QGLWidget> . In other words, QT does not release ownership to Ogre renderer because it may not be able to read it fully.This is what the world really needs, a debugger that caters to gamers. :)
-
well, i asked on the Ogre forum and managed to get an answer, i had to call update() in paintEvent and it worked, the mesh still doesn't rotate smoothly though but it's a start
-
well, that's how it is.......there's still a lot of work to do with it and i've found my self creating multiple windows and scene managers for each part, like a mat_mgr for material editing, blah blah
-
[quote author="Taamalus" date="1289060400"].... I just getting into QT as a game engine. I did not see your second control QPaintEngine. One of the QT team should be able to respond. Or delete this thread, and rephrase the question using only QT controls.
Another potential issue I see is that there is no 'visible statement' in your code snippet you posted, to link to QT's OpenGL support; <QGLWidget> . In other words, QT does not release ownership to Ogre renderer because it may not be able to read it fully.[/quote]Taamalus, it should be Qt, QT is Quick Time :)
-
Hi,
My name is hugo and i'm working on a adaptation of ogre3D engine
using qt5 :
http://advancingusability.wordpress.com/2013/03/30/how-to-integrate-ogre3d-into-a-qt5-qml-scene/I've post similar message in different forums
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=79649&p=499433#p499433
My problem is very similar to yours. I 'm using a special version of QtOgre
and I don't understand how to use or where to put my rendering
loop...Because on this version the autor defined two method called
activateOgrecontext and doneOgreContext which activate already the rendering
process.
But on this particulary point I don't understand how it works! Because there
is no call to Node root->startRendering() or renderingqueue or something
else....Ogre::Root* OgreEngine::startEngine()
{
m_resources_cfg = "resources.cfg";activateOgreContext();
Ogre::Root *ogreRoot = new Ogre::Root;
Ogre::RenderSystem *renderSystem = ogreRoot->getRenderSystemByName("OpenGL
Rendering Subsystem");
ogreRoot->setRenderSystem(renderSystem);
ogreRoot->initialise(false);Ogre::NameValuePairList params;
params["externalGLControl"] = "true";
params["currentGLContext"] = "true";//Finally create our window.
m_ogreWindow = ogreRoot->createRenderWindow("OgreWindow", 1, 1, false,
¶ms);
m_ogreWindow->setVisible(false);
m_ogreWindow->update(false);doneOgreContext();
return ogreRoot;
}void OgreEngine::activateOgreContext()
{
glPopAttrib();
glPopClientAttrib();m_qtContext->functions()->glUseProgram(0);
m_qtContext->doneCurrent();m_ogreContext->makeCurrent(m_quickWindow);
}void OgreEngine::doneOgreContext()
{
m_ogreContext->functions()->glBindBuffer(GL_ARRAY_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
m_ogreContext->functions()->glBindRenderbuffer(GL_RENDERBUFFER, 0);
m_ogreContext->functions()->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);// unbind all possible remaining buffers; just to be on safe side
m_ogreContext->functions()->glBindBuffer(GL_ARRAY_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_COPY_READ_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
// m_ogreContext->functions()->glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
// m_ogreContext->functions()->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_TEXTURE_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
m_ogreContext->functions()->glBindBuffer(GL_UNIFORM_BUFFER, 0);m_ogreContext->doneCurrent();
m_qtContext->makeCurrent(m_quickWindow);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
}when you want to draw something but only in initialisation you do :
void ExampleApp::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());}
after read somme tutorial i've try to loop the rendering process :
void ExampleApp::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();pRenderWindow=m_ogreEngine->getRenderWindow();
//initialisation we create a first scene and the frame listener
m_ogreEngine->activateOgreContext();
createScene();
createFrameListener();
m_ogreEngine->doneOgreContext();
emit(ogreInitialized());m_ogreEngine->activateOgreContext();
if(!m_root->renderOneFrame())
std::cout<<"root renderOneFrame"<<std::endl;// 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;
}m_ogreEngine->doneOgreContext();
emit(ogreInitialized());}
But my app freeze...
Do you have an idea?
-
Last try!
Hi,
My name is hugo and i’m working on a adaptation of ogre3D engine
using qt5 :
http://advancingusability.wordpress.com/2013/03/30/how-to-integrate-ogre3d-into-a-qt5-qml-scene/I’ve post similar message in different forums
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=79649&p=499433#p499433
My problem is very similar to yours. I ‘m using a special version of QtOgre
and I don’t understand how to use or where to put my rendering
loop…Because on this version the autor defined two method called
activateOgrecontext and doneOgreContext which activate already the rendering
process.
But on this particulary point I don’t understand how it works! Because there
is no call to Node root->startRendering() or renderingqueue or something
else….
@
Ogre::Root* OgreEngine::startEngine()
{ m_resources_cfg = “resources.cfg”;
activateOgreContext(); Ogre::Root *ogreRoot = new Ogre::Root; Ogre::RenderSystem *renderSystem = ogreRoot->getRenderSystemByName(“OpenGL Rendering Subsystem”); ogreRoot->setRenderSystem(renderSystem); ogreRoot->initialise(false); Ogre::NameValuePairList params; params[“externalGLControl”] = “true”; params[“currentGLContext”] = “true”; //Finally create our window. m_ogreWindow = ogreRoot->createRenderWindow(“OgreWindow”, 1, 1, false, ¶ms); m_ogreWindow->setVisible(false); m_ogreWindow->update(false); doneOgreContext(); return ogreRoot; }
@
@
void OgreEngine::activateOgreContext()
{ glPopAttrib(); glPopClientAttrib();
m_qtContext->functions()->glUseProgram(0); m_qtContext->doneCurrent(); m_ogreContext->makeCurrent(m_quickWindow); }void OgreEngine::doneOgreContext()
{ m_ogreContext->functions()->glBindBuffer(GL_ARRAY_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); m_ogreContext->functions()->glBindRenderbuffer(GL_RENDERBUFFER, 0); m_ogreContext->functions()->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
// unbind all possible remaining buffers; just to be on safe side m_ogreContext->functions()->glBindBuffer(GL_ARRAY_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_COPY_READ_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_COPY_WRITE_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0); // m_ogreContext->functions()->glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); // m_ogreContext->functions()->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_TEXTURE_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0); m_ogreContext->functions()->glBindBuffer(GL_UNIFORM_BUFFER, 0); m_ogreContext->doneCurrent(); m_qtContext->makeCurrent(m_quickWindow); glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); }
@
when you want to draw something but only in initialisation you do :
@
void ExampleApp::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());}
@
after read somme tutorial i’ve try to loop the rendering process :@
void ExampleApp::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(); pRenderWindow=m_ogreEngine->getRenderWindow(); //initialisation we create a first scene and the frame listener m_ogreEngine->activateOgreContext(); createScene(); createFrameListener(); m_ogreEngine->doneOgreContext(); emit(ogreInitialized()); m_ogreEngine->activateOgreContext(); if(!m_root->renderOneFrame()) std::cout<<“root renderOneFrame”<<std::endl; // 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; } m_ogreEngine->doneOgreContext(); emit(ogreInitialized()); }
@But my app freeze…
Do you have an idea?
-
Your better off not using Qt at all in regards to a 3D Game Engine. I worked on it for years with developers from Irrlicht, Ogre3D, Horde3D, Gameplay3D, OSG, SFML2, .... and have even tried to assist commercial Game Engine developers (Leadwerks) . You will solve one problem with integration and expose ten other issues. The way Qt's abstraction and just in general its designed is bad for games or external 3d graphics engines.
Qt5 makes the problem even worse.
I won't go into it, because core Qt devs never listen and tempers just git heated. But if you want to know what the problems are do a google search.
Without a huge amount of effort re-factoring some of Qt's core components like Autodesk or The Foundry had to do to get things to work out its not going to happen.
Valve, Leadwerks, Gameplay, ... all just used Gtk.
If you have the skills you would be even better off using ...
Poco C++
Boost
Luajit and Luawrapper
SFML2
BulletAnd OpenGL 4.3 or better
http://ogldev.atspace.co.uk/index.html- Drawing a pixel
- Triangle
- Shaders
- Uniform Variables
- Translation Transformation
- Rotation Transformation
- Scaling Transformation
- Interpolation
- Indexed Draws
- Concatenating Transformations
- Perspective Projection
- Camera Space
- Camera Control 1
- Camera Control 2
- Basic Texture Mapping
- Ambient Lighting
- Diffuse Lighting
- Specular Lighting
- Point Lighting
- Spot Lighting
- Loading Models with Assimp
- Shadow Mapping - Part 1
- Shadow Mapping - Part 2
- Skybox
- Normal Mapping
- Billboarding and Geometry Shaders
- Particle System Using Transform Feedback
- 3D Picking
- Basic Tessellation
- PN Triangle Tessellation
- Vertex Array Objects
- Instance Rendering
- GLFX - OpenGL Effects Library
- Deferred Shading - Part 1
- Deferred Shading - Part 2
- Deferred Shading - Part 3
- Skeletal Animation with Assimp
- Silhouette Detection
- Stencil Shadow Volume
- Object Motion Blur
http://nopper.tv/norbert/opengl.html
- Rendering a Triangle
- Grey Filter
- Perspective Rendering a Cube
- Phong rendering of a sphere
- Texturing a Cube
- Normal Mapping
- Enviroment/cube mapping
- GPU Particles
- Geometry Shaders
- Reflection and Refraction
- Shadow Mapping
- Simple Tessellation
- Terrain Rendering
- Water Rendering
- Model Loading and Rendering
- Clipping Planes and two sided Rendering
- Using Stencil Buffer and Clipping
- Rendering to texture and planar reflection
- Texture matrix, alpha blending and discarding
- Compute Shaders
- Shadow Volumes
- Displacement Mapping
- Erode effect using perlin noise
- Model with groups and materials
- Fur rendering
- Projection shadow for directional lighting
- Screen Space Ambient Occlusion (SSAO)
- CPU ray tracing
- GPU ray tracing using computer shader.
http://antongerdelan.net/opengl/index.html
- Hello Triangle
- Extended Initialisation
- Shaders
- Vertex Buffers
- Matrices and Vectors
- Virtual Camera
- Quaternion Quick-Start
- Ray-Based Picking
- Phong Lighting
- Texture Maps
- Importing a Mesh
- Multi-Texturing
- Using Textures for Light Coefficients
- Fragment Rejection
- Alpha Blending for Transparency
- Spotlights and Directional Lights
- Distance Fog
- Normal Mapping
- Cube Maps: Sky Boxes and Enviroment Mapping
- Geometry Shaders
- Tessellation Shaders
- Overlay Panels
- Sprite Sheets and 2D Animation
- Bitmap Fonts
- Vertex Displacement Animation
- Particle Systems
- Hardware Skinning
- Morph Target Animation
- Switching Framebuffer
- Image Processing with a Kernel
- Colour-Based Picking
- Deferred Shading
- Texture Projection Shadows
http://www.opengl-tutorial.org/
- Opening a window
- The first triangle
- Matrices
- A Colored Cube
- A Textured Cube
- Keyboard and Mouse
- Model loading
- Basic shading
- VBO Indexing
- Transparency
- 2D text
- OpenGL Extensions
- Normal Mapping
- Render To Texture
- Lightmaps
- Shadow mapping
- Rotations
- Billboards & Particles
- Billboards - Particles / Instancing
- Picking with an OpenGL hack
- Picking with a physics library
- Picking with custom Ray-OBB function