diff options
author | Kevin Rushforth <[email protected]> | 2007-03-26 22:58:59 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2007-03-26 22:58:59 +0000 |
commit | d319a907da13b127971aec547022a7dce8cb9c05 (patch) | |
tree | 02fb5b94e0493d4e21bf24b9afc3b64d019fe34b /src/native/ogl | |
parent | e9005593c05ad268256398f2901febdc14d95b26 (diff) |
Issue 239: Stencil buffer should be cleared at the start of each frame
This partial fix adds a new "j3d.stencilClear" boolean property that specifies
whether the stencil buffer is cleared every frame by default.
Note that this is the first part of the partial fix. We still need to finish
the D3D code, and we need to verify whether the stencil mask needs to be
saved/forced to all 1s/restored
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@802 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/native/ogl')
-rw-r--r-- | src/native/ogl/Canvas3D.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c index 37c8b9f..e70b0c3 100644 --- a/src/native/ogl/Canvas3D.c +++ b/src/native/ogl/Canvas3D.c @@ -682,7 +682,6 @@ getPropertiesFromCurrentContext( ctxInfo->multi_draw_arrays_sun = JNI_TRUE; } - if (isExtensionSupported(tmpExtensionStr, "GL_EXT_compiled_vertex_array") && getJavaBoolEnv(env, "isCompiledVertexArray")) { ctxInfo->compiled_vertex_array_ext = JNI_TRUE; @@ -1461,19 +1460,21 @@ void JNICALL Java_javax_media_j3d_NativePipeline_texturemapping( } JNIEXPORT -void JNICALL Java_javax_media_j3d_NativePipeline_clear(JNIEnv *env, - jobject obj, - jlong ctxInfo, - jfloat r, - jfloat g, - jfloat b) +void JNICALL Java_javax_media_j3d_NativePipeline_clear( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jfloat r, + jfloat g, + jfloat b, + jboolean clearStencil) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; - #ifdef VERBOSE - fprintf(stderr, "Canvas3D.clear()\n"); + fprintf(stderr, "Canvas3D.clear(%g, %g, %g, %s)\n", + r, g, b, (stencilClear ? "true" : "false")); #endif glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); @@ -1484,18 +1485,33 @@ void JNICALL Java_javax_media_j3d_NativePipeline_clear(JNIEnv *env, glDepthMask(GL_TRUE); glClear(GL_DEPTH_BUFFER_BIT); 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) { + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + } + +/* TODO: we should be able to do the following, which should perform better... */ #if 0 - - /* Java 3D always clears the Z-buffer */ + int clearMask = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT; + + if (clearStencil) { + glClearStencil(0); + clearMask |= GL_STENCIL_BUFFER_BIT; + } + glPushAttrib(GL_DEPTH_BUFFER_BIT); glDepthMask(GL_TRUE); glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + glClear(clearMask); glPopAttrib(); #endif - } JNIEXPORT |