aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphil <[email protected]>2019-06-09 20:21:20 +1200
committerphil <[email protected]>2019-06-09 20:21:20 +1200
commit54d37207423e46ea80975651910478baa8dd8421 (patch)
tree81480ac72e6c1f55950a24122d7494df2864ffbf
parenteab9c8934c3a2f311f308972ad337c6f81728764 (diff)
The Renderer now wraps a use/release context call pair around any of the
Pure Immediate mode operations in the main doWork loop. The renderer also now lazily creates a context on the first Pure Immediate mode call. GarphicsContext3D calls makeCxtCurrent in doClear in the case where a context had to be created (that creation call should in fact now be redundant but it is left in)
-rw-r--r--src/javax/media/j3d/GraphicsContext3D.java3
-rw-r--r--src/javax/media/j3d/Renderer.java58
2 files changed, 61 insertions, 0 deletions
diff --git a/src/javax/media/j3d/GraphicsContext3D.java b/src/javax/media/j3d/GraphicsContext3D.java
index 75b2d1d..b6eb1c5 100644
--- a/src/javax/media/j3d/GraphicsContext3D.java
+++ b/src/javax/media/j3d/GraphicsContext3D.java
@@ -1731,6 +1731,9 @@ public int numSounds() {
return;
}
+ // createNewContext finishes with a release, re-make current so the init calls below work
+ canvas3d.makeCtxCurrent();
+
canvas3d.ctxTimeStamp =
VirtualUniverse.mc.getContextTimeStamp();
canvas3d.screen.renderer.listOfCtxs.add(canvas3d.ctx);
diff --git a/src/javax/media/j3d/Renderer.java b/src/javax/media/j3d/Renderer.java
index 6362672..7116842 100644
--- a/src/javax/media/j3d/Renderer.java
+++ b/src/javax/media/j3d/Renderer.java
@@ -620,6 +620,63 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine
if (canvas.isFatalError()) {
continue;
}
+
+ if (canvas.ctx == null) {
+ synchronized (VirtualUniverse.mc.contextCreationLock) {
+ canvas.ctx = canvas.createNewContext(null, false);
+
+ if (canvas.ctx == null) {
+ canvas.drawingSurfaceObject.unLock();
+ // Issue 260 : indicate fatal error and notify error listeners
+ canvas.setFatalError();
+ RenderingError err =
+ new RenderingError(RenderingError.CONTEXT_CREATION_ERROR,
+ J3dI18N.getString("Renderer7"));
+ err.setCanvas3D(canvas);
+ err.setGraphicsDevice(canvas.graphicsConfiguration.getDevice());
+ notifyErrorListeners(err);
+
+ break doneRender;
+ }
+ // createNewContext finishes with a release, re-make current so the init calls below work
+ canvas.makeCtxCurrent();
+
+ if (canvas.graphics2D != null) {
+ canvas.graphics2D.init();
+ }
+
+ canvas.ctxTimeStamp = VirtualUniverse.mc.getContextTimeStamp();
+ canvas.screen.renderer.listOfCtxs.add(canvas.ctx);
+ canvas.screen.renderer.listOfCanvases.add(canvas);
+
+ // enable separate specular color
+ canvas.enableSeparateSpecularColor();
+ }
+
+ // create the cache texture state in canvas
+ // for state download checking purpose
+ if (canvas.texUnitState == null) {
+ canvas.createTexUnitState();
+ }
+
+ canvas.drawingSurfaceObject.contextValidated();
+ canvas.screen.renderer.currentCtx = canvas.ctx;
+ canvas.screen.renderer.currentDrawable = canvas.drawable;
+ canvas.graphicsContext3D.initializeState();
+ canvas.ctxChanged = true;
+ canvas.canvasDirty = 0xffff;
+ // Update Appearance
+ canvas.graphicsContext3D.updateState(canvas.view.renderBin, RenderMolecule.SURFACE);
+
+
+ canvas.currentLights = new LightRetained[canvas.getNumCtxLights(canvas.ctx)];
+
+ for (j=0; j<canvas.currentLights.length; j++) {
+ canvas.currentLights[j] = null;
+ }
+ }
+
+ canvas.makeCtxCurrent();
try {
@@ -757,6 +814,7 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine
}
m[nmesg++].decRefcount();
+ canvas.releaseCtx();
} else { // retained mode rendering
long startRenderTime = 0L;
if (MasterControl.isStatsLoggable(Level.INFO)) {