void UDPAssetProvider::SendPendingRequests(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net) { AssetRequestVector::iterator i = pending_requests_.begin(); while(i != pending_requests_.end()) { RexUUID asset_uuid(i->asset_id_); if (i->asset_type_ == RexAT_Texture) RequestTexture(net, asset_uuid, i->tags_); else RequestOtherAsset(net, asset_uuid, i->asset_type_, i->tags_); i = pending_requests_.erase(i); } }
TextureDefinition* TextureManager::CreateTexture(const char* texturefilename, int minfilter, int magfilter, int wraps, int wrapt) { MyAssert( texturefilename ); LOGInfo( LOGTag, "CreateTexture - %s\n", texturefilename ); // find the texture if it already exists: TextureDefinition* pTextureDef = FindTexture( texturefilename ); if( pTextureDef != 0 ) { pTextureDef->AddRef(); return pTextureDef; } // Create a new texture and add it to m_TexturesStillLoading pTextureDef = MyNew TextureDefinition(); pTextureDef->m_ManagedByTextureManager = true; strcpy_s( pTextureDef->m_Filename, MAX_PATH, texturefilename ); pTextureDef->m_MinFilter = minfilter; pTextureDef->m_MagFilter = magfilter; pTextureDef->m_WrapS = wraps; pTextureDef->m_WrapT = wrapt; m_TexturesStillLoading.AddTail( pTextureDef ); // if the file load hasn't started... start the file load. MyAssert( pTextureDef->m_pFile == 0 ); #if 0 //MYFW_ANDROID //LOGInfo( LOGTag, "Loading Texture: pTextureDef->m_pFile %d\n", pTextureDef->m_pFile ); if( pTextureDef->m_pFile == 0 ) { pTextureDef->m_pFile = RequestTexture( pTextureDef->m_Filename, pTextureDef ); //textureloaded = true; } #else if( pTextureDef->m_pFile == 0 ) { //LOGInfo( LOGTag, "Loading Texture: RequestFile\n" ); pTextureDef->m_pFile = RequestFile( pTextureDef->m_Filename ); //LOGInfo( LOGTag, "Loading Texture: ~RequestFile\n" ); } #endif return pTextureDef; }
void TextureManager::Tick() { // Initialize all FBOs { CPPListNode* pNextNode; for( CPPListNode* pNode = m_UninitializedFBOs.GetHead(); pNode != 0; pNode = pNextNode ) { pNextNode = pNode->GetNext(); FBODefinition* pFBODef = (FBODefinition*)pNode; if( pFBODef->m_FailedToInit ) continue; bool success = pFBODef->Create(); if( success ) { LOGInfo( LOGTag, "pFBODef->Create() succeeded\n" ); //g_pPanelMemory->AddTexture( pFBODef ); m_InitializedFBOs.MoveTail( pFBODef ); pFBODef->m_FullyLoaded = true; } else { pFBODef->m_FailedToInit = true; LOGError( LOGTag, "========================\n" ); LOGError( LOGTag, "pFBODef->Create() failed\n" ); LOGError( LOGTag, "========================\n" ); } } } //// debug: list all textures that need loading. //for( CPPListNode* pNode = m_TexturesStillLoading.GetHead(); pNode; pNode = pNode->GetNext() ) //{ // TextureDefinition* pTextureDef = (TextureDefinition*)pNode; // LOGInfo( LOGTag, "Still need to load: %s\n", pTextureDef->m_Filename ); //} int texturesloadedthistick = 0; CPPListNode* pNextNode; for( CPPListNode* pNode = m_TexturesStillLoading.GetHead(); pNode != 0; pNode = pNextNode ) { pNextNode = pNode->GetNext(); if( m_MaxTexturesToLoadInOneTick != -1 && texturesloadedthistick >= m_MaxTexturesToLoadInOneTick ) break; texturesloadedthistick++; TextureDefinition* pTextureDef = (TextureDefinition*)pNode; //LOGInfo( LOGTag, "Loading Texture: %s\n", pTextureDef->m_Filename ); // if we have an opengl texture, then nothing to do. this shouldn't happen, loaded textures should be in "m_LoadedTextures". MyAssert( pTextureDef->m_TextureID == 0 ); if( pTextureDef->m_TextureID != 0 ) { LOGInfo( LOGTag, "Loading Texture: Already had a texture id?!? pTextureDef->m_TextureID != 0\n" ); continue; } bool textureloaded = false; #if 0 //MYFW_ANDROID //LOGInfo( LOGTag, "Loading Texture: pTextureDef->m_pFile %d\n", pTextureDef->m_pFile ); if( pTextureDef->m_pFile == 0 ) { pTextureDef->m_pFile = RequestTexture( pTextureDef->m_Filename, pTextureDef ); textureloaded = true; } else { LOGInfo( LOGTag, "Loading Texture: calling Android_LoadTextureFromMemory\n" ); pTextureDef->m_TextureID = Android_LoadTextureFromMemory( pTextureDef ); textureloaded = true; } #else // if the file load hasn't started... start the file load. if( pTextureDef->m_pFile == 0 ) { //LOGInfo( LOGTag, "Loading Texture: RequestFile\n" ); pTextureDef->m_pFile = RequestFile( pTextureDef->m_Filename ); //LOGInfo( LOGTag, "Loading Texture: ~RequestFile\n" ); } else { // if the file is ready, create an opengl texture from it. if( pTextureDef->m_pFile->m_FileLoadStatus == FileLoadStatus_Success ) { //LOGInfo( LOGTag, "Loading Texture: pTextureDef->m_pFile->m_FileReady\n" ); pTextureDef->m_TextureID = CreateTextureFromBuffer( pTextureDef ); //LOGInfo( LOGTag, "Loading Texture: CreateTextureFromBuffer\n" ); if( pTextureDef->m_TextureID != 0 ) { //LOGInfo( LOGTag, "Loading Texture: textureloaded = true\n" ); textureloaded = true; } } if( pTextureDef->m_pFile->m_FileLoadStatus > FileLoadStatus_Success ) { LOGError( LOGTag, "File load failed %s\n", pTextureDef->m_Filename ); SAFE_RELEASE( pTextureDef ); } } #endif if( textureloaded ) { LOGInfo( LOGTag, "textureloaded %s\n", pTextureDef->m_Filename ); // by default, we don't free the texture from main ram, so if we free the opengl tex, we can "reload" quick. if( pTextureDef->QueryFreeWhenCreated() ) g_pFileManager->FreeFile( pTextureDef->m_pFile ); m_LoadedTextures.MoveTail( pTextureDef ); pTextureDef->m_FullyLoaded = true; #if MYFW_USING_WX g_pPanelMemory->AddTexture( pTextureDef, "Global", pTextureDef->m_Filename, TextureDefinition::StaticOnDrag ); #endif LOGInfo( LOGTag, "pTextureDef->m_FullyLoaded = true %s\n", pTextureDef->m_Filename ); } } }