MCPcopy Create free account
hub / github.com/defold/defold / Draw

Function Draw

engine/render/src/render/render.cpp:1167–1306  ·  view source on GitHub ↗

NOTE: Currently only used externally in 1 test (fontview.cpp) TODO: Replace that occurrance with DrawRenderList

Source from the content-addressed store, hash-verified

1165 // NOTE: Currently only used externally in 1 test (fontview.cpp)
1166 // TODO: Replace that occurrance with DrawRenderList
1167 Result Draw(HRenderContext render_context, HPredicate predicate, HNamedConstantBuffer constant_buffer)
1168 {
1169 if (render_context == 0x0)
1170 {
1171 return RESULT_INVALID_CONTEXT;
1172 }
1173
1174 dmGraphics::HContext context = dmRender::GetGraphicsContext(render_context);
1175 dmGraphics::HTexture render_context_textures[RenderObject::MAX_TEXTURE_COUNT] = {};
1176
1177 HMaterial material = render_context->m_Material;
1178 HMaterial context_material = render_context->m_Material;
1179
1180 if(context_material)
1181 {
1182 dmGraphics::EnableProgram(context, GetMaterialProgram(context_material));
1183 GetRenderContextTextures(render_context, context_material->m_Samplers, render_context_textures);
1184 }
1185
1186 dmGraphics::PipelineState ps_orig = dmGraphics::GetPipelineState(context);
1187
1188 for (uint32_t i = 0; i < render_context->m_RenderObjects.Size(); ++i)
1189 {
1190 RenderObject* ro = render_context->m_RenderObjects[i];
1191 if (ro->m_VertexCount == 0)
1192 continue;
1193
1194 MaterialTagList taglist;
1195 uint32_t taglistkey = dmRender::GetMaterialTagListKey(ro->m_Material);
1196 dmRender::GetMaterialTagList(render_context, taglistkey, &taglist);
1197
1198 if (predicate && !dmRender::MatchMaterialTags(taglist.m_Count, taglist.m_Tags, predicate->m_TagCount, predicate->m_Tags))
1199 {
1200 continue;
1201 }
1202
1203 if (!context_material)
1204 {
1205 if(material != ro->m_Material)
1206 {
1207 material = ro->m_Material;
1208 dmGraphics::EnableProgram(context, GetMaterialProgram(material));
1209
1210 // Reset the override texture binding array. The new material may have a different
1211 // resource layout than the current material.
1212 memset(render_context_textures, 0, sizeof(render_context_textures));
1213 GetRenderContextTextures(render_context, material->m_Samplers, render_context_textures);
1214 }
1215 }
1216
1217 ApplyMaterialConstants(render_context, material, ro);
1218
1219 if (ro->m_ConstantBuffer) // from components/scripts
1220 ApplyNamedConstantBuffer(render_context, material, ro->m_ConstantBuffer);
1221
1222 if (constant_buffer) // from render script
1223 ApplyNamedConstantBuffer(render_context, material, constant_buffer);
1224

Callers 1

DrawRenderListFunction · 0.70

Calls 15

GetGraphicsContextFunction · 0.85
EnableProgramFunction · 0.85
GetMaterialProgramFunction · 0.85
GetRenderContextTexturesFunction · 0.85
GetPipelineStateFunction · 0.85
GetMaterialTagListKeyFunction · 0.85
GetMaterialTagListFunction · 0.85
MatchMaterialTagsFunction · 0.85
ApplyMaterialConstantsFunction · 0.85
ApplyNamedConstantBufferFunction · 0.85
ApplyRenderStateFunction · 0.85
GetNumTextureHandlesFunction · 0.85

Tested by

no test coverage detected