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

Function NewMaterial

engine/render/src/render/material.cpp:309–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307 }
308
309 HMaterial NewMaterial(dmRender::HRenderContext render_context, dmGraphics::HProgram program)
310 {
311 dmGraphics::HContext graphics_context = dmRender::GetGraphicsContext(render_context);
312 if (!program)
313 {
314 return 0;
315 }
316
317 Material* m = new Material;
318 m->m_RenderContext = render_context;
319 m->m_Program = program;
320 m->m_VertexDeclarationShared = 0;
321 m->m_VertexDeclarationPerVertex = 0;
322 m->m_VertexDeclarationPerInstance = 0;
323 m->m_InstancingSupported = dmGraphics::IsContextFeatureSupported(graphics_context, dmGraphics::CONTEXT_FEATURE_INSTANCING);
324
325 CreateAttributes(graphics_context, m);
326 CreateVertexDeclarations(graphics_context, m);
327 CreateConstants(graphics_context, m);
328
329 bool has_light_buffer;
330 uint16_t light_buffer_set;
331 uint16_t light_buffer_binding;
332 GetProgramLightBufferBinding(render_context, m->m_Program, &has_light_buffer, &light_buffer_set, &light_buffer_binding);
333 m->m_HasLightBuffer = has_light_buffer;
334 m->m_LightBufferSet = light_buffer_set;
335 m->m_LightBufferBinding = light_buffer_binding;
336
337 return (HMaterial)m;
338 }
339
340 void DeleteMaterial(dmRender::HRenderContext render_context, HMaterial material)
341 {

Callers 7

SetUpMethod · 0.85
TEST_FFunction · 0.85
SetUpMethod · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
InitializeDebugRendererFunction · 0.85

Calls 6

GetGraphicsContextFunction · 0.85
CreateAttributesFunction · 0.85
CreateVertexDeclarationsFunction · 0.85
CreateConstantsFunction · 0.85

Tested by 5

SetUpMethod · 0.68
TEST_FFunction · 0.68
SetUpMethod · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68