TextureAtlas::TextureAtlas(const char* path, float scale, TextureList regions) : TextureAtlas(path, scale) { regions_.reserve(regions.size()); for (auto&& p : regions) { add_region(std::get<0>(p), std::get<1>(p), std::get<2>(p), std::get<3>(p)); } }
void sendToShader( GLuint shaderProgram ) { auto numTextures = diffuseTextures.size(); for( int i = 0; i != numTextures; i++ ) { glActiveTexture( GL_TEXTURE0 + i ); std::stringstream stream; stream << "diffuse" << i; std::string uniformName = stream.str(); glBindTexture( GL_TEXTURE_2D, diffuseTextures[ i ]->id ); glUniform1i( glGetUniformLocation( shaderProgram, uniformName.c_str() ), i ); } }
TextureAtlas::TextureAtlas(const char* id, const DataMap& data, float scale, TextureList regions) : TextureAtlas(id, data, scale) { regions_.reserve(regions.size()); for (auto&& p : regions) { add_region(std::get<0>(p), std::get<1>(p), std::get<2>(p), std::get<3>(p)); } }
void WaterNode::Handle(RenderingEventArg arg){ if (waterShader != NULL){ Vector<2, int> dim(400,300); reflectionFbo = new FrameBuffer(dim, 1, false); arg.renderer.BindFrameBuffer(reflectionFbo); waterShader->SetTexture("reflection", reflectionFbo->GetTexAttachment(0)); if (normaldudvmap != NULL) waterShader->SetTexture("normaldudvmap", (ITexture2DPtr)normaldudvmap); waterShader->Load(); TextureList texs = waterShader->GetTextures(); for (unsigned int i = 0; i < texs.size(); ++i) arg.renderer.LoadTexture(texs[i].get()); }else if (surface != NULL) arg.renderer.LoadTexture(surface); }
void TextureManager::reloadTextures() { m_collectionMap.clear(); m_texturesCaseSensitive.clear(); m_texturesCaseInsensitive.clear(); m_texturesByName.clear(); m_texturesByUsage.clear(); typedef std::pair<TextureMap::iterator, bool> InsertResult; for (size_t i = 0; i < m_collections.size(); i++) { TextureCollection* collection = m_collections[i]; const TextureList textures = collection->textures(); for (size_t j = 0; j < textures.size(); j++) { Texture* texture = textures[j]; m_collectionMap[texture] = collection; InsertResult result = m_texturesCaseSensitive.insert(TextureMapEntry(texture->name(), texture)); if (!result.second) { // texture with this name already existed result.first->second->setOverridden(true); m_texturesCaseSensitive.erase(result.first); m_texturesCaseSensitive.insert(TextureMapEntry(texture->name(), texture)); } m_texturesCaseInsensitive[Utility::toLower(texture->name())] = texture; texture->setOverridden(false); } } TextureMap::iterator it, end; for (it = m_texturesCaseSensitive.begin(), end = m_texturesCaseSensitive.end(); it != end; ++it) { Texture* texture = it->second; m_texturesByName.push_back(texture); m_texturesByUsage.push_back(texture); } std::sort(m_texturesByName.begin(), m_texturesByName.end(), CompareTexturesByName()); }