1 module des.gl.rbo; 2 3 import des.gl.general; 4 5 /// 6 class GLRenderBuffer : GLObject!"Renderbuffer" 7 { 8 mixin DES; 9 mixin ClassLogger; 10 11 protected: 12 uint _id; 13 Format _format; 14 15 public: 16 17 /// 18 enum Format 19 { 20 R8 = GL_R8, /// `GL_R8` 21 R8UI = GL_R8UI, /// `GL_R8UI` 22 R8I = GL_R8I, /// `GL_R8I` 23 R16UI = GL_R16UI, /// `GL_R16UI` 24 R16I = GL_R16I, /// `GL_R16I` 25 R32UI = GL_R32UI, /// `GL_R32UI` 26 R32I = GL_R32I, /// `GL_R32I` 27 RG8 = GL_RG8, /// `GL_RG8` 28 RG8UI = GL_RG8UI, /// `GL_RG8UI` 29 RG8I = GL_RG8I, /// `GL_RG8I` 30 RG16UI = GL_RG16UI, /// `GL_RG16UI` 31 RG16I = GL_RG16I, /// `GL_RG16I` 32 RG32UI = GL_RG32UI, /// `GL_RG32UI` 33 RG32I = GL_RG32I, /// `GL_RG32I` 34 RGB8 = GL_RGB8, /// `GL_RGB8` 35 RGBA8 = GL_RGBA8, /// `GL_RGBA8` 36 SRGB8_ALPHA8 = GL_SRGB8_ALPHA8, /// `GL_SRGB8_ALPHA8` 37 RGB5_A1 = GL_RGB5_A1, /// `GL_RGB5_A1` 38 RGBA4 = GL_RGBA4, /// `GL_RGBA4` 39 RGB10_A2 = GL_RGB10_A2, /// `GL_RGB10_A2` 40 RGBA8UI = GL_RGBA8UI, /// `GL_RGBA8UI` 41 RGBA8I = GL_RGBA8I, /// `GL_RGBA8I` 42 RGB10_A2UI = GL_RGB10_A2UI, /// `GL_RGB10_A2UI` 43 RGBA16UI = GL_RGBA16UI, /// `GL_RGBA16UI` 44 RGBA16I = GL_RGBA16I, /// `GL_RGBA16I` 45 RGBA32I = GL_RGBA32I, /// `GL_RGBA32I` 46 RGBA32UI = GL_RGBA32UI, /// `GL_RGBA32UI` 47 DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16, /// `GL_DEPTH_COMPONENT16` 48 DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24, /// `GL_DEPTH_COMPONENT24` 49 DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F, /// `GL_DEPTH_COMPONENT32F` 50 DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8, /// `GL_DEPTH24_STENCIL8` 51 DEPTH32F_STENCIL8 = GL_DEPTH32F_STENCIL8, /// `GL_DEPTH32F_STENCIL8` 52 STENCIL_INDEX8 = GL_STENCIL_INDEX8 /// `GL_STENCIL_INDEX8` 53 } 54 55 /// 56 this() 57 { 58 super( GL_RENDERBUFFER ); 59 logger.Debug( "pass" ); 60 } 61 62 final pure const @property 63 { 64 /// 65 Format format() { return _format; } 66 } 67 68 /// `glRenderbufferStorage` 69 void storage( in uivec2 sz, Format fmt ) 70 in 71 { 72 assert( sz[0] < GL_MAX_RENDERBUFFER_SIZE ); 73 assert( sz[1] < GL_MAX_RENDERBUFFER_SIZE ); 74 } 75 body 76 { 77 bind(); 78 _format = fmt; 79 checkGLCall!glRenderbufferStorage( GL_RENDERBUFFER, cast(GLenum)fmt, sz[0], sz[1] ); 80 unbind(); 81 debug logger.Debug( "size [%d,%d], format [%s]", sz[0], sz[1], fmt ); 82 } 83 84 /// ditto 85 void storage(T)( in Vector!(2,T) sz, Format fmt ) 86 if( isIntegral!T ) 87 in 88 { 89 assert( sz[0] > 0 ); 90 assert( sz[1] > 0 ); 91 } 92 body { storage( uivec2(sz), fmt ); } 93 94 /// set storage with new size and old format 95 void resize( in uivec2 sz ) 96 in 97 { 98 assert( sz[0] > 0 ); 99 assert( sz[1] > 0 ); 100 } 101 body { storage( sz, _format ); } 102 103 /// ditto 104 void resize(T)( in Vector!(2,T) sz ) 105 if( isIntegral!T ) 106 in 107 { 108 assert( sz[0] > 0 ); 109 assert( sz[1] > 0 ); 110 } 111 body { resize( uivec2(sz) ); } 112 }