예제 #1
0
//-----------------------------------------------------------------------
void GraphicsContextGL4::DrawIndexedInstanced(
    std::size_t indexCount,
    std::size_t instanceCount)
{
    ApplyPipelineState();

    // Bind index buffer
    POMDOG_ASSERT(indexBuffer);
    auto indexBufferGL = dynamic_cast<IndexBufferGL4*>(indexBuffer->NativeIndexBuffer());
    POMDOG_ASSERT(indexBufferGL != nullptr);
    indexBufferGL->BindBuffer();

    // Draw
    POMDOG_ASSERT(indexCount > 0);
    POMDOG_ASSERT(indexCount <= indexBuffer->IndexCount());
    POMDOG_ASSERT(instanceCount > 0);
    POMDOG_ASSERT(instanceCount < static_cast<decltype(instanceCount)>(std::numeric_limits<GLsizei>::max()));

    glDrawElementsInstanced(
        primitiveTopology.value,
        static_cast<GLsizei>(indexCount),
        ToIndexElementType(indexBuffer->ElementSize()),
        nullptr,
        static_cast<GLsizei>(instanceCount));
    POMDOG_CHECK_ERROR_GL4("glDrawElementsInstanced");
}
예제 #2
0
//---------------------------------------------------------------------------//
  void RenderContextDX12::renderGeometry(const Geometry::GeometryData* pGeometry)
  {
    ApplyViewport();
    ApplyRenderTargets();
    ApplyPipelineState();

    myCommandList->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    myCommandList->IASetVertexBuffers(0, 1, &pGeometry->getVertexBuffer()->GetVertexBufferView());
    myCommandList->IASetIndexBuffer(&pGeometry->getIndexBuffer()->GetIndexBufferView());
    myCommandList->DrawIndexedInstanced(pGeometry->getNumIndices(), 1, 0, 0, 0);
  }
예제 #3
0
//-----------------------------------------------------------------------
void GraphicsContextGL4::Draw(std::size_t vertexCount)
{
    ApplyPipelineState();

    // Draw
    POMDOG_ASSERT(!vertexBuffers.empty());
    POMDOG_ASSERT(vertexBuffers.front().VertexBuffer);
    POMDOG_ASSERT(vertexCount > 0);
    POMDOG_ASSERT(vertexCount <= vertexBuffers.front().VertexBuffer->VertexCount());

    glDrawArrays(
        primitiveTopology.value,
        0,
        static_cast<GLsizei>(vertexCount));
    POMDOG_CHECK_ERROR_GL4("glDrawArrays");
}
예제 #4
0
//-----------------------------------------------------------------------
void GraphicsContextGL4::DrawInstanced(
    std::size_t vertexCount, std::size_t instanceCount)
{
    ApplyPipelineState();

    // Draw
    POMDOG_ASSERT(!vertexBuffers.empty());
    POMDOG_ASSERT(vertexBuffers.front().VertexBuffer);
    POMDOG_ASSERT(vertexCount > 0);
    POMDOG_ASSERT(vertexCount <= vertexBuffers.front().VertexBuffer->VertexCount());
    POMDOG_ASSERT(instanceCount > 0);
    POMDOG_ASSERT(instanceCount <= static_cast<decltype(instanceCount)>(std::numeric_limits<GLsizei>::max()));

    glDrawArraysInstanced(
        primitiveTopology.value,
        0,
        static_cast<GLsizei>(vertexCount),
        static_cast<GLsizei>(instanceCount));
    POMDOG_CHECK_ERROR_GL4("glDrawArraysInstanced");
}