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

Method OnPrepareResources

trinity/Shader/Utils/Tr2DataTextureManager.cpp:62–77  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: Allocate all device resources here --------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

60// Allocate all device resources here
61// --------------------------------------------------------------------------------
62bool Tr2DataTextureManager::OnPrepareResources()
63{
64 USE_MAIN_THREAD_RENDER_CONTEXT();
65
66 // create the data texture here, prefill it with zeros
67 std::vector<Vector4> t( m_textureWidth * m_textureHeight, Vector4( 0.f, 0.f, 0.f, 0.f ) );
68 Tr2SubresourceData init = { &t[0], m_textureWidth * uint32_t( sizeof( Vector4 ) ), m_textureWidth * m_textureHeight * uint32_t( sizeof( Vector4 ) ) };
69 if( FAILED( m_dataTexture->GetTexture()->Create( Tr2BitmapDimensions( m_textureWidth, m_textureHeight, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, &init, renderContext ) ) )
70 {
71 m_dataTexture->OnTextureChange().Broadcast();
72 return false;
73 }
74 m_dataTexture->OnTextureChange().Broadcast();
75
76 return true;
77}
78
79
80// --------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 4

BroadcastMethod · 0.80
Vector4Class · 0.50
CreateMethod · 0.45
GetTextureMethod · 0.45

Tested by

no test coverage detected