MCPcopy Create free account
hub / github.com/SpartanJ/eepp / loadFromStream

Method loadFromStream

src/eepp/graphics/textureatlasloader.cpp:126–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void TextureAtlasLoader::loadFromStream( IOStream& IOS ) {
127 mRL.setThreaded( mThreaded );
128
129 if ( IOS.isOpen() ) {
130 IOS.read( (char*)&mTexGrHdr, sizeof( sTextureAtlasHdr ) );
131
132 if ( mTexGrHdr.Magic == EE_TEXTURE_ATLAS_MAGIC ) {
133 for ( Uint32 i = 0; i < mTexGrHdr.TextureCount; i++ ) {
134 sTextureHdr tTextureHdr;
135 sTempTexAtlas tTexAtlas;
136
137 IOS.read( (char*)&tTextureHdr, sizeof( sTextureHdr ) );
138
139 tTexAtlas.Texture = tTextureHdr;
140 tTexAtlas.TextureRegions.resize( tTextureHdr.TextureRegionCount );
141
142 std::string name( &tTextureHdr.Name[0] );
143 std::string path( FileSystem::fileRemoveFileName( mTextureAtlasPath ) + name );
144
145 //! Checks if the texture is already loaded
146 Texture* tTex = TextureFactory::instance()->getByName( path );
147
148 if ( !mSkipResourceLoad && NULL == tTex ) {
149 if ( NULL != mPack ) {
150 mRL.add( [this, path = std::move( path )] {
151 TextureFactory::instance()->loadFromPack( mPack, path );
152 } );
153 } else {
154 mRL.add( [path = std::move( path )] {
155 TextureFactory::instance()->loadFromFile( path );
156 } );
157 }
158 }
159
160 IOS.read( (char*)&tTexAtlas.TextureRegions[0],
161 sizeof( sTextureRegionHdr ) * tTextureHdr.TextureRegionCount );
162
163 mTempAtlass.push_back( tTexAtlas );
164 }
165 }
166
167 if ( !mSkipResourceLoad ) {
168 mIsLoading = true;
169 mRL.load( [this]( ResourceLoader* ) {
170 if ( !mLoaded ) {
171 createTextureRegions();
172 }
173 } );
174 }
175 }
176}
177
178void TextureAtlasLoader::loadFromFile( const std::string& TextureAtlasPath ) {
179 if ( TextureAtlasPath.size() )

Callers

nothing calls this directly

Calls 10

push_backMethod · 0.80
setThreadedMethod · 0.45
isOpenMethod · 0.45
readMethod · 0.45
resizeMethod · 0.45
getByNameMethod · 0.45
addMethod · 0.45
loadFromPackMethod · 0.45
loadFromFileMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected