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

Method DrawHelper

trinity/Tr2Blitter.cpp:101–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101bool Tr2Blitter::DrawHelper( Tr2RenderContext& renderContext, Tr2Shader* shader, Tr2Material* material, const Tr2TextureAL* halTexture, bool isCameraSpace, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord )
102{
103 CCP_ASSERT( material );
104 if( !material )
105 {
106 // Final build should not crash even if we get here with a null effect
107 return false;
108 }
109
110 if( m_screenVertexDecl == -1 || !m_vertexBuffer.IsValid() )
111 {
112 return false;
113 }
114
115 if( !shader )
116 {
117 return false;
118 }
119
120 Tr2ScreenVertex* quad = NULL;
121 CR_RETURN_VAL( m_vertexBuffer.MapForWriting( quad, renderContext ), false );
122
123 if( isCameraSpace )
124 {
125 CCP_ASSERT( tlVertexCoord[0] == 0.0f && tlVertexCoord[1] == 0.0f );
126 CCP_ASSERT( brVertexCoord[0] == 1.0f && brVertexCoord[1] == 1.0f );
127
128 SetupScreenQuadInCameraSpace( quad );
129 }
130 else
131 {
132 SetupScreenQuad( quad, tlTexCoord, brTexCoord, tlVertexCoord, brVertexCoord );
133 }
134
135 m_vertexBuffer.UnmapForWriting( renderContext );
136
137 renderContext.m_esm.ApplyVertexDeclaration( m_screenVertexDecl );
138 renderContext.m_esm.ApplyStreamSource( 0, m_vertexBuffer, 0, sizeof( Tr2ScreenVertex ) );
139
140 static CTr2TransientTextureReference textureReference;
141 Tr2TextureAL texCopy;
142 if( halTexture )
143 {
144 texCopy = *halTexture;
145 textureReference.SetTexture( &texCopy );
146 GlobalStore().GetVariable( "BlitSource" )->SetValue( &textureReference );
147 }
148
149 unsigned int passCount = shader->GetPassCount( 0 );
150
151 for( unsigned int passIx = 0; passIx < passCount; ++passIx )
152 {
153 shader->ApplyAllStateForPass( 0, passIx, renderContext );
154 material->ApplyMaterialDataForPass( 0, passIx, renderContext );
155 {
156 renderContext.SetTopology( TOP_TRIANGLE_STRIP );
157 renderContext.DrawPrimitive( 0, 2 );
158 }

Callers

nothing calls this directly

Calls 15

SetupScreenQuadFunction · 0.85
ApplyStreamSourceMethod · 0.80
GetPassCountMethod · 0.80
ApplyAllStateForPassMethod · 0.80
IsValidMethod · 0.45
MapForWritingMethod · 0.45
UnmapForWritingMethod · 0.45
SetTextureMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected