1
1

vbo.d 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Written in the D programming language.
  2. /**
  3. Copyright: Copyright Felix 'Zoadian' Hufnagel 2014-.
  4. License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
  5. Authors: $(WEB zoadian.de, Felix 'Zoadian' Hufnagel)
  6. */
  7. module aurora.gl.vbo;
  8. import derelict.opengl3.gl3;
  9. import aurora.gl.util;
  10. //==============================================================================
  11. ///
  12. enum VertexBufferObjectTarget {
  13. Array = GL_ARRAY_BUFFER,
  14. AtomicCounter = GL_ATOMIC_COUNTER_BUFFER,
  15. CopyRead= GL_COPY_READ_BUFFER,
  16. CopyWrite = GL_COPY_WRITE_BUFFER,
  17. DrawIndirect = GL_DRAW_INDIRECT_BUFFER,
  18. DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER,
  19. ElementArray = GL_ELEMENT_ARRAY_BUFFER,
  20. PixelPack = GL_PIXEL_PACK_BUFFER,
  21. PixelUnpack = GL_PIXEL_UNPACK_BUFFER,
  22. ShaderStorage = GL_SHADER_STORAGE_BUFFER,
  23. Texture = GL_TEXTURE_BUFFER,
  24. TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER,
  25. Uniform = GL_UNIFORM_BUFFER
  26. }
  27. //==============================================================================
  28. ///
  29. final class VertexBufferObject {
  30. private:
  31. uint _id;
  32. public:
  33. ///
  34. this() {
  35. check!glGenBuffers(1, &this._id);
  36. }
  37. ///
  38. ~this() {
  39. check!glDeleteBuffers(1, &this._id);
  40. }
  41. public:
  42. ///
  43. void bind(VertexBufferObjectTarget target) {
  44. check!glBindBuffer(target, this._id);
  45. }
  46. ///
  47. static unbind(VertexBufferObjectTarget target = VertexBufferObjectTarget.Array) {
  48. check!glBindBuffer(target, 0);
  49. }
  50. public:
  51. ///
  52. @property bool isValid() const @safe nothrow {
  53. return (this._id > 0);
  54. }
  55. }