bool DX10_Renderer::CreateTexture(std::string _texFileName, ID3D10ShaderResourceView*& _prTex) { ID3D10ShaderResourceView* pTexture = 0; // Look for the texture by name to see if it is already loaded std::map<std::string, ID3D10ShaderResourceView*>::iterator texCheck; texCheck = m_textures.find(_texFileName); // Check if the Texture exists if (texCheck != m_textures.end()) { // Texture is already loaded. Save its ID pTexture = texCheck->second; } else { // Texture is new, create and save. std::string filePath = TEXTUREFILEPATH; filePath.append(_texFileName); VALIDATEHR(D3DX10CreateShaderResourceViewFromFileA(m_pDX10Device, filePath.c_str(), 0, 0, &pTexture, 0)); std::pair<std::string, ID3D10ShaderResourceView*> texPair(_texFileName, pTexture); VALIDATE(m_textures.insert(texPair).second); } _prTex = pTexture; return true; }
void TexObjMgr::bindTexture(GLenum target, GLuint tex) { if(texPool.find(tex) == texPool.end()) { if (curMaxId < tex) { curMaxId = tex; pair<GLuint, TexObject> texPair(tex, TexObject()); texPool.insert(texPair); } } this->curObjPtr = &texPool[tex]; curObjPtr->target = target; }
void TexObjMgr::genTextures(GLsizei count, GLuint * textures) { if (textures == NULL) { return; } for (GLsizei i = 0; i < count; i++) { GLuint newId; if (freedName.size() > 0) { newId = freedName.back(); *textures = newId; freedName.pop_back(); } else { newId = (++curMaxId); *textures = newId; } pair<GLuint, TexObject> texPair(newId, TexObject()); texPool.insert(texPair); textures++; } }