9a3b3aa13c
- Rework tracing system, now using "{}" for formatting instead of the
standard %s,%d,%f formatting that C++ uses.
- Rework enums creators to not take in namespace
- Fix single use CommandBuffers sometimes failing due to indexing them
with the current frame in flight
- Add DropEvent to Window
34 lines
903 B
C++
34 lines
903 B
C++
#include "copium/buffer/IndexBuffer.h"
|
|
|
|
#include <vulkan/vulkan.hpp>
|
|
|
|
#include "copium/util/Trace.h"
|
|
|
|
namespace Copium
|
|
{
|
|
IndexBuffer::IndexBuffer(int indexCount)
|
|
: Buffer{VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
|
indexCount * sizeof(uint16_t),
|
|
1},
|
|
indexCount{indexCount}
|
|
{
|
|
}
|
|
|
|
void IndexBuffer::Bind(const CommandBuffer& commandBuffer)
|
|
{
|
|
vkCmdBindIndexBuffer(commandBuffer, handle, 0, VK_INDEX_TYPE_UINT16);
|
|
}
|
|
|
|
void IndexBuffer::Draw(const CommandBuffer& commandBuffer)
|
|
{
|
|
vkCmdDrawIndexed(commandBuffer, indexCount, 1, 0, 0, 0);
|
|
}
|
|
|
|
void IndexBuffer::Draw(const CommandBuffer& commandBuffer, int indices)
|
|
{
|
|
CP_ASSERT(indices >= 0 && indices <= indexCount, "amount of indices is out of range");
|
|
vkCmdDrawIndexed(commandBuffer, indices, 1, 0, 0, 0);
|
|
}
|
|
}
|