aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/win32
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2004-10-15 23:33:45 +0000
committerChien Yang <[email protected]>2004-10-15 23:33:45 +0000
commit14b52db7ab4c4be2bd39ff944cec056c291f999a (patch)
tree3bf6c274a97828b9ca4cd28de6ed602dfeac9af3 /src/classes/win32
parentcdf24368541b18e5ffc56f5c9449310e874f4a2f (diff)
Issue number: 4, 28, 71 and 76
Windows OpenGL only : This fix will use hardware Pbuffer for offScreenBuffer rendering if the graphics hardware support it, else BitMap is use as a fallback. 1) Fixed issue 4 - Speed of OffScreen Canvas3D 2) Fixed issue 28 - Combine Mode & Missing Texture in OffScreen snapshot on Win/XP 3) Fixed issue 71 - OGL: OffScreen canvas ignore GraphicsConfigTemplate under windows. 4) Fixed issue 76 - OffScreen rendering should use Pbuffer on Windows / OpenGL 5) Cleanup native ChoosePixelFormat code. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@56 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/win32')
-rw-r--r--src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java75
-rw-r--r--src/classes/win32/javax/media/j3d/NativeScreenInfo.java18
2 files changed, 87 insertions, 6 deletions
diff --git a/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java
index 997aaee..2759ea5 100644
--- a/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java
+++ b/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java
@@ -19,6 +19,7 @@ import sun.awt.Win32GraphicsConfig;
import java.awt.GraphicsConfigTemplate;
class NativeConfigTemplate3D {
+ private final static boolean debug = false;
NativeConfigTemplate3D() {
VirtualUniverse.createMC();
@@ -40,7 +41,12 @@ class NativeConfigTemplate3D {
* selects the proper visual
*/
native int
- choosePixelFormat(long ctx, int screen, int[] attrList);
+ choosePixelFormat(long ctx, int screen, int[] attrList, long[] pFormatInfo);
+
+ // Native method to free an PixelFormatInfo struct. This is static since it
+ // may need to be called to clean up the Canvas3D fbConfigTable after the
+ // NativeConfigTemplate3D has been disposed of.
+ static native void freePixelFormatInfo(long pFormatInfo);
// Native methods to return whether a particular attribute is available
native boolean isStereoAvailable(long ctx, long display, int screen, int pixelFormat);
@@ -58,6 +64,17 @@ class NativeConfigTemplate3D {
Win32GraphicsDevice gd =
(Win32GraphicsDevice)((Win32GraphicsConfig)gc[0]).getDevice();
+ /* Not ready to enforce ARB extension in J3D1.3.2, but will likely to
+ do so in J3D 1.4.
+ System.out.println("getBestConfiguration : Checking WGL ARB support\n");
+
+ if (!NativeScreenInfo.isWglARB()) {
+ Thread.dumpStack();
+ System.out.println("getBestConfiguration : WGL ARB support fail\n");
+ return null;
+ }
+ */
+
// holds the list of attributes to be tramslated
// for glxChooseVisual call
int attrList[] = new int[NUM_ITEMS];
@@ -72,12 +89,40 @@ class NativeConfigTemplate3D {
attrList[ANTIALIASING] = template.getSceneAntialiasing();
NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd);
int screen = nativeScreenInfo.getScreen();
- int pixelFormat = choosePixelFormat(0, screen, attrList);
- if (pixelFormat == -1) {
+
+ long[] pFormatInfo = new long[1];
+
+ /* Deliberately set this to -1. pFormatInfo is not use in
+ D3D, so this value will be unchange in the case of D3D.
+ In the case of OGL, the return value should be 0 or a
+ positive valid address.
+ */
+ pFormatInfo[0] = -1;
+
+ int pixelFormat = choosePixelFormat(0, screen, attrList, pFormatInfo);
+ if (debug) {
+ System.out.println(" choosePixelFormat() returns " + pixelFormat);
+ System.out.println(" pFormatInfo is " + pFormatInfo[0]);
+ System.out.println();
+ }
+
+ if (pixelFormat < 0) {
// current mode don't support the minimum config
return null;
}
- return new J3dGraphicsConfig(gd, pixelFormat);
+
+ GraphicsConfiguration gc1 = new J3dGraphicsConfig(gd, pixelFormat);
+ // We need to cache the offScreen pixelformat that glXChoosePixelFormat()
+ // returns, since this is not cached with J3dGraphicsConfig and there
+ // are no public constructors to allow us to extend it.
+ synchronized (Canvas3D.fbConfigTable) {
+ if (Canvas3D.fbConfigTable.get(gc1) == null)
+ Canvas3D.fbConfigTable.put(gc1, new Long(pFormatInfo[0]));
+ else
+ freePixelFormatInfo(pFormatInfo[0]);
+ }
+
+ return gc1;
}
/**
@@ -90,6 +135,17 @@ class NativeConfigTemplate3D {
Win32GraphicsDevice gd =
(Win32GraphicsDevice)((Win32GraphicsConfig) gc).getDevice();
+ /* Not ready to enforce ARB extension in J3D1.3.2, but will likely to
+ do so in J3D 1.4.
+ System.out.println("isGraphicsConfigSupported : Checking WGL ARB support\n");
+
+ if (!NativeScreenInfo.isWglARB()) {
+ Thread.dumpStack();
+ System.out.println("isGraphicsConfigSupported : WGL ARB support fail\n");
+ return false;
+ }
+ */
+
// holds the list of attributes to be tramslated
// for glxChooseVisual call
int attrList[] = new int[NUM_ITEMS];
@@ -106,9 +162,16 @@ class NativeConfigTemplate3D {
NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd);
int screen = nativeScreenInfo.getScreen();
- int pixelFormat = choosePixelFormat(0, screen, attrList);
+ long[] pFormatInfo = new long[1];
+
+ int pixelFormat = choosePixelFormat(0, screen, attrList, pFormatInfo);
+ if (debug) {
+ System.out.println(" choosePixelFormat() returns " + pixelFormat);
+ System.out.println(" pFormatInfo is " + pFormatInfo[0]);
+ System.out.println();
+ }
- if (pixelFormat == -1) {
+ if (pixelFormat < 0) {
// current mode don't support the minimum config
return false;
} else return true;
diff --git a/src/classes/win32/javax/media/j3d/NativeScreenInfo.java b/src/classes/win32/javax/media/j3d/NativeScreenInfo.java
index 43ee7e5..ef539ec 100644
--- a/src/classes/win32/javax/media/j3d/NativeScreenInfo.java
+++ b/src/classes/win32/javax/media/j3d/NativeScreenInfo.java
@@ -19,6 +19,24 @@ class NativeScreenInfo {
private int display = 0;
private int screen = 0;
+
+ private static boolean wglARBChecked = false;
+ private static boolean isWglARB;
+
+ private native static boolean queryWglARB();
+
+ // This method will return true if wglGetExtensionsStringARB is supported,
+ // else return false
+ synchronized static boolean isWglARB() {
+
+ if (!wglARBChecked) {
+ // Query for wglGetExtensionsStringARB support.
+ isWglARB = queryWglARB();
+ wglARBChecked = true;
+ }
+ return isWglARB;
+ }
+
NativeScreenInfo(GraphicsDevice graphicsDevice) {
// Get the screen number
screen = ((sun.awt.Win32GraphicsDevice)graphicsDevice).getScreen();