BsGLVertexBuffer.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 GLVertexBuffer : public VertexBuffer
  11. {
  12. public:
  13. ~GLVertexBuffer();
  14. /**
  15. * @copydoc HardwareBuffer::readData
  16. */
  17. void readData(UINT32 offset, UINT32 length, void* pDest);
  18. /**
  19. * @copydoc HardwareBuffer::writeData
  20. */
  21. void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
  22. /**
  23. * @brief Returns internal OpenGL buffer ID.
  24. */
  25. GLuint getGLBufferId() const { return mBufferId; }
  26. /**
  27. * @brief Registers a new VertexArrayObject that uses this vertex buffer.
  28. */
  29. void registerVAO(const GLVertexArrayObject& vao);
  30. /**
  31. * @brief Unregisters a VAO from this vertex buffer. Does not destroy it.
  32. */
  33. void unregisterVAO(const GLVertexArrayObject& vao);
  34. protected:
  35. friend class GLHardwareBufferManager;
  36. GLVertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage);
  37. /**
  38. * @copydoc VertexBuffer::initialize_internal()
  39. */
  40. void initialize_internal();
  41. /**
  42. * @copydoc VertexBuffer::destroy_internal()
  43. */
  44. void destroy_internal();
  45. /**
  46. * @copydoc HardwareBuffer::lockImpl()
  47. */
  48. void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
  49. /**
  50. * @copydoc HardwareBuffer::unlockImpl()
  51. */
  52. void unlockImpl();
  53. private:
  54. GLuint mBufferId;
  55. Vector<GLVertexArrayObject> mVAObjects;
  56. };
  57. }