BsGLGpuBuffer.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 BansheeEngine
  8. {
  9. /** @addtogroup GL
  10. * @{
  11. */
  12. /** OpenGL implementation of a generic GPU buffer. */
  13. class BS_RSGL_EXPORT GLGpuBufferCore : public GpuBufferCore
  14. {
  15. public:
  16. ~GLGpuBufferCore();
  17. /** @copydoc GpuBufferCore::lock */
  18. void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) override;
  19. /** @copydoc GpuBufferCore::unlock */
  20. void unlock() override;
  21. /** @copydoc GpuBufferCore::readData */
  22. void readData(UINT32 offset, UINT32 length, void* pDest) override;
  23. /** @copydoc GpuBufferCore::writeData */
  24. void writeData(UINT32 offset, UINT32 length, const void* pSource,
  25. BufferWriteType writeFlags = BufferWriteType::Normal) override;
  26. /** @copydoc GpuBufferCore::copyData */
  27. void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
  28. UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) 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 GLHardwareBufferCoreManager;
  40. GLGpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferFormat format,
  41. GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
  42. /** @copydoc GpuBufferCore::initialize */
  43. void initialize() override;
  44. /** @copydoc GpuBufferCore::createView */
  45. GpuBufferView* createView() override;
  46. /** @copydoc GpuBufferCore::destroyView */
  47. void destroyView(GpuBufferView* view) override;
  48. GLuint mTextureID;
  49. GLBuffer mBuffer;
  50. GLenum mFormat;
  51. };
  52. /** @} */
  53. }