diff options
author | Kevin Rushforth <[email protected]> | 2004-11-05 17:49:17 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2004-11-05 17:49:17 +0000 |
commit | 7ce0d5ef623370a6122c63ea70e0ae5b022998f9 (patch) | |
tree | a8e21f2e6be6225f26902bcad0badbd9533aad6e | |
parent | 49fe0098cf0aa3fdd764f2b564075ac55ef59280 (diff) |
1. Added new boolean property, "j3d.usePbuffer", which can be used to
enable or disable the use of OpenGL Pbuffer rendering for off-screen
Canvas3D objects. The default value for this property is "true". To
disable Pbuffer rendering, use "java -Dj3d.usePbuffer=false ..."
2. Changed the few remaining C++-style "//" comments to "/* ... */"
for maximum portability.
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@75 ba19aa83-45c5-6ac9-afd3-db810772062c
-rw-r--r-- | src/classes/share/javax/media/j3d/MasterControl.java | 27 | ||||
-rw-r--r-- | src/native/ogl/Canvas3D.c | 17 | ||||
-rw-r--r-- | src/native/ogl/NativeConfigTemplate3D.c | 37 | ||||
-rw-r--r-- | src/native/ogl/NativeScreenInfo.c | 2 | ||||
-rw-r--r-- | src/native/ogl/gldefs.h | 2 |
5 files changed, 49 insertions, 36 deletions
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index 23e1288..798d308 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -90,21 +90,26 @@ class MasterControl { /** * by MIK OF CLASSX - * the flag to indicate whether the background of the offscreen canvas must be transparent or not - * false by default + * + * the flag to indicate whether the background of the offscreen + * canvas must be transparent or not false by default */ boolean transparentOffScreen = false; - - + /** + * Flag to indicate whether Pbuffers are used for off-screen + * rendering; true by default. Set by the "j3d.usePbuffer" + * property, When this flag is set to false, Bitmap (Windows) or + * Pixmap (UNIX) rendering will be used + */ + boolean usePbuffer = true; /** - * the flag to indicate whether should renderer view frustum culling be true. + * Flag to indicate whether should renderer view frustum culling is done; * true by default. + * Set by the -Dj3d.viewFrustumCulling property, When this flag is + * set to false, the renderer view frustum culling is turned off. */ - // Set by the -Dj3d.viewFrustumCulling property, When this flag is - // set to false, the renderer view frustum culling is turned off. - boolean viewFrustumCulling = true; /** @@ -476,7 +481,11 @@ class MasterControl { "compaction"); // by MIK OF CLASSX - transparentOffScreen = getBooleanProperty("j3d.transparentOffScreen", transparentOffScreen,"transparent OffScreen"); + transparentOffScreen = getBooleanProperty("j3d.transparentOffScreen", transparentOffScreen, "transparent OffScreen"); + + usePbuffer = getBooleanProperty("j3d.usePbuffer", + usePbuffer, + "Off-screen Pbuffer"); viewFrustumCulling = getBooleanProperty("j3d.viewFrustumCulling", viewFrustumCulling,"View frustum culling in the renderer is"); diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c index 339fe63..2e18925 100644 --- a/src/native/ogl/Canvas3D.c +++ b/src/native/ogl/Canvas3D.c @@ -2670,10 +2670,10 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( glXGetFBConfigAttrib((Display *) display, fbConfigList[0], GLX_DRAWABLE_TYPE, &val); /* fprintf(stderr, "GLX_DRAWABLE_TYPE returns %d\n", val); */ - - if ((val & GLX_PBUFFER_BIT) != 0) { + + if (getJavaBoolEnv(env,"usePbuffer") && (val & GLX_PBUFFER_BIT) != 0) { /* fprintf(stderr, "Using pbuffer %d\n", val); */ - + /* Initialize the attribute list to be used for choosing FBConfig */ attrCount = 0; @@ -2703,8 +2703,9 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( XSetWindowAttributes win_attrs; Colormap cmap; unsigned long win_mask; - + /* fprintf(stderr, "Using pixmap %d\n", val); */ + vinfo = glXGetVisualFromFBConfig((Display*)display, fbConfigList[0]); if (vinfo == NULL) { fprintf(stderr, "Java 3D ERROR : glXGetVisualFromFBConfig failed\n"); @@ -2881,7 +2882,9 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( return (jint) hpbufdc; } - + + /* fprintf(stderr, "***** Use Bitmap for offscreen ******\n"); */ + /* create a DIB */ memset(&bih, 0, sizeof(BITMAPINFOHEADER)); @@ -2891,7 +2894,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( bih.biPlanes = 1; - // by MIK OF CLASSX + /* by MIK OF CLASSX */ if (getJavaBoolEnv(env, "transparentOffScreen")) { bih.biBitCount = 32; } @@ -3128,7 +3131,7 @@ void initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo){ ctxInfo->implicit_multisample = getJavaBoolEnv(env, "implicitAntialiasing"); - // by MIK OF CLASSX + /* by MIK OF CLASSX */ ctxInfo->alphaClearValue = (getJavaBoolEnv(env, "transparentOffScreen") ? 0.0f : 1.0f); /* ARB extensions */ diff --git a/src/native/ogl/NativeConfigTemplate3D.c b/src/native/ogl/NativeConfigTemplate3D.c index 7d85dd4..9ebb0f3 100644 --- a/src/native/ogl/NativeConfigTemplate3D.c +++ b/src/native/ogl/NativeConfigTemplate3D.c @@ -319,7 +319,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual( glxAttrs[index++] = GLX_BLUE_SIZE; glxAttrs[index++] = mx_ptr[BLUE_SIZE]; - // by MIK OF CLASSX + /* by MIK OF CLASSX */ if (getJavaBoolEnv(env, "transparentOffScreen")) { glxAttrs[index++] = GLX_ALPHA_SIZE; glxAttrs[index++] = 1; @@ -335,10 +335,13 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual( (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT); - fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal, - dbVal, antialiasVal, index); - - if(fbConfigList == NULL) { // Try with Pixmap, if Pbuffer fail. */ + /* Get Pbuffer-capabale visual unless j3d.usePbuffer property is FALSE */ + if (getJavaBoolEnv(env,"usePbuffer")) { + fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal, + dbVal, antialiasVal, index); + } + + if(fbConfigList == NULL) { /* Try with Pixmap, if Pbuffer fail. */ glxAttrs[drawableIndex] = (GLX_PIXMAP_BIT | GLX_WINDOW_BIT); @@ -347,7 +350,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual( } - if(fbConfigList == NULL) { // Try with Window only, if Pixmap fail. + if(fbConfigList == NULL) { /* Try with Window only, if Pixmap fail. */ glxAttrs[drawableIndex] = GLX_WINDOW_BIT; fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal, @@ -1159,7 +1162,7 @@ int chooseSTDPixelFormat( /* We are here b/c there is no support for Pbuffer on the HW. This is a fallback path, we will hardcore the value. */ - // by MIK OF CLASSX + /* by MIK OF CLASSX */ pfd.iPixelType = PFD_TYPE_RGBA; if (getJavaBoolEnv(env, "transparentOffScreen")) { pfd.cRedBits = 8; @@ -1193,7 +1196,7 @@ int chooseSTDPixelFormat( return pFormat; } -PixelFormatInfo * newPixelFormatInfo(HDC hdc) +PixelFormatInfo * newPixelFormatInfo(HDC hdc, jboolean usePbuffer) { PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL; @@ -1238,7 +1241,7 @@ PixelFormatInfo * newPixelFormatInfo(HDC hdc) /* fprintf(stderr, "WGL Supported extensions: %s.\n", pFormatInfo->supportedExtensions); */ - if(isSupportedWGL(pFormatInfo->supportedExtensions, "WGL_ARB_pixel_format")) { + if (isSupportedWGL(pFormatInfo->supportedExtensions, "WGL_ARB_pixel_format")) { pFormatInfo->wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB"); @@ -1252,7 +1255,8 @@ PixelFormatInfo * newPixelFormatInfo(HDC hdc) /* fprintf(stderr, "wglChoosePixelFormatARB is supported.\n"); */ pFormatInfo->supportARB = GL_TRUE; - if(isSupportedWGL( pFormatInfo->supportedExtensions, "WGL_ARB_pbuffer")) { + if (usePbuffer && + isSupportedWGL(pFormatInfo->supportedExtensions, "WGL_ARB_pbuffer")) { /* Get pbuffer entry points */ pFormatInfo->wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB"); @@ -1278,7 +1282,7 @@ PixelFormatInfo * newPixelFormatInfo(HDC hdc) else { printErrorMessage("Problem in getting WGL_ARB_pbuffer functions !\n"); } - } + } } else { printErrorMessage("Problem in getting WGL_ARB_pixel_format functions !\n"); @@ -1310,15 +1314,12 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( HGLRC hrc; HDC hdc; int pixelFormat; - int wglAttrs[MAX_WGL_ATTRS_LENGTH]; + int wglAttrs[MAX_WGL_ATTRS_LENGTH]; int index, lastIndex; - PixelFormatInfo *pFormatInfo = NULL; + PixelFormatInfo *pFormatInfo = NULL; jlong * offScreenPFListPtr; PIXELFORMATDESCRIPTOR dummy_pfd = getDummyPFD(); - - /* fprintf(stderr, "In NativeConfigTemplate.\n"); */ - /* * Select any pixel format and bound current context to * it so that we can get the wglChoosePixelFormatARB entry point. @@ -1360,7 +1361,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( return -1; } - pFormatInfo = newPixelFormatInfo(hdc); + pFormatInfo = newPixelFormatInfo(hdc, getJavaBoolEnv(env,"usePbuffer")); offScreenPFListPtr = (*env)->GetLongArrayElements(env, offScreenPFArray, NULL); @@ -1386,7 +1387,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( wglAttrs[index++] = WGL_BLUE_BITS_ARB; wglAttrs[index++] = mx_ptr[BLUE_SIZE]; - // by MIK OF CLASSX + /* by MIK OF CLASSX */ if (getJavaBoolEnv(env, "transparentOffScreen")) { wglAttrs[index++] = WGL_ALPHA_BITS_ARB; wglAttrs[index++] = 1; diff --git a/src/native/ogl/NativeScreenInfo.c b/src/native/ogl/NativeScreenInfo.c index 8ea4b17..472d49d 100644 --- a/src/native/ogl/NativeScreenInfo.c +++ b/src/native/ogl/NativeScreenInfo.c @@ -86,7 +86,7 @@ Java_javax_media_j3d_NativeScreenInfo_queryGLX13( int major, minor; int errorBase, eventBase; Display* dpy = (Display*)display; - // It should be cleaner to return both the major and minor to the caller. + /* It should be cleaner to return both the major and minor to the caller. */ if (!glXQueryExtension(dpy, &errorBase, &eventBase)) { fprintf(stderr, "Java 3D ERROR : GLX extension is not supported\n"); diff --git a/src/native/ogl/gldefs.h b/src/native/ogl/gldefs.h index 7d5b70b..c1f0c55 100644 --- a/src/native/ogl/gldefs.h +++ b/src/native/ogl/gldefs.h @@ -521,7 +521,7 @@ typedef struct { */ jboolean implicit_multisample; - // by MIK OF CLASSX + /* by MIK OF CLASSX */ /* Used by transparentOffScreen feature. This is the value of the alpha channel |