aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2005-12-13 01:39:34 +0000
committerChien Yang <[email protected]>2005-12-13 01:39:34 +0000
commit946937c96fddcdadb6e9d4daffc075ab343d5138 (patch)
tree749a24d459c93b928392b852cf64b33ec5e04558 /src
parentc6487f83fcbb54bf2a98914094e8813641f017e2 (diff)
1) Fixed issue 175 : OffScreenRendering: Issue with Updating Texture Size from Behavior.
2) Fixed issue 208 : Sound nodes cannot be placed below Switch groups git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@476 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java47
-rw-r--r--src/classes/share/javax/media/j3d/J3dMessage.java7
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java28
-rw-r--r--src/classes/share/javax/media/j3d/Renderer.java27
-rw-r--r--src/classes/share/javax/media/j3d/SoundStructure.java7
-rw-r--r--src/native/ogl/Canvas3D.c30
6 files changed, 103 insertions, 43 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index c79b3c2..6fbdcac 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -1895,10 +1895,9 @@ public class Canvas3D extends Canvas {
(offScreenCanvasSize.height != height)) {
if (window != 0) {
- removeCtx();
- // Fix for Issue 18.
+ // Fix for Issue 18 and Issue 175
// Will do destroyOffScreenBuffer in the Renderer thread.
- sendDestroyOffScreenBuffer();
+ sendDestroyCtxAndOffScreenBuffer();
window = 0;
}
@@ -1909,11 +1908,10 @@ public class Canvas3D extends Canvas {
if (width > 0 && height > 0) {
sendCreateOffScreenBuffer();
}
-
ctx = 0;
}
else if (ctx != 0) {
- removeCtx();
+ removeCtx();
}
offScreenBuffer = buffer;
@@ -2470,7 +2468,7 @@ public class Canvas3D extends Canvas {
// The native method that sets this ctx to be the current one
- static native void useCtx(long ctx, long display, int window);
+ static native boolean useCtx(long ctx, long display, int window);
native void clear(long ctx, float r, float g, float b, int winWidth, int winHeight,
ImageComponent2DRetained image, int imageScaleMode, byte[] imageYdown);
@@ -4363,12 +4361,7 @@ public class Canvas3D extends Canvas {
// Send a destroyOffScreenBuffer message to Renderer (via
// MasterControl) and wait for it to be done
- private void sendDestroyOffScreenBuffer() {
- // Nothing to do unless screen.renderer is non-null
- if ((screen == null) || (screen.renderer == null)) {
- return;
- }
-
+ private void sendDestroyCtxAndOffScreenBuffer() {
// Wait for the buffer to be destroyed unless called from
// a Behavior or from a Rendering thread
Thread currentThread = Thread.currentThread();
@@ -4378,32 +4371,27 @@ public class Canvas3D extends Canvas {
offScreenBufferPending = true;
}
- // Fix for Issue 18
- // Send message to Renderer thread to perform destroyOffScreenBuffer.
- VirtualUniverse.mc.postRequest(MasterControl.FREE_CONTEXT,
- new Object[]{this,
- new Long(screen.display),
- new Integer(window),
- new Long(0),
- Boolean.TRUE});
+ // Fix for Issue 18 and Issue 175
+ // Send message to Renderer thread to perform remove Ctx and destroyOffScreenBuffer.
+
+ VirtualUniverse.mc.sendDestroyCtxAndOffScreenBuffer(this);
- // Wait for off-screen buffer to be destroyed
+ // Wait for ctx and off-screen buffer to be destroyed
while (offScreenBufferPending) {
MasterControl.threadYield();
}
}
private void removeCtx() {
+
if ((screen != null) &&
(screen.renderer != null) &&
(ctx != 0)) {
- VirtualUniverse.mc.postRequest(MasterControl.FREE_CONTEXT,
- new Object[]{this,
- new Long(screen.display),
- new Integer(window),
- new Long(ctx),
- Boolean.FALSE});
-
+ VirtualUniverse.mc.postRequest(MasterControl.FREE_CONTEXT,
+ new Object[]{this,
+ new Long(screen.display),
+ new Integer(window),
+ new Long(ctx)});
// Fix for Issue 19
// Wait for the context to be freed unless called from
// a Behavior or from a Rendering thread
@@ -4413,7 +4401,8 @@ public class Canvas3D extends Canvas {
while (ctxTimeStamp != 0) {
MasterControl.threadYield();
}
- }
+
+ }
ctx = 0;
}
}
diff --git a/src/classes/share/javax/media/j3d/J3dMessage.java b/src/classes/share/javax/media/j3d/J3dMessage.java
index d2d073d..c717388 100644
--- a/src/classes/share/javax/media/j3d/J3dMessage.java
+++ b/src/classes/share/javax/media/j3d/J3dMessage.java
@@ -84,9 +84,10 @@ class J3dMessage extends Object {
static final int ORDERED_GROUP_TABLE_CHANGED = 59;
static final int BEHAVIOR_REEVALUATE = 60;
static final int CREATE_OFFSCREENBUFFER = 61;
- static final int SHADER_ATTRIBUTE_CHANGED = 62;
- static final int SHADER_ATTRIBUTE_SET_CHANGED = 63;
- static final int SHADER_APPEARANCE_CHANGED = 64;
+ static final int DESTROY_CTX_AND_OFFSCREENBUFFER = 62;
+ static final int SHADER_ATTRIBUTE_CHANGED = 63;
+ static final int SHADER_ATTRIBUTE_SET_CHANGED = 64;
+ static final int SHADER_APPEARANCE_CHANGED = 65;
/**
* This is the time snapshot at which this change occured
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index c5ba916..e1ead5e 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -3000,6 +3000,31 @@ class MasterControl {
setWorkForRequestRenderer();
}
+ // Issue for Issue 175
+ // Pass DestroyCtxAndOffScreenBuffer to the Renderer thread for execution.
+ void sendDestroyCtxAndOffScreenBuffer(Canvas3D c) {
+ // Assertion check. Look for comment in sendCreateOffScreenBuffer.
+ GraphicsDevice gd = c.graphicsConfiguration.getDevice();
+ J3dDebug.doAssert((Screen3D.deviceRendererMap.get(gd) != null),
+ "Screen3D.deviceRendererMap.get(gd) != null");
+ synchronized (mcThreadLock) {
+ // Assert the master control thread is created.
+ J3dDebug.doAssert((mcThread != null), "mcThread != null");
+ Renderer rdr = createRenderer(c.graphicsConfiguration);
+ J3dMessage createMessage = VirtualUniverse.mc.getMessage();
+ createMessage.threads = J3dThread.RENDER_THREAD;
+ createMessage.type = J3dMessage.DESTROY_CTX_AND_OFFSCREENBUFFER;
+ createMessage.universe = null;
+ createMessage.view = null;
+ createMessage.args[0] = c;
+ rdr.rendererStructure.addMessage(createMessage);
+ synchronized (requestObjList) {
+ setWorkForRequestRenderer();
+ pendingRequest = true;
+ }
+ }
+ }
+
// Fix for Issue 18
// Pass CreateOffScreenBuffer to the Renderer thread for execution.
void sendCreateOffScreenBuffer(Canvas3D c) {
@@ -3046,7 +3071,7 @@ class MasterControl {
*/
void doWork() {
runMonitor(CHECK_FOR_WORK, null, null, null, null);
-
+
synchronized (timeLock) {
synchronized (requestObjList) {
if (pendingRequest) {
@@ -3366,7 +3391,6 @@ class MasterControl {
}
}
-
while (!done) {
// First try a RenderThread
while (!renderWaiting &&
diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java
index 8abfe00..e3237ae 100644
--- a/src/classes/share/javax/media/j3d/Renderer.java
+++ b/src/classes/share/javax/media/j3d/Renderer.java
@@ -342,8 +342,7 @@ class Renderer extends J3dThread {
((Integer) obj[2]).intValue(),
((Long) obj[3]).longValue(),
false, !c.offScreen,
- ((Boolean)obj[4]).booleanValue());
-
+ false);
}
return;
} else { // RENDER || REQUESTRENDER
@@ -473,6 +472,21 @@ class Renderer extends J3dThread {
m[nmesg++].decRefcount();
continue;
}
+ else if (renderType == J3dMessage.DESTROY_CTX_AND_OFFSCREENBUFFER) {
+ // Fix for issue 175.
+ // destroy ctx.
+ // Should be able to collaspe both call into one. Will do this in 1.5,
+ // it is a little risky for 1.4 beta3.
+ removeCtx(canvas, canvas.screen.display, canvas.window, canvas.ctx,
+ false, !canvas.offScreen, false);
+ // destroy offScreenBuffer.
+ removeCtx(canvas, canvas.screen.display, canvas.window, 0,
+ false, !canvas.offScreen, true);
+
+ canvas.offScreenBufferPending = false;
+ m[nmesg++].decRefcount();
+ continue;
+ }
if ((canvas.view == null) || !canvas.firstPaintCalled) {
// This happen when the canvas just remove from the View
@@ -642,7 +656,6 @@ class Renderer extends J3dThread {
ImageComponent2DRetained offBufRetained = null;
if (renderType == J3dMessage.RENDER_OFFSCREEN) {
-
if (canvas.window == 0 || !canvas.active) {
canvas.offScreenRendering = false;
continue;
@@ -1449,7 +1462,13 @@ class Renderer extends J3dThread {
// with drawingSurface already lock
final void makeCtxCurrent(long sharedCtx, long display, int window) {
if (sharedCtx != currentCtx) {
- Canvas3D.useCtx(sharedCtx, display, window);
+ Canvas3D.useCtx(sharedCtx, display, window);
+ /*
+ if(!Canvas3D.useCtx(sharedCtx, display, window)) {
+ Thread.dumpStack();
+ System.err.println("useCtx Fail");
+ }
+ */
currentCtx = sharedCtx;
}
}
diff --git a/src/classes/share/javax/media/j3d/SoundStructure.java b/src/classes/share/javax/media/j3d/SoundStructure.java
index e2407b6..dd18252 100644
--- a/src/classes/share/javax/media/j3d/SoundStructure.java
+++ b/src/classes/share/javax/media/j3d/SoundStructure.java
@@ -106,7 +106,8 @@ class SoundStructure extends J3dStructure {
transformMsg = true;
break;
case J3dMessage.SWITCH_CHANGED:
- processSwitchChanged(m);
+ // This method isn't implemented yet.
+ // processSwitchChanged(m);
// may need to process dirty switched-on transform
if (universe.transformStructure.getLazyUpdate()) {
transformMsg = true;
@@ -442,7 +443,9 @@ class SoundStructure extends J3dStructure {
}
}
+ // Implementation be needed.
void processSwitchChanged(J3dMessage m) {
+ /*
SoundRetained sound;
LeafRetained leaf;
UnorderList arrList;
@@ -468,6 +471,7 @@ class SoundStructure extends J3dStructure {
}
}
}
+ */
}
// How can active flag (based on View orientataion) be set here for all Views?!?
@@ -718,4 +722,5 @@ class SoundStructure extends J3dStructure {
}
void cleanup() {}
+
}
diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c
index f653e84..f18d817 100644
--- a/src/native/ogl/Canvas3D.c
+++ b/src/native/ogl/Canvas3D.c
@@ -1309,7 +1309,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext(
JNIEXPORT
-void JNICALL Java_javax_media_j3d_Canvas3D_useCtx(
+jboolean JNICALL Java_javax_media_j3d_Canvas3D_useCtx(
JNIEnv *env,
jclass cl,
jlong ctxInfo,
@@ -1318,13 +1318,36 @@ void JNICALL Java_javax_media_j3d_Canvas3D_useCtx(
{
GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo;
jlong ctx = ctxProperties->context;
+ int result;
#if defined(UNIX)
- glXMakeCurrent((Display *)display, (GLXDrawable)window, (GLXContext)ctx);
+
+ result = glXMakeCurrent((Display *)display, (GLXDrawable)window, (GLXContext)ctx);
+ if (result != GL_TRUE) {
+ fprintf(stderr, "Java 3D ERROR : In Canvas3D.useCtx() glXMakeCurrent fails\n");
+ return JNI_FALSE;
+ }
+
#endif
#ifdef WIN32
- wglMakeCurrent((HDC) window, (HGLRC) ctx);
+ DWORD err;
+ LPTSTR errString;
+
+ result = wglMakeCurrent((HDC) window, (HGLRC) ctx);
+ /* fprintf(stderr, "useCtx : wglMakeCurrent : window %d, ctx %d, result = %d\n",
+ window, (int) ctx, result); */
+
+ if (result != GL_TRUE) {
+ err = GetLastError();
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, err, 0, (LPTSTR)&errString, 0, NULL);
+ fprintf(stderr, "wglMakeCurrent Failed: %s\n", errString);
+ return JNI_FALSE;
+ }
+
#endif
+ return JNI_TRUE;
}
JNIEXPORT
@@ -2741,7 +2764,6 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer(
hpbuf = pFormatInfoPtr->wglCreatePbufferARB( hdc, pFormatInfoPtr->offScreenPFormat,
width, height, piAttrs);
-
if(hpbuf == NULL) {
printErrorMessage("In Canvas3D : wglCreatePbufferARB FAIL.");
ReleaseDC(hwnd, hdc);