Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
I kept playing with RTT and I noticed an issue: If you do not set a single threading model then if you go from fullscreen to windowed mode and back to fullscreen, the system hangs (I get a black screen and I can only reboot) - you may have to press 'f' several times before the hang occurs... If you instead choose to use a single threading model it looks like that everything goes fine. I've read about something like this in other posts: someone had the same issue in a multi-screen setup, but this is not my case, someone else noticed that the osgdistortion example (that employs RTT) also sets a single threading model. To reproduce the problem I guess that you can just use the code posted above. In order to solve the issue: am I supposed to lock something when toggling fullscreen/windowed mode? Should I try by changing threading model on the fly before switching fullscreen/windowed mode? In this case, where is it safe to do it? I'm on Windows 7 64bit and OSG version is 3.0.0 rc1 (32bit). Cheers. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41286#41286 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
Hi, I just tried the prerender example by issuing the --fb parameter and I get the same problem as described above...so I guess that this is the expected behaviour even though it is not the effect one could expect. So, is there something that must be done in order to use RTT when a window resizing occurs? Thanks. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41232#41232 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
Hi, this is known behaviour. Currently OSG caters for the common case where the size and attachments of the RTT camera does not change frequently. There are workarounds. I suggest you search the list archives for runCameraSetup. You can also check how osgPPU handles resizes. rgds jp On 07/07/11 11:35, Alessandro Terenzi wrote: Hi, I just tried the prerender example by issuing the --fb parameter and I get the same problem as described above...so I guess that this is the expected behaviour even though it is not the effect one could expect. So, is there something that must be done in order to use RTT when a window resizing occurs? Thanks. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41232#41232 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.orgHi, -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
Thanks JP, after having searched the archives, I tried to create a cull callback and in its operator() method I tried different things among adding these lines: Code: cv-getCurrentRenderBin()-getStage()-setCameraRequiresSetUp(true); cv-getCurrentRenderBin()-getStage()-runCameraSetUp(cv-getRenderInfo()); But this seems to be not enough. I also tried to detach the COLOR_BUFFER and attach it again along with the RTT texture, but still same issue. I do not understand what happens behind the scenes, so I still cannot think about what else to try...any hint about the workaround you were talking about? :) Cheers. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41234#41234 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
Hi, Are you recreating the texture so that it fits the new view size? Are you modifying the RTT camera viewport? Above is however not needed when using FBO RTT, the texture size can stay the same no matter what the final view window size is, unless you want to match it pixel for pixel. I double checked it with your original app. You only had: camera_RTT-setViewport(0,0,screenWidth,screenHeight); missing, then the FBO path works fine. I also attach code that worked for me. Any specific reason for not using FBO? jp On 07/07/11 13:14, Alessandro Terenzi wrote: Thanks JP, after having searched the archives, I tried to create a cull callback and in its operator() method I tried different things among adding these lines: Code: cv-getCurrentRenderBin()-getStage()-setCameraRequiresSetUp(true); cv-getCurrentRenderBin()-getStage()-runCameraSetUp(cv-getRenderInfo()); But this seems to be not enough. I also tried to detach the COLOR_BUFFER and attach it again along with the RTT texture, but still same issue. I do not understand what happens behind the scenes, so I still cannot think about what else to try...any hint about the workaround you were talking about? :) Cheers. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41234#41234 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. #include osgDB/ReadFile #include osgUtil/Optimizer #include osg/CoordinateSystemNode #include osg/Switch #include osgText/Text #include osgViewer/CompositeViewer #include osgViewer/ViewerEventHandlers #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/StateSetManipulator #include osgGA/AnimationPathManipulator #include osgGA/TerrainManipulator #include iostream int main( int argc, char **argv ) { osg::ArgumentParser arguments(argc,argv); osgViewer::Viewer viewer(arguments); // add stats and window size handlers... viewer.addEventHandler( new osgViewer::StatsHandler() ); viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); int screenWidth = 1366; int screenHeight = 768; // create the texture to render to... osg::ref_ptrosg::Texture2D texture_RTT = new osg::Texture2D; texture_RTT-setTextureSize(screenWidth, screenHeight); texture_RTT-setInternalFormat(GL_RGBA); texture_RTT-setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); texture_RTT-setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); texture_RTT-setResizeNonPowerOfTwoHint(false); // create the quad... osg::ref_ptrosg::Geometry quad_RTT = osg::createTexturedQuadGeometry( osg::Vec3(0.0, 0.0, 0.0), osg::Vec3(screenWidth, 0.0, 0.0), osg::Vec3(0.0, screenHeight, 0.0)); quad_RTT-setDataVariance( osg::Object::DYNAMIC ); osg::ref_ptrosg::Geode quad_geode_RTT = new osg::Geode; quad_geode_RTT-addDrawable(quad_RTT.get()); quad_geode_RTT-setDataVariance( osg::Object::DYNAMIC ); osg::StateSet *quadState = quad_geode_RTT-getOrCreateStateSet(); quadState-setTextureAttributeAndModes(0, texture_RTT.get(), osg::StateAttribute::ON); quadState-setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED ); // create the camera... osg::ref_ptrosg::Camera camera_RTT = new osg::Camera; #ifdef USE_IMAGE osg::ref_ptrosg::Image image_RTT = new osg::Image; image_RTT-allocateImage(screenWidth, screenHeight, 1, GL_RGBA, GL_UNSIGNED_BYTE); camera_RTT-attach(osg::Camera::COLOR_BUFFER, image_RTT.get()); texture_RTT-setImage(0, image_RTT.get()); #else camera_RTT-attach(osg::Camera::COLOR_BUFFER, texture_RTT.get()); #endif camera_RTT-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); //camera_RTT-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER); camera_RTT-setRenderOrder(osg::Camera::PRE_RENDER); camera_RTT-setReferenceFrame( osg::Camera::ABSOLUTE_RF ); camera_RTT-setClearColor( osg::Vec4( 0., 0., 1., 1. ) ); camera_RTT-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // add whatever children you want drawn to the texture osg::ref_ptr osg::Node node = osgDB::readNodeFile(cow.osg); if(node.valid()) { const osg::BoundingSphere bs = node-getBound(); float znear =
Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
Well, no, I was not re-creating the texture, so if I understood it correctly: if I want to use the FRAME_BUFFER target I also need to re-create the texture every time a resize occurs and also call runCameraSetup as well, right? Actually the decision not to use FBOs is not final, I'm just trying the possibilities...to this regard I wonder which target, among FRAME_BUFFER, FBO and pbuffer, is the one that is most likely going to work on, let's say, 3 or 5 years old computers? Thank you again. Cheers. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41237#41237 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT issue when switching from fullscreen to windowed mode
Hi Alessandro, On 07/07/11 15:46, Alessandro Terenzi wrote: Well, no, I was not re-creating the texture, so if I understood it correctly: if I want to use the FRAME_BUFFER target I also need to re-create the texture every time a resize occurs and also call runCameraSetup as well, right? If you change texture dimensions you definitely need to call setCameraRequiresSetUp(true); The runCameraSetup is actually performed inside RenderStage, so you don't have to call this yourself. I'm not 100% sure of the requirement to resize the texture when the viewport changes for FRAME_BUFFER, but I assume that if the camera is re-using the frame buffer of the viewer then their sizes should match. You'll have to double check this. Actually the decision not to use FBOs is not final, I'm just trying the possibilities...to this regard I wonder which target, among FRAME_BUFFER, FBO and pbuffer, is the one that is most likely going to work on, let's say, 3 or 5 years old computers? Well I've tested your code on an old (+-5 years) Dell D820 laptop with an NVidia GeForce Go 7400 and FBO works fine on that. I'd say if you can use FBO at all go for that. cheers jp Thank you again. Cheers. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41237#41237 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org