2828public abstract class GLFrameBuffer <T extends GLTexture > implements Disposable {
2929 protected final static int GL_DEPTH24_STENCIL8_OES = 0x88F0 ;
3030 /** the currently bound framebuffer; null for the default one. */
31- protected static GLFrameBuffer currentBoundFramebuffer ;
31+ protected static GLFrameBuffer <?> currentBoundFramebuffer ;
3232 /** the default framebuffer handle, a.k.a screen. */
3333 protected static int defaultFramebufferHandle ;
3434 /** # of nested buffers right now */
@@ -38,7 +38,7 @@ public abstract class GLFrameBuffer<T extends GLTexture> implements Disposable{
3838 /** the color buffer texture **/
3939 protected Seq <T > textureAttachments = new Seq <>();
4040 /** the framebuffer that was bound before this one began (null to indicate that nothing was bound) **/
41- protected GLFrameBuffer lastBoundFramebuffer = null ;
41+ protected GLFrameBuffer <?> lastBoundFramebuffer = null ;
4242 /** the framebuffer handle **/
4343 protected int framebufferHandle ;
4444 /** the depthbuffer render object handle **/
@@ -87,13 +87,12 @@ public Seq<T> getTextureAttachments(){
8787 protected abstract T createTexture (FrameBufferTextureAttachmentSpec attachmentSpec );
8888
8989 /** Override this method in a derived class to dispose the backing texture as you like. */
90- protected abstract void disposeColorTexture (T colorTexture );
90+ protected abstract void disposeTexture (T colorTexture );
9191
9292 /** Override this method in a derived class to attach the backing texture to the GL framebuffer object. */
93- protected abstract void attachFrameBufferColorTexture ( T texture );
93+ protected abstract void attachTexture ( int attachment , T texture );
9494
9595 protected void build (){
96-
9796 checkValidBuilder ();
9897
9998 // iOS uses a different framebuffer handle! (not necessarily 0)
@@ -143,21 +142,18 @@ protected void build(){
143142 T texture = createTexture (attachmentSpec );
144143 textureAttachments .add (texture );
145144 if (attachmentSpec .isColorTexture ()){
146- Gl .framebufferTexture2D (Gl .framebuffer , GL30 .GL_COLOR_ATTACHMENT0 + colorTextureCounter , GL30 .GL_TEXTURE_2D ,
147- texture .getTextureObjectHandle (), 0 );
145+ attachTexture (Gl .colorAttachment0 + colorTextureCounter , texture );
148146 colorTextureCounter ++;
149147 }else if (attachmentSpec .isDepth ){
150- Gl .framebufferTexture2D (Gl .framebuffer , GL20 .GL_DEPTH_ATTACHMENT , GL20 .GL_TEXTURE_2D ,
151- texture .getTextureObjectHandle (), 0 );
148+ attachTexture (Gl .depthAttachment , texture );
152149 }else if (attachmentSpec .isStencil ){
153- Gl .framebufferTexture2D (Gl .framebuffer , GL20 .GL_STENCIL_ATTACHMENT , GL20 .GL_TEXTURE_2D ,
154- texture .getTextureObjectHandle (), 0 );
150+ attachTexture (Gl .stencilAttachment , texture );
155151 }
156152 }
157153 }else {
158154 T texture = createTexture (bufferBuilder .textureAttachmentSpecs .first ());
159155 textureAttachments .add (texture );
160- Gl .bindTexture ( texture . glTarget , texture . getTextureObjectHandle () );
156+ attachTexture ( Gl .colorAttachment0 , texture );
161157 }
162158
163159 if (isMRT ){
@@ -167,8 +163,6 @@ protected void build(){
167163 }
168164 buffer .position (0 );
169165 Core .gl30 .glDrawBuffers (colorTextureCounter , buffer );
170- }else {
171- attachFrameBufferColorTexture (textureAttachments .first ());
172166 }
173167
174168 if (bufferBuilder .hasDepthRenderBuffer ){
@@ -225,7 +219,7 @@ protected void build(){
225219
226220 if (result != Gl .framebufferComplete ){
227221 for (T texture : textureAttachments ){
228- disposeColorTexture (texture );
222+ disposeTexture (texture );
229223 }
230224
231225 if (hasDepthStencilPackedBuffer ){
@@ -277,7 +271,7 @@ private void checkValidBuilder(){
277271 @ Override
278272 public void dispose (){
279273 for (T texture : textureAttachments ){
280- disposeColorTexture (texture );
274+ disposeTexture (texture );
281275 }
282276
283277 if (hasDepthStencilPackedBuffer ){
0 commit comments