import com.badlogic.gdx.graphics.g3d.utils.TextureProvider.FileTextureProvider;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.BufferUtils;
+import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.Pool;
* @author badlogic
*
*/
-public class Model {
+public class Model implements Disposable {
/** the meshes of the model **/
public Array<Mesh> meshes = new Array<Mesh>();
/** parts of meshes, used by nodes that have a graphical representation FIXME not sure if superfluous, stored in Nodes as well, could be useful to create bullet meshes **/
node.calculateTransforms(true);
}
}
+
+ @Override
+ public void dispose () {
+ for(Mesh mesh: meshes) {
+ mesh.dispose();
+ }
+ for(NewMaterial material: materials) {
+ // FIXME dispose textures! attribtue should probably be disposable, can decide whether it wants to get rid of resource or not
+ }
+ }
}
\ No newline at end of file
import com.badlogic.gdx.graphics.g3d.utils.RenderContext;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.utils.Array;
+import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.Pool;
-public class ModelBatch {
+public class ModelBatch implements Disposable {
protected Camera camera;
protected final Pool<Renderable> renderablesPool = new Pool<Renderable>() {
@Override
reuseableRenderables.add(renderable);
}
}
+
+ @Override
+ public void dispose () {
+ shaderProvider.dispose();
+ }
}
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.g3d.utils.RenderContext;
+import com.badlogic.gdx.utils.Disposable;
-public interface Shader {
+public interface Shader extends Disposable {
int compareTo(Shader other); // TODO: probably better to add some weight value to sort on
boolean canRender(Renderable instance);
void begin(Camera camera, RenderContext context);
}
}
}
+
+ @Override
+ public void dispose () {
+ program.dispose();
+ }
}
@Override
public void dispose () {
+ for(Shader shader: shaders) {
+ shader.dispose();
+ }
}
}
modelBatch.addModel(model, transform, lights);
modelBatch.end();
}
+
+ @Override
+ public void dispose () {
+ model.dispose();
+ modelBatch.dispose();
+ }
@Override
public boolean touchDown (int x, int y, int pointer, int newParam) {