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 uint32_t bindFlags = 0;
20
21 union
22 {
23 const VertexFormat * vertexFormat;
24 GLenum indexSize;
25 };
26
27 std::vector<uint8_t> mappedData;
28 MapMode::EMapMode mapFlags;
29 };
30
32 {
33 const VertexFormat * formats[8];
34 size_t numFormats;
35 };
36
37 struct BuffersGL20 : public BuffersCommon
38 {
39 VertexBufferHandle loadVertexBuffer(const void *data, const size_t count, const VertexFormat & format) override;
40 VertexBufferHandle loadVertexBuffer(const void *data, const size_t count, VertexFormatHandle formatHandle) override;
41 void releaseVertexBuffer(VertexBufferHandle vertexBufferHandle) override;
42
43 IndexBufferHandle loadIndexBuffer(const void *data, const size_t count, const size_t indexSize) override;
44 void releaseIndexBuffer(IndexBufferHandle indexBufferHandle) override;
45
46 InputLayoutHandle loadInputLayout(const VertexFormatHandle * vertexFormats, const size_t count, EffectHandle effectHandle) override;
47 void releaseInputLayout(InputLayoutHandle vertexFormatHandle) override;
48
49 BufferHandle loadBuffer(const void * data, const size_t size, Usage::EUsage usage, uint32_t accessMode, uint32_t bindFlags, uint32_t stride = 0) override;
50 void retrieveSubBuffer(void * data, BufferHandle source, const size_t offset, const size_t size) override;
51
52 void releaseBuffer(BufferHandle bufferHandle) override;
53
54 void * getNativeHandle(BufferHandle bufferHandle) override { return (void*)(size_t)buffers[bufferHandle].bufferId; }
55
56 void releaseResources() override;
57
58 void annotate(BufferHandle handle, const StringView& name) override;
59 void annotate(VertexBufferHandle handle, const StringView& name) override;
60
62
64 };
65}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:50
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:91
void releaseInputLayout(InputLayoutHandle vertexFormatHandle) override
Releases the input layout with the given inputLayoutHandle.
Definition: BuffersGL20.cpp:86
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:44
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:54
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:68
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:73
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:54
void releaseVertexBuffer(VertexBufferHandle vertexBufferHandle) override
Release the vertex buffer with the given handle.
Definition: BuffersGL20.cpp:49
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