// ----------------------------------------------------------------------------------------- void CDemoGlassApplication::createScene() { m_pSceneManager->createSkyBox(_T("snow.jpg"), 500); CPepeEngineEntity* pVase = new CPepeEngineEntity(_T("Vase"), _T("Teapot.3ds")); CPepeEngineSceneNode* pRootNode = m_pSceneManager->getRootSceneNode(); pRootNode->attachObject(pVase); pRootNode->setPosition(0.0f, 0.0f, -15.0f); pRootNode->setScale(0.1f, 0.1f, 0.1f); pVase->setVertexShader(_T("glass.vs")); pVase->setPixelShader(_T("glass.ps")); pVase->setCullingMode(CULL_CLOCKWISE); GPUProgramPtr pVasePS = IPepeEngineGPUProgramManager::getSingleton().getByName(_T("glass.ps")); TexturePtr pRainbowTexture = IPepeEngineTextureManager::getSingleton().create(_T("Rainbow.tga")); pRainbowTexture->load(); pVasePS->getParameters()->bindTexture(_T("Rainbow"), pRainbowTexture); pVasePS->getParameters()->setNamedConstant(_T("indexOfRefractionRatio"), 1.14f); pVasePS->getParameters()->setNamedConstant(_T("rainbowSpread"), 0.18f); pVasePS->getParameters()->setNamedConstant(_T("rainbowScale"), 0.2f); pVasePS->getParameters()->setNamedConstant(_T("reflectionScale"), 1.0f); pVasePS->getParameters()->setNamedConstant(_T("refractionScale"), 1.0f); pVasePS->getParameters()->setNamedConstant(_T("ambient"), 0.2f); pVasePS->getParameters()->setNamedConstant(_T("baseColor"), CPepeEngineVector4(0.78f, 0.78f, 0.78f, 1.0f)); }
//----------------------------------------------------------------------- TexturePtr TextureManager::load(const String &name, const String& group, TextureType texType, int numMipmaps, Real gamma, bool isAlpha, PixelFormat desiredFormat, bool hwGamma) { ResourceCreateOrRetrieveResult res = createOrRetrieve(name,group,false,0,0,texType,numMipmaps,gamma,isAlpha,desiredFormat,hwGamma); TexturePtr tex = res.first; tex->load(); return tex; }
//--------------------------------------------------------------------- RenderTexture * RenderSystem::createRenderTexture( const String & name, unsigned int width, unsigned int height, TextureType texType, PixelFormat internalFormat, const NameValuePairList *miscParams ) { /// Create a new 2D texture, and return surface to render to TexturePtr mTexture = TextureManager::getSingleton().createManual( name, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, texType, width, height, 0, internalFormat, TU_RENDERTARGET ); // Ensure texture loaded and internal resources created mTexture->load(); return mTexture->getBuffer()->getRenderTarget(); }
//--------------------------------------------------------------------- void ShadowTextureManager::getShadowTextures(const ShadowTextureConfigList& configList, ShadowTextureList& listToPopulate) { listToPopulate.clear(); set<Texture*>::type usedTextures; for (ShadowTextureConfigList::const_iterator c = configList.begin(); c != configList.end(); ++c) { const ShadowTextureConfig& config = *c; bool found = false; for (ShadowTextureList::iterator t = mTextureList.begin(); t != mTextureList.end(); ++t) { const TexturePtr& tex = *t; // Skip if already used this one if (usedTextures.find(tex.getPointer()) != usedTextures.end()) continue; if (config.width == tex->getWidth() && config.height == tex->getHeight() && config.format == tex->getFormat() && config.fsaa == tex->getFSAA()) { // Ok, a match listToPopulate.push_back(tex); usedTextures.insert(tex.getPointer()); found = true; break; } } if (!found) { // Create a new texture static const String baseName = "Ogre/ShadowTexture"; String targName = baseName + StringConverter::toString(mCount++); TexturePtr shadowTex = TextureManager::getSingleton().createManual( targName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, TEX_TYPE_2D, config.width, config.height, 0, config.format, TU_RENDERTARGET, NULL, false, config.fsaa); // Ensure texture loaded shadowTex->load(); listToPopulate.push_back(shadowTex); usedTextures.insert(shadowTex.getPointer()); mTextureList.push_back(shadowTex); } } }