BsGLVertexBuffer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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(GpuBufferUsage usage, bool useSystemMemory, const VertexBufferProperties& properties);
  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. /**
  58. * @brief OpenGL implementation of a vertex buffer.
  59. */
  60. class BS_RSGL_EXPORT GLVertexBuffer : public VertexBuffer
  61. {
  62. public:
  63. ~GLVertexBuffer() { }
  64. protected:
  65. friend class GLHardwareBufferManager;
  66. GLVertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage);
  67. /**
  68. * @copydoc CoreObject::createCore
  69. */
  70. virtual SPtr<CoreObjectCore> createCore() const;
  71. };
  72. }