BsGLGpuBuffer.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsGLPrerequisites.h"
  5. #include "BsGpuBuffer.h"
  6. #include "BsGLBuffer.h"
  7. namespace bs { namespace ct
  8. {
  9. /** @addtogroup GL
  10. * @{
  11. */
  12. /** OpenGL implementation of a generic GPU buffer. */
  13. class GLGpuBuffer : public GpuBuffer
  14. {
  15. public:
  16. ~GLGpuBuffer();
  17. /** @copydoc GpuBuffer::lock */
  18. void* lock(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 deviceIdx = 0, UINT32 queueIdx = 0) override;
  19. /** @copydoc GpuBuffer::unlock */
  20. void unlock() override;
  21. /** @copydoc GpuBuffer::readData */
  22. void readData(UINT32 offset, UINT32 length, void* dest, UINT32 deviceIdx = 0, UINT32 queueIdx = 0) override;
  23. /** @copydoc GpuBuffer::writeData */
  24. void writeData(UINT32 offset, UINT32 length, const void* source,
  25. BufferWriteType writeFlags = BWT_NORMAL, UINT32 queueIdx = 0) override;
  26. /** @copydoc GpuBuffer::copyData */
  27. void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length,
  28. bool discardWholeBuffer = false, const SPtr<CommandBuffer>& commandBuffer = nullptr) override;
  29. /**
  30. * Returns internal OpenGL buffer ID. If binding the buffer to the pipeline, bind the texture using
  31. * getGLTextureId() instead.
  32. */
  33. GLuint getGLBufferId() const { return mBuffer.getGLBufferId(); }
  34. /** Returns internal OpenGL texture ID. */
  35. GLuint getGLTextureId() const { return mTextureID; }
  36. /** Returns the internal OpenGL format used by the elements of the buffer. */
  37. GLuint getGLFormat() const { return mFormat; }
  38. protected:
  39. friend class GLHardwareBufferManager;
  40. GLGpuBuffer(const GPU_BUFFER_DESC& desc, GpuDeviceFlags deviceMask);
  41. /** @copydoc GpuBuffer::initialize */
  42. void initialize() override;
  43. GLuint mTextureID;
  44. GLBuffer mBuffer;
  45. GLenum mFormat;
  46. };
  47. /** @} */
  48. }}