Cogs.Core
BuffersGL20.h
1#pragma once
2
3#include "../Base/BuffersCommon.h"
4
5#include "CommonGL20.h"
6
7namespace Cogs
8{
9 struct BufferGL20
10 {
11 GLuint bufferId;
12 GLuint counterBufferId;
13
14 size_t size;
15 size_t count;
16
17 GLenum target;
18
19 union
20 {
21 const VertexFormat * vertexFormat;
22 GLenum indexSize;
23 };
24
25 std::vector<uint8_t> mappedData;
26 MapMode::EMapMode mapFlags;
27 };
28
30 {
31 const VertexFormat * formats[8];
32 size_t numFormats;
33 };
34
35 struct BuffersGL20 : public BuffersCommon
36 {
37 VertexBufferHandle loadVertexBuffer(const void *data, const size_t count, const VertexFormat & format) override;
38 VertexBufferHandle loadVertexBuffer(const void *data, const size_t count, VertexFormatHandle formatHandle) override;
39 void releaseVertexBuffer(VertexBufferHandle vertexBufferHandle) override;
40
41 IndexBufferHandle loadIndexBuffer(const void *data, const size_t count, const size_t indexSize) override;
42 void releaseIndexBuffer(IndexBufferHandle indexBufferHandle) override;
43
44 InputLayoutHandle loadInputLayout(const VertexFormatHandle * vertexFormats, const size_t count, EffectHandle effectHandle) override;
45 void releaseInputLayout(InputLayoutHandle vertexFormatHandle) override;
46
47 BufferHandle loadBuffer(const void * data, const size_t size, Usage::EUsage usage, uint32_t accessMode, uint32_t bindFlags, uint32_t stride = 0) override;
48 void retrieveSubBuffer(void * data, BufferHandle source, const size_t offset, const size_t size) override;
49
50 void releaseBuffer(BufferHandle bufferHandle) override;
51
52 void * getNativeHandle(BufferHandle bufferHandle) override { return (void*)(size_t)buffers[bufferHandle].bufferId; }
53
54 void releaseResources() override;
55
56 void annotate(BufferHandle handle, const StringView& name) override;
57 void annotate(VertexBufferHandle handle, const StringView& name) override;
58
60 size_t bufferMemoryConsumption = 0;
61
63 };
64}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
void releaseResources() override
Releases all allocated buffer resources.
BufferHandle loadBuffer(const void *data, const size_t size, Usage::EUsage usage, uint32_t accessMode, uint32_t bindFlags, uint32_t stride=0) override
Loads a new buffer using the given data to populate the buffer.
Definition: BuffersGL20.cpp:88
void releaseInputLayout(InputLayoutHandle vertexFormatHandle) override
Releases the input layout with the given inputLayoutHandle.
Definition: BuffersGL20.cpp:83
VertexBufferHandle loadVertexBuffer(const void *data, const size_t count, const VertexFormat &format) override
Loads a new vertex buffer and populates it with the given data.
Definition: BuffersGL20.cpp:42
IndexBufferHandle loadIndexBuffer(const void *data, const size_t count, const size_t indexSize) override
Loads a new index buffer and populates it with the given indexData.
Definition: BuffersGL20.cpp:52
void releaseBuffer(BufferHandle bufferHandle) override
Releases the buffer with the given bufferHandle.
void releaseIndexBuffer(IndexBufferHandle indexBufferHandle) override
Releases the index buffer with the given handle.
Definition: BuffersGL20.cpp:65
void annotate(BufferHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
InputLayoutHandle loadInputLayout(const VertexFormatHandle *vertexFormats, const size_t count, EffectHandle effectHandle) override
Loads a new input layout to map vertex flow between vertex buffers with the given vertexFormats to ef...
Definition: BuffersGL20.cpp:70
void retrieveSubBuffer(void *data, BufferHandle source, const size_t offset, const size_t size) override
Retrieves the contents of a buffer.
void * getNativeHandle(BufferHandle bufferHandle) override
Get the device-specific handle (D3D buffer pointer, OpenGL buffer ID etc) associated with the given b...
Definition: BuffersGL20.h:52
void releaseVertexBuffer(VertexBufferHandle vertexBufferHandle) override
Release the vertex buffer with the given handle.
Definition: BuffersGL20.cpp:47
EMapMode
Mapping mode enumeration.
Definition: Flags.h:93
EUsage
Usage enumeration.
Definition: Flags.h:24
Vertex format structure used to describe a single vertex for the input assembler.
Definition: VertexFormat.h:60