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/BsVertexBuffer.h"
7#include "BsGLHardwareBuffer.h"
8#include "BsGLVertexArrayObjectManager.h"
9
10namespace bs { namespace ct
11{
12 /** @addtogroup GL
13 * @{
14 */
15
16 /** OpenGL implementation of a vertex buffer. */
17 class GLVertexBuffer : public VertexBuffer
18 {
19 public:
20 GLVertexBuffer(const VERTEX_BUFFER_DESC& desc, GpuDeviceFlags deviceMask);
21 ~GLVertexBuffer();
22
23 /** Returns internal OpenGL buffer ID. */
24 GLuint getGLBufferId() const { return static_cast<GLHardwareBuffer*>(mBuffer)->getGLBufferId(); }
25
26 /** Registers a new VertexArrayObject that uses this vertex buffer. */
27 void registerVAO(const GLVertexArrayObject& vao);
28
29 /** Unregisters a VAO from this vertex buffer. Does not destroy it. */
30 void unregisterVAO(const GLVertexArrayObject& vao);
31
32 protected:
33 /** @copydoc VertexBuffer::initialize */
34 void initialize() override;
35
36 private:
37 Vector<GLVertexArrayObject> mVAObjects;
38 };
39
40 /** @} */
41}}