Carry init & dispose methods down into RenderStrategy, so that textures can be disposed of and reloaded.
This commit is contained in:
parent
dc66d2a93e
commit
d22cefa248
@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import javax.media.opengl.GL;
|
import javax.media.opengl.GL;
|
||||||
import javax.media.opengl.GL2;
|
import javax.media.opengl.GL2;
|
||||||
import javax.media.opengl.GL2ES1;
|
import javax.media.opengl.GL2ES1;
|
||||||
|
import javax.media.opengl.GLAutoDrawable;
|
||||||
import javax.media.opengl.GLProfile;
|
import javax.media.opengl.GLProfile;
|
||||||
import javax.media.opengl.fixedfunc.GLLightingFunc;
|
import javax.media.opengl.fixedfunc.GLLightingFunc;
|
||||||
import javax.media.opengl.fixedfunc.GLMatrixFunc;
|
import javax.media.opengl.fixedfunc.GLMatrixFunc;
|
||||||
@ -35,10 +36,22 @@ public class RealisticRenderStrategy extends RenderStrategy {
|
|||||||
private Map<URI, Texture> texCache = new HashMap<URI, Texture>();
|
private Map<URI, Texture> texCache = new HashMap<URI, Texture>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearCaches() {
|
public void updateFigure() {
|
||||||
needClearCache = true;
|
needClearCache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(GLAutoDrawable drawable) {
|
||||||
|
oldTexCache = new HashMap<URI,Texture>();
|
||||||
|
texCache = new HashMap<URI,Texture>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(GLAutoDrawable drawable) {
|
||||||
|
oldTexCache = null;
|
||||||
|
texCache = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDrawn(RocketComponent c) {
|
public boolean isDrawn(RocketComponent c) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.sf.openrocket.gui.figure3d;
|
package net.sf.openrocket.gui.figure3d;
|
||||||
|
|
||||||
import javax.media.opengl.GL2;
|
import javax.media.opengl.GL2;
|
||||||
|
import javax.media.opengl.GLAutoDrawable;
|
||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
|
||||||
@ -13,8 +14,16 @@ public abstract class RenderStrategy {
|
|||||||
|
|
||||||
public abstract void postGeometry(GL2 gl, RocketComponent c, float alpha);
|
public abstract void postGeometry(GL2 gl, RocketComponent c, float alpha);
|
||||||
|
|
||||||
public void clearCaches() {
|
public void updateFigure() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void init(GLAutoDrawable drawable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose(GLAutoDrawable drawable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -375,6 +375,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void dispose(GLAutoDrawable drawable) {
|
public void dispose(GLAutoDrawable drawable) {
|
||||||
log.verbose("GL - dispose() called");
|
log.verbose("GL - dispose() called");
|
||||||
|
rr.dispose(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,9 +39,13 @@ public class RocketRenderer {
|
|||||||
cr = new ComponentRenderer();
|
cr = new ComponentRenderer();
|
||||||
cr.init(drawable);
|
cr.init(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dispose(GLAutoDrawable drawable) {
|
||||||
|
currentStrategy.dispose(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateFigure() {
|
public void updateFigure() {
|
||||||
currentStrategy.clearCaches();
|
currentStrategy.updateFigure();
|
||||||
cr.updateFigure();
|
cr.updateFigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user