I hazard a a guess that that one reason you might be failing is the card does not support the texture/ FBO size you trying to use ( never assume always as the card what it supports ) // Must be called in an OGL context ( i.e. the draw thread) GLint maxTextureSize; glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTextureSize); Secondly it might also be a combination of bad drivers especially with ATI known poor Opengl drivers
Gordon Product Manager 3d __________________________________________________________ Gordon Tomlinson Email : gtomlinson @ overwatch.textron.com __________________________________________________________ ________________________________ From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Jesper D. Thomsen Sent: Wednesday, May 13, 2009 9:34 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Problems with FBOs when taking high resolutionscreenshots. Hi all, I'm using OSG (2.6.1 compiled for windows XP/Vista by Visual Studio 2005) to create a viewport in an MFC application. I have a function where I take a high resolution screenshot by doing RTT rendering to an FBO. I've now begun receiving bug reports from some users (so far, all ATI graphics card users) that the screenshots come out mostly black. This happens either all the time or after the first screenshot, which led me to guess that some kind of FBO resource is not getting released properly. On an older machine the screenshots always come out somewhat black. In both cases this occors when the screenshot is larger than 2048x2048 pixels. The lower-left 2048x2048 pixels of the screenshot are always correct, but the rest is black. I've tried using Pixel_buffer also, but with the exact same result on my old testmachine. On my own machine (Vista 64 - NV Quadro FX 2700M) the screenshots work fine at all tested resolutions. Does anybody know if this is just a hard limitation in the drivers/graphics cards, or am I just forgetting something in my code (Code posted below). Regards, and thanks in advance (again). Jesper D. Thomsen -------- Code: ------------- bool CModelView::CreateOSGImageSnap(int p_width, int p_height, double p_left, double p_right, double p_bottom, double p_top, double p_near, double p_far, double p_eye_pivot_0, double p_eye_pivot_1, double p_eye_pivot_2, double p_eye_eulerpar_0, double p_eye_eulerpar_1, double p_eye_eulerpar_2, double p_eye_eulerpar_3, double p_eye_dist, bool p_ortho, osg::Image* p_image){ osg::ref_ptr<osg::Camera> t_camera = new osg::Camera; osg::ref_ptr<osg::Group> t_parent = new osg::Group; unsigned int t_samples = 0; unsigned int t_colorSamples = 0; t_camera->setViewport(0,0,p_width,p_height); if(p_ortho){ t_camera->setProjectionMatrixAsOrtho(p_left,p_right,p_bottom,p_top,p_nea r,p_far); }else{ t_camera->setProjectionMatrixAsFrustum(p_left,p_right,p_bottom,p_top,p_n ear,p_far); } osg::Matrixd t_matrix = osg::Matrixd::translate(-(osg::Vec3d(p_eye_pivot_0,p_eye_pivot_1,p_eye_p ivot_2)))* osg::Matrixd::rotate((osg::Quat(p_eye_eulerpar_1,p_eye_eulerpar_2,p_eye_ eulerpar_3,p_eye_eulerpar_0)).inverse())* osg::Matrixd::translate(0.0,0.0,-p_eye_dist); t_camera->setViewMatrix(t_matrix); t_camera->setRenderOrder(osg::Camera::PRE_RENDER); t_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT ); t_camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); t_camera->setClearColor( osg::Vec4(GetBackgroundColor()[0],GetBackgroundColor()[1],GetBackgroundC olor()[2],1.0) ); p_image->allocateImage(p_width, p_height, 1, GL_RGB, GL_UNSIGNED_BYTE); t_camera->attach(osg::Camera::COLOR_BUFFER, p_image, t_samples, t_colorSamples); t_camera->setPostDrawCallback(new MyCameraPostDrawCallback(p_image)); osg::Node* t_oldroot = mOSG->getASG()->getOSGRoot(); t_camera->addChild(mOSG->getASG()->getOSGRoot()); t_parent->addChild(t_camera.get()); mOSG->getViewer()->setSceneData(t_parent.get()); mOSG->getViewer()->frame(); mOSG->getViewer()->setSceneData(t_oldroot); mOSG->getViewer()->frame(); return true; //Fixme: This should be changed to a bool describing whether the snapshot was successful. };
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org