| 39 | } |
| 40 | |
| 41 | void Material::Draw(LLGL::CommandBuffer* const commands,LLGL::Buffer* vertexBuffer, LLGL::Buffer* indexBuffer) |
| 42 | { |
| 43 | //calculate wvp matrix |
| 44 | auto view = MaterialManager::GetCurrentViewMatrix(); |
| 45 | auto projection = MaterialManager::GetCurrentProjectionMatrix(); |
| 46 | auto wvp = projection * view * transformMatrix; //transformMatrix * view * projection; |
| 47 | |
| 48 | const decimalType* pSource = (const decimalType*)glm::value_ptr(wvp); |
| 49 | for (int i = 0; i < 16; ++i) { |
| 50 | settings.wvpMatrix[i] = pSource[i]; |
| 51 | } |
| 52 | |
| 53 | // Set graphics pipeline |
| 54 | commands->SetPipelineState(*pipeline); |
| 55 | |
| 56 | commands->UpdateBuffer(*constantBuffer, 0, &settings, sizeof(settings)); |
| 57 | |
| 58 | if (resourceHeap) { |
| 59 | commands->SetResourceHeap(*resourceHeap); |
| 60 | } |
| 61 | |
| 62 | // Set vertex buffer |
| 63 | commands->SetVertexBuffer(*vertexBuffer); |
| 64 | commands->SetIndexBuffer(*indexBuffer); |
| 65 | commands->DrawIndexed(indexBuffer->GetDesc().size / sizeof(uint32_t), 0); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | Create a material given a shader. Also registers it in the material manager |
no test coverage detected