aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglPipeline.java30
-rw-r--r--src/native/d3d/Canvas3D.cpp37
-rw-r--r--src/native/d3d/D3dCtx.hpp4
-rw-r--r--src/native/ogl/Canvas3D.c24
4 files changed, 68 insertions, 27 deletions
diff --git a/src/classes/jogl/javax/media/j3d/JoglPipeline.java b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
index 4ba4868..541d78c 100644
--- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
@@ -7633,10 +7633,13 @@ class JoglPipeline extends Pipeline {
void clear(Context ctx, float r, float g, float b, boolean clearStencil) {
if (VERBOSE) System.err.println("JoglPipeline.clear()");
-
+
JoglContext jctx = (JoglContext) ctx;
GLContext context = context(ctx);
GL gl = context.getGL();
+
+ // OBSOLETE CLEAR CODE
+ /*
gl.glClearColor(r, g, b, jctx.getAlphaClearValue());
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
@@ -7647,12 +7650,33 @@ class JoglPipeline extends Pipeline {
gl.glPopAttrib();
// Issue 239 - clear stencil if specified
- // TODO KCR : Issue 239 - should we also set stencil mask? If so, we
- // may need to save/restore like we do for depth mask
if (clearStencil) {
+ gl.glPushAttrib(GL.GL_STENCIL_BUFFER_BIT);
gl.glClearStencil(0);
+ gl.glStencilMask(~0);
gl.glClear(GL.GL_STENCIL_BUFFER_BIT);
+ gl.glPopAttrib();
}
+ */
+
+ // Mask of which buffers to clear, this always includes color & depth
+ int clearMask = GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT;
+
+ // Issue 239 - clear stencil if specified
+ if (clearStencil) {
+ gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
+
+ gl.glClearStencil(0);
+ gl.glStencilMask(~0);
+ clearMask |= GL.GL_STENCIL_BUFFER_BIT;
+ } else {
+ gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT);
+ }
+
+ gl.glDepthMask(true);
+ gl.glClearColor(r, g, b, jctx.getAlphaClearValue());
+ gl.glClear(clearMask);
+ gl.glPopAttrib();
}
diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp
index 8463b0d..010da46 100644
--- a/src/native/d3d/Canvas3D.cpp
+++ b/src/native/d3d/Canvas3D.cpp
@@ -302,18 +302,22 @@ void JNICALL Java_javax_media_j3d_NativePipeline_clear(
{
GetDevice();
-
+
+// TODO ACES: The d3dCtx->stencilEnable and d3dCtx->stencilWriteEnable flags
+// are not used in the rest of the code. They are never set to a value, and
+// they are not looked at by most of the code.
+
/* Java 3D always clears the Z-buffer */
- /* @TODO check same operation for stencil */
-
+
if (!d3dCtx->zWriteEnable) {
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
- }
+ }
- // TODO KCR : Issue 239 - use clearStencil to decide whether to clear stencil
+ // Issue 239 - clear stencil, if requested
+ if (clearStencil) {
+ device->SetRenderState(D3DRS_STENCILENABLE, TRUE);
+ device->SetRenderState(D3DRS_STENCILWRITEMASK, ~0);
- /* clear stencil, if in used */
- if (d3dCtx->stencilWriteEnable ) {
// clear stencil and ZBuffer
HRESULT hr = device->Clear(0, NULL,
D3DCLEAR_STENCIL | D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
@@ -321,7 +325,16 @@ void JNICALL Java_javax_media_j3d_NativePipeline_clear(
if (hr == D3DERR_INVALIDCALL) {
printf("[Java3D] Error cleaning Canvas3D stencil & ZBuffer\n");
}
- // printf("canvas3D clear stencil & ZBuffer\n");
+ // printf("canvas3D clear stencil & ZBuffer\n");
+
+ // TODO: DO WE NEED TO RESTORE THE STENCIL ENABLE AND WRITE MASK???
+// if (!d3dCtx->stencilEnable) {
+// device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+// }
+// if (!d3dCtx->stencilWriteEnable) {
+// device->SetRenderState(D3DRS_STENCILWRITEMASK, 0);
+// }
+
}
else {
// clear ZBuffer only
@@ -332,15 +345,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_clear(
}
// printf("canvas3D clear ZBuffer\n");
}
-
+
if (!d3dCtx->zWriteEnable) {
device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
- }
- // disable stencil
- if (d3dCtx->stencilEnable && !d3dCtx->stencilWriteEnable) {
- device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
}
-
+
}
extern "C" JNIEXPORT
diff --git a/src/native/d3d/D3dCtx.hpp b/src/native/d3d/D3dCtx.hpp
index 4365119..96aea9f 100644
--- a/src/native/d3d/D3dCtx.hpp
+++ b/src/native/d3d/D3dCtx.hpp
@@ -137,6 +137,10 @@ public:
DWORD softwareVertexProcessing;
DWORD zWriteEnable;
DWORD zEnable;
+
+// TODO ACES: The following two stencil enable flags are not used
+// consistently throughout the pipeline. They are never set to a value,
+// and they are not looked at by most of the code.
DWORD stencilWriteEnable; // new on 1.4
DWORD stencilEnable; // new on 1.4
diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c
index e70b0c3..fd0d7b9 100644
--- a/src/native/ogl/Canvas3D.c
+++ b/src/native/ogl/Canvas3D.c
@@ -1476,7 +1476,8 @@ void JNICALL Java_javax_media_j3d_NativePipeline_clear(
fprintf(stderr, "Canvas3D.clear(%g, %g, %g, %s)\n",
r, g, b, (stencilClear ? "true" : "false"));
#endif
-
+
+#ifdef OBSOLETE_CLEAR_CODE
glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue);
glClear(GL_COLOR_BUFFER_BIT);
@@ -1487,31 +1488,34 @@ void JNICALL Java_javax_media_j3d_NativePipeline_clear(
glPopAttrib();
/* Issue 239 - clear stencil if specified */
- /*
- * TODO KCR : Issue 239 - should we also set stencil mask? If so, we
- * may need to save/restore like we do for depth mask
- */
if (clearStencil) {
+ glPushAttrib(GL_STENCIL_BUFFER_BIT);
glClearStencil(0);
+ glStencilMask(~0);
glClear(GL_STENCIL_BUFFER_BIT);
+ glPopAttrib();
}
-/* TODO: we should be able to do the following, which should perform better... */
-#if 0
+#endif /* OBSOLETE_CLEAR_CODE */
+
+ /* Mask of which buffers to clear, this always includes color & depth */
int clearMask = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT;
+ /* Issue 239 - clear stencil if specified */
if (clearStencil) {
+ glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
glClearStencil(0);
+ glStencilMask(~0);
clearMask |= GL_STENCIL_BUFFER_BIT;
+ } else {
+ glPushAttrib(GL_DEPTH_BUFFER_BIT);
}
- glPushAttrib(GL_DEPTH_BUFFER_BIT);
glDepthMask(GL_TRUE);
glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue);
glClear(clearMask);
glPopAttrib();
-#endif
-
}
JNIEXPORT