BsGLVertexBuffer.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "BsVertexBuffer.h"
  6. #include "BsGLVertexArrayObjectManager.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup GL
  10. * @{
  11. */
  12. /** OpenGL implementation of a vertex buffer. */
  13. class BS_RSGL_EXPORT GLVertexBufferCore : public VertexBufferCore
  14. {
  15. public:
  16. GLVertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
  17. ~GLVertexBufferCore();
  18. /** @copydoc VertexBufferCore::readData */
  19. void readData(UINT32 offset, UINT32 length, void* dest) override;
  20. /** @copydoc VertexBufferCore::writeData */
  21. void writeData(UINT32 offset, UINT32 length, const void* source,
  22. BufferWriteType writeFlags = BufferWriteType::Normal) override;
  23. /** Returns internal OpenGL buffer ID. */
  24. GLuint getGLBufferId() const { return mBufferId; }
  25. /** Registers a new VertexArrayObject that uses this vertex buffer. */
  26. void registerVAO(const GLVertexArrayObject& vao);
  27. /** Unregisters a VAO from this vertex buffer. Does not destroy it. */
  28. void unregisterVAO(const GLVertexArrayObject& vao);
  29. protected:
  30. /** @copydoc VertexBufferCore::initialize */
  31. void initialize() override;
  32. /** @copydoc VertexBufferCore::lockImpl */
  33. void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
  34. /** @copydoc VertexBufferCore::unlockImpl */
  35. void unlockImpl() override;
  36. private:
  37. GLuint mBufferId;
  38. bool mZeroLocked;
  39. Vector<GLVertexArrayObject> mVAObjects;
  40. };
  41. /** @} */
  42. }