vao.d 843 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Written in the D programming language.
  2. /**
  3. Copyright: Copyright Felix 'Zoadian' Hufnagel 2014-.
  4. License: $(WEB http://www.gnu.org/licenses/lgpl.html, LGPLv3).
  5. Authors: $(WEB zoadian.de, Felix 'Zoadian' Hufnagel)
  6. */
  7. module three.gl.vao;
  8. import derelict.opengl3.gl3;
  9. import three.gl.util;
  10. //==============================================================================
  11. ///
  12. final class VertexArrayObject {
  13. private:
  14. uint _id;
  15. public:
  16. ///
  17. this() {
  18. check!glGenVertexArrays(1, &this._id);
  19. }
  20. ///
  21. ~this() {
  22. check!glDeleteVertexArrays(1, &this._id);
  23. }
  24. public:
  25. ///
  26. void bind() {
  27. assert(this.isValid);
  28. check!glBindVertexArray(this._id);
  29. }
  30. ///
  31. static void unbind() {
  32. check!glBindVertexArray(0);
  33. }
  34. public:
  35. ///
  36. @property bool isValid() const @safe nothrow {
  37. return (this._id > 0);
  38. }
  39. }