| 68 | //////////////////////////////// |
| 69 | |
| 70 | HLightInstance NewLightInstance(HRenderContext render_context, HLightPrototype light_prototype) |
| 71 | { |
| 72 | // Reached max count. |
| 73 | if (render_context->m_RenderLightsIndices.Remaining() == 0) |
| 74 | { |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | if (render_context->m_RenderLights.Full()) |
| 79 | { |
| 80 | render_context->m_RenderLights.Allocate(32); |
| 81 | } |
| 82 | |
| 83 | LightInstance* light_instance = new LightInstance; |
| 84 | light_instance->m_Position = dmVMath::Point3(0.0f, 0.0f, 0.0f); |
| 85 | light_instance->m_Direction = light_prototype->m_Direction; |
| 86 | light_instance->m_LightPrototype = light_prototype; |
| 87 | light_instance->m_LightBufferIndex = render_context->m_RenderLightsIndices.Pop(); |
| 88 | |
| 89 | if (light_instance->m_LightBufferIndex >= render_context->m_LightBufferScratch.Size()) |
| 90 | { |
| 91 | render_context->m_LightBufferScratch.SetSize(light_instance->m_LightBufferIndex+1); |
| 92 | } |
| 93 | |
| 94 | CommitLightInstance(render_context, light_instance); |
| 95 | CommitLightCount(render_context); |
| 96 | |
| 97 | return render_context->m_RenderLights.Put(light_instance); |
| 98 | } |
| 99 | |
| 100 | void DeleteLightInstance(HRenderContext render_context, HLightInstance instance) |
| 101 | { |