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

Method Initialize

trinity/Shader/Parameter/TriTextureParameter.cpp:198–241  ·  view source on GitHub ↗

---------------------------------------------------------------

Source from the content-addressed store, hash-verified

196
197// ---------------------------------------------------------------
198bool TriTextureParameter::Initialize()
199{
200 if( m_resource )
201 {
202 m_resource->OnTextureChange().UnregisterListener( this );
203 m_resource = nullptr;
204 }
205 if( m_lowResResource )
206 {
207 m_lowResResource->OnTextureChange().UnregisterListener( this );
208 m_lowResResource = nullptr;
209 }
210 m_textureRes = nullptr;
211
212 if( !m_resourcePath.empty() )
213 {
214 if( !BePaths->FileExistsLocally( CA2W( m_resourcePath.c_str() ) ) )
215 {
216 auto dot = m_resourcePath.rfind( '.' );
217 if( dot != std::string::npos )
218 {
219 auto lowResPath = m_resourcePath.substr( 0, dot ) + "_lowdetail" + m_resourcePath.substr( dot );
220 if( BePaths->FileExistsLocally( CA2W( lowResPath.c_str() ) ) )
221 {
222 BeResMan->GetResource( lowResPath.c_str(), "", BlueInterfaceIID<ITr2TextureProvider>(), (void**)&m_lowResResource );
223 if( m_lowResResource )
224 {
225 m_lowResResource->OnTextureChange().RegisterListener<TriTextureParameter, &TriTextureParameter::OnTextureChanged>( this );
226 }
227 }
228 }
229 }
230
231
232 BeResMan->GetResource( m_resourcePath.c_str(), "", BlueInterfaceIID<ITr2TextureProvider>(), (void**)&m_resource );
233 if( m_resource )
234 {
235 m_resource->OnTextureChange().RegisterListener<TriTextureParameter, &TriTextureParameter::OnTextureChanged>( this );
236 }
237 m_textureRes = BlueCastPtr( m_resource );
238 }
239 OnTextureChanged();
240 return true;
241}
242
243// --------------------------------------------------------------------------------------
244// Description:

Callers

nothing calls this directly

Calls 3

UnregisterListenerMethod · 0.80
emptyMethod · 0.80
GetResourceMethod · 0.45

Tested by

no test coverage detected