void EndUpdate(){ if (mVertexBuffer && mMapped) { mVertexBuffer->Unmap(0); mMapped = 0; } }
void Render(const RenderParam& param, RenderParamOut* paramOut){ RenderEventMarker mark("ParticleRenderObject"); if (mMapped) { mVertexBuffer->Unmap(0); mMapped = 0; } if (param.mRenderPass != RENDER_PASS::PASS_NORMAL || !mVertexBuffer || mBatches.empty()) return; auto& renderer = Renderer::GetInstance(); mMaterial->Bind(true); mVertexBuffer->Bind(); renderer.SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_POINTLIST); /*for (auto batch : mBatches){ ++sNumDrawCalls; pRenderer->Draw(batch.second, batch.first); sNumDrawPrimitives += batch.second; }*/ //draw UINT num = 0; UINT start = mBatches[0].first; for(const auto& it : mBatches) { if (start > it.first) { // draw assert(start + num <= mMaxVertices); renderer.Draw(num, start); ++sNumDrawCalls; sNumDrawPrimitives += num; start = it.first; num = 0; } num += it.second; } if (num) { assert(num < mMaxVertices); renderer.Draw(num, start); ++sNumDrawCalls; sNumDrawPrimitives += num; } mMaterial->Unbind(); }