[osg-users] porting from osg-3.4.0 to osg-3.6.3
Herman Varma
hermanvarma at eastlink.ca
Mon Oct 8 12:38:59 PDT 2018
Hi,
Hi Robert
I down down further to this statement
m_pOsgViewer->frame();//
In 3.4.0 it executes and in 3.6.3 it bombs here
The full code is posted below
void vtScene::UpdateWindow(vtWindow *pWindow)
{
if (!m_bInitialized) return;
// window background color
osg::Vec4 color2;
v2s(pWindow->GetBgColor(), color2);
m_pOsgViewer->getCamera()->setClearColor(color2);
// window size
IPoint2 winsize = pWindow->GetSize();
if (winsize.x == 0 || winsize.y == 0)
{
VTLOG("Warning: winsize %d %d\n", winsize.x, winsize.y);
return;
}
m_pOsgViewer->getCamera()->setViewport(0, 0, winsize.x, winsize.y);
// As of OSG 0.9.5, we need to store our own camera params and recreate
// the projection matrix each frame.
float aspect;
if (winsize.x == 0 || winsize.y == 0) // safety
aspect = 1.0;
else
aspect = (float) winsize.x / winsize.y;
if (m_pCamera->IsOrtho())
{
// Arguments are left, right, bottom, top, zNear, zFar
float w2 = m_pCamera->GetWidth() /2;
float h2 = w2 / aspect;
m_pOsgViewer->getCamera()->setProjectionMatrixAsOrtho(-w2, w2, -h2, h2,
m_pCamera->GetHither(), m_pCamera->GetYon());
}
else
{
float fov_x = m_pCamera->GetFOV();
float a = tan (fov_x/2);
float b = a / aspect;
float fov_y_div2 = atan(b);
float fov_y_deg = osg::RadiansToDegrees(fov_y_div2 * 2);
m_pOsgViewer->getCamera()->setProjectionMatrixAsPerspective(fov_y_deg,
aspect, m_pCamera->GetHither(), m_pCamera->GetYon());
}
// And apply the rotation and translation of the camera itself
const osg::Matrix &mat2 = m_pCamera->getMatrix();
osg::Matrix imat;
imat.invert(mat2);
m_pOsgViewer->getCamera()->setViewMatrix(imat);
m_pOsgViewer->getCamera()->setCullMask(0x3);
// Also set the mask for the case of split-screen stereo
m_pOsgViewer->getCamera()->setCullMaskLeft(0x3);
m_pOsgViewer->getCamera()->setCullMaskRight(0x3);
m_pOsgViewer->frame();// ***************************It bombs on this statement
}
I also ran it in debug mode and posted a diagnostic.jpg of the resulting
debug screen
Thank you!
Cheers,
Herman
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75049#75049
Attachments:
http://forum.openscenegraph.org//files/diagnostic_569.jpg
More information about the osg-users
mailing list