void CTransitionPostProc::configureInput( irr::u8 n ) { if( !supported ) return; if( n == 1u ) { mat.setTexture( 0u, getInputTexture( 1u ) ); matFast.setTexture( 0u, getInputTexture( 1u ) ); } }
void CWaterPostProc::configureInput( irr::u8 n ) { if( !supported ) return; if( n == 0u ) { mat.setTexture( 0u, getInputTexture( 0u ) ); matUnder.setTexture( 0u, getInputTexture( 0u ) ); } }
//------------------------------------------------------------------------------ void UnitInMipmapOut::init() { // default initialization UnitInOut::init(); // if we have to create mipmaps for an input texture if (mGenerateMipmapInputIndex >= 0) { setOutputTexture(getInputTexture(mGenerateMipmapInputIndex)); assignOutputTexture(); } // enable mipmap levels in the output texture enableMipmapGeneration(); // if generating of mipmaps done in software, then generate drawables if (mUseShader) { // disable standard fbo //getOrCreateStateSet()->removeAttribute(mFBO.get()); getOrCreateStateSet()->removeAttribute(mViewport.get()); // this is the base level of mipmap generation // if the output texture is the same as input texture, then // we do not need to recompute the level 0, because it should // stay the same. int baseLevel = (mGenerateMipmapInputIndex < 0 ? 0 : 1); // attach a drawable for each mipmap level for (int i = baseLevel; i < mNumLevels; i++) { // setup the drawable osg::Drawable* draw = mMipmapDrawable[i]; osg::StateSet* ss = draw->getOrCreateStateSet(); // setup drawable uniforms osg::Uniform* w = ss->getOrCreateUniform(OSGPPU_VIEWPORT_WIDTH_UNIFORM, osg::Uniform::FLOAT); osg::Uniform* h = ss->getOrCreateUniform(OSGPPU_VIEWPORT_HEIGHT_UNIFORM, osg::Uniform::FLOAT); w->set((float)mMipmapViewport[i]->width()); h->set((float)mMipmapViewport[i]->height()); osg::Uniform* iw = ss->getOrCreateUniform(OSGPPU_VIEWPORT_INV_WIDTH_UNIFORM, osg::Uniform::FLOAT); osg::Uniform* ih = ss->getOrCreateUniform(OSGPPU_VIEWPORT_INV_HEIGHT_UNIFORM, osg::Uniform::FLOAT); iw->set(1.0f / (float)mMipmapViewport[i]->width()); ih->set(1.0f / (float)mMipmapViewport[i]->height()); osg::Uniform* ln = ss->getOrCreateUniform(OSGPPU_MIPMAP_LEVEL_NUM_UNIFORM, osg::Uniform::FLOAT); ln->set((float)mNumLevels); osg::Uniform* le = ss->getOrCreateUniform(OSGPPU_MIPMAP_LEVEL_UNIFORM, osg::Uniform::FLOAT); le->set((float)i); } } }
bool initDirect3DTextures() { // Note: sharing is not supported on some platforms if (FAILED(dev->CreateOffscreenPlainSurface(WIDTH, HEIGHT, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pSurface, NULL/*&surfaceShared*/))) { std::cerr << "Can't create surface for result" << std::endl; return false; } // Note: sharing is not supported on some platforms if (FAILED(dev->CreateOffscreenPlainSurface(WIDTH, HEIGHT, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pReadOnlySurface, NULL/*&readOnlySurfaceShared*/))) { std::cerr << "Can't create read only surface" << std::endl; return false; } else { IDirect3DSurface9* pTmpSurface; if (FAILED(dev->CreateOffscreenPlainSurface(WIDTH, HEIGHT, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pTmpSurface, NULL))) { std::cerr << "Can't create temp surface for CPU write" << std::endl; return false; } D3DLOCKED_RECT memDesc = {0, NULL}; RECT rc = {0, 0, WIDTH, HEIGHT}; if (SUCCEEDED(pTmpSurface->LockRect(&memDesc, &rc, 0))) { cv::Mat m(cv::Size(WIDTH, HEIGHT), CV_8UC4, memDesc.pBits, (int)memDesc.Pitch); getInputTexture().copyTo(m); pTmpSurface->UnlockRect(); dev->StretchRect(pTmpSurface, NULL, pReadOnlySurface, NULL, D3DTEXF_NONE); } else { std::cerr << "Can't LockRect() on surface" << std::endl; } pTmpSurface->Release(); } if (FAILED(dev->CreateOffscreenPlainSurface(WIDTH, HEIGHT, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pCPUWriteSurface, NULL))) { std::cerr << "Can't create surface for CPU write" << std::endl; return false; } return true; }