Hi,
I'm attempting to create an osg::Camera that renders to a texture via a frame
buffer object, but it is not working. When I debug it I see that the after
attempting to bind the FBO in RenderStage::runCameraSetup() it checks the FBO
status and it is returned as GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT.
I basically copied the code from osgprerender.cpp so I don't understand why it
is not working. Can someone take a look at my code and perhaps help me?
Thank you!
Here's the code:
Code:
osg::Camera* pCamera = new osg::Camera();
pCamera->setClearColor(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
pCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
pCamera->setProjectionMatrixAsOrtho(-halfWidth, halfWidth, -halfHeight,
halfHeight, 1.0f, 11000.0f);
pCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
pCamera->setViewMatrixAsLookAt(gccXYZ, lookAt, upVec);
pCamera->setViewport(0, 0, imageWidthPixels, imageHeightPixels);
pCamera->setRenderOrder(osg::Camera::PRE_RENDER);
pCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
osg::Texture2D* pRenderTexture = new osg::Texture2D;
pRenderTexture->setTextureSize(imageWidthPixels, imageHeightPixels);
pRenderTexture->setInternalFormat(GL_RGBA8);
pRenderTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
pRenderTexture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
pRenderTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
pRenderTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
pCamera->attach(osg::Camera::COLOR_BUFFER, pRenderTexture, 0, 0, false, 0, 0);
Cheers,
Alex
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45519#45519
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org