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

Method GatherSprites

trinity/EveSprite2dBracketRenderer.cpp:20–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void EveSprite2dBracketRenderer::GatherSprites( Tr2Sprite2dScene* renderer )
21{
22 CCP_STATS_ZONE( __FUNCTION__ );
23
24 USE_MAIN_THREAD_RENDER_CONTEXT();
25 using namespace Tr2RenderContextEnum;
26
27 if( !m_display )
28 {
29 return;
30 }
31
32 if( m_brackets.empty() )
33 {
34 return;
35 }
36
37 unsigned int vertexCount = (unsigned int)m_brackets.size() * 4;
38 unsigned int indexCount = (unsigned int)m_brackets.size() * 6;
39
40 Tr2Sprite2dD3DVertex* vertices;
41
42 if( m_bracketCountInBuffers != m_brackets.size() )
43 {
44 {
45 USE_MAIN_THREAD_RENDER_CONTEXT();
46 // Allocate new vertex/index buffers
47 if( FAILED( m_vertexBuffer.Create( sizeof( Tr2Sprite2dD3DVertex ), vertexCount, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, nullptr, renderContext ) ) )
48 {
49 CCP_LOGERR( "%s failed to create vertex buffer", __FUNCTION__ );
50 return;
51 }
52
53 if( FAILED( m_indexBuffer.Create( 2, indexCount, Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, nullptr, renderContext ) ) )
54 {
55 CCP_LOGERR( "%s failed to create index buffer", __FUNCTION__ );
56 return;
57 }
58 }
59
60 m_bracketCountInBuffers = (unsigned int)m_brackets.size();
61
62 // Fill in the parts of the vertex buffer that don't change
63 HRESULT hr = m_vertexBuffer.MapForWriting( vertices, renderContext );
64 if( FAILED( hr ) )
65 {
66 CCP_LOGERR( "%s failed to lock vertex buffer (%d)", __FUNCTION__, hr );
67 return;
68 }
69
70 // Fill the index buffer now - it only changes when the count changes.
71 unsigned short* indices;
72 hr = m_indexBuffer.MapForWriting( indices, renderContext );
73 if( FAILED( hr ) )
74 {
75 CCP_LOGERR( "%s failed to lock index buffer (%d)", __FUNCTION__, hr );
76 return;
77 }

Callers

nothing calls this directly

Calls 15

PackBlendModeFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.80
GetTranslationMethod · 0.80
IsDisplayMethod · 0.80
GetIconMethod · 0.80
GetTextureWindowMethod · 0.80
RenderTriangleVertsMethod · 0.80
CreateMethod · 0.45
MapForWritingMethod · 0.45
UnmapForWritingMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected