BsGLVertexBuffer.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "BsGLPrerequisites.h"
  3. #include "BsVertexBuffer.h"
  4. #include "BsGLVertexArrayObjectManager.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief OpenGL implementation of a vertex buffer.
  9. */
  10. class BS_RSGL_EXPORT GLVertexBufferCore : public VertexBufferCore
  11. {
  12. public:
  13. GLVertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
  14. ~GLVertexBufferCore();
  15. /**
  16. * @copydoc VertexBufferCore::readData
  17. */
  18. void readData(UINT32 offset, UINT32 length, void* pDest);
  19. /**
  20. * @copydoc VertexBufferCore::writeData
  21. */
  22. void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
  23. /**
  24. * @brief Returns internal OpenGL buffer ID.
  25. */
  26. GLuint getGLBufferId() const { return mBufferId; }
  27. /**
  28. * @brief Registers a new VertexArrayObject that uses this vertex buffer.
  29. */
  30. void registerVAO(const GLVertexArrayObject& vao);
  31. /**
  32. * @brief Unregisters a VAO from this vertex buffer. Does not destroy it.
  33. */
  34. void unregisterVAO(const GLVertexArrayObject& vao);
  35. protected:
  36. /**
  37. * @copydoc VertexBufferCore::initialize
  38. */
  39. void initialize();
  40. /**
  41. * @copydoc VertexBufferCore::lockImpl
  42. */
  43. void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
  44. /**
  45. * @copydoc VertexBufferCore::unlockImpl
  46. */
  47. void unlockImpl();
  48. private:
  49. GLuint mBufferId;
  50. bool mZeroLocked;
  51. Vector<GLVertexArrayObject> mVAObjects;
  52. };
  53. }