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/BsGpuBuffer.h"
7#include "BsGLHardwareBuffer.h"
8
9namespace bs { namespace ct
10{
11 /** @addtogroup GL
12 * @{
13 */
14
15 /** OpenGL implementation of a generic GPU buffer. */
16 class GLGpuBuffer : public GpuBuffer
17 {
18 public:
19 ~GLGpuBuffer();
20
21 /**
22 * Returns internal OpenGL buffer ID. If binding the buffer to the pipeline, bind the texture using
23 * getGLTextureId() instead.
24 */
25 GLuint getGLBufferId() const { return static_cast<GLHardwareBuffer*>(mBuffer)->getGLBufferId(); }
26
27 /** Returns internal OpenGL texture ID. */
28 GLuint getGLTextureId() const { return mTextureID; }
29
30 /** Returns the internal OpenGL format used by the elements of the buffer. */
31 GLuint getGLFormat() const { return mFormat; }
32
33 protected:
34 friend class GLHardwareBufferManager;
35
36 GLGpuBuffer(const GPU_BUFFER_DESC& desc, GpuDeviceFlags deviceMask);
37 GLGpuBuffer(const GPU_BUFFER_DESC& desc, SPtr<HardwareBuffer> underlyingBuffer);
38
39 /** @copydoc GpuBuffer::initialize */
40 void initialize() override;
41
42 GLuint mTextureID = 0;
43 GLenum mFormat = 0;
44 };
45
46 /** @} */
47}}