Joined: 26 May 2017
|Posted: Fri May 26, 2017 6:37 pm Post subject:
MFC mdi child windows show the scene with different lighting
I have a MFC MDI osg project. Every child window has the same model and ligthing and teh sequence of initialization. I have attached a screenshot to show how it looks as we open more child windows.
The structure of the project is as below.
The sequence of operations are as below.
A new instance of myOSGViewer is created in OnCreate() of the view class.
In OnInitialUpdate() of view class
myOSGViewer is initialized as below.
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator('1', "Trackball", new osgGA::TrackballManipulator());
keyswitchManipulator->addMatrixManipulator('2', "Flight", new osgGA::FlightManipulator());
keyswitchManipulator->addMatrixManipulator('3', "Drive", new osgGA::DriveManipulator());
keyswitchManipulator->addMatrixManipulator('4', "Terrain", new osgGA::TerrainManipulator());
keyswitchManipulator->addMatrixManipulator('5', "Orbit", new osgGA::OrbitManipulator());
keyswitchManipulator->addMatrixManipulator('6', "FirstPerson", new osgGA::FirstPersonManipulator());
keyswitchManipulator->addMatrixManipulator('7', "Spherical", new osgGA::SphericalManipulator());
viewer = new osgViewer::Viewer();
mEvents = new KeyboardEventHandler(this);
ConstructModel(); //scene is created. light transform is also created added to the scene graph
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(m_hWnd);
osg::GraphicsContext* gc = osg::GraphicsContext::createGraphicsContext(traits.get());
osg::ref_ptr<osg::Camera> camera = viewer->getCamera();
camera->setViewport(new osg::Viewport(traits->x, traits->y, traits->width, traits->height));
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
camera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f));
30.0f, static_cast<double>(traits->width) / static_cast<double>(traits->height), 1.0, 1000.0);
viewer->getCameraManipulator()->setHomePosition(eyeP, centreP, upP);
mThreadHandle1 = new CRenderingThread1(myOSGViewer);
For every OnFileNew the above steps happen. I find that the child windows dont have the same level of brightness. I have attached a screenshot of the problem.
Hope I have been clear in putting the problem. In case any more detail is required I will be happy to provide. Any thought or idea is will be appreciated.
Joined: 19 Jan 2015
|Posted: Tue Jun 06, 2017 6:22 am Post subject:
That is very strange. I'm using MFC and I haven't experienced that. Can you modify the OSG MFC Example to reproduce the problem and post it in the forum? I can have a look at it on my side. Unfortunately I am not able to reproduce the problem with the code you posted.