////////////////////////////////////////////////////////////////////////// /// @brief SwrDraw /// @param hContext - Handle passed back from SwrCreateContext /// @param topology - Specifies topology for draw. /// @param startVertex - Specifies start vertex in vertex buffer for draw. /// @param primCount - Number of vertices. void SwrDraw( HANDLE hContext, PRIMITIVE_TOPOLOGY topology, uint32_t startVertex, uint32_t numVertices) { DrawInstanced(hContext, topology, numVertices, startVertex); }
////////////////////////////////////////////////////////////////////////// /// @brief SwrDrawInstanced /// @param hContext - Handle passed back from SwrCreateContext /// @param topology - Specifies topology for draw. /// @param numVertsPerInstance - How many vertices to read sequentially from vertex data. /// @param numInstances - How many instances to render. /// @param startVertex - Specifies start vertex for draw. (vertex data) /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data) void SwrDrawInstanced( HANDLE hContext, PRIMITIVE_TOPOLOGY topology, uint32_t numVertsPerInstance, uint32_t numInstances, uint32_t startVertex, uint32_t startInstance ) { DrawInstanced(hContext, topology, numVertsPerInstance, startVertex, numInstances, startInstance); }
/** Draws a StaticMeshVisual instanced */ void D3D11GraphicsEngineTest::DrawVisualInstances(MeshVisualInfo* visual) { // Bind distance information to make fade-out working BindDistanceInformationFor(visual); // Check if cache exists // There should be no visuals without meshes here, so we don't have to check the map for being empty, too. if(visual->MeshesCached.empty()) { int i=0; // Counter for materials visual->MeshesCached.resize(visual->MeshesByTexture.size()); for(std::map<MeshKey, std::vector<MeshInfo*>>::iterator it = visual->MeshesByTexture.begin(); it != visual->MeshesByTexture.end(); it++) { // Add key and vector visual->MeshesCached[i].first = (*it).first; visual->MeshesCached[i].second = (*it).second; i++; } } // Loop through the materials for(int m=0;m<visual->MeshesCached.size();m++) { const MeshKey& key = visual->MeshesCached[m].first; std::vector<MeshInfo*>& mlist = visual->MeshesCached[m].second; // Bind shader and texture for every submesh (Should only be one, maybe more for very high-poly meshes) BindShaderForKey(key); // Loop through the submeshes and draw them all in one batch for(int i=0;i<mlist.size();i++) { // Bind tesselation info if possible //TryBindPNAENShaderForVisual(visual, mlist[i]); // Draw using normal- or PNAEN-Indices whether we have tesselation enabled or not if(!ActiveHDS) { // Draw batch DrawInstanced( mlist[i]->MeshVertexBuffer, mlist[i]->MeshIndexBuffer, mlist[i]->Indices.size(), DynamicInstancingBuffer, sizeof(VobInstanceInfo), visual->Instances.size(), sizeof(ExVertexStruct), visual->StartInstanceNum); }else { // Draw batch tesselated DrawInstanced( mlist[i]->MeshVertexBuffer, mlist[i]->MeshIndexBufferPNAEN, mlist[i]->IndicesPNAEN.size(), DynamicInstancingBuffer, sizeof(VobInstanceInfo), visual->Instances.size(), sizeof(ExVertexStruct), visual->StartInstanceNum); } } } }
void DX11Mesh::Draw() { DrawInstanced(1); }