diff options
author | Alessandro Borges <[email protected]> | 2006-11-03 20:23:51 +0000 |
---|---|---|
committer | Alessandro Borges <[email protected]> | 2006-11-03 20:23:51 +0000 |
commit | c98a3e3f48f46c6cc75fe9f630c267702f3473d5 (patch) | |
tree | 0065dd83bdbc602abc4ead481ec168fa3515e26c /src/native/d3d | |
parent | 2f2aff63657e093a2c5482b4c0c9895124644c75 (diff) |
Issue 219 - Support for Non Power of Two texture size
check cap-bits D3DPTEXTURECAPS_POW2 and
D3DPTEXTURECAPS_NONPOW2CONDITIONAL if vcards support NPOT textures.
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@739 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/native/d3d')
-rw-r--r-- | src/native/d3d/D3dDeviceInfo.cpp | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/native/d3d/D3dDeviceInfo.cpp b/src/native/d3d/D3dDeviceInfo.cpp index 89a38b9..6511987 100644 --- a/src/native/d3d/D3dDeviceInfo.cpp +++ b/src/native/d3d/D3dDeviceInfo.cpp @@ -24,8 +24,7 @@ D3dDeviceInfo::~D3dDeviceInfo() VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) { - if (deviceType == D3DDEVTYPE_HAL ) - { + if (deviceType == D3DDEVTYPE_HAL ){ isHardware = true; isHardwareTnL = (d3dCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT); } @@ -35,6 +34,51 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) isHardwareTnL = false; } + + // D3DTEXTURECAPS_NONPOW2CONDITIONAL caps-bit indicates "conditional" + // Non Power of Two (NPOT) + // textures that only support CLAMP addressing and don't + // support mipmaps or compressed textures. + // But some new vcards supports NP2 unconditional (GF6 and above). + // Correct test for any kind of NP2 support: + // If both unconditional and conditional support is + // unavailable then NP2 is not possible anyway. + // ------------------------------------------- + // POW2 | NP2_CONDITIONAL | result + // ------------------------------------------- + // true | true | CONDITIONAL NPOT(*) + // true | false | POW2 Only + // false| any | UNConditional NPOT (**) // + // --------------------------------------------- + // (**)OpenGL like, Java3D preferred. + // (*) below test: + /* + * if (((d3dCaps->TextureCaps & D3DPTEXTURECAPS_POW2) != 0) && // POW2 is true + * ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == 0)){ //NPOT_Cond is false + * //Pow2 Only + * supportNPOT = false; + * } + * else{ + * // both conditional and unconditional + * supportNPOT = true; + * } + */ + if(d3dCaps->TextureCaps & D3DPTEXTURECAPS_POW2){ + supportNPOT = false; + if(d3dCaps->TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL){ + // NPOT conditionl But, in certain cases textures can ignore the power of 2 limitation + // As OpenGL is UNCONDITIONAL, it is not used by Java3D + //supportNPOT = true; + } + }else{ + //UNconditional: Textures do not need to be a power of 2 in size + supportNPOT = true; + } + + + + + // check if it supports at least vertex shader 1.1 if(d3dCaps->VertexShaderVersion < D3DVS_VERSION(1,1)) { @@ -167,6 +211,10 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) texMask = 0; + if(supportNPOT){ + texMask |= javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO; + } + if ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) && (maxTextureDepth > 0)) { @@ -216,8 +264,7 @@ void D3dDeviceInfo::findDepthStencilFormat(int minZDepth, int minZDepthStencil) for (int i=0; i < D3DDEPTHFORMATSIZE; i++) { //printf("\ndepthFormatSupport %s, %b",getPixelFormatName(d3dDepthFormat[i]), depthFormatSupport[i]); - if (depthFormatSupport[i]) - { + if (depthFormatSupport[i]){ // prefer one with stencil buffer, follow by D3DFMT_D16_LOCKABLE, // printf("\n ZDepth %d, Stencil %d ",d3dDepthTable[i],d3dStencilDepthTable[i]); if (d3dDepthTable[i] >= minZDepth && d3dStencilDepthTable[i] >= minZDepthStencil ) |