Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Render(ID3D11DeviceContext* devcontext, ID3D11Buffer* iBuffer)
- {
- if (m_quads.size() == 0)
- return;
- UINT stride = sizeof(TL_VERTEX);
- UINT offset = 0;
- int size = (m_quads.size()) * 6;
- int numVertices = 0;
- D3D11_MAPPED_SUBRESOURCE ms;
- if (m_quads.size() == 0)
- return;
- devcontext->Map(m_vb, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms);
- for (int i = 0; i < m_quads.size(); i++)
- {
- memcpy(&ms.pData + (i - 1 * sizeof(m_quads[i].m_vertices)), &m_quads[i].m_vertices, sizeof(m_quads[i].m_vertices));
- numVertices = numVertices + (sizeof(TL_VERTEX) * 6);
- }
- //std::cout << sizeof(ms.pData) << std::endl;
- devcontext->Unmap(m_vb, NULL);
- devcontext->IASetVertexBuffers(0, 1, &m_vb, &stride, &offset);
- devcontext->PSSetShaderResources(0, 1, &m_texture);
- if (indexCount < size)
- {
- indexCount = size;
- std::cout << "IndexCount is smaller! " << indexCount << " | " << size << std::endl;
- tempIndices = new DWORD[indexCount];
- for (int i = 0; i < indexCount; i = i + 6)
- {
- //std::cout << i << std::endl;
- tempIndices[i] = i;
- tempIndices[i + 1] = i + 1;
- tempIndices[i + 2] = i + 2;
- tempIndices[i + 3] = i + 3;
- tempIndices[i + 4] = i + 4;
- tempIndices[i + 5] = i + 5;
- }
- }
- D3D11_MAPPED_SUBRESOURCE is;
- devcontext->Map(iBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &is);
- memcpy(is.pData, &tempIndices, sizeof(tempIndices));
- devcontext->Unmap(iBuffer, NULL);
- devcontext->IASetIndexBuffer(iBuffer, DXGI_FORMAT_R32_UINT, 0);
- //std::cout << sizeof(m_quads) << std::endl;
- //devcontext->DrawIndexed(6, 0, 0);
- devcontext->DrawIndexed(numVertices, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement