commit fbe9542f4ae011a90afa9d47814ef24281eb3ee5
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Apr 26 20:08:01 2019 +0100

    Correct the same bug for DistortedTextures and DistortedFramebuffers: only mark them for creation when we actually have everything ready, i.e. as the last statement in the constructor.

diff --git a/src/main/java/org/distorted/library/main/DistortedFramebuffer.java b/src/main/java/org/distorted/library/main/DistortedFramebuffer.java
index 8665c30..b9a8281 100644
--- a/src/main/java/org/distorted/library/main/DistortedFramebuffer.java
+++ b/src/main/java/org/distorted/library/main/DistortedFramebuffer.java
@@ -214,22 +214,23 @@ public class DistortedFramebuffer extends DistortedOutputSurface
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// create SYSTEM or TREE framebuffers (those are just like normal FBOs, just hold information
-// that they were autocreated only for the Library's internal purposes (SYSTEM) or for using
-// inside a Tree of DistortedNodes (TREE)
-// SYSTEM surfaces do not get removed in onDestroy().
+// create a multi-framebuffer (1 object containing multiple FBOs)
 
-  DistortedFramebuffer(int numcolors, int depthStencil, int type, int width, int height)
+  DistortedFramebuffer(int numfbos, int numcolors, int depthStencil, int type, int width, int height)
     {
-    super(width,height,NOT_CREATED_YET,1,numcolors,depthStencil,NOT_CREATED_YET, type);
+    super(width,height,NOT_CREATED_YET,numfbos,numcolors,depthStencil,NOT_CREATED_YET, type);
+    markForCreation();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// create a multi-framebuffer (1 object containing multiple FBOs)
+// create SYSTEM or TREE framebuffers (those are just like normal FBOs, just hold information
+// that they were autocreated only for the Library's internal purposes (SYSTEM) or for using
+// inside a Tree of DistortedNodes (TREE)
+// SYSTEM surfaces do not get removed in onDestroy().
 
-  DistortedFramebuffer(int numfbos, int numcolors, int depthStencil, int type, int width, int height)
+  DistortedFramebuffer(int numcolors, int depthStencil, int type, int width, int height)
     {
-    super(width,height,NOT_CREATED_YET,numfbos,numcolors,depthStencil,NOT_CREATED_YET, type);
+    this(1,numcolors,depthStencil,type,width,height);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -247,7 +248,7 @@ public class DistortedFramebuffer extends DistortedOutputSurface
   @SuppressWarnings("unused")
   public DistortedFramebuffer(int width, int height, int numcolors, int depthStencil)
     {
-    super(width,height,NOT_CREATED_YET,1,numcolors,depthStencil,NOT_CREATED_YET,TYPE_USER);
+    this(1,numcolors,depthStencil,TYPE_USER,width,height);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/main/DistortedSurface.java b/src/main/java/org/distorted/library/main/DistortedSurface.java
index 797ccdf..b69989a 100644
--- a/src/main/java/org/distorted/library/main/DistortedSurface.java
+++ b/src/main/java/org/distorted/library/main/DistortedSurface.java
@@ -43,8 +43,6 @@ public abstract class DistortedSurface extends DistortedObject
     {
     super(type);
 
-    if( create!=DONT_CREATE ) markForCreation();
-
     mNumFBOs      = numfbos;
     mNumColors    = numcolors;
     mWidth        = width ;
diff --git a/src/main/java/org/distorted/library/main/DistortedTexture.java b/src/main/java/org/distorted/library/main/DistortedTexture.java
index 7d1b4d8..c39a479 100644
--- a/src/main/java/org/distorted/library/main/DistortedTexture.java
+++ b/src/main/java/org/distorted/library/main/DistortedTexture.java
@@ -117,6 +117,7 @@ public class DistortedTexture extends DistortedSurface
     {
     super(width,height,NOT_CREATED_YET,1,1,type);
     mBmp= null;
+    markForCreation();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -127,8 +128,7 @@ public class DistortedTexture extends DistortedSurface
  */
   public DistortedTexture(int width, int height)
     {
-    super(width,height,NOT_CREATED_YET,1,1,TYPE_USER);
-    mBmp= null;
+    this(width,height,TYPE_USER);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
