3#include "VertexFormat.h"
78 const VertexFormat*
const* vertexFormats =
nullptr,
const uint32_t* vertexBufferStrides =
nullptr,
const uint32_t* vertexBufferOffsets =
nullptr,
158 template<
typename MappedDataType>
170 bufferHandle(bufferHandle),
173 data =
reinterpret_cast<MappedDataType *
>(context->
map(bufferHandle, mapMode, &stride));
185 context->
unmap(bufferHandle);
209 operator MappedDataType *() {
return data; }
224 explicit operator bool()
const {
return data !=
nullptr; }
235 assert(index < size &&
"Index out of bounds.");
250 assert(index < size &&
"Index out of bounds.");
260 struct IContext * context =
nullptr;
262 MappedDataType * data =
nullptr;
Provides a weakly referenced view over the contents of a string.
Contains all Cogs related functionality.
static const Handle_t NoHandle
Represents a handle to nothing.
Provides buffer management functionality.
virtual void releaseVertexBuffer(VertexBufferHandle vertexBufferHandle)=0
Release the vertex buffer with the given handle.
virtual void annotate(VertexBufferHandle handle, const StringView &name)
Associate a name with an object for use in graphics debugging.
virtual VertexArrayObjectHandle loadVertexArrayObject(const EffectHandle effectHandle, const VertexBufferHandle *vertexBufferHandles, const size_t vertexBufferCount, const VertexFormat *const *vertexFormats=nullptr, const uint32_t *vertexBufferStrides=nullptr, const uint32_t *vertexBufferOffsets=nullptr, const IndexBufferHandle indexBufferHandle=IndexBufferHandle::NoHandle, uint32_t indexBufferStride=0)=0
Create a vertex array object that encapsulates binding of a set of vertex buffers and an optional ind...
virtual void annotate(BufferHandle handle, const StringView &name)
Associate a name with an object for use in graphics debugging.
virtual void retrieveSubBuffer(void *data, BufferHandle source, const size_t offset, const size_t size)=0
Retrieves the contents of a buffer.
virtual void * getNativeHandle(BufferHandle bufferHandle)=0
Get the device-specific handle (D3D buffer pointer, OpenGL buffer ID etc) associated with the given b...
virtual InputLayoutHandle loadInputLayout(const VertexFormatHandle *vertexFormats, const size_t count, EffectHandle effectHandle)=0
Loads a new input layout to map vertex flow between vertex buffers with the given vertexFormats to ef...
virtual void releaseResources()=0
Releases all allocated buffer resources.
virtual IndexBufferHandle loadIndexBuffer(const void *indexData, const size_t count, const size_t indexSize)=0
Loads a new index buffer and populates it with the given indexData.
virtual void releaseInputLayout(InputLayoutHandle inputLayoutHandle)=0
Releases the input layout with the given inputLayoutHandle.
virtual void releaseIndexBuffer(IndexBufferHandle indexBufferHandle)=0
Releases the index buffer with the given handle.
virtual BufferHandle loadBuffer(const void *data, const size_t size, Usage::EUsage usage, uint32_t accessMode, uint32_t bindFlags, uint32_t stride=0)=0
Loads a new buffer using the given data to populate the buffer.
virtual void releaseBuffer(BufferHandle bufferHandle)=0
Releases the buffer with the given bufferHandle.
virtual VertexBufferHandle loadVertexBuffer(const void *vertexData, const size_t count, const VertexFormat &vertexFormat)=0
Loads a new vertex buffer and populates it with the given data.
virtual void releaseVertexArrayObject(VertexArrayObjectHandle vertexArrayObjectHandle)=0
Releases the vertex array object with the given handle.
Represents a graphics device context which can receive rendering commands.
virtual void * map(BufferHandle bufferHandle, MapMode::EMapMode mapMode, uint32_t *stride=nullptr)=0
Maps the given buffer so it can be accessed.
virtual void unmap(BufferHandle bufferHandle)=0
Unmaps the given buffer, applying any synchronization necessary to reflect changes in the mapped memo...
EMapMode
Mapping mode enumeration.
Provides RAII style mapping of a buffer resource.
const MappedDataType & operator[](size_t index) const
Indexing operator provided to perform optional boundary checks on the mapped data.
MappedBuffer(struct IContext *context, BufferHandle bufferHandle, MapMode::EMapMode mapMode=MapMode::Read, size_t size=0)
Constructs a mapped buffer, initializing the mapped contents from the context and buffer handle given...
~MappedBuffer()
Destructs the mapped buffer.
MappedDataType * get()
Get the raw pointer to the mapped data.
const MappedDataType * operator->() const
Const overload of pointer operator.
MappedBuffer(const MappedBuffer &other)=delete
Deleted copy constructor.
MappedDataType * operator->()
Pointer operator to allow using the mapped structure as if it was a raw pointer to the data.
MappedDataType & operator[](size_t index)
Indexing operator provided to perform optional boundary checks on the mapped data.
uint32_t getStride() const
Get the stride of the mapped resource in bytes.
Vertex element structure used to describe a single data element in a vertex for the input assembler.