| 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 | { |