MCPcopy Create free account
hub / github.com/OpenMW/openmw / createObjectsForFrame

Method createObjectsForFrame

apps/openmw/mwrender/postprocessor.cpp:435–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433 }
434
435 void PostProcessor::createObjectsForFrame(size_t frameId)
436 {
437 auto& textures = mTextures[frameId];
438
439 int width = renderWidth();
440 int height = renderHeight();
441
442 for (osg::ref_ptr<osg::Texture>& texture : textures)
443 {
444 if (!texture)
445 {
446 if (Stereo::getMultiview())
447 texture = new osg::Texture2DArray;
448 else
449 texture = new osg::Texture2D;
450 }
451 Stereo::setMultiviewCompatibleTextureSize(texture, width, height);
452 texture->setSourceFormat(GL_RGBA);
453 texture->setSourceType(GL_UNSIGNED_BYTE);
454 texture->setInternalFormat(GL_RGBA);
455 texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture::LINEAR);
456 texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture::LINEAR);
457 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
458 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
459 texture->setResizeNonPowerOfTwoHint(false);
460 Stereo::setMultiviewCompatibleTextureSize(texture, width, height);
461 texture->dirtyTextureObject();
462 }
463
464 textures[Tex_Normal]->setSourceFormat(GL_RGB);
465 textures[Tex_Normal]->setInternalFormat(GL_RGB);
466
467 textures[Tex_Distortion]->setSourceFormat(GL_RGB);
468 textures[Tex_Distortion]->setInternalFormat(GL_RGB);
469
470 Stereo::setMultiviewCompatibleTextureSize(textures[Tex_Distortion], static_cast<int>(width * DistortionRatio),
471 static_cast<int>(height * DistortionRatio));
472 textures[Tex_Distortion]->dirtyTextureObject();
473
474 auto setupDepth = [](osg::Texture* tex) {
475 tex->setSourceFormat(GL_DEPTH_STENCIL_EXT);
476 tex->setSourceType(SceneUtil::AutoDepth::depthSourceType());
477 tex->setInternalFormat(SceneUtil::AutoDepth::depthInternalFormat());
478 };
479
480 setupDepth(textures[Tex_Depth]);
481 setupDepth(textures[Tex_OpaqueDepth]);
482 textures[Tex_OpaqueDepth]->setName("opaqueTexMap");
483
484 auto& fbos = mFbos[frameId];
485
486 fbos[FBO_Primary] = new osg::FrameBufferObject;
487 fbos[FBO_Primary]->setAttachment(
488 osg::Camera::COLOR_BUFFER0, Stereo::createMultiviewCompatibleAttachment(textures[Tex_Scene]));
489 if (mNormals && mNormalsSupported)
490 fbos[FBO_Primary]->setAttachment(
491 osg::Camera::COLOR_BUFFER1, Stereo::createMultiviewCompatibleAttachment(textures[Tex_Normal]));
492 fbos[FBO_Primary]->setAttachment(

Callers

nothing calls this directly

Calls 9

getMultiviewFunction · 0.85
getTextureWidthMethod · 0.80
getTextureHeightMethod · 0.80
setFilterMethod · 0.45
setNameMethod · 0.45
dirtyMethod · 0.45

Tested by

no test coverage detected