OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

porting from osg-3.4.0 to osg-3.6.3


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
hvarma (Herman Varma)
Newbie


Joined: 12 Sep 2018
Posts: 11

PostPosted: Sun Oct 07, 2018 5:21 pm    Post subject:
porting from osg-3.4.0 to osg-3.6.3
Reply with quote

Hi Robert

I followed your advice and used the Simple app in VTP with Debug statements.
I compared the debug statements wit those osg-3.4.0.

I was able to track it down to this section

while (!viewer->done())
{
vtGetScene()->DoUpdate(); // calls
viewer::frame
}
In 3.4.0 it executes and in 3.6.3 it bombs on

vtGetScene()->DoUpdate();


DoUpdate() is defined by vs2017 as void VTScene::DoUpdate() backward
compatibility

Also
viewer->done() value has a bool value of 0 at the bomb instant.


Full code below

int main(int argc, char ** argv)
{
#if WIN32 && defined(_MSC_VER) && VTDEBUG
// sometimes, MSVC seems to need to be told to show unfreed memory
on exit
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

// Log messages to make troubleshooting easier
VTSTARTLOG("debug.txt");
VTLOG("osgViewerSimple\n");

// Make a scene and a viewer:
vtGetScene()->Init(argc, argv);
osgViewer::Viewer *viewer = vtGetScene()->getViewer();

// Add a handler for GUI events.
osg::ref_ptr<vtOSGEventHandler> pHandler = new vtOSGEventHandler;
viewer->addEventHandler(pHandler);

// We must call realize to be certain that a display/context is set
up.
viewer->realize();

// Tell our scene about OSG's context.

vtGetScene()->SetGraphicsContext(viewer->getCamera()->getGraphicsContext());

// Only then can we safely get window size.
vtGetScene()->GetWindowSizeFromOSG();

printf("Creating the terrain..\n");
CreateScene();

printf("Running..\n");

VTLOG("Getscene Loop %d\n", (int)viewer->done());

while (!viewer->done())
{
vtGetScene()->DoUpdate(); // calls
viewer::frame
}

VTLOG("Done Updatescene.\n");

g_terrscene->CleanupScene();
delete g_terrscene;

vtGetScene()->Shutdown();

return 0;
}


Thanks
------------------------------

Message: 2
Date: Thu, 04 Oct 2018 15:31:14 +0200
From: "Herman Varma" <>
To:
Subject: Re: Problems porting from osg-3.4.0 to osg-3.6.0
Message-ID: <>
Content-Type: text/plain; charset=UTF-8

Hi,


I have upgraded the vtp code to osg 3.6.3
Everything compiled and linked properly. However I still have some execution
problems.

I just want to check if the code below is coded properly

FQuat TransformExtension::GetOrient() const
{
const osg::Matrix &xform = m_pTransform->getMatrix();
osg::Quat q;

// xform.get(q);
// Replacing xform.get(q)
// with
q = xform.getRotate();

return FQuat(q.x(), q.y(), q.z(), q.w());
}

...

Thank you!

Cheers,
Herman

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75036#75036







------------------------------

Subject: Digest Footer




------------------------------

End of osg-users Digest, Vol 136, Issue 4
*****************************************



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message Send e-mail
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Mon Oct 08, 2018 7:48 am    Post subject:
porting from osg-3.4.0 to osg-3.6.3
Reply with quote

Hi Herman,

Quote:
From the details provided there isn't anything we suggest, the only
thing we can do is suggest that you provide more information.

The first thing would be to post a stack trace, at least then we might
have an idea what bit of code is failing and with what error.

Robert.
On Sun, 7 Oct 2018 at 18:21, Herman Varma <> wrote:
Quote:

Hi Robert

I followed your advice and used the Simple app in VTP with Debug statements.
I compared the debug statements wit those osg-3.4.0.

I was able to track it down to this section

while (!viewer->done())
{
vtGetScene()->DoUpdate(); // calls
viewer::frame
}
In 3.4.0 it executes and in 3.6.3 it bombs on

vtGetScene()->DoUpdate();


DoUpdate() is defined by vs2017 as void VTScene::DoUpdate() backward
compatibility

Also
viewer->done() value has a bool value of 0 at the bomb instant.


Full code below

int main(int argc, char ** argv)
{
#if WIN32 && defined(_MSC_VER) && VTDEBUG
// sometimes, MSVC seems to need to be told to show unfreed memory
on exit
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

// Log messages to make troubleshooting easier
VTSTARTLOG("debug.txt");
VTLOG("osgViewerSimple\n");

// Make a scene and a viewer:
vtGetScene()->Init(argc, argv);
osgViewer::Viewer *viewer = vtGetScene()->getViewer();

// Add a handler for GUI events.
osg::ref_ptr<vtOSGEventHandler> pHandler = new vtOSGEventHandler;
viewer->addEventHandler(pHandler);

// We must call realize to be certain that a display/context is set
up.
viewer->realize();

// Tell our scene about OSG's context.

vtGetScene()->SetGraphicsContext(viewer->getCamera()->getGraphicsContext());

// Only then can we safely get window size.
vtGetScene()->GetWindowSizeFromOSG();

printf("Creating the terrain..\n");
CreateScene();

printf("Running..\n");

VTLOG("Getscene Loop %d\n", (int)viewer->done());

while (!viewer->done())
{
vtGetScene()->DoUpdate(); // calls
viewer::frame
}

VTLOG("Done Updatescene.\n");

g_terrscene->CleanupScene();
delete g_terrscene;

vtGetScene()->Shutdown();

return 0;
}


Thanks
------------------------------

Message: 2
Date: Thu, 04 Oct 2018 15:31:14 +0200
From: "Herman Varma" <>
To:
Subject: Re: Problems porting from osg-3.4.0 to osg-3.6.0
Message-ID: <>
Content-Type: text/plain; charset=UTF-8

Hi,


I have upgraded the vtp code to osg 3.6.3
Everything compiled and linked properly. However I still have some execution
problems.

I just want to check if the code below is coded properly

FQuat TransformExtension::GetOrient() const
{
const osg::Matrix &xform = m_pTransform->getMatrix();
osg::Quat q;

// xform.get(q);
// Replacing xform.get(q)
// with
q = xform.getRotate();

return FQuat(q.x(), q.y(), q.z(), q.w());
}

...

Thank you!

Cheers,
Herman

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75036#75036







------------------------------

Subject: Digest Footer




------------------------------

End of osg-users Digest, Vol 136, Issue 4
*****************************************




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hvarma (Herman Varma)
Newbie


Joined: 12 Sep 2018
Posts: 11

PostPosted: Mon Oct 08, 2018 7:38 pm    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Tue Oct 09, 2018 6:30 am    Post subject:
porting from osg-3.4.0 to osg-3.6.3
Reply with quote

Hi Herman,

Thanks for the stack trace, the crash site and value of nv suggest
that for some reason the application is setting up the viewer without
an EventVIsitior. The osgViewer assigns one by default so this must
have been reset, or the call to handle customized in some way that is
non-standard.

Have a look for any places where setEventVisitor is called in VTP.

Robert.
On Tue, 9 Oct 2018 at 07:15, Herman Varma <> wrote:
Quote:

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





------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hvarma (Herman Varma)
Newbie


Joined: 12 Sep 2018
Posts: 11

PostPosted: Tue Oct 09, 2018 1:49 pm    Post subject:
porting from osg-3.4.0 to osg-3.6.3
Reply with quote

Hi Robert


Yes VTP calls setEventVisitor

m_pOsgViewer->setEventVisitor(NULL);

in
bool vtScene::Init(int argc, char** argv, bool bStereo, int iStereoMode)

Code is listed below marked as //*******CALLED HERE





/**
* Initialize the vtlib library, including the display and scene graph.
* You should call this function only once, before any other vtlib calls.
*
* \param argc, argv Command-line arguments.
* \param bStereo True for a stereo display output.
* \param iStereoMode Currently for vtosg, supported values are 0 for
* Anaglyphic (red-blue) and 1 for Quad-buffer (shutter glasses).
*/
bool vtScene::Init(int argc, char** argv, bool bStereo, int iStereoMode)
{
VTLOG1("vtScene::Init\n");

// Redirect cout messages (where OSG sends its messages) to our own log
previous_cout = std::cout.rdbuf(&g_Trap);
previous_cerr = std::cerr.rdbuf(&g_Trap);

#if 0
// If you encounter trouble in OSG that you want to debug, enable this
// to get a LOT of diagnostic messages from OSG.
osg::setNotifyLevel(osg::INFO);
#endif

m_pDefaultCamera = new vtCamera;
m_pDefaultWindow = new vtWindow;
SetCamera(m_pDefaultCamera);
AddWindow(m_pDefaultWindow);

// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);

m_pOsgViewer = new osgViewer::Viewer(arguments);

m_pOsgViewer->setDisplaySettings(osg::DisplaySettings::instance());
if (bStereo)
{
osg::DisplaySettings* displaySettings = m_pOsgViewer->getDisplaySettings();
displaySettings->setStereo(true);
osg::DisplaySettings::StereoMode mode;
if (iStereoMode == 0) mode = osg::DisplaySettings::ANAGLYPHIC;
if (iStereoMode == 1) mode = osg::DisplaySettings::QUAD_BUFFER;
if (iStereoMode == 2) mode = osg::DisplaySettings::HORIZONTAL_SPLIT;
if (iStereoMode == 3) mode = osg::DisplaySettings::VERTICAL_SPLIT;
displaySettings->setStereoMode(mode);
}
#ifdef __DARWIN_OSX__
// Kill multi-threading on OSX until wxGLContext properly implemented on that platform
m_pOsgViewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
#endif

// We can't use displaySettings->setNumMultiSamples here to enable anti-
// aliasing, because it has to be done eariler (at the time the OpenGL
// context is made).

#ifdef VTP_USE_OSG_STATS
osgViewer::StatsHandler* pStatsHandler = new osgViewer::StatsHandler;
pStatsHandler->setKeyEventPrintsOutStats(0);
pStatsHandler->setKeyEventTogglesOnScreenStats('x'); // I dont think this is used for anything else at the moment
m_pOsgViewer->addEventHandler(pStatsHandler);
#endif

// Kill the event visitor (saves a scenegraph traversal)
// This will need to be restored if we need to use FRAME events etc. in the scenegraph
m_pOsgViewer->setEventVisitor(NULL);//*******CALLED HERE

if (bStereo)
{
// displaySettings->getScreenDistance(); default is 0.5
// m_pOsgSceneView->getFusionDistanceMode(); default is PROPORTIONAL_TO_SCREEN_DISTANCE
// m_pOsgSceneView->getFusionDistanceValue(); default is 1.0
// The FusionDistanceValue is only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.

// We use real-world units for fusion distance value
m_pOsgViewer->setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE, 100.0f);
}

// From the OSG mailing list: You must specify the lighting mode in
// setDefaults() and override the default options. If you call
// setDefaults() with the default options, a headlight is added to the
// global state set of the SceneView. With the default options applied,
// I have tried subsequently calling setLightingMode(NO_SCENE_LIGHT)
// and setLight(NULL), but I still get a headlight.
m_pOsgViewer->setLightingMode(osg::View::NO_LIGHT);
m_pOsgViewer->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
m_pOsgViewer->getCamera()->setCullingMode(m_pOsgViewer->getCamera()->getCullingMode() & ~osg::CullSettings::SMALL_FEATURE_CULLING);

// We maintain a node between OSG's viewer/camera and the vtlib Root, to
// control global state
m_StateRoot = new osg::Group;
m_pOsgViewer->setSceneData(m_StateRoot);

// By default, things are lit, unless they ask not to be
m_StateRoot->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute:ShockedN);

//m_StateRoot->addCullCallback(new MyCull);
//m_StateRoot->setUpdateCallback(new MyUpdate);
//m_StateRoot->setEventCallback(new MyEvent);

m_bInitialized = true;

_initialTick = _timer.tick();
_frameTick = _initialTick;

return true;
}



Thank you!

Cheers,
Herman
Back to top
View user's profile Send private message Send e-mail
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Tue Oct 09, 2018 4:21 pm    Post subject:
porting from osg-3.4.0 to osg-3.6.3
Reply with quote

Hi Herman,

On Tue, 9 Oct 2018 at 16:05, Herman Varma <> wrote:
Quote:
Yes VTP calls setEventVisitor

m_pOsgViewer->setEventVisitor(NULL);

That's an easy one then, just comment that line out.

The motivation behind the above line is a bit mus-guided as the OSG
keeps track whether a scene graph has an even callbacks and for the
subgraphs that don't contain any it doesn't do any traversal, so if
you don't use event callbacks the event traversal is close to a non
op.

The time you do use an event callback you'll only pay the cost for the
traversal down to the node that has the callback.

If you really do want to switch off the event visitor then setting the
EventVisitor TraversalMask to 0x0 will switch off traversal.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Tue Oct 09, 2018 4:23 pm    Post subject:
porting from osg-3.4.0 to osg-3.6.3
Reply with quote

I wrote:
Quote:
That's an easy one then, just comment that line out.

The motivation behind the above line is a bit mus-guided as the OSG keeps track whether a scene graph has an even callbacks and for the subgraphs that don't contain any it doesn't do any traversal, so if you don't use event callbacks the event traversal is close to a non op.

The time you do use an event callback you'll only pay the cost for the traversal down to the node that has the callback.

If you really do want to switch off the event visitor then setting the EventVisitor TraversalMask to 0x0 will switch off traversal.

The above features apply along way back, possibly even the OSG-1.x era
so it's safe to have the event visitor attached, so even if you want
to compile against 3.4 and 3.6.x the remove of the
setEventVisitor(NULL); is perfectly safe.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hvarma (Herman Varma)
Newbie


Joined: 12 Sep 2018
Posts: 11

PostPosted: Tue Oct 09, 2018 5:39 pm    Post subject:
"Problems porting from osg-3.4.0 to osg-3.6.0"
Reply with quote

Hi Robert

I commented out setEventVisitor(NULL) statement.
Thanks to you everything is operating properly with openscenegraph-3.6.3
Now its on to bringing VTP up to spec with wxWidgets.
I fosrsee similar obstacles (sigh!). Hopefully I can iron them out with good people like yourself.

Thanks again

Cheers,
Herman
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Porting application from OSG 3.0 to O... Daniel Trstenjak General 1 Fri Oct 26, 2018 9:15 am View latest post
No new posts Problems porting from osg-3.4.0 to os... hvarma General 10 Wed Sep 12, 2018 3:29 pm View latest post
No new posts porting old code to the latest osg is... Trajce Nikolov NICK General 4 Fri Sep 02, 2016 12:11 am View latest post
No new posts porting issue sajis997 General 1 Sun Dec 09, 2012 2:52 pm View latest post
No new posts example of porting of scenegraph to n... Sergey Kurdakov General 2 Fri Sep 16, 2011 3:17 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP