Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
glGenericVertexData.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef GL_GENERIC_VERTEX_DATA_H
34#define GL_GENERIC_VERTEX_DATA_H
35
39
40namespace Divide {
41
43 public:
44 glGenericVertexData(GFXDevice& context, U16 ringBufferLength, const std::string_view name);
45
46 void reset() override;
47
48 [[nodiscard]] BufferLock setIndexBuffer(const IndexBuffer& indices) override;
49 [[nodiscard]] BufferLock setBuffer(const SetBufferParams& params) override;
50 [[nodiscard]] BufferLock updateBuffer(U32 buffer, U32 elementCountOffset, U32 elementCountRange, bufferPtr data) override;
51
52 protected:
53 friend class GFXDevice;
54 friend class glVertexArray;
55 void draw(const GenericDrawCommand& command, VDIUserData* data) override;
56
57 protected:
58 void bindBufferInternal(const SetBufferParams::BufferBindConfig& bindConfig);
59
60 private:
62 glBufferImpl_uptr _buffer{ nullptr };
63 size_t _ringSizeFactor{ 1u };
64 size_t _elementStride{ 0u };
65 SetBufferParams::BufferBindConfig _bindConfig{};
66 };
67
68 struct IndexBufferEntry : public NonCopyable {
70
71 size_t _bufferSize{0u};
72 gl46core::GLuint _handle{ GL_NULL_HANDLE };
73 gl46core::GLsync _idxBufferSync{ nullptr };
74 };
75
76 eastl::fixed_vector<IndexBufferEntry,1,true> _idxBuffers;
77 eastl::fixed_vector<GenericBufferImpl,1,true> _bufferObjects;
78
80};
81
82}; // namespace Divide
83#endif //GL_GENERIC_VERTEX_DATA_H
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
GFXDevice & context() const noexcept
void draw(const GenericDrawCommand &command, VDIUserData *data) override
Submit a draw command to the GPU using this object and the specified command.
BufferLock updateBuffer(U32 buffer, U32 elementCountOffset, U32 elementCountRange, bufferPtr data) override
Update the elementCount worth of data contained in the buffer starting from elementCountOffset size o...
eastl::fixed_vector< IndexBufferEntry, 1, true > _idxBuffers
BufferLock setBuffer(const SetBufferParams &params) override
Specify the structure and data of the given buffer.
void bindBufferInternal(const SetBufferParams::BufferBindConfig &bindConfig)
eastl::fixed_vector< GenericBufferImpl, 1, true > _bufferObjects
void reset() override
Also clears GPU memory.
BufferLock setIndexBuffer(const IndexBuffer &indices) override
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::shared_mutex SharedMutex
Definition: SharedMutex.h:43
constexpr gl46core::GLuint GL_NULL_HANDLE
Invalid object value. Used to compare handles and determine if they were properly created.
Definition: glResources.h:105
uint16_t U16
uint32_t U32
void * bufferPtr
SetBufferParams::BufferBindConfig _bindConfig
size_t _bufferSize
IndexBuffer _data
gl46core::GLuint _handle
gl46core::GLsync _idxBufferSync