BsGLVertexBuffer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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::destroy
  42. */
  43. void destroy();
  44. /**
  45. * @copydoc VertexBufferCore::lockImpl
  46. */
  47. void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
  48. /**
  49. * @copydoc VertexBufferCore::unlockImpl
  50. */
  51. void unlockImpl();
  52. private:
  53. GLuint mBufferId;
  54. bool mZeroLocked;
  55. Vector<GLVertexArrayObject> mVAObjects;
  56. };
  57. }