33 const auto& material =
object->GetMaterialReference();
34 if (material ==
nullptr)
return;
36 short orderLayer = material->GetOrderLayer();
37 const auto& shaders = material->GetShaders();
38 if (shaders ==
nullptr)
return;
40 auto orderLayerIter = m_rendersLayer.find(orderLayer);
41 if (orderLayerIter != m_rendersLayer.end()) {
42 auto& programLayer = orderLayerIter->second;
43 auto handlerPair = programLayer.find(shaders);
44 if (handlerPair != programLayer.end()) {
45 auto& layerVector = handlerPair->second;
46 layerVector.erase(std::remove(layerVector.begin(), layerVector.end(),
object),
50 if (layerVector.empty()) programLayer.erase(handlerPair);
52 if (programLayer.empty()) m_rendersLayer.erase(orderLayerIter);
57 const auto cameraMatrix = camera.GetCameraMatrixStruct();
58 const auto& cameraBuffer = camera.GetFrameBuffer();
59 const auto& frameBuffer = cameraBuffer ==
nullptr
60 ? m_renderMgr->GetMainBuffer() : cameraBuffer;
61 OrderRenderLayer orderRenderLayer(m_rendersLayer.begin(), m_rendersLayer.end());
62 frameBuffer->AttachFrameBuffer();
64 for (
const auto& orderLayerPair : orderRenderLayer) {
65 const auto& orderLayer = orderLayerPair.second;
66 ProgramRenderLayer programComp(orderLayer.begin(), orderLayer.end());
68 for (
const auto& programPair : programComp) {
69 const auto& handler = *programPair.first->GetForwardHandle();
70 const auto& renderComp = programPair.second;
72 if (programPair.first ==
nullptr)
continue;
73 if (renderComp.empty())
continue;
75 glUseProgram(handler.Program);
80 for (
const auto& render : renderComp) {
81 if (render ==
nullptr)
continue;
82 if (!render->isRenderActive)
continue;
84 const auto& material = render->GetMaterial();
85 material->AttachElement();
86 render->SetMatrix(cameraMatrix, &handler);
87 BindSourceBuffer(*frameBuffer, handler, layoutBegin + material->GetTextureCount() + 1);
88 render->Render(&handler);
94 glBindBuffer(GL_ARRAY_BUFFER, 0);
95 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);