void ezImguiRenderer::RenderBatch(const ezRenderViewContext& renderContext, ezRenderPipelinePass* pPass, const ezRenderDataBatch& batch) { if (ezImgui::GetSingleton() == nullptr) return; SetupRenderer(); ezRenderContext* pRenderContext = renderContext.m_pRenderContext; ezGALContext* pGALContext = pRenderContext->GetGALContext(); pRenderContext->BindShader(m_hShader); const auto& textures = ezImgui::GetSingleton()->m_hTextures; const ezUInt32 numTextures = textures.GetCount(); for (auto it = batch.GetIterator<ezImguiRenderData>(); it.IsValid(); ++it) { const ezImguiRenderData* pRenderData = pRenderData = it; EZ_ASSERT_DEV(pRenderData->m_Vertices.GetCount() < VertexBufferSize, "GUI has too many elements to render in one drawcall"); EZ_ASSERT_DEV(pRenderData->m_Indices.GetCount() < IndexBufferSize, "GUI has too many elements to render in one drawcall"); pGALContext->UpdateBuffer(m_hVertexBuffer, 0, ezMakeArrayPtr(pRenderData->m_Vertices.GetPtr(), pRenderData->m_Vertices.GetCount()).ToByteArray()); pGALContext->UpdateBuffer(m_hIndexBuffer, 0, ezMakeArrayPtr(pRenderData->m_Indices.GetPtr(), pRenderData->m_Indices.GetCount()).ToByteArray()); pRenderContext->BindMeshBuffer(m_hVertexBuffer, m_hIndexBuffer, &m_VertexDeclarationInfo, ezGALPrimitiveTopology::Triangles, pRenderData->m_Indices.GetCount() / 3); ezUInt32 uiFirstIndex = 0; const ezUInt32 numBatches = pRenderData->m_Batches.GetCount(); for (ezUInt32 batchIdx = 0; batchIdx < numBatches; ++batchIdx) { const ezImguiBatch& batch = pRenderData->m_Batches[batchIdx]; if (batch.m_uiVertexCount > 0 && batch.m_uiTextureID < numTextures) { pGALContext->SetScissorRect(batch.m_ScissorRect); pRenderContext->BindTexture2D("BaseTexture", textures[batch.m_uiTextureID]); pRenderContext->DrawMeshBuffer(batch.m_uiVertexCount / 3, uiFirstIndex / 3); } uiFirstIndex += batch.m_uiVertexCount; } } }
MikkInterfaceImpl(Mesh& mesh, const VertexDataStream& position, const VertexDataStream& normal, const VertexDataStream& tex) : triangles(mesh.m_Triangles) , positionStream(position) , normalStream(normal) , texStream(tex) , tangentStream(*mesh.AddDataStream(ezGALVertexAttributeSemantic::Tangent, 3)) // Make sure tangent stream exists. , bitangentStream(*mesh.AddDataStream(ezGALVertexAttributeSemantic::BiTangent, 1)) , bitangentIndexNegative(0) , bitangentIndexPositive(sizeof(float)) { float biTangentSignValues[] = {-1.0f, 1.0f}; bitangentStream.AddValues(ezMakeArrayPtr(biTangentSignValues)); }
#include <krEngineTests/pch.h> #include <catch.hpp> TEST_CASE("ezArrayPtr Extension", "[common]") { SECTION("Make From ezStaticArray") { ezStaticArray<int, 3> data; data.ExpandAndGetRef() = 3; data.ExpandAndGetRef() = 5; data.ExpandAndGetRef() = 7; auto arrayPtr = ezMakeArrayPtr(data); ezStaticArray<int, 3> result; for (auto i : arrayPtr) { result.PushBack(i); } REQUIRE(result[0] == 3); REQUIRE(result[1] == 5); REQUIRE(result[2] == 7); } SECTION("Make From ezHybridArray") { ezHybridArray<int, 2> data; data.ExpandAndGetRef() = 3; data.ExpandAndGetRef() = 5; data.ExpandAndGetRef() = 7;