1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsGLPrerequisites.h"
6#include "RenderAPI/BsCommandBuffer.h"
7#include "BsGLRenderAPI.h"
8
9namespace bs { namespace ct
10{
11 /** @addtogroup GL
12 * @{
13 */
14
15 /**
16 * Command buffer implementation for OpenGL, which doesn't support multi-threaded command generation. Instead all
17 * commands are stored in an internal buffer, and then sent to the actual render API when the buffer is executed.
18 */
19 class GLCommandBuffer : public CommandBuffer
20 {
21 public:
22 /** Registers a new command in the command buffer. */
23 void queueCommand(const std::function<void()> command);
24
25 /** Appends all commands from the secondary buffer into this command buffer. */
26 void appendSecondary(const SPtr<GLCommandBuffer>& secondaryBuffer);
27
28 /** Executes all commands in the command buffer. Not supported on secondary buffer. */
29 void executeCommands();
30
31 /** Removes all commands from the command buffer. */
32 void clear();
33
34 private:
35 friend class GLCommandBufferManager;
36 friend class GLRenderAPI;
37
38 GLCommandBuffer(GpuQueueType type, UINT32 deviceIdx, UINT32 queueIdx, bool secondary);
39
40 Vector<std::function<void()>> mCommands;
41
42 DrawOperationType mCurrentDrawOperation = DOT_TRIANGLE_LIST;
43 };
44
45 /** @} */
46}}