1
1

renderbuffer.d 999 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.renderbuffer;
  8. import derelict.opengl3.gl3;
  9. import three.gl.util;
  10. import std.stdio;
  11. //==============================================================================
  12. ///
  13. final class Renderbuffer {
  14. private:
  15. GLuint _id;
  16. public:
  17. ///
  18. this() {
  19. check!glGenRenderbuffers(1, &this._id);
  20. writeln("Renderbuffer created: ", this._id);
  21. }
  22. ///
  23. ~this() {
  24. check!glDeleteRenderbuffers(1, &this._id);
  25. writeln("Renderbuffer destroxed: ", this._id);
  26. }
  27. public:
  28. ///
  29. void bind() {
  30. assert(this.isValid);
  31. check!glBindRenderbuffer(GL_RENDERBUFFER, this._id);
  32. }
  33. ///
  34. static void unbind(){
  35. check!glBindRenderbuffer(GL_RENDERBUFFER, 0);
  36. }
  37. public:
  38. ///
  39. @property bool isValid() const @safe nothrow {
  40. return (this._id > 0);
  41. }
  42. }