Need help with multiple viewport in Qt opengl
-
I am drawing my scene and tripod on separate viewports. First I draw my scene , then on another viewport on left corner, tripod is
drawn. In debug mode,* everything runs fine and in release mode, tripod viewport is behaving weird*,
I don't know, how release and debug mode can create difference in scene rendering.I am using Qt version 4.8.1
debug mode:!https://lh6.googleusercontent.com/-0WorR-2ecOM/UZsjTPh2iPI/AAAAAAAAAAo/jZKZ7gVC6yg/s128/debug.png(scene and tripod in release mode)!
Release mode:
!https://lh6.googleusercontent.com/-sIVXQ6-L_n0/UZsjTDFCnEI/AAAAAAAAAAk/GN2xG5c8Bt8/s128/release.png(tripod is gone and chair in scene is showing in tripod viewport)!
What's troubling more is the fact that it runs fine in debug and runs weird in release mode.If anybody has seen such behavior before,
please let me know.I would like more insight in multiple viewport stuff, here is my paintGL code
@
void GLView::paintGL ( )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |GL_STENCIL_BUFFER_BIT);
glLoadIdentity ();glDisable (GL_DEPTH_TEST);
if(mDrawBackground)
drawBackground();
glEnable (GL_DEPTH_TEST);glEnable (GL_LIGHTING);
setView();glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0, 1.0);
glTranslatef(-mBoundingBox->centroid().x(), -mBoundingBox->centroid().y(), -mBoundingBox->centroid().z());if(mSurfacePolygonMode & PMS_SHADED)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
drawScene(PMS_SHADED);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
if(mSurfacePolygonMode & PMS_LINE)
{
if(mShowHiddenLines)
{
//drawing boundaries
drawBoundary();
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDisable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
drawScene(PMS_LINE);
glEnable(GL_DEPTH_TEST);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
drawScene(PMS_SHADED);
glDisable(GL_STENCIL_TEST);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
drawScene(PMS_LINE);
}
else
{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
drawScene(PMS_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
}
if(mSurfacePolygonMode & PMS_POINT)
{
glPointSize(5.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
drawScene(PMS_POINT);
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
}drawFeatures();
resetView();- if(mDrawTripod)
drawTripod();*
}
@
code for drawTripod
@
void GLWidget::drawTripod ( )
{glMatrixMode(GL_PROJECTION);
glLoadIdentity();/glClearColor(0,0,0,1.0);
glClear(GL_COLOR_BUFFER_BIT);/
glViewport(-mWindowWidth0.4, -mWindowHeight0.4, mWindowWidth, mWindowHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-viewOrthoaspectRatio,viewOrthoaspectRatio,-viewOrtho,viewOrtho,-10viewOrtho,10viewOrtho);
glMatrixMode(GL_MODELVIEW);
unSetView();glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glColor3d(0,0,0);
renderText(4.5,-0.3,0.0, "X");
renderText(-0.2,4.5,0.0, "Y");
renderText(0.0,0.0,4.5, "Z");
glCallList(mTripodDL);
glDisable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);}
@
need help with this urgently as this bug popped up just before delivery. - if(mDrawTripod)