aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/d3d/NativeConfigTemplate3D.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/native/d3d/NativeConfigTemplate3D.cpp')
-rw-r--r--src/native/d3d/NativeConfigTemplate3D.cpp104
1 files changed, 64 insertions, 40 deletions
diff --git a/src/native/d3d/NativeConfigTemplate3D.cpp b/src/native/d3d/NativeConfigTemplate3D.cpp
index c18134b..db2dace 100644
--- a/src/native/d3d/NativeConfigTemplate3D.cpp
+++ b/src/native/d3d/NativeConfigTemplate3D.cpp
@@ -20,7 +20,7 @@ jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isStereoAvailable(
jlong pFormatInfo,
jboolean offScreen)
{
- // DirectX 8.0 don't support stereo
+ // DirectX 9.0 don't support stereo
return false;
}
@@ -47,20 +47,24 @@ jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isSceneAntialiasing
BOOL antialiasingSupport = false;
lock();
- if (d3dDriverList == NULL) {
+ if (d3dDriverList == NULL)
+ {
D3dDriverInfo::initialize(env);
}
- if (d3dDriverList != NULL) {
- D3dDriverInfo *driverInfo = d3dDriverList[screen];
- for (int i=0; i < numDeviceTypes; i++) {
+ if (d3dDriverList != NULL)
+ {
+ D3dDriverInfo *driverInfo = d3dDriverList[screen];
+ for (int i=0; i < numDeviceTypes; i++)
+ {
D3dDeviceInfo *pDeviceInfo = driverInfo->d3dDeviceList[i];
if (pDeviceInfo->desktopCompatible &&
- pDeviceInfo->supportAntialiasing()) {
- antialiasingSupport = true;
- break;
- }
- }
+ pDeviceInfo->supportAntialiasing())
+ {
+ antialiasingSupport = true;
+ break;
+ }
+ }
}
unlock();
return antialiasingSupport;
@@ -74,6 +78,8 @@ jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isSceneAntialiasing
return JNI_FALSE;
}
+
+
extern "C" JNIEXPORT
jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
JNIEnv *env,
@@ -84,6 +90,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
jlongArray offScreenPFArray)
{
int depth, red, green, blue;
+ int stencilDepth;
int retValue = -1;
jint *mx_ptr = (jint *) env->GetPrimitiveArrayCritical(attrList, NULL);
@@ -91,43 +98,51 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
green = mx_ptr[GREEN_SIZE];
blue = mx_ptr[BLUE_SIZE];
depth = mx_ptr[DEPTH_SIZE];
+ stencilDepth = mx_ptr[STENCIL_SIZE];
env->ReleasePrimitiveArrayCritical(attrList, mx_ptr, 0);
- if (mx_ptr[STEREO] != REQUIRED) {
- lock();
-
- if (d3dDriverList == NULL) {
- D3dDriverInfo::initialize(env);
- }
+ if (mx_ptr[STEREO] != REQUIRED)
+ {
+ lock();
+ if (d3dDriverList == NULL)
+ {
+ D3dDriverInfo::initialize(env);
+ }
- if (d3dDriverList != NULL) {
+ if (d3dDriverList != NULL)
+ {
BOOL bFullScreen;
D3dDriverInfo *pDriver = d3dDriverList[screen];
- D3dDeviceInfo *deviceInfo =
- D3dCtx::setDeviceInfo(pDriver, &bFullScreen, depth);
-
- if (deviceInfo != NULL) {
- if ((depth <= deviceInfo->maxZBufferDepthSize) &&
- (red <= pDriver->redDepth) &&
- (green <= pDriver->greenDepth) &&
- (blue <= pDriver->blueDepth)) {
- retValue = depth;
- }
+ D3dDeviceInfo *deviceInfo = D3dCtx::setDeviceInfo(pDriver, &bFullScreen, depth, stencilDepth);
+
+ if (deviceInfo != NULL)
+ {
+ if ((depth <= deviceInfo->maxZBufferDepthSize) &&
+ (red <= pDriver->redDepth) &&
+ (green <= pDriver->greenDepth) &&
+ (blue <= pDriver->blueDepth)&&
+ (stencilDepth)<= deviceInfo->maxStencilDepthSize)
+ {
+ // first 0-7bits for depth,8-15 Stencil
+ retValue = depth |(stencilDepth <<8);
+ }
}
}
unlock();
}
- if (mx_ptr[ANTIALIASING] == REQUIRED) {
- if (Java_javax_media_j3d_NativeConfigTemplate3D_isSceneAntialiasingMultisampleAvailable(env, obj, 0, JNI_TRUE, screen) == JNI_TRUE)
+ if (mx_ptr[ANTIALIASING] == REQUIRED)
+ {
+ if (Java_javax_media_j3d_NativeConfigTemplate3D_isSceneAntialiasingMultisampleAvailable(env, obj, 0, JNI_TRUE, screen) == JNI_TRUE)
{
- retValue |= (1 << 31);
- } else {
- retValue = -1;
- }
+ retValue |= (1 << 31);
+ }
+ else
+ {
+ retValue = -1;
+ }
}
-
return retValue;
}
@@ -136,13 +151,22 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
/*
* Class: javax_media_j3d_NativeConfigTemplate3D
* Method: getStencilSize
- * Signature: (JZ)I
- * @TODO: FIX THIS !!!!!
+ * Signature: (JZ)I *
*/
JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_getStencilSize
- (JNIEnv *, jobject, jlong, jboolean)
+ (JNIEnv *env, jobject obj, jlong pFormatInfo, jboolean offScreen)
{
- // dummy value
-
- return 8;
+ int stencilSize = (int)pFormatInfo;
+
+ stencilSize = (stencilSize >> 8) & 0xff;
+
+ /** // next version pFormatInfo will be a D3DFORMAT value or index for
+ D3DFORMAT fmt = d3dCtx->deviceInfo->depthStencilFormat;
+ if (fmt == D3DFMT_D15S1) stencilSize = 1;
+ else
+ if (fmt == D3DFMT_D24X4S4) stencilSize = 4;
+ else
+ if(fmt == D3DFMT_D24S8)stencilSize = 8;
+ */
+ return stencilSize;
}