MCPcopy Create free account
hub / github.com/carbonengine/trinity / DoPrepare

Method DoPrepare

trinity/Tr2AtlasTexture.cpp:207–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207bool Tr2AtlasTexture::DoPrepare()
208{
209 CCP_STATS_ZONE( __FUNCTION__ );
210
211 if( m_textureAtlas )
212 {
213 // In case we're reloading
214 m_textureAtlas->RemoveFromAtlas( this );
215 }
216 // Allow loading to a specific atlas by setting this before DoLoad
217 if( !m_textureAtlas )
218 {
219 m_textureAtlas = g_textureAtlasMan->FindAtlas( m_loadedBitmap->GetFormat() );
220 }
221
222 m_texture = Tr2TextureAL();
223
224 if( !Tr2Renderer::IsResourceCreationAllowed() )
225 {
226 return false;
227 }
228
229 bool isOK = false;
230 if( m_textureAtlas && !m_isStandAlone )
231 {
232 isOK = m_textureAtlas->DoPrepare( this );
233
234 // Estimate memory usage based on 32-bit textures (the average case for atlas textures)
235 m_memoryUsage = m_width * m_height * 4;
236 }
237
238 if( !isOK )
239 {
240 USE_MAIN_THREAD_RENDER_CONTEXT();
241 if( Tr2ImageIOHelpers::Create2DTexture( *m_loadedBitmap, m_texture, m_memoryUsage, renderContext ) )
242 {
243 m_x = 0;
244 m_y = 0;
245 m_width = m_loadedBitmap->GetWidth();
246 m_height = m_loadedBitmap->GetHeight();
247 m_textureWidth = m_width;
248 m_textureHeight = m_height;
249
250 isOK = true;
251
252 if( m_textureAtlas )
253 {
254 // An appropriate texture atlas was found but it didn't have space.
255 // Register with it, and it may pull the texture in at some point.
256 m_textureAtlas->RegisterOutsider( this );
257 }
258 }
259 }
260
261 FinalizePrepare();
262
263 SetGood( isOK );
264

Callers

nothing calls this directly

Calls 9

Create2DTextureFunction · 0.85
RemoveFromAtlasMethod · 0.80
FindAtlasMethod · 0.80
RegisterOutsiderMethod · 0.80
resetMethod · 0.80
Tr2TextureALClass · 0.70
GetFormatMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected