aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2007-03-29 22:39:59 +0000
committerKevin Rushforth <[email protected]>2007-03-29 22:39:59 +0000
commitecd1e078bb8529490d9951335ab95e041a40f66c (patch)
tree8da42160266cb3a4731e881c5af5364a51ac8fd3 /src/classes
parentbb5331e867166954565f09ebfae6e9ef8e7d91f3 (diff)
Issue 239: Stencil buffer should be cleared at the start of each frame
Note that the D3D code may still need to save/restore the stencil write mask and enable flag. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@804 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglPipeline.java30
1 files changed, 27 insertions, 3 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();
}