vao.d 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. import std.stdio;
  11. //==============================================================================
  12. ///
  13. final class VertexArrayObject {
  14. private:
  15. uint _id;
  16. public:
  17. ///
  18. this() {
  19. check!glGenVertexArrays(1, &this._id);
  20. writeln("vao created: ", this._id);
  21. }
  22. ///
  23. ~this() {
  24. writeln("vao destroxing..: ", this._id);
  25. check!glDeleteVertexArrays(1, &this._id);
  26. writeln("vao destroyed: ", this._id);
  27. }
  28. public:
  29. ///
  30. void bind() {
  31. assert(this.isValid);
  32. check!glBindVertexArray(this._id);
  33. }
  34. ///
  35. static void unbind() {
  36. check!glBindVertexArray(0);
  37. }
  38. public:
  39. ///
  40. @property bool isValid() const @safe nothrow {
  41. return (this._id > 0);
  42. }
  43. }