mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:23:52 +00:00
Merged pull request #1967
This commit is contained in:
commit
b30e309532
2 changed files with 13 additions and 37 deletions
|
@ -169,19 +169,18 @@ namespace MWGui
|
|||
// We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
|
||||
mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);
|
||||
|
||||
mShowWallpaper = visible && (MWBase::Environment::get().getStateManager()->getState()
|
||||
== MWBase::StateManager::State_NoGame);
|
||||
mVisible = visible;
|
||||
mLoadingBox->setVisible(mVisible);
|
||||
setVisible(true);
|
||||
|
||||
if (!visible)
|
||||
if (!mVisible)
|
||||
{
|
||||
mShowWallpaper = false;
|
||||
draw();
|
||||
return;
|
||||
}
|
||||
|
||||
mVisible = visible;
|
||||
mLoadingBox->setVisible(mVisible);
|
||||
|
||||
setVisible(true);
|
||||
mShowWallpaper = MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame;
|
||||
|
||||
if (mShowWallpaper)
|
||||
{
|
||||
|
|
|
@ -836,13 +836,8 @@ namespace MWRender
|
|||
|
||||
screenshotCamera->addChild(quad);
|
||||
|
||||
mRootNode->addChild(screenshotCamera);
|
||||
|
||||
renderCameraToImage(screenshotCamera,image,screenshotW,screenshotH);
|
||||
|
||||
screenshotCamera->removeChildren(0,screenshotCamera->getNumChildren());
|
||||
mRootNode->removeChild(screenshotCamera);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -867,6 +862,8 @@ namespace MWRender
|
|||
image->setDataType(GL_UNSIGNED_BYTE);
|
||||
image->setPixelFormat(texture->getInternalFormat());
|
||||
|
||||
mRootNode->addChild(camera);
|
||||
|
||||
// The draw needs to complete before we can copy back our image.
|
||||
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback);
|
||||
camera->setFinalDrawCallback(callback);
|
||||
|
@ -882,32 +879,17 @@ namespace MWRender
|
|||
|
||||
// now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed
|
||||
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
||||
|
||||
camera->removeChildren(0, camera->getNumChildren());
|
||||
mRootNode->removeChild(camera);
|
||||
}
|
||||
|
||||
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform)
|
||||
{
|
||||
osg::ref_ptr<osg::Camera> rttCamera (new osg::Camera);
|
||||
rttCamera->setNodeMask(Mask_RenderToTexture);
|
||||
rttCamera->attach(osg::Camera::COLOR_BUFFER, image);
|
||||
rttCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
rttCamera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
|
||||
rttCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::PIXEL_BUFFER_RTT);
|
||||
rttCamera->setProjectionMatrixAsPerspective(mFieldOfView, w/float(h), mNearClip, mViewDistance);
|
||||
rttCamera->setViewMatrix(mViewer->getCamera()->getViewMatrix() * cameraTransform);
|
||||
|
||||
rttCamera->setViewport(0, 0, w, h);
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> texture (new osg::Texture2D);
|
||||
texture->setInternalFormat(GL_RGB);
|
||||
texture->setTextureSize(w, h);
|
||||
texture->setResizeNonPowerOfTwoHint(false);
|
||||
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
||||
rttCamera->attach(osg::Camera::COLOR_BUFFER, texture);
|
||||
|
||||
image->setDataType(GL_UNSIGNED_BYTE);
|
||||
image->setPixelFormat(texture->getInternalFormat());
|
||||
|
||||
rttCamera->setUpdateCallback(new NoTraverseCallback);
|
||||
rttCamera->addChild(mSceneRoot);
|
||||
|
||||
|
@ -916,14 +898,9 @@ namespace MWRender
|
|||
|
||||
rttCamera->setCullMask(mViewer->getCamera()->getCullMask() & (~Mask_GUI));
|
||||
|
||||
mRootNode->addChild(rttCamera);
|
||||
|
||||
rttCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
renderCameraToImage(rttCamera.get(),image,w,h);
|
||||
|
||||
rttCamera->removeChildren(0, rttCamera->getNumChildren());
|
||||
mRootNode->removeChild(rttCamera);
|
||||
}
|
||||
|
||||
osg::Vec4f RenderingManager::getScreenBounds(const MWWorld::Ptr& ptr)
|
||||
|
|
Loading…
Reference in a new issue