summaryrefslogtreecommitdiffstats
path: root/src/native/d3d
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2005-10-17 22:56:23 +0000
committerKevin Rushforth <[email protected]>2005-10-17 22:56:23 +0000
commit356bbf2bd325380e16fd77d34fffd084dc1c0928 (patch)
tree1d67b61e1a427baa49047341ee825bca9b423553 /src/native/d3d
parent68449b2071392af151a75f90610026465c426401 (diff)
Merged changes from dev-1_4 branch into the main trunk.
NOTE: all 1.4 development will now proceed on the main trunk. The dev-1_4 branch is closed. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@445 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/native/d3d')
-rw-r--r--src/native/d3d/Attributes.cpp164
-rw-r--r--src/native/d3d/Canvas3D.cpp38
-rw-r--r--src/native/d3d/CompressedGeometryRetained.cpp39
-rw-r--r--src/native/d3d/D3dCtx.cpp652
-rw-r--r--src/native/d3d/D3dCtx.hpp113
-rw-r--r--src/native/d3d/D3dDeviceInfo.cpp183
-rw-r--r--src/native/d3d/D3dDeviceInfo.hpp23
-rw-r--r--src/native/d3d/D3dDisplayList.cpp72
-rw-r--r--src/native/d3d/D3dDriverInfo.cpp79
-rw-r--r--src/native/d3d/D3dDriverInfo.hpp4
-rw-r--r--src/native/d3d/D3dImageComponent.cpp4
-rw-r--r--src/native/d3d/D3dImageComponent.hpp6
-rw-r--r--src/native/d3d/D3dUtil.cpp2652
-rw-r--r--src/native/d3d/D3dUtil.hpp56
-rw-r--r--src/native/d3d/D3dVertexBuffer.cpp29
-rw-r--r--src/native/d3d/D3dVertexBuffer.hpp11
-rw-r--r--src/native/d3d/GeometryArrayRetained.cpp215
-rw-r--r--src/native/d3d/GraphicsContext3D.cpp10
-rw-r--r--src/native/d3d/Lights.cpp6
-rw-r--r--src/native/d3d/NativeAPIInfo.c4
-rw-r--r--src/native/d3d/NativeConfigTemplate3D.cpp15
-rw-r--r--src/native/d3d/RasterRetained.cpp12
-rw-r--r--src/native/d3d/StdAfx.h17
-rw-r--r--src/native/d3d/build-windows-i586-vc.xml5
24 files changed, 2453 insertions, 1956 deletions
diff --git a/src/native/d3d/Attributes.cpp b/src/native/d3d/Attributes.cpp
index 6d97058..c4fd82f 100644
--- a/src/native/d3d/Attributes.cpp
+++ b/src/native/d3d/Attributes.cpp
@@ -306,7 +306,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setViewport(
width = d3dCtx->devmode.dmPelsWidth;
height = d3dCtx->devmode.dmPelsHeight;
}
- D3DVIEWPORT8 vp = {x, y, width, height, 0.0f, 1.0f};
+ D3DVIEWPORT9 vp = {x, y, width, height, 0.0f, 1.0f};
device->SetViewport(&vp);
}
@@ -422,11 +422,21 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative(
jboolean db_enable_override,
jboolean db_enable,
jboolean db_write_enable,
+ jint db_func,
jfloat at_value,
jint at_func,
jboolean ignoreVertexColors,
jboolean rasterOpEnable,
- jint rasterOp)
+ jint rasterOp,
+ jboolean userStencilAvailable,
+ jboolean stencilEnable,
+ jint stencilFailOp,
+ jint stencilZFailOp,
+ jint stencilZPassOp,
+ jint stencilFunction,
+ jint stencilReferenceValue,
+ jint stencilCompareMask,
+ jint stencilWriteMask)
{
GetDevice();
@@ -499,7 +509,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPolygonAttributes(
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
d3dCtx->twoSideLightingEnable = false;
- device->SetRenderState(D3DRS_ZBIAS, 0);
+ device->SetRenderState(D3DRS_DEPTHBIAS, 0);
}
@@ -535,7 +545,7 @@ void JNICALL Java_javax_media_j3d_PolygonAttributesRetained_updateNative(
}
}
- device->SetRenderState(D3DRS_ZBIAS, zbias_w);
+ device->SetRenderState(D3DRS_DEPTHBIAS, zbias_w);
if (cullFace == javax_media_j3d_PolygonAttributes_CULL_NONE) {
d3dCtx->cullMode = D3DCULL_NONE;
@@ -582,14 +592,16 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes(
// D3D don't support Line width
// glLineWidth(1);
-
+ //D3D9 doesnot support line Patterns
+ // must update this to use ID3DXLine Interface
+/*
D3DLINEPATTERN pattern;
pattern.wRepeatFactor = 0;
pattern.wLinePattern = 0;
device->SetRenderState(D3DRS_LINEPATTERN,
*((LPDWORD) (&pattern)));
-
+*/
}
@@ -608,7 +620,8 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative(
{
GetDevice();
- D3DLINEPATTERN pattern;
+ //Alessandro
+ //D3DLINEPATTERN pattern;
/*
if (lineWidth > 1) {
@@ -619,12 +632,14 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative(
}
*/
// glLineWidth(lineWidth);
-
+ /** Alessandro
if (linePattern == javax_media_j3d_LineAttributes_PATTERN_SOLID) {
pattern.wRepeatFactor = 0;
pattern.wLinePattern = 0;
} else {
+ **/
+
/*
if (!d3dCtx->deviceInfo->linePatternSupport) {
if (debug && !isLinePatternMessOutput) {
@@ -633,6 +648,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative(
}
}
*/
+ /** alessandro
if (linePattern == javax_media_j3d_LineAttributes_PATTERN_DASH) { // dashed lines
pattern.wRepeatFactor = 1;
pattern.wLinePattern = 0x00ff;
@@ -650,7 +666,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative(
device->SetRenderState(D3DRS_LINEPATTERN,
*((LPDWORD) (&pattern)));
-
+ **/
/*
if (lineAntialiasing == JNI_TRUE) {
glEnable (GL_LINE_SMOOTH);
@@ -1378,7 +1394,7 @@ void JNICALL Java_javax_media_j3d_MaterialRetained_updateNative(
jint colorTarget,
jboolean lightEnable)
{
- D3DMATERIAL8 material;
+ D3DMATERIAL9 material;
GetDevice();
@@ -1650,8 +1666,8 @@ void JNICALL Java_javax_media_j3d_TextureRetained_bindTexture(
if (objectId >= d3dCtx->textureTableLen) {
DWORD i;
DWORD len = max(objectId+1, d3dCtx->textureTableLen << 1);
- LPDIRECT3DTEXTURE8 *newTable = (LPDIRECT3DTEXTURE8 *)
- malloc(sizeof(LPDIRECT3DTEXTURE8) * len);
+ LPDIRECT3DTEXTURE9 *newTable = (LPDIRECT3DTEXTURE9 *)
+ malloc(sizeof(LPDIRECT3DTEXTURE9) * len);
if (newTable == NULL) {
printf("Not enough memory to alloc texture table of size %d.\n", len);
@@ -1698,31 +1714,31 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes(
switch (minFilter) {
case javax_media_j3d_Texture_FASTEST:
case javax_media_j3d_Texture_BASE_LEVEL_POINT:
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MINFILTER, D3DTEXF_POINT);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MIPFILTER, D3DTEXF_POINT);
+ device->SetSamplerState(d3dCtx->texUnitStage,
+ D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MIPFILTER, D3DTEXF_POINT);
break;
case javax_media_j3d_Texture_BASE_LEVEL_LINEAR:
- d3dCtx->texLinearMode = true;
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MINFILTER, D3DTEXF_LINEAR);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MIPFILTER, D3DTEXF_POINT);
+ d3dCtx->texLinearMode = true;
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MIPFILTER, D3DTEXF_POINT);
break;
case javax_media_j3d_Texture_MULTI_LEVEL_POINT:
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MINFILTER, D3DTEXF_POINT);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
break;
case javax_media_j3d_Texture_NICEST:
case javax_media_j3d_Texture_MULTI_LEVEL_LINEAR:
d3dCtx->texLinearMode = true;
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MINFILTER, D3DTEXF_LINEAR);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
break;
}
@@ -1730,14 +1746,14 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes(
switch (magFilter) {
case javax_media_j3d_Texture_FASTEST:
case javax_media_j3d_Texture_BASE_LEVEL_POINT:
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MAGFILTER, D3DTEXF_POINT);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MAGFILTER, D3DTEXF_POINT);
break;
case javax_media_j3d_Texture_NICEST:
case javax_media_j3d_Texture_BASE_LEVEL_LINEAR:
d3dCtx->texLinearMode = true;
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
break;
}
@@ -1797,19 +1813,19 @@ void updateTextureBoundary(JNIEnv *env,
switch (boundaryModeS) {
case javax_media_j3d_Texture_WRAP:
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSU,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSU,
D3DTADDRESS_WRAP);
break;
case javax_media_j3d_Texture_CLAMP:
if (!d3dCtx->texLinearMode || !d3dCtx->deviceInfo->texBorderModeSupport) {
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSU,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSU,
D3DTADDRESS_CLAMP);
} else {
useBorderMode = TRUE;
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSU,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSU,
D3DTADDRESS_BORDER);
}
break;
@@ -1817,19 +1833,19 @@ void updateTextureBoundary(JNIEnv *env,
switch (boundaryModeT) {
case javax_media_j3d_Texture_WRAP:
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSV,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSV,
D3DTADDRESS_WRAP);
break;
case javax_media_j3d_Texture_CLAMP:
if (!d3dCtx->texLinearMode || !d3dCtx->deviceInfo->texBorderModeSupport) {
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSV,
- D3DTADDRESS_CLAMP);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSV,
+ D3DTADDRESS_CLAMP);
} else {
useBorderMode = TRUE;
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSV,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSV,
D3DTADDRESS_BORDER);
}
break;
@@ -1838,19 +1854,19 @@ void updateTextureBoundary(JNIEnv *env,
if (boundaryModeR >= 0) {
switch (boundaryModeR) {
case javax_media_j3d_Texture_WRAP:
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSW,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSW,
D3DTADDRESS_WRAP);
break;
case javax_media_j3d_Texture_CLAMP:
if (!d3dCtx->texLinearMode || !d3dCtx->deviceInfo->texBorderModeSupport) {
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSW,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSW,
D3DTADDRESS_CLAMP);
} else {
useBorderMode = TRUE;
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_ADDRESSW,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_ADDRESSW,
D3DTADDRESS_BORDER);
}
break;
@@ -1861,8 +1877,8 @@ void updateTextureBoundary(JNIEnv *env,
D3DCOLOR color = D3DCOLOR_COLORVALUE(boundaryRed, boundaryGreen,
boundaryBlue, boundaryAlpha);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_BORDERCOLOR,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_BORDERCOLOR,
*((DWORD *) &color));
}
}
@@ -1918,24 +1934,24 @@ void updateTextureAnisotropicFilter(
DWORD deg = degree + 0.5f; // round float to int
// This will overwrite the previous setting in
// updateTextureFilterModes()
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MINFILTER,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MINFILTER,
D3DTEXF_ANISOTROPIC);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MAGFILTER,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MAGFILTER,
D3DTEXF_ANISOTROPIC);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MIPFILTER,
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MIPFILTER,
D3DTEXF_ANISOTROPIC);
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MAXANISOTROPY, deg);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MAXANISOTROPY, deg);
} else {
// updateTextureFilterModes() will always invoke before
// updateTextureAnisotropicFilter() to set Filter mode
// correctly.
- device->SetTextureStageState(d3dCtx->texUnitStage,
- D3DTSS_MAXANISOTROPY, 1);
+ device->SetSamplerState (d3dCtx->texUnitStage,
+ D3DSAMP_MAXANISOTROPY, 1);
}
}
@@ -2010,7 +2026,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSubImage(
return;
}
- LPDIRECT3DTEXTURE8 surf = d3dCtx->textureTable[currBindTex];
+ LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[currBindTex];
if ((surf == NULL) ||
((level > 0) && (!d3dCtx->deviceInfo->supportMipmap))) {
@@ -2074,7 +2090,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureImage(
return;
}
- LPDIRECT3DTEXTURE8 surf = d3dCtx->textureTable[currBindTex];
+ LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[currBindTex];
if (level == 0) {
if (surf != NULL) {
@@ -2225,8 +2241,8 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_bindTexture(
if (objectId >= d3dCtx->volumeTableLen) {
DWORD i;
DWORD len = max(objectId+1, d3dCtx->volumeTableLen << 1);
- LPDIRECT3DVOLUMETEXTURE8 *newTable = (LPDIRECT3DVOLUMETEXTURE8 *)
- malloc(sizeof(LPDIRECT3DVOLUMETEXTURE8) * len);
+ LPDIRECT3DVOLUMETEXTURE9 *newTable = (LPDIRECT3DVOLUMETEXTURE9 *)
+ malloc(sizeof(LPDIRECT3DVOLUMETEXTURE9) * len);
if (newTable == NULL) {
printf("Not enough memory to alloc volume texture table of size %d.\n", len);
@@ -2371,7 +2387,7 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage(
return;
}
- LPDIRECT3DVOLUMETEXTURE8 surf = d3dCtx->volumeTable[currBindTex];
+ LPDIRECT3DVOLUMETEXTURE9 surf = d3dCtx->volumeTable[currBindTex];
if (level == 0) {
if (surf != NULL) {
@@ -2465,7 +2481,7 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage(
return;
}
- LPDIRECT3DVOLUMETEXTURE8 surf = d3dCtx->volumeTable[currBindTex];
+ LPDIRECT3DVOLUMETEXTURE9 surf = d3dCtx->volumeTable[currBindTex];
if ((surf == NULL) ||
((level > 0) && (!d3dCtx->deviceInfo->supportMipmap))) {
@@ -2520,8 +2536,8 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_bindTexture(
if (objectId >= d3dCtx->cubeMapTableLen) {
DWORD i;
DWORD len = max(objectId+1, d3dCtx->cubeMapTableLen << 1);
- LPDIRECT3DCUBETEXTURE8 *newTable = (LPDIRECT3DCUBETEXTURE8 *)
- malloc(sizeof(LPDIRECT3DCUBETEXTURE8) * len);
+ LPDIRECT3DCUBETEXTURE9 *newTable = (LPDIRECT3DCUBETEXTURE9 *)
+ malloc(sizeof(LPDIRECT3DCUBETEXTURE9) * len);
if (newTable == NULL) {
printf("Not enough memory to alloc cubeMap table of size %d.\n", len);
@@ -2641,7 +2657,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureSubImage(
return;
}
- LPDIRECT3DCUBETEXTURE8 surf = d3dCtx->cubeMapTable[currBindTex];
+ LPDIRECT3DCUBETEXTURE9 surf = d3dCtx->cubeMapTable[currBindTex];
if ((surf == NULL) ||
((level > 0) && (!d3dCtx->deviceInfo->supportMipmap))) {
@@ -2707,7 +2723,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage(
return;
}
- LPDIRECT3DCUBETEXTURE8 surf = d3dCtx->cubeMapTable[currBindTex];
+ LPDIRECT3DCUBETEXTURE9 surf = d3dCtx->cubeMapTable[currBindTex];
if (level == 0) {
if (surf != NULL) {
diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp
index 4195f14..3636e6d 100644
--- a/src/native/d3d/Canvas3D.cpp
+++ b/src/native/d3d/Canvas3D.cpp
@@ -55,9 +55,11 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext(
jlong fbConfigListPtr,
jlong sharedCtx,
jboolean isSharedCtx,
- jboolean offScreen)
+ jboolean offScreen,
+ jboolean glslLibraryAvailable,
+ jboolean cgLibraryAvailable)
{
- HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(window));
+ HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(jlong(window)));
lock();
D3dCtx* ctx = new D3dCtx(env, obj, hwnd, offScreen, vid);
@@ -109,9 +111,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext(
jlong fbConfigListPtr,
jboolean offScreen,
jint width,
- jint height)
+ jint height,
+ jboolean glslLibraryAvailable,
+ jboolean cgLibraryAvailable)
{
- HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(window));
+ HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(jlong(window)));
lock();
// always use offscreen for property since it
@@ -187,7 +191,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_composite(
// However we use the following texturemapping function instead
// so this will not invoke.
if (d3dCtx->backSurface == NULL) {
- device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO,
+ device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO,//iSwapChain is 0
&d3dCtx->backSurface);
}
jbyte *byteData = (jbyte *) (env->GetPrimitiveArrayCritical(
@@ -262,7 +266,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping(
env, texture, ctx, 0, minX, minY, J3D_RGBA, format,
minX, minY, rasWidth, maxX-minX, maxY-minY, imageYdown);
- LPDIRECT3DTEXTURE8 surf = d3dCtx->textureTable[objectId];
+ LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[objectId];
if (surf == NULL) {
if (debug) {
@@ -366,7 +370,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear(
id = env->GetFieldID(pa2d_class, "height", "I");
int height = env->GetIntField(pa2d, id);
- LPDIRECT3DTEXTURE8 surf;
+ LPDIRECT3DTEXTURE9 surf;
if ((d3dImage == NULL) || (d3dImage->surf == NULL)) {
surf = createSurfaceFromImage(env, pa2d, ctx,
@@ -420,11 +424,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear(
sw = winWidth/(float) width;
sh = winHeight/(float) height;
if (sw >= sh) {
- scaleWidth = width*sh;
+ scaleWidth = int(width*sh);
scaleHeight = winHeight;
} else {
scaleWidth = winWidth;
- scaleHeight = height*sw;
+ scaleHeight = int(height*sw);
}
texModeRepeat = FALSE;
break;
@@ -435,9 +439,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear(
sh = winHeight/(float) height;
if (sw >= sh) {
scaleWidth = winWidth;
- scaleHeight = height*sw;
+ scaleHeight = int(height*sw);
} else {
- scaleWidth = width*sh;
+ scaleWidth = int(width*sh);
scaleHeight = winHeight;
}
texModeRepeat = FALSE;
@@ -551,7 +555,7 @@ VOID freePointerList()
if (useFreePointerList0) {
if (freePointerList1.size() > 0) {
lockSurfaceList();
- for (void **p = freePointerList1.begin();
+ for (ITER_VOID p = freePointerList1.begin();
p != freePointerList1.end(); ++p) {
delete (*p);
}
@@ -563,7 +567,7 @@ VOID freePointerList()
} else {
if (freePointerList0.size() > 0) {
lockSurfaceList();
- for (void **p = freePointerList0.begin();
+ for (ITER_VOID p = freePointerList0.begin();
p != freePointerList0.end(); ++p) {
delete (*p);
}
@@ -599,7 +603,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers(
if (D3DERR_DEVICENOTRESET == hr) {
if (debug) {
printf("Buffer swap error %s, try Reset() the surface... \n",
- DXGetErrorString8(hr));
+ DXGetErrorString9(hr));
}
retCode = d3dCtx->resetSurface(env, obj);
GetDevice2();
@@ -607,7 +611,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers(
if (FAILED(hr)) {
if (debug) {
printf("Buffer swap error %s \n",
- DXGetErrorString8(hr));
+ DXGetErrorString9(hr));
}
}
}
@@ -891,11 +895,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_readOffScreenBuffer(
}
if (d3dCtx->backSurface == NULL) {
- HRESULT hr = device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO,
+ HRESULT hr = device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO, //iSwapChain is 0
&d3dCtx->backSurface);
if (FAILED(hr)) {
printf("[Java 3D] GetBackBuffer fail %s\n",
- DXGetErrorString8(hr));
+ DXGetErrorString9(hr));
return;
}
}
diff --git a/src/native/d3d/CompressedGeometryRetained.cpp b/src/native/d3d/CompressedGeometryRetained.cpp
deleted file mode 100644
index df44ebb..0000000
--- a/src/native/d3d/CompressedGeometryRetained.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * Use is subject to license terms.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-#include "StdAfx.h"
-
-extern "C" JNIEXPORT
-void JNICALL Java_javax_media_j3d_CompressedGeometryRetained_execute
- (JNIEnv *env, jobject obj, jlong ctx, jint version, jint bufferType,
- jint bufferContents, jint renderFlags, jint offset, jint size,
- jbyteArray geometry)
-{
- // Not support by D3D, problem should not call this.
- printf("Error: CompressedGeometryRetained execute should not invoke by D3D");
-}
-
-extern "C" JNIEXPORT
-jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressByRef
- (JNIEnv *env, jobject obj, jlong ctx)
-{
- // Not support by D3D
- return JNI_FALSE ;
-}
-
-extern "C" JNIEXPORT
-jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressHW
- (JNIEnv *env, jobject obj, jlong ctx, jint majorVersion, jint minorVersion)
-{
- // Not support by D3D
- return JNI_FALSE ;
-}
diff --git a/src/native/d3d/D3dCtx.cpp b/src/native/d3d/D3dCtx.cpp
index 05f0bc5..85c81b6 100644
--- a/src/native/d3d/D3dCtx.cpp
+++ b/src/native/d3d/D3dCtx.cpp
@@ -20,14 +20,14 @@ D3dCtxVector d3dCtxList;
* D3dCtx ctx* = new D3dCtx(env, obj, hwnd, offScreen, vid);
* if (ctx->initialize(env, obj)) {
* delete ctx;
- * }
+ * }
* d3dCtxList.push_back(ctx);
- *
+ *
*
* When ctx remove :
*
* d3dCtxList.erase(find(d3dCtxList.begin(), d3dCtxList.end(), ctx);
- * delete ctx;
+ * delete ctx;
*
*/
@@ -37,10 +37,10 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
jint vid)
{
int i;
-
+ jniEnv = env;
monitor = NULL;
hwnd = _hwnd;
- pD3D = NULL;
+ pD3D = NULL;
pDevice = NULL;
offScreen = _offScreen;
offScreenWidth = 0;
@@ -57,6 +57,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
inToggle = false;
useFreeList0 = true;
reIndexifyTable = NULL;
+ bFastDrawQuads = getSystemProperty(env,"j3d.d3dForceFastQuads","true");
// set default RenderingState variable
cullMode = D3DCULL_CW;
@@ -107,37 +108,37 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
bindTextureId = NULL;
bindTextureIdLen = 0;
- textureTable = (LPDIRECT3DTEXTURE8 *) malloc(
- sizeof(LPDIRECT3DTEXTURE8) * TEXTURETABLESIZE);
+ textureTable = (LPDIRECT3DTEXTURE9 *) malloc(
+ sizeof(LPDIRECT3DTEXTURE9) * TEXTURETABLESIZE);
if (textureTable == NULL) {
error(OUTOFMEMORY);
exit(1);
}
- ZeroMemory(textureTable, sizeof(LPDIRECT3DTEXTURE8)*TEXTURETABLESIZE);
+ ZeroMemory(textureTable, sizeof(LPDIRECT3DTEXTURE9)*TEXTURETABLESIZE);
textureTableLen = TEXTURETABLESIZE;
bindTextureId = NULL;
- volumeTable = (LPDIRECT3DVOLUMETEXTURE8 *) malloc(
- sizeof(LPDIRECT3DVOLUMETEXTURE8) * TEXTURETABLESIZE);
+ volumeTable = (LPDIRECT3DVOLUMETEXTURE9 *) malloc(
+ sizeof(LPDIRECT3DVOLUMETEXTURE9) * TEXTURETABLESIZE);
if (volumeTable == NULL) {
error(OUTOFMEMORY);
exit(1);
}
- ZeroMemory(volumeTable, sizeof(LPDIRECT3DVOLUMETEXTURE8)*TEXTURETABLESIZE);
+ ZeroMemory(volumeTable, sizeof(LPDIRECT3DVOLUMETEXTURE9)*TEXTURETABLESIZE);
volumeTableLen = TEXTURETABLESIZE;
- cubeMapTable = (LPDIRECT3DCUBETEXTURE8 *) malloc(
- sizeof(LPDIRECT3DCUBETEXTURE8) * TEXTURETABLESIZE);
+ cubeMapTable = (LPDIRECT3DCUBETEXTURE9 *) malloc(
+ sizeof(LPDIRECT3DCUBETEXTURE9) * TEXTURETABLESIZE);
if (cubeMapTable == NULL) {
error(OUTOFMEMORY);
exit(1);
}
- ZeroMemory(cubeMapTable, sizeof(LPDIRECT3DCUBETEXTURE8)*TEXTURETABLESIZE);
+ ZeroMemory(cubeMapTable, sizeof(LPDIRECT3DCUBETEXTURE9)*TEXTURETABLESIZE);
cubeMapTableLen = TEXTURETABLESIZE;
@@ -152,14 +153,14 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
if (d3dDriverList == NULL) {
// keep trying to initialize even though
- // last time it fail.
+ // last time it fail.
D3dDriverInfo::initialize(env);
}
if (d3dDriverList == NULL) {
/*
* This happen when either
- * (1) D3D v8.0 not install or
+ * (1) D3D v9.0 not install or
* (2) Not enough memory or
* (3) No adapter found in the system.
*/
@@ -167,13 +168,13 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
return;
}
- pD3D = Direct3DCreate8( D3D_SDK_VERSION );
+ pD3D = Direct3DCreate9( D3D_SDK_VERSION );
if (pD3D == NULL) {
error(D3DNOTFOUND);
return;
}
- // find current monitor handle before
+ // find current monitor handle before
// get current display mode
monitor = findMonitor();
@@ -185,7 +186,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
warning(NEEDSWITCHMODE);
}
- // find the adapter for this
+ // find the adapter for this
setDriverInfo();
GetWindowRect(topHwnd, &savedTopRect);
@@ -193,9 +194,9 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
for (i=0; i < 4; i++) {
rasterRect[i].sx = 0;
- rasterRect[i].sy = 0;
+ rasterRect[i].sy = 0;
rasterRect[i].sz = 0;
- rasterRect[i].rhw = 0;
+ rasterRect[i].rhw = 0;
}
rasterRect[0].tu = 0;
@@ -216,7 +217,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen,
GetWindowRect(hwnd, &windowRect);
}
-D3dCtx::~D3dCtx()
+D3dCtx::~D3dCtx()
{
release();
SafeRelease(pD3D);
@@ -270,7 +271,7 @@ VOID D3dCtx::releaseTexture()
D3dImageComponent::remove(&BackgroundImageList, this);
unlockBackground();
- // free list0
+ // free list0
freeList();
// free list1
freeList();
@@ -281,7 +282,7 @@ VOID D3dCtx::setViewport()
int renderWidth = getWidth();
int renderHeight = getHeight();
HRESULT hr;
- D3DVIEWPORT8 vp = {0, 0, renderWidth, renderHeight, 0.0f, 1.0f};
+ D3DVIEWPORT9 vp = {0, 0, renderWidth, renderHeight, 0.0f, 1.0f};
hr = pDevice->SetViewport( &vp );
@@ -314,14 +315,15 @@ VOID D3dCtx::releaseVB()
while (p != NULL) {
vbVector = p->vbVector;
if (vbVector != NULL) {
- for (r = vbVector->begin(); r != vbVector->end(); ++r) {
+ for (ITER_LPD3DVERTEXBUFFER r = vbVector->begin();
+ r != vbVector->end(); ++r) {
if (*r == p) {
vbVector->erase(r);
found = true;
break;
}
}
- }
+ }
q = p;
p = p->next;
delete q;
@@ -352,7 +354,7 @@ VOID D3dCtx::release()
quadIndexBufferSize = 0;
releaseVB();
- // trying to free VertexBuffer
+ // trying to free VertexBuffer
// This will crash the driver if Indices/StreamSource
// Not set before.
// pDevice->SetIndices(NULL, 0);
@@ -360,7 +362,7 @@ VOID D3dCtx::release()
SafeRelease(depthStencilSurface);
SafeRelease(frontSurface);
SafeRelease(backSurface);
-
+
SafeRelease(pDevice);
currDisplayListID = 0;
multiTextureSupport = false;
@@ -397,7 +399,7 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
oldWidth = offScreenWidth;
offScreenWidth = driverInfo->desktopMode.Width;
needBiggerRenderSurface = true;
-
+
}
if (offScreenHeight > driverInfo->desktopMode.Height) {
@@ -410,7 +412,7 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
needBiggerRenderSurface = true;
}
*/
-
+
if (!bFullScreen) {
getScreenRect(hwnd, &savedClientRect);
CopyMemory(&screenRect, &savedClientRect, sizeof (RECT));
@@ -419,21 +421,22 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
dwBehavior = findBehavior();
if (debug) {
- printf("Use %s, ", driverInfo->adapterIdentifier.Description);
-
+ printf("[Java3D]: Use %s, ", driverInfo->adapterIdentifier.Description);
+
if (deviceInfo->isHardwareTnL &&
- (dwBehavior == D3DCREATE_SOFTWARE_VERTEXPROCESSING)) {
+ (dwBehavior == D3DCREATE_SOFTWARE_VERTEXPROCESSING))
+ {
// user select non-TnL device
printf("Hardware Rasterizer\n");
} else {
- printf("%s \n", deviceInfo->deviceName);
+ printf("%s (TnL) \n", deviceInfo->deviceName);
}
}
setPresentParams(env, obj);
-
+
if (debug) {
- printf("\nCreate device :\n");
+ printf("\n[Java3D]: Create device :\n");
printInfo(&d3dPresent);
}
@@ -441,27 +444,75 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
if ((d3dPresent.BackBufferWidth <= 0) ||
(d3dPresent.BackBufferHeight <= 0)) {
if (debug) {
- printf("D3D: Can't create device of buffer size %dx%d\n",
+ printf("[Java3D]: D3D: Can't create device of buffer size %dx%d\n",
d3dPresent.BackBufferWidth,
d3dPresent.BackBufferHeight);
}
return false;
}
- hr = pD3D->CreateDevice(driverInfo->iAdapter,
+if(bUseNvPerfHUD)
+{
+ // using NVIDIA NvPerfHUD profiler
+ printf("\n[Java3D]: running in NVIDIA NvPerfHUD mode:");
+ UINT adapterToUse=driverInfo->iAdapter;
+ D3DDEVTYPE deviceType=deviceInfo->deviceType;
+ DWORD behaviorFlags = dwBehavior;
+ bool isHUDavail = false;
+
+ // Look for 'NVIDIA NVPerfHUD' adapter
+ // If it is present, override default settings
+ for (UINT adapter=0;adapter<pD3D->GetAdapterCount(); adapter++)
+ {
+ D3DADAPTER_IDENTIFIER9 identifier;
+ HRESULT Res=pD3D->GetAdapterIdentifier(adapter,0,&identifier);
+ printf("\n Adapter identifier : %s",identifier.Description);
+ if (strcmp(identifier.Description,"NVIDIA NVPerfHUD")==0)
+ {
+ adapterToUse=adapter;
+ deviceType=D3DDEVTYPE_REF;
+ behaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
+ isHUDavail = true;
+ printf("\n[Java3D]: found a NVIDIA NvPerfHUD adapter");
+ break;
+ }
+ }
+ hr = pD3D->CreateDevice( adapterToUse,
+ deviceType,
+ topHwnd,
+ behaviorFlags,
+ &d3dPresent,
+ &pDevice);
+ if(!FAILED(hr)&& isHUDavail)
+ {
+ printf("\n[Java3D]: Using NVIDIA NvPerfHUD ! \n");
+ }
+ else
+ {
+ printf("\n[Java3D]: No suitable device found for NVIDIA NvPerfHUD ! \n");
+ }
+}
+else
+{
+ // NORMAL Mode
+ hr = pD3D->CreateDevice(driverInfo->iAdapter,
deviceInfo->deviceType,
topHwnd,
dwBehavior,
&d3dPresent,
&pDevice);
+}
+
- if (FAILED(hr) && (requiredDeviceID < 0)) {
+ if (FAILED(hr) && (requiredDeviceID < 0))
+ {
+ printf("\n[Java3D]: Using D3DDEVTYPE_REF mode.\n");
if (deviceInfo->deviceType != D3DDEVTYPE_REF) {
// switch to reference mode
warning(CREATEDEVICEFAIL, hr);
deviceInfo = driverInfo->d3dDeviceList[DEVICE_REF];
- dwBehavior = findBehavior();
- deviceInfo->findDepthStencilFormat(minZDepth);
+ dwBehavior = findBehavior();
+ deviceInfo->findDepthStencilFormat(minZDepth);
d3dPresent.AutoDepthStencilFormat =
deviceInfo->depthStencilFormat;
if (deviceInfo->depthStencilFormat == D3DFMT_UNKNOWN) {
@@ -471,8 +522,8 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
return false;
}
if (debug) {
- printf("Fallback to create reference device :\n");
- printInfo(&d3dPresent);
+ printf("[Java3D]: Fallback to create reference device :\n");
+ printInfo(&d3dPresent);
}
hr = pD3D->CreateDevice(driverInfo->iAdapter,
@@ -482,12 +533,12 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
&d3dPresent,
&pDevice);
}
- }
+ }
/*
if (offScreen && needBiggerRenderSurface) {
- IDirect3DSurface8 *pRenderTarget;
- IDirect3DSurface8 *pStencilDepthTarget;
+ IDirect3DSurface9 *pRenderTarget;
+ IDirect3DSurface9 *pStencilDepthTarget;
hr = pDevice->CreateRenderTarget(oldWidth,
oldHeight,
@@ -495,9 +546,9 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
D3DMULTISAMPLE_NONE,
true,
&pRenderTarget);
-
+
if (FAILED(hr)) {
- printf("Fail to CreateRenderTarget %s\n", DXGetErrorString8(hr));
+ printf("Fail to CreateRenderTarget %s\n", DXGetErrorString9(hr));
} else {
hr = pDevice->CreateDepthStencilSurface(oldWidth,
oldHeight,
@@ -505,13 +556,13 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
D3DMULTISAMPLE_NONE,
&pStencilDepthTarget);
if (FAILED(hr)) {
- printf("Fail to CreateDepthStencilSurface %s\n", DXGetErrorString8(hr));
+ printf("Fail to CreateDepthStencilSurface %s\n", DXGetErrorString9(hr));
pRenderTarget->Release();
} else {
hr = pDevice->SetRenderTarget(pRenderTarget,
pStencilDepthTarget);
if (FAILED(hr)) {
- printf("Fail to SetRenderTarget %s\n", DXGetErrorString8(hr));
+ printf("Fail to SetRenderTarget %s\n", DXGetErrorString9(hr));
pRenderTarget->Release();
pStencilDepthTarget->Release();
} else {
@@ -541,8 +592,12 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
bindTextureIdLen = 1;
}
- jclass canvasCls = env->GetObjectClass(obj);
- jfieldID id = env->GetFieldID(canvasCls, "numTexCoordSupported", "I");
+
+ jclass canvasCls = env->GetObjectClass(obj);
+ jfieldID id;
+
+ // TODO check it !!!!
+ id = env->GetFieldID(canvasCls, "maxTexCoordSets", "I"); //was numtexCoordSupported
env->SetIntField(obj, id, TEXSTAGESUPPORT);
if (bindTextureIdLen > 1) {
@@ -551,9 +606,11 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
bindTextureIdLen = TEXSTAGESUPPORT;
}
multiTextureSupport = true;
- id = env->GetFieldID(canvasCls, "multiTexAccelerated", "Z");
+ id = env->GetFieldID(canvasCls, "multiTexAccelerated", "Z");
env->SetBooleanField(obj, id, JNI_TRUE);
- id = env->GetFieldID(canvasCls, "numTexUnitSupported", "I");
+
+ // TODO check it !!!!
+ id = env->GetFieldID(canvasCls, "maxTextureUnits", "I"); //was numTexUnitSupported
env->SetIntField(obj, id, bindTextureIdLen);
} else {
bindTextureIdLen = 1;
@@ -573,10 +630,10 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj)
if (debug && (deviceInfo != NULL)) {
if (multiTextureSupport) {
- printf("Max Texture Unit Stage support : %d \n",
+ printf("Max Texture Unit Stage support : %d \n",
deviceInfo->maxTextureBlendStages);
- printf("Max Simultaneous Texture unit support : %d \n",
+ printf("Max Simultaneous Texture unit support : %d \n",
deviceInfo->maxSimultaneousTextures);
} else {
printf("MultiTexture support : false\n");
@@ -606,7 +663,7 @@ INT D3dCtx::resize(JNIEnv *env, jobject obj)
BOOL moveRequest;
- GetWindowRect(hwnd, &windowRect);
+ GetWindowRect(hwnd, &windowRect);
if ((windowRect.right == screenRect.right) &&
(windowRect.left == screenRect.left) &&
@@ -624,22 +681,22 @@ INT D3dCtx::resize(JNIEnv *env, jobject obj)
moveRequest = false;
}
-
+
HMONITOR oldMonitor = monitor;
monitor = findMonitor();
- getScreenRect(hwnd, &screenRect);
+ getScreenRect(hwnd, &screenRect);
if (monitor != oldMonitor) {
- enumDisplayMode(&devmode);
+ enumDisplayMode(&devmode);
setDriverInfo();
release();
initialize(env, obj);
- return RECREATEDDRAW;
- }
+ return RECREATEDDRAW;
+ }
if (!moveRequest) {
-
+
retValue = resetSurface(env, obj);
if (retValue != RECREATEDFAIL) {
return retValue;
@@ -656,16 +713,16 @@ INT D3dCtx::toggleMode(BOOL _bFullScreen, JNIEnv *env, jobject obj)
INT retValue;
if ((pDevice == NULL) ||
- (!_bFullScreen &&
+ (!_bFullScreen &&
!deviceInfo->canRenderWindowed)) {
// driver did not support window mode
return NOCHANGE;
}
-
+
int onScreenCount = 0;
-
- for (D3dCtx **p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) {
- if (!(*p)->offScreen &&
+
+ for (ITER_D3dCtxVector p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) {
+ if (!(*p)->offScreen &&
// (monitor == (*p)->monitor) &&
(++onScreenCount > 1)) {
// don't toggle if there are more than one onScreen ctx exists
@@ -683,7 +740,7 @@ INT D3dCtx::toggleMode(BOOL _bFullScreen, JNIEnv *env, jobject obj)
if (retValue != RECREATEDFAIL) {
forceResize = true;
} else {
- // Switch back to window mode if fall to toggle fullscreen
+ // Switch back to window mode if fall to toggle fullscreen
// and vice versa
bFullScreen = !bFullScreen;
release();
@@ -729,7 +786,7 @@ VOID D3dCtx::setPresentParams(JNIEnv *env, jobject obj)
GetWindowRect(hwnd, &savedClientRect);
d3dPresent.Windowed = false;
- d3dPresent.hDeviceWindow = topHwnd;
+ d3dPresent.hDeviceWindow = topHwnd;
if ((antialiasing != UNNECESSARY) &&
deviceInfo->supportAntialiasing()) {
@@ -741,7 +798,10 @@ VOID D3dCtx::setPresentParams(JNIEnv *env, jobject obj)
d3dPresent.BackBufferHeight = driverInfo->desktopMode.Height;
d3dPresent.BackBufferFormat = driverInfo->desktopMode.Format;
d3dPresent.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
- d3dPresent.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ if (deviceInfo->supportRasterPresImmediate)
+ d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ else
+ d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
} else {
d3dPresent.Windowed = true;
@@ -757,7 +817,11 @@ VOID D3dCtx::setPresentParams(JNIEnv *env, jobject obj)
d3dPresent.BackBufferHeight = getHeight();
d3dPresent.BackBufferFormat = driverInfo->desktopMode.Format;
d3dPresent.FullScreen_RefreshRateInHz = 0;
- d3dPresent.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
+
+ if (deviceInfo->supportRasterPresImmediate)
+ d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ else
+ d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
@@ -788,15 +852,15 @@ INT D3dCtx::resetSurface(JNIEnv *env, jobject obj)
setPresentParams(env, obj);
if (debug) {
printf("\nReset Device :\n");
- printInfo(&d3dPresent);
- }
+ printInfo(&d3dPresent);
+ }
// Must release any non default pool surface, otherwise
// Reset() will fail
SafeRelease(depthStencilSurface);
SafeRelease(frontSurface);
SafeRelease(backSurface);
-
+
releaseVB();
SafeRelease(lineModeIndexBuffer);
quadIndexBufferSize = 0;
@@ -822,12 +886,12 @@ INT D3dCtx::resetSurface(JNIEnv *env, jobject obj)
}
-VOID D3dCtx::error(int idx)
+VOID D3dCtx::error(int idx)
{
error(getErrorMessage(idx));
}
-VOID D3dCtx::error(int idx, HRESULT hr)
+VOID D3dCtx::error(int idx, HRESULT hr)
{
error(getErrorMessage(idx), hr);
}
@@ -835,37 +899,37 @@ VOID D3dCtx::error(int idx, HRESULT hr)
VOID D3dCtx::warning(int idx)
{
- printf("%s\n", getErrorMessage(idx));
+ printf("[Java3D] Warning : %s\n", getErrorMessage(idx));
}
-VOID D3dCtx::warning(int idx, HRESULT hr)
+VOID D3dCtx::warning(int idx, HRESULT hr)
{
- printf("%s - %s\n", getErrorMessage(idx), DXGetErrorString8(hr));
+ printf("[Java3D] Warning : %s - %s\n", getErrorMessage(idx), DXGetErrorString9(hr));
}
-VOID D3dCtx::error(char *s)
+VOID D3dCtx::error(char *s)
{
showError(hwnd, s, bFullScreen);
}
-VOID D3dCtx::error(char *s, HRESULT hr)
+VOID D3dCtx::error(char *s, HRESULT hr)
{
char message[400];
- sprintf(message, "%s - %s", s, DXGetErrorString8(hr));
- showError(hwnd, message, bFullScreen);
+ sprintf(message, "%s - %s", s, DXGetErrorString9(hr));
+ showError(hwnd, message, bFullScreen);
}
VOID D3dCtx::d3dWarning(int idx)
{
- printf("%s\n", getErrorMessage(idx));
+ printf("[Java3D] Warning: %s\n", getErrorMessage(idx));
}
-
-VOID D3dCtx::d3dWarning(int idx, HRESULT hr)
+
+VOID D3dCtx::d3dWarning(int idx, HRESULT hr)
{
- printf("%s - %s\n",
- getErrorMessage(idx), DXGetErrorString8(hr));
+ printf("[Java3D] Warning: %s - %s\n",
+ getErrorMessage(idx), DXGetErrorString9(hr));
}
@@ -889,7 +953,7 @@ VOID D3dCtx::showError(HWND hwnd, char *s, BOOL bFullScreen)
firstError = false;
if (bFullScreen) {
// In full screen mode, we can't see message box
- printf("[Java 3D] %s\n", s);
+ printf("[Java3D] Error: %s\n", s);
exit(1);
} else {
MessageBox(hwnd, s, "Java 3D", MB_OK|MB_ICONERROR);
@@ -898,7 +962,7 @@ VOID D3dCtx::showError(HWND hwnd, char *s, BOOL bFullScreen)
}
-DWORD D3dCtx::getWidth()
+DWORD D3dCtx::getWidth()
{
if (!offScreen) {
return screenRect.right - screenRect.left;
@@ -909,7 +973,7 @@ DWORD D3dCtx::getWidth()
}
-DWORD D3dCtx::getHeight()
+DWORD D3dCtx::getHeight()
{
if (!offScreen) {
return screenRect.bottom - screenRect.top;
@@ -927,10 +991,10 @@ D3dDeviceInfo* D3dCtx::selectDevice(int deviceID,
D3dDeviceInfo *pDevice;
for (int i=0; i < numDeviceTypes; i++) {
- pDevice = driverInfo->d3dDeviceList[i];
+ pDevice = driverInfo->d3dDeviceList[i];
if ((((deviceID == DEVICE_HAL) || (deviceID == DEVICE_HAL_TnL)) &&
(pDevice->deviceType == D3DDEVTYPE_HAL)) ||
- (deviceID == DEVICE_REF) &&
+ (deviceID == DEVICE_REF) &&
(pDevice->deviceType == D3DDEVTYPE_REF)) {
if ((*bFullScreen && !pDevice->fullscreenCompatible) ||
(!*bFullScreen && !pDevice->desktopCompatible)) {
@@ -943,7 +1007,7 @@ D3dDeviceInfo* D3dCtx::selectDevice(int deviceID,
exit(1);
}
if (pDevice->maxZBufferDepthSize == 0) {
- if (pDevice->deviceType == D3DDEVTYPE_HAL) {
+ if (pDevice->deviceType == D3DDEVTYPE_HAL) {
d3dError(HALNOTCOMPATIBLE);
} else {
// should not happen, REF device always support
@@ -964,7 +1028,7 @@ D3dDeviceInfo* D3dCtx::selectDevice(int deviceID,
exit(1);
}
return pDevice;
- }
+ }
}
@@ -989,7 +1053,7 @@ D3dDeviceInfo* D3dCtx::selectBestDevice(D3dDriverInfo *driverInfo,
if (pDevice->depthStencilFormat == D3DFMT_UNKNOWN) {
if (pDevice->deviceType == D3DDEVTYPE_REF) {
- d3dError(DEPTHSTENCILNOTFOUND);
+ d3dError(DEPTHSTENCILNOTFOUND);
return NULL;
} else {
continue;
@@ -1015,7 +1079,7 @@ D3dDeviceInfo* D3dCtx::selectBestDevice(D3dDriverInfo *driverInfo,
}
}
}
- }
+ }
}
if (bestDevice == NULL) {
@@ -1023,7 +1087,7 @@ D3dDeviceInfo* D3dCtx::selectBestDevice(D3dDriverInfo *driverInfo,
d3dError(DEVICENOTFOUND);
return NULL;
}
-
+
// TODO: suggest another display mode for user
/*
if (bestDevice->deviceType == D3DDEVTYPE_REF) {
@@ -1053,14 +1117,14 @@ VOID D3dCtx::setDeviceFromProperty(JNIEnv *env)
if ( systemClass != NULL )
{
- jmethodID method = env->GetStaticMethodID(
+ jmethodID method = env->GetStaticMethodID(
systemClass, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;" );
if ( method != NULL )
{
jstring name = env->NewStringUTF( "j3d.d3ddevice" );
jstring property = reinterpret_cast<jstring>(
- env->CallStaticObjectMethod(
+ env->CallStaticObjectMethod(
systemClass, method, name ));
jboolean isCopy;
@@ -1086,12 +1150,12 @@ VOID D3dCtx::setDeviceFromProperty(JNIEnv *env)
}
name = env->NewStringUTF( "j3d.d3ddriver" );
property = reinterpret_cast<jstring>(
- env->CallStaticObjectMethod(
+ env->CallStaticObjectMethod(
systemClass, method, name ));
if ( property != NULL )
{
const char* chars = env->GetStringUTFChars(
- property, &isCopy);
+ property, &isCopy);
if ( chars != 0 )
{
// atoi() return 0, our default value, on error.
@@ -1112,14 +1176,14 @@ VOID D3dCtx::setFullScreenFromProperty(JNIEnv *env)
if ( systemClass != NULL )
{
- jmethodID method = env->GetStaticMethodID(
+ jmethodID method = env->GetStaticMethodID(
systemClass, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;" );
if ( method != NULL )
{
jstring name = env->NewStringUTF( "j3d.fullscreen" );
jstring property = reinterpret_cast<jstring>(
- env->CallStaticObjectMethod(
+ env->CallStaticObjectMethod(
systemClass, method, name ));
if ( property != NULL )
{
@@ -1149,14 +1213,14 @@ VOID D3dCtx::setVBLimitProperty(JNIEnv *env)
if ( systemClass != NULL )
{
- jmethodID method = env->GetStaticMethodID(
+ jmethodID method = env->GetStaticMethodID(
systemClass, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;" );
if ( method != NULL )
{
jstring name = env->NewStringUTF( "j3d.vertexbufferlimit" );
jstring property = reinterpret_cast<jstring>(
- env->CallStaticObjectMethod(
+ env->CallStaticObjectMethod(
systemClass, method, name ));
if ( property != NULL )
{
@@ -1190,14 +1254,14 @@ VOID D3dCtx::setDebugProperty(JNIEnv *env)
if ( systemClass != NULL )
{
- jmethodID method = env->GetStaticMethodID(
+ jmethodID method = env->GetStaticMethodID(
systemClass, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;" );
if ( method != NULL )
{
jstring name = env->NewStringUTF( "j3d.debug" );
jstring property = reinterpret_cast<jstring>(
- env->CallStaticObjectMethod(
+ env->CallStaticObjectMethod(
systemClass, method, name ));
if ( property != NULL )
{
@@ -1219,6 +1283,41 @@ VOID D3dCtx::setDebugProperty(JNIEnv *env)
}
}
+BOOL D3dCtx::getSystemProperty(JNIEnv *env, char *strName, char *strValue)
+{
+ jclass systemClass = env->FindClass( "javax/media/j3d/MasterControl" );
+
+ if ( systemClass != NULL )
+ {
+ jmethodID method = env->GetStaticMethodID(
+ systemClass, "getProperty",
+ "(Ljava/lang/String;)Ljava/lang/String;" );
+ if ( method != NULL )
+ {
+ jstring name = env->NewStringUTF( strName );
+ jstring property = reinterpret_cast<jstring>(
+ env->CallStaticObjectMethod(
+ systemClass, method, name ));
+ if ( property != NULL )
+ {
+ jboolean isCopy;
+ const char * chars = env->GetStringUTFChars(property, &isCopy );
+ if ( chars != 0 && stricmp( chars, strValue ) == 0 )
+ {
+ env->ReleaseStringUTFChars( property, chars );
+ return true;
+ }
+ else
+ {
+ env->ReleaseStringUTFChars( property, chars );
+ return false;
+ }
+ }
+ }
+ }
+ return false;
+}
+
VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env)
{
jclass cls = env->FindClass("javax/media/j3d/VirtualUniverse");
@@ -1227,7 +1326,7 @@ VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env)
implicitMultisample = false;
return;
}
-
+
jfieldID fieldID = env->GetStaticFieldID(cls, "mc", "Ljavax/media/j3d/MasterControl;");
if (fieldID == NULL) {
@@ -1242,7 +1341,7 @@ VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env)
return;
}
- cls = env->FindClass("javax/media/j3d/MasterControl");
+ cls = env->FindClass("javax/media/j3d/MasterControl");
if (cls == NULL) {
implicitMultisample = false;
@@ -1262,7 +1361,7 @@ VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env)
// Callback to notify Canvas3D which mode it is currently running
-VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj)
+VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj)
{
int mask = javax_media_j3d_Canvas3D_EXT_ABGR |
javax_media_j3d_Canvas3D_EXT_BGR;
@@ -1276,11 +1375,11 @@ VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj)
}
jclass canvasCls = env->GetObjectClass(obj);
- jfieldID id = env->GetFieldID(canvasCls, "fullScreenMode", "Z");
+ jfieldID id = env->GetFieldID(canvasCls, "fullScreenMode", "Z");
env->SetBooleanField(obj, id, bFullScreen);
- id = env->GetFieldID(canvasCls, "fullscreenWidth", "I");
+ id = env->GetFieldID(canvasCls, "fullscreenWidth", "I");
env->SetIntField(obj, id, driverInfo->desktopMode.Width);
- id = env->GetFieldID(canvasCls, "fullscreenHeight", "I");
+ id = env->GetFieldID(canvasCls, "fullscreenHeight", "I");
env->SetIntField(obj, id, driverInfo->desktopMode.Height);
id = env->GetFieldID(canvasCls, "textureExtendedFeatures", "I");
@@ -1288,35 +1387,54 @@ VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj)
id = env->GetFieldID(canvasCls, "extensionsSupported", "I");
env->SetIntField(obj, id, mask);
-
+
id = env->GetFieldID(canvasCls, "nativeGraphicsVersion", "Ljava/lang/String;");
- char *version = "DirectX 8.0 or above";
+ char *version = "DirectX 9.0 or above";
env->SetObjectField(obj, id, env->NewStringUTF(version));
- float degree = deviceInfo->maxAnisotropy;
+ float degree = float(deviceInfo->maxAnisotropy);
id = env->GetFieldID(canvasCls, "anisotropicDegreeMax", "F");
env->SetFloatField(obj, id, degree);
id = env->GetFieldID(canvasCls, "textureWidthMax", "I");
- env->SetIntField(obj, id, deviceInfo->maxTextureWidth);
+ env->SetIntField(obj, id, deviceInfo->maxTextureWidth);
id = env->GetFieldID(canvasCls, "textureHeightMax", "I");
- env->SetIntField(obj, id, deviceInfo->maxTextureHeight);
+ env->SetIntField(obj, id, deviceInfo->maxTextureHeight);
if (deviceInfo->maxTextureDepth > 0) {
id = env->GetFieldID(canvasCls, "texture3DWidthMax", "I");
- env->SetIntField(obj, id, deviceInfo->maxTextureWidth);
+ env->SetIntField(obj, id, deviceInfo->maxTextureWidth);
id = env->GetFieldID(canvasCls, "texture3DHeightMax", "I");
- env->SetIntField(obj, id, deviceInfo->maxTextureHeight);
+ env->SetIntField(obj, id, deviceInfo->maxTextureHeight);
id = env->GetFieldID(canvasCls, "texture3DDepthMax", "I");
env->SetIntField(obj, id, deviceInfo->maxTextureDepth);
+
+ // issue 135
+ // private String nativeGraphicsVendor = "<UNKNOWN>";
+ // private String nativeGraphicsRenderer = "<UNKNOWN>";
+ id = env->GetFieldID(canvasCls, "nativeGraphicsVendor", "Ljava/lang/String;");
+ //char *nGVendor = driverInfo->adapterIdentifier.DeviceName ;
+ char *nGVendor = deviceInfo->deviceVendor ;
+ env->SetObjectField(obj, id, env->NewStringUTF(nGVendor));
+ // printf("DEBUG vendor : %s ", nGVendor);
+
+ id = env->GetFieldID(canvasCls, "nativeGraphicsRenderer", "Ljava/lang/String;");
+ // char *nGRenderer = driverInfo->adapterIdentifier.Description;
+ char *nGRenderer = deviceInfo->deviceRenderer;
+ env->SetObjectField(obj, id, env->NewStringUTF(nGRenderer));
+
+
}
}
-VOID D3dCtx::createVertexBuffer()
+
+
+
+VOID D3dCtx::createVertexBuffer()
{
if (srcVertexBuffer != NULL) {
// Each pDevice has its own vertex buffer,
@@ -1328,27 +1446,45 @@ VOID D3dCtx::createVertexBuffer()
if (dstVertexBuffer != NULL) {
dstVertexBuffer->Release();
}
+ DWORD usage_D3DVERTEX = D3DUSAGE_DONOTCLIP|
+ D3DUSAGE_WRITEONLY|
+ D3DUSAGE_SOFTWAREPROCESSING;
+
+ DWORD usage_D3DTLVERTEX= D3DUSAGE_DONOTCLIP|
+ D3DUSAGE_SOFTWAREPROCESSING;
+
+//# if NVIDIA_DEBUG
+ if(deviceInfo->isHardwareTnL)
+ {
+ // remove SoftwareProcessing
+ usage_D3DVERTEX = D3DUSAGE_DONOTCLIP|
+ D3DUSAGE_WRITEONLY;
+
+ usage_D3DTLVERTEX = D3DUSAGE_DONOTCLIP;
+ }
+// # endif
HRESULT hr =
pDevice->CreateVertexBuffer(sizeof(D3DVERTEX),
- D3DUSAGE_DONOTCLIP|
- D3DUSAGE_WRITEONLY|
- D3DUSAGE_SOFTWAREPROCESSING,
+ usage_D3DVERTEX,
D3DFVF_XYZ,
D3DPOOL_MANAGED,
- &srcVertexBuffer);
+ &srcVertexBuffer,
+ NULL);
if (FAILED(hr)) {
+ printf("\n[Java3D] Failed to create VertexBuffer (D3DVERTEX)\n");
error(CREATEVERTEXBUFFER, hr);
+
}
hr = pDevice->CreateVertexBuffer(sizeof(D3DTLVERTEX),
- D3DUSAGE_DONOTCLIP|
- D3DUSAGE_SOFTWAREPROCESSING,
+ usage_D3DTLVERTEX,
D3DFVF_XYZRHW|D3DFVF_TEX1,
D3DPOOL_MANAGED,
- &dstVertexBuffer);
+ &dstVertexBuffer,NULL);
if (FAILED(hr)) {
+ printf("\n[Java3D] Warning: Failed to create VertexBuffer (D3DTLVERTEX)\n");
error(CREATEVERTEXBUFFER, hr);
}
}
@@ -1377,34 +1513,39 @@ VOID D3dCtx::transform(D3DVERTEX *worldCoord, D3DTLVERTEX *screenCoord) {
if (!softwareVertexProcessing) {
// ProcessVertices() only work in software vertex
// processing mode
- pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
- TRUE);
+ //pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
+ pDevice->SetSoftwareVertexProcessing(TRUE);
}
pDevice->SetRenderState(D3DRS_CLIPPING, FALSE);
- hr = srcVertexBuffer->Lock(0, 0, (BYTE **)&pv, 0);
+ hr = srcVertexBuffer->Lock(0, 0, (VOID **)&pv, 0);
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock buffer %s\n", DXGetErrorString8(hr));
+ printf("[Java3D] Fail to lock buffer %s\n", DXGetErrorString9(hr));
}
} else {
pv[0].x = worldCoord->x;
pv[0].y = worldCoord->y;
pv[0].z = worldCoord->z;
-
+
srcVertexBuffer->Unlock();
- pDevice->SetStreamSource(0, srcVertexBuffer,
- sizeof(D3DVERTEX));
- pDevice->SetVertexShader(D3DFVF_XYZ);
+ pDevice->SetStreamSource(0, srcVertexBuffer,0, sizeof(D3DVERTEX));
+
+ //pDevice->SetVertexShader(D3DFVF_XYZ);
+ pDevice->SetVertexShader(NULL);
+ pDevice->SetFVF(D3DFVF_XYZ);
+
hr = pDevice->ProcessVertices(0, 0, 1,
- dstVertexBuffer, 0);
-
+ dstVertexBuffer,
+ NULL,
+ 0);
+
if (FAILED(hr)) {
if (debug) {
- printf("Fail to processVertices %s\n", DXGetErrorString8(hr));
+ printf("[Java3D] Fail to processVertices %s\n", DXGetErrorString9(hr));
}
} else {
- hr = dstVertexBuffer->Lock(0, 0, (BYTE **)&tlpv, D3DLOCK_READONLY);
+ hr = dstVertexBuffer->Lock(0, 0, (VOID **)&tlpv, D3DLOCK_READONLY);
if (SUCCEEDED(hr)) {
screenCoord->sx = tlpv[0].sx;
screenCoord->sy = tlpv[0].sy;
@@ -1420,12 +1561,12 @@ VOID D3dCtx::transform(D3DVERTEX *worldCoord, D3DTLVERTEX *screenCoord) {
}
pDevice->SetRenderState(D3DRS_CLIPPING, TRUE);
if (!softwareVertexProcessing) {
- pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
- FALSE);
+ //pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
+ pDevice->SetSoftwareVertexProcessing(FALSE);
}
// restore original texture state
pDevice->SetTextureStageState(0, D3DTSS_COLOROP, texState);
- }
+ }
}
@@ -1437,13 +1578,13 @@ VOID D3dCtx::getScreenRect(HWND hwnd, RECT *rect) {
if ((deviceInfo->isHardware) &&
(numDriver > 1)) {
- MONITORINFO info;
+ MONITORINFO info;
HMONITOR hMonitor = driverInfo->hMonitor;
info.cbSize = sizeof(MONITORINFO);
if (hMonitor == NULL) {
- hMonitor = MonitorFromWindow(hwnd,
- MONITOR_DEFAULTTONEAREST);
+ hMonitor = MonitorFromWindow(hwnd,
+ MONITOR_DEFAULTTONEAREST);
}
GetMonitorInfo(hMonitor, &info);
monitorLeft = info.rcMonitor.left;
@@ -1463,20 +1604,20 @@ VOID D3dCtx::getScreenRect(HWND hwnd, RECT *rect) {
* Return NULL if this window intersect several monitor
*/
-HMONITOR D3dCtx::findMonitor()
+HMONITOR D3dCtx::findMonitor()
{
if ((osvi.dwMajorVersion < 4) ||
(numDriver < 2)) {
return NULL;
- }
+ }
RECT rect;
- MONITORINFO info;
- HMONITOR hmonitor = MonitorFromWindow(hwnd,
- MONITOR_DEFAULTTONEAREST);
+ MONITORINFO info;
+ HMONITOR hmonitor = MonitorFromWindow(hwnd,
+ MONITOR_DEFAULTTONEAREST);
info.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(hmonitor, &info);
+ GetMonitorInfo(hmonitor, &info);
GetWindowRect(hwnd, &rect);
if ((info.rcMonitor.left <= rect.left) &&
@@ -1502,7 +1643,7 @@ D3dDeviceInfo* D3dCtx::setDeviceInfo(D3dDriverInfo *driverInfo,
int minZDepth)
{
if (requiredDeviceID >= 0) {
- return selectDevice(requiredDeviceID, driverInfo,
+ return selectDevice(requiredDeviceID, driverInfo,
bFullScreen, minZDepth);
} else {
return selectBestDevice(driverInfo, bFullScreen,
@@ -1528,7 +1669,7 @@ VOID D3dCtx::setDriverInfo()
if (d3dDriverList[i]->hMonitor == monitor) {
newDriver = d3dDriverList[i];
break;
- }
+ }
}
}
} else {
@@ -1545,26 +1686,27 @@ VOID D3dCtx::setDriverInfo()
VOID D3dCtx::setDefaultAttributes()
{
- pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
- softwareVertexProcessing);
+ /*pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
+ softwareVertexProcessing);*/
+ pDevice->SetSoftwareVertexProcessing(softwareVertexProcessing);
pDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE,
D3DMCS_MATERIAL);
pDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE,
D3DMCS_MATERIAL);
pDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
- // Default specular is FALSE
+ // Default specular is FALSE
pDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
// Texture & CULL mode default value for D3D is different from OGL
pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
- // Default in D3D is D3DCMP_LESSEQUAL, OGL is D3DCMP_LESS
+ // Default in D3D is D3DCMP_LESSEQUAL, OGL is D3DCMP_LESS
// Set Range based fog
- pDevice->SetRenderState(D3DRS_RANGEFOGENABLE,
+ pDevice->SetRenderState(D3DRS_RANGEFOGENABLE,
deviceInfo->rangeFogEnable);
-
+
// disable antialiasing (default is true in D3D)
if (!implicitMultisample) {
pDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
@@ -1582,13 +1724,13 @@ VOID D3dCtx::setDefaultAttributes()
pDevice->SetTextureStageState(i, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(i, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDevice->SetTextureStageState(i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- pDevice->SetTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
- pDevice->SetTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
+ //pDevice->SetTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
+ //pDevice->SetTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
bindTextureId[i] = -1;
}
}
-
+
for (int i=0; i < TEXSTAGESUPPORT; i++) {
texGenMode[i] = TEX_GEN_NONE;
texTransformSet[i] = false;
@@ -1599,11 +1741,11 @@ VOID D3dCtx::setDefaultAttributes()
}
}
-VOID D3dCtx::enumDisplayMode(DEVMODE* dmode)
+VOID D3dCtx::enumDisplayMode(DEVMODE* dmode)
{
MONITORINFOEX mi;
-
+
if (monitor == NULL) {
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, dmode );
} else {
@@ -1613,22 +1755,70 @@ VOID D3dCtx::enumDisplayMode(DEVMODE* dmode)
EnumDisplaySettings( mi.szDevice, ENUM_CURRENT_SETTINGS, dmode);
}
}
-
-DWORD D3dCtx::findBehavior()
+// check what kind of Vertex processing will be used
+DWORD D3dCtx::findBehavior()
{
+ bForceHwdVertexProcess = getSystemProperty(jniEnv,"j3d.d3dVertexProcess","hardware");
+ bForceMixVertexProcess = getSystemProperty(jniEnv,"j3d.d3dVertexProcess","mixed");
+ bForceSWVertexProcess = getSystemProperty(jniEnv,"j3d.d3dVertexProcess","software");
+
+ bUseNvPerfHUD = getSystemProperty(jniEnv,"j3d.useNvPerfHUD","true");
+
+ if (bUseNvPerfHUD) // must have bForceHwdVertexProcess as true
+ {
+ printf("\n[Java3D]: using j3d.useNvPerfHUD=true\n");
+ bForceHwdVertexProcess = true;
+ bForceMixVertexProcess = false;
+ bForceSWVertexProcess = false;
+ }
+
+ if (bForceHwdVertexProcess)
+ {
+ softwareVertexProcessing = FALSE;
+ printf("\n[Java3D]: using d3dVertexProcess=hardware\n");
+ return D3DCREATE_HARDWARE_VERTEXPROCESSING;
+ }
+
+ if (bForceMixVertexProcess)
+ {
+ printf("\n[Java3D]: using d3dVertexProcess=mixed\n");
+ softwareVertexProcessing = FALSE;
+ return D3DCREATE_MIXED_VERTEXPROCESSING;
+ }
+
+ if (bForceSWVertexProcess)
+ {
+ printf("\n[Java3D]: using d3dVertexProcess=software\n");
+ softwareVertexProcessing = TRUE;
+ return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+ }
+ // high-end video cards: NV25 and above
+ if (deviceInfo->isHardwareTnL && deviceInfo->supportShaders11 &&
+ ((requiredDeviceID < 0) || (requiredDeviceID == DEVICE_HAL_TnL)))
+ {
+ if (debug){printf("\n[Java3D]: using hardware Vertex Processing.\n");}
+ softwareVertexProcessing = FALSE;
+ return D3DCREATE_HARDWARE_VERTEXPROCESSING;
+ }
+ // midle-end video cards
if (deviceInfo->isHardwareTnL &&
- ((requiredDeviceID < 0) || (requiredDeviceID == DEVICE_HAL_TnL))) {
- softwareVertexProcessing = FALSE;
- return D3DCREATE_MIXED_VERTEXPROCESSING;
- } else {
- softwareVertexProcessing = TRUE;
- return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
- }
+ ((requiredDeviceID < 0) || (requiredDeviceID == DEVICE_HAL_TnL)))
+ {
+ if (debug){printf("\n[Java3D]: using mixed Vertex Processing.\n");}
+ softwareVertexProcessing = FALSE;
+ return D3DCREATE_MIXED_VERTEXPROCESSING;
+ }
+ else // low-end vcards use Software Vertex Processing
+ {
+ if (debug){printf("\n[Java3D]: using software Vertex Processing.\n");}
+ softwareVertexProcessing = TRUE;
+ return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+ }
}
-VOID D3dCtx::printInfo(D3DPRESENT_PARAMETERS *d3dPresent)
+VOID D3dCtx::printInfo(D3DPRESENT_PARAMETERS *d3dPresent)
{
-
+
if (d3dPresent->Windowed) {
printf("Window ");
} else {
@@ -1652,11 +1842,11 @@ VOID D3dCtx::setWindowMode()
SetWindowLong(topHwnd, GWL_STYLE, winStyle);
SetWindowPos(topHwnd, HWND_NOTOPMOST, savedTopRect.left, savedTopRect.top,
savedTopRect.right - savedTopRect.left,
- savedTopRect.bottom - savedTopRect.top,
+ savedTopRect.bottom - savedTopRect.top,
SWP_SHOWWINDOW);
} else {
SetWindowLong(topHwnd, GWL_STYLE,
- WS_POPUP|WS_SYSMENU|WS_VISIBLE);
+ WS_POPUP|WS_SYSMENU|WS_VISIBLE);
}
}
@@ -1672,7 +1862,7 @@ VOID D3dCtx::setAmbientLightMaterial()
pDevice->GetMaterial(&savedMaterial);
pDevice->GetLightEnable(0, &savedLightEnable);
- CopyColor(ambientMaterial.Ambient,
+ CopyColor(ambientMaterial.Ambient,
currentColor_r,
currentColor_g,
currentColor_b,
@@ -1700,18 +1890,19 @@ VOID D3dCtx::restoreDefaultLightMaterial()
pDevice->LightEnable(0, savedLightEnable);
}
-VOID D3dCtx::freeVBList(D3dVertexBufferVector *v)
+VOID D3dCtx::freeVBList(D3dVertexBufferVector *v)
{
- LPD3DVERTEXBUFFER *p, r;
+ //LPD3DVERTEXBUFFER *p;
+ LPD3DVERTEXBUFFER r;
lockGeometry();
- for (p = v->begin(); p != v->end(); ++p) {
+ for (ITER_LPD3DVERTEXBUFFER p = v->begin(); p != v->end(); ++p) {
// Remove itself from current ctx vertexBufferTable list
r = (*p)->next;
if (r != NULL) {
r->previous = (*p)->previous;
- }
+ }
(*p)->previous->next = r;
// Now we can free current VB
delete (*p);
@@ -1721,9 +1912,9 @@ VOID D3dCtx::freeVBList(D3dVertexBufferVector *v)
}
-VOID D3dCtx::freeResourceList(LPDIRECT3DRESOURCE8Vector *v)
+VOID D3dCtx::freeResourceList(LPDIRECT3DRESOURCE9Vector *v)
{
- LPDIRECT3DRESOURCE8 *s;
+ ITER_LPDIRECT3DRESOURCE9 s;
lockSurfaceList();
for (s = v->begin(); s != v->end(); ++s) {
@@ -1754,7 +1945,7 @@ VOID D3dCtx::freeList()
}
}
-VOID D3dCtx::freeVB(LPD3DVERTEXBUFFER vb)
+VOID D3dCtx::freeVB(LPD3DVERTEXBUFFER vb)
{
if (vb != NULL) {
lockSurfaceList();
@@ -1768,14 +1959,14 @@ VOID D3dCtx::freeVB(LPD3DVERTEXBUFFER vb)
}
-VOID D3dCtx::freeResource(LPDIRECT3DRESOURCE8 res)
+VOID D3dCtx::freeResource(LPDIRECT3DRESOURCE9 res)
{
if (res != NULL) {
lockSurfaceList();
if (useFreeList0) {
freeResourceList0.push_back(res);
} else {
- freeResourceList1.push_back(res);
+ freeResourceList1.push_back(res);
}
unlockSurfaceList();
}
@@ -1785,14 +1976,18 @@ BOOL D3dCtx::createFrontBuffer()
{
HRESULT hr;
- hr = pDevice->CreateImageSurface(driverInfo->desktopMode.Width,
+ /*CreateImageSurface*/
+ hr = pDevice->CreateOffscreenPlainSurface(
+ driverInfo->desktopMode.Width,
driverInfo->desktopMode.Height,
D3DFMT_A8R8G8B8,
- &frontSurface);
+ D3DPOOL_SCRATCH,
+ &frontSurface,
+ NULL);
if (FAILED(hr)) {
if (debug) {
- printf("[Java3D] Fail to CreateImageSurface %s\n",
- DXGetErrorString8(hr));
+ printf("[Java3D] Fail to CreateOffscreenPlainSurface %s\n",
+ DXGetErrorString9(hr));
}
frontSurface = NULL;
return false;
@@ -1800,5 +1995,74 @@ BOOL D3dCtx::createFrontBuffer()
return true;
}
+jboolean D3dCtx::getJavaBoolEnv(JNIEnv *env, char* envStr)
+{
+ jclass systemClass = env->FindClass( "javax/media/j3d/MasterControl" );
+
+ if ( systemClass != NULL )
+ {
+ jmethodID method = env->GetStaticMethodID(
+ systemClass, "getProperty",
+ "(Ljava/lang/String;)Ljava/lang/String;" );
+ if ( method != NULL )
+ {
+ jstring name = env->NewStringUTF( envStr );
+ jstring property = reinterpret_cast<jstring>(
+ env->CallStaticObjectMethod(
+ systemClass, method, name ));
+ if ( property != NULL )
+ {
+ jboolean isCopy;
+ const char * chars = env->GetStringUTFChars(
+ property, &isCopy );
+ if ( chars != 0 )
+ {
+ if ( stricmp( chars, "true" ) == 0 )
+ {
+ env->ReleaseStringUTFChars( property, chars );
+ return true;
+ }
+ else
+ {
+ env->ReleaseStringUTFChars( property, chars );
+ return false;
+ }
+ env->ReleaseStringUTFChars( property, chars );
+ }
+ }
+ }
+ }
+ return false;
+}
+
+
+
+/**
+// this routine is not safe using current D3D routines
+VOID D3dCtx::getDXVersion(CHAR* strResult)
+{
+ HRESULT hr;
+ // TCHAR strResult[128];
+
+ DWORD dwDirectXVersion = 0;
+ TCHAR strDirectXVersion[10];
+
+ hr = GetDXVersion( &dwDirectXVersion, strDirectXVersion, 10 );
+ if( SUCCEEDED(hr) )
+ {
+ strcpy( strResult, "DirectX ");
+ if( dwDirectXVersion > 0 )
+
+ strcpy( strResult, strDirectXVersion );
+ else
+ strcpy( strResult, "not installed") );
+ }
+ else
+ {
+ strcpy( strResult, "Unknown version of DirectX installed");
+ }
+
+}
+ **/
diff --git a/src/native/d3d/D3dCtx.hpp b/src/native/d3d/D3dCtx.hpp
index 230f099..96a111a 100644
--- a/src/native/d3d/D3dCtx.hpp
+++ b/src/native/d3d/D3dCtx.hpp
@@ -18,7 +18,7 @@
#include "D3dVertexBuffer.hpp"
#include "D3dDisplayList.hpp"
-#define TEXTURETABLESIZE 8
+#define TEXTURETABLESIZE 8
#define TEXSTAGESUPPORT 8
#define DISPLAYLIST_INITSIZE 8
#define NOCHANGE 0
@@ -26,6 +26,9 @@
#define RECREATEDDRAW 2
#define RECREATEDFAIL -1
+#undef javax_media_j3d_Canvas3D_STENCIL_BUFFER
+#define javax_media_j3d_Canvas3D_STENCIL_BUFFER 4096L
+
// Use in texCoordPosition[]
// Must be negative number
@@ -47,8 +50,11 @@ typedef struct _D3DTLVERTEX {
float tu, tv;
} D3DTLVERTEX;
-typedef vector<LPDIRECT3DRESOURCE8> LPDIRECT3DRESOURCE8Vector;
-typedef vector<LPDIRECT3DVERTEXBUFFER8> LPDIRECT3DVERTEXBUFFER8Vector;
+typedef vector<LPDIRECT3DRESOURCE9> LPDIRECT3DRESOURCE9Vector;
+typedef vector<LPDIRECT3DVERTEXBUFFER9> LPDIRECT3DVERTEXBUFFER9Vector;
+//issue 135 iterator for vectors
+typedef vector<LPDIRECT3DRESOURCE9>::iterator ITER_LPDIRECT3DRESOURCE9;
+typedef vector<LPDIRECT3DVERTEXBUFFER9>::iterator ITER_LPDIRECT3DVERTEXBUFFER9;
class D3dCtx {
public:
@@ -56,47 +62,54 @@ public:
HWND hwnd; // window handle
HWND topHwnd; // Top window handle
D3dDriverInfo *driverInfo; // Driver use
- D3dDeviceInfo *deviceInfo; // Device use
-
- LPDIRECT3D8 pD3D; // Direct3D interface
- LPDIRECT3DDEVICE8 pDevice; // Instance of D3D Device
-
- LPDIRECT3DSURFACE8 depthStencilSurface;
+ D3dDeviceInfo *deviceInfo; // Device use
+
+ LPDIRECT3D9 pD3D; // Direct3D interface
+ LPDIRECT3DDEVICE9 pDevice; // Instance of D3D Device
+
+ LPDIRECT3DSURFACE9 depthStencilSurface;
// This is used for readRaster and offscreen rendering
// Only allocate the memory area if necessary
- LPDIRECT3DSURFACE8 frontSurface;
+ LPDIRECT3DSURFACE9 frontSurface;
- LPDIRECT3DSURFACE8 backSurface;
+ LPDIRECT3DSURFACE9 backSurface;
// Parameters use for CreateDevice()
- D3DPRESENT_PARAMETERS d3dPresent;
+ D3DPRESENT_PARAMETERS d3dPresent;
DWORD dwBehavior;
-
+ BOOL bForceHwdVertexProcess; // true if j3d.d3dVertexProcess is hardware
+ BOOL bForceMixVertexProcess; // true if j3d.d3dVertexProcess is mixed
+ BOOL bForceSWVertexProcess; // true if j3d.d3dVertexProcess is software
+
+ BOOL bUseNvPerfHUD; // true if j3d.useNvPerfHUD is true
+ // it also makes bForceHwdVertexProcess true
+
BOOL offScreen; // true if it is offScreen rendering
// in this case only backSurface is used
+ BOOL bFastDrawQuads;
DWORD offScreenWidth;
DWORD offScreenHeight;
-
+
BOOL bFullScreen; // true if in full screen mode
BOOL bFullScreenRequired; // true if must run in full
// screen mode or die
- BOOL inToggle; // in toggle fullscreen/window mode
+ BOOL inToggle; // in toggle fullscreen/window mode
RECT screenRect; // coordinate of window relative to
// the whole desktop in multiple monitor
RECT windowRect; // coordinate of window relative to
- // the current monitor desktop only
+ // the current monitor desktop only
INT minZDepth; // min Z depth set in NativeConfigTemplate
DEVMODE devmode; // current display mode
DWORD antialiasing; // PREFERRED, REQUIRED or UNNECESSARY
-
+
// Store current color as in OGL glColor()
float currentColor_r;
- float currentColor_g;
- float currentColor_b;
- float currentColor_a;
+ float currentColor_g;
+ float currentColor_b;
+ float currentColor_a;
// Two side light is used. Note that D3D don't support two side
// lighting.
@@ -113,16 +126,16 @@ public:
DWORD zEnable;
// Ambient material used when coloring Attributes
- D3DMATERIAL8 ambientMaterial;
+ D3DMATERIAL9 ambientMaterial;
// temporary variables for ambient light setting
- D3DLIGHT8 savedLight;
- D3DMATERIAL8 savedMaterial;
+ D3DLIGHT9 savedLight;
+ D3DMATERIAL9 savedMaterial;
BOOL savedLightEnable;
// temporary variables used for building VertexBuffer
LPD3DVERTEXBUFFER pVB; // point to the current VB being update
- DWORD texSetUsed;
+ DWORD texSetUsed;
DWORD texStride[TEXSTAGESUPPORT];
// true when in toggle mode
@@ -132,25 +145,25 @@ public:
INT *bindTextureId;
DWORD bindTextureIdLen;
- LPDIRECT3DTEXTURE8 *textureTable;
+ LPDIRECT3DTEXTURE9 *textureTable;
DWORD textureTableLen;
// Volume Texture related variables
// Since 2d & 3d texture ID can't be the same from Java3D.
// We don't need bindVolumeId
- LPDIRECT3DVOLUMETEXTURE8 *volumeTable;
+ LPDIRECT3DVOLUMETEXTURE9 *volumeTable;
DWORD volumeTableLen;
// Texture Cube Mapping related variables
- LPDIRECT3DCUBETEXTURE8 *cubeMapTable;
+ LPDIRECT3DCUBETEXTURE9 *cubeMapTable;
DWORD cubeMapTableLen;
-
+
// true if hardware support MultiTexture
BOOL multiTextureSupport;
// handle to monitor that this ctx belongs to. This is equal to
// NULL if this window is a primary display screen or it covers
- // more than one screen.
+ // more than one screen.
HMONITOR monitor;
// D3D don't have concept of current texture unit stage,
@@ -160,7 +173,7 @@ public:
// true if linear filtering is to be used
BOOL texLinearMode;
-
+
// This is used temporary to store the blend function
// when two pass texture is used to simulate BLEND mode
@@ -169,10 +182,10 @@ public:
DWORD blendEnable;
- // This is used for to transform vertex
+ // This is used for to transform vertex
// from world to screen coordinate
- LPDIRECT3DVERTEXBUFFER8 srcVertexBuffer;
- LPDIRECT3DVERTEXBUFFER8 dstVertexBuffer;
+ LPDIRECT3DVERTEXBUFFER9 srcVertexBuffer;
+ LPDIRECT3DVERTEXBUFFER9 dstVertexBuffer;
// For Rect of texture map in Raster write
D3DTLVERTEX rasterRect[4];
@@ -188,7 +201,7 @@ public:
BOOL texTransformSet[TEXSTAGESUPPORT];
// Remember the last Texture Transform pass down, since
- // TexCoordGen may destroy it in some mode so we have to
+ // TexCoordGen may destroy it in some mode so we have to
// restore it later manually.
D3DXMATRIX texTransform[TEXSTAGESUPPORT];
@@ -215,11 +228,11 @@ public:
BOOL resetColorTarget;
// Use for QuadArray
- LPDIRECT3DINDEXBUFFER8 quadIndexBuffer;
+ LPDIRECT3DINDEXBUFFER9 quadIndexBuffer;
DWORD quadIndexBufferSize;
// Use for Quad Polygon Line mode
- LPDIRECT3DINDEXBUFFER8 lineModeIndexBuffer;
+ LPDIRECT3DINDEXBUFFER9 lineModeIndexBuffer;
// Use temporary for reindexing
DWORD *reIndexifyTable;
@@ -237,8 +250,8 @@ public:
// Use to free resource surface in swap()
BOOL useFreeList0;
- LPDIRECT3DRESOURCE8Vector freeResourceList0;
- LPDIRECT3DRESOURCE8Vector freeResourceList1;
+ LPDIRECT3DRESOURCE9Vector freeResourceList0;
+ LPDIRECT3DRESOURCE9Vector freeResourceList1;
D3dVertexBufferVector freeVBList0;
D3dVertexBufferVector freeVBList1;
@@ -280,14 +293,14 @@ public:
VOID setPresentParams(JNIEnv *env, jobject obj);
VOID setAmbientLightMaterial();
VOID restoreDefaultLightMaterial();
- VOID freeResource(LPDIRECT3DRESOURCE8 surf);
+ VOID freeResource(LPDIRECT3DRESOURCE9 surf);
VOID freeVB(LPD3DVERTEXBUFFER vb);
-
+
VOID freeList();
- VOID freeResourceList(LPDIRECT3DRESOURCE8Vector *v);
- VOID freeVBList(D3dVertexBufferVector *v);
+ VOID freeResourceList(LPDIRECT3DRESOURCE9Vector *v);
+ VOID freeVBList(D3dVertexBufferVector *v);
BOOL createFrontBuffer();
-
+
static D3dDeviceInfo* selectDevice(int deviceID,
D3dDriverInfo *driverInfo,
BOOL *bFullScreen,
@@ -296,15 +309,20 @@ public:
BOOL *bFullScreen,
int minZDepth);
static VOID setDeviceFromProperty(JNIEnv *env);
+ static BOOL getSystemProperty(JNIEnv *env, char *strName, char *strValue);
static VOID setDebugProperty(JNIEnv *env);
static VOID setVBLimitProperty(JNIEnv *env);
- static VOID setImplicitMultisamplingProperty(JNIEnv *env);
+ static VOID setImplicitMultisamplingProperty(JNIEnv *env);
+
+
private:
RECT savedTopRect; // for toggle between fullscreen mode
- RECT savedClientRect;
+ RECT savedClientRect;
DWORD winStyle;
+ // a private reference for JNIEnv
+ JNIEnv* jniEnv;
VOID createVertexBuffer();
@@ -315,11 +333,14 @@ private:
static VOID printWarningMessage(D3dDeviceInfo *deviceInfo);
static VOID showError(HWND hwnd, char *s, BOOL bFullScreen);
VOID setDefaultAttributes();
- VOID printInfo(D3DPRESENT_PARAMETERS *d3dPresent);
+ VOID printInfo(D3DPRESENT_PARAMETERS *d3dPresent);
VOID setWindowMode();
+ jboolean getJavaBoolEnv(JNIEnv *env, char* envStr);
};
typedef vector<D3dCtx *> D3dCtxVector;
+//issue 135 added iterator for D3dCtxVector
+typedef vector<D3dCtx *>::iterator ITER_D3dCtxVector;
extern D3dCtxVector d3dCtxList;
const extern D3DXMATRIX identityMatrix;
#endif
diff --git a/src/native/d3d/D3dDeviceInfo.cpp b/src/native/d3d/D3dDeviceInfo.cpp
index 5628273..7fffdf5 100644
--- a/src/native/d3d/D3dDeviceInfo.cpp
+++ b/src/native/d3d/D3dDeviceInfo.cpp
@@ -22,63 +22,95 @@ D3dDeviceInfo::~D3dDeviceInfo()
{
}
-VOID D3dDeviceInfo::setCaps(D3DCAPS8 *d3dCaps) {
-
- if (deviceType == D3DDEVTYPE_HAL) {
- isHardware = true;
- isHardwareTnL = (d3dCaps->DevCaps &
- D3DDEVCAPS_HWTRANSFORMANDLIGHT);
- } else {
- isHardware = false;
- isHardwareTnL = false;
+VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps)
+{
+ if (deviceType == D3DDEVTYPE_HAL )
+ {
+ isHardware = true;
+ isHardwareTnL = (d3dCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT);
+ }
+ else // D3DDEVTYPE_REF
+ {
+ isHardware = false;
+ isHardwareTnL = false;
}
+
+ // check if it supports at least vertex shader 1.1
+ if(d3dCaps->VertexShaderVersion < D3DVS_VERSION(1,1))
+ {
+ supportShaders11 = false;
+ }
+ else
+ {
+ supportShaders11 = true;
+ }
+ DWORD vsVersion = d3dCaps->VertexShaderVersion;
+ if (debug)
+ {
+ char* dt;
+ if (isHardware)
+ dt = "HAL";
+ else
+ dt ="REL";
+
+ printf("Java3D: Supported Shaders = %d.%d in mode %s ",
+ HIBYTE(LOWORD(vsVersion)),
+ LOBYTE(LOWORD(vsVersion)),
+ dt);
+
+ }
+
+ //supportStreamOffset =
+
+ supportDepthBias = (d3dCaps->RasterCaps & D3DPRASTERCAPS_DEPTHBIAS) != 0;
+
maxTextureBlendStages = d3dCaps->MaxTextureBlendStages;
maxSimultaneousTextures = d3dCaps->MaxSimultaneousTextures;
- maxTextureUnitStageSupport = min(maxTextureBlendStages,
- maxSimultaneousTextures);
- supportMipmap = ((d3dCaps->TextureCaps &
- D3DPTEXTURECAPS_MIPMAP) != 0);
- texturePow2Only = ((d3dCaps->TextureCaps &
- D3DPTEXTURECAPS_POW2) != 0);
- textureSquareOnly = ((d3dCaps->TextureCaps &
- D3DPTEXTURECAPS_SQUAREONLY) != 0);
- linePatternSupport = ((d3dCaps->PrimitiveMiscCaps &
- D3DPMISCCAPS_LINEPATTERNREP) != 0);
- texBorderModeSupport = ((d3dCaps->TextureAddressCaps &
- D3DPTADDRESSCAPS_BORDER) != 0);
- texLerpSupport = ((d3dCaps->TextureOpCaps &
- D3DTEXOPCAPS_LERP) != 0);
- canRenderWindowed = ((d3dCaps->Caps2 &
- D3DCAPS2_CANRENDERWINDOWED) != 0);
+
+ maxTextureUnitStageSupport = min(maxTextureBlendStages, maxSimultaneousTextures);
+
+ supportMipmap = ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0);
+
+ texturePow2Only = ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_POW2) != 0);
+
+ textureSquareOnly = ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) != 0);
+
+ linePatternSupport = false; //((d3dCaps->PrimitiveMiscCaps & D3DPMISCCAPS_LINEPATTERNREP) != 0);
+
+ texBorderModeSupport = ((d3dCaps->TextureAddressCaps & D3DPTADDRESSCAPS_BORDER) != 0);
+
+ texLerpSupport = ((d3dCaps->TextureOpCaps & D3DTEXOPCAPS_LERP) != 0);
+
+ canRenderWindowed = true;//((d3dCaps->Caps2 & D3DCAPS2_CANRENDERWINDOWED) != 0);
+
maxPrimitiveCount = d3dCaps->MaxPrimitiveCount;
- maxVertexIndex = min(vertexBufferMaxVertexLimit,
- d3dCaps->MaxVertexIndex);
+ maxVertexIndex = min(vertexBufferMaxVertexLimit, d3dCaps->MaxVertexIndex);
+
maxTextureHeight = d3dCaps->MaxTextureHeight;
maxTextureWidth = d3dCaps->MaxTextureWidth;
maxTextureDepth = d3dCaps->MaxVolumeExtent;
maxActiveLights = d3dCaps->MaxActiveLights;
- maxPointSize = d3dCaps->MaxPointSize;
+ maxPointSize = DWORD(d3dCaps->MaxPointSize);
maxAnisotropy = d3dCaps->MaxAnisotropy;
- maxVertexCount[GEO_TYPE_QUAD_SET] = min(vertexBufferMaxVertexLimit,
+ maxVertexCount[GEO_TYPE_QUAD_SET] = min(vertexBufferMaxVertexLimit,
maxPrimitiveCount << 1);
// Since index is used, we need to make sure than index range
// is also support.
- maxVertexCount[GEO_TYPE_QUAD_SET] = min(maxVertexCount[GEO_TYPE_QUAD_SET],
- maxVertexIndex);
-
- maxVertexCount[GEO_TYPE_TRI_SET] = min(vertexBufferMaxVertexLimit,
- maxPrimitiveCount*3);
- maxVertexCount[GEO_TYPE_POINT_SET] = min(vertexBufferMaxVertexLimit,
- maxPrimitiveCount);
- maxVertexCount[GEO_TYPE_LINE_SET] = min(vertexBufferMaxVertexLimit,
- maxPrimitiveCount << 1);
- maxVertexCount[GEO_TYPE_TRI_STRIP_SET] = min(vertexBufferMaxVertexLimit,
- maxPrimitiveCount + 2);
- maxVertexCount[GEO_TYPE_TRI_FAN_SET] = min(vertexBufferMaxVertexLimit,
- maxPrimitiveCount + 2);
+ maxVertexCount[GEO_TYPE_QUAD_SET] = min(maxVertexCount[GEO_TYPE_QUAD_SET], maxVertexIndex);
+
+ maxVertexCount[GEO_TYPE_TRI_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount*3);
+
+ maxVertexCount[GEO_TYPE_POINT_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount);
+
+ maxVertexCount[GEO_TYPE_LINE_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount << 1);
+
+ maxVertexCount[GEO_TYPE_TRI_STRIP_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount + 2);
+
+ maxVertexCount[GEO_TYPE_TRI_FAN_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount + 2);
+
maxVertexCount[GEO_TYPE_LINE_STRIP_SET] = min(vertexBufferMaxVertexLimit,
maxPrimitiveCount +1);
maxVertexCount[GEO_TYPE_INDEXED_QUAD_SET] = maxVertexCount[GEO_TYPE_QUAD_SET];
@@ -89,38 +121,57 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS8 *d3dCaps) {
maxVertexCount[GEO_TYPE_INDEXED_TRI_FAN_SET] = maxVertexCount[GEO_TYPE_TRI_FAN_SET];
maxVertexCount[GEO_TYPE_INDEXED_LINE_STRIP_SET] = maxVertexCount[GEO_TYPE_LINE_STRIP_SET];
+ if ( (d3dCaps->PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) != 0)
+ supportRasterPresImmediate = true;
+ else
+ supportRasterPresImmediate = false;
if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) &&
- ((d3dCaps->RasterCaps & D3DPRASTERCAPS_WFOG) != 0)) {
+ ((d3dCaps->RasterCaps & D3DPRASTERCAPS_WFOG) != 0))
+ {
// use pixel w-fog
fogMode = D3DRS_FOGTABLEMODE;
rangeFogEnable = false;
- } else if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0) &&
- ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGRANGE) != 0)) {
- // use vertex range based fog
- fogMode = D3DRS_FOGVERTEXMODE;
- rangeFogEnable = true;
- } else if ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) {
- // use pixel z-fog
- fogMode = D3DRS_FOGTABLEMODE;
- rangeFogEnable = false;
- } else if (D3DPRASTERCAPS_FOGVERTEX) {
- // use vertex z-fog
- fogMode = D3DRS_FOGVERTEXMODE;
- rangeFogEnable = false;
- } else {
- if (debug) {
- printf("[Java 3D] Fog not support in this device !\n");
- }
+ }
+ else
+ if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0) &&
+ ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGRANGE) != 0))
+
+ {
+ // use vertex range based fog
+ fogMode = D3DRS_FOGVERTEXMODE;
+ rangeFogEnable = true;
+ }
+ else
+ if ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0)
+ {
+ // use pixel z-fog
+ fogMode = D3DRS_FOGTABLEMODE;
+ rangeFogEnable = false;
+ }
+ else
+ if (D3DPRASTERCAPS_FOGVERTEX)
+ {
+ // use vertex z-fog
+ fogMode = D3DRS_FOGVERTEXMODE;
+ rangeFogEnable = false;
+ }
+ else
+ {
+ if (debug)
+ {
+ printf("[Java 3D] Fog not support in this device !\n");
+ }
}
texMask = 0;
if ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) &&
- (maxTextureDepth > 0)) {
+ (maxTextureDepth > 0))
+ {
texMask |= javax_media_j3d_Canvas3D_TEXTURE_3D;
- }
+ }
if (d3dCaps->TextureCaps & D3DPTEXTURECAPS_CUBEMAP) {
texMask |= javax_media_j3d_Canvas3D_TEXTURE_CUBE_MAP;
@@ -137,17 +188,17 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS8 *d3dCaps) {
if (d3dCaps->TextureOpCaps & D3DTEXOPCAPS_SUBTRACT) {
texMask |= javax_media_j3d_Canvas3D_TEXTURE_COMBINE_SUBTRACT;
}
-
+
if (d3dCaps->TextureOpCaps & D3DTEXOPCAPS_LERP) {
texMask |= (javax_media_j3d_Canvas3D_TEXTURE_LERP|
javax_media_j3d_Canvas3D_TEXTURE_COMBINE);
- } else if (d3dCaps->TextureOpCaps &
+ } else if (d3dCaps->TextureOpCaps &
(D3DTEXOPCAPS_DOTPRODUCT3|D3DTEXOPCAPS_SUBTRACT|
D3DTEXOPCAPS_MODULATE|D3DTEXOPCAPS_ADD|
D3DTEXOPCAPS_ADDSIGNED)) {
texMask |= javax_media_j3d_Canvas3D_TEXTURE_COMBINE;
}
-
+
if (maxAnisotropy > 1) {
texMask |= javax_media_j3d_Canvas3D_TEXTURE_ANISOTROPIC_FILTER;
@@ -164,7 +215,7 @@ void D3dDeviceInfo::findDepthStencilFormat(int minZDepth)
depthStencilFormat = D3DFMT_UNKNOWN;
for (int i=0; i < D3DDEPTHFORMATSIZE; i++) {
if (depthFormatSupport[i]) {
- // prefer one with stencil buffer, follow by D3DFMT_D16_LOCKABLE,
+ // prefer one with stencil buffer, follow by D3DFMT_D16_LOCKABLE,
if (d3dDepthTable[i] >= minZDepth) {
depthStencilFormat = (D3DFORMAT) d3dDepthFormat[i];
break;
diff --git a/src/native/d3d/D3dDeviceInfo.hpp b/src/native/d3d/D3dDeviceInfo.hpp
index 4008011..ffb4587 100644
--- a/src/native/d3d/D3dDeviceInfo.hpp
+++ b/src/native/d3d/D3dDeviceInfo.hpp
@@ -24,12 +24,16 @@ public:
// Hardware Rasterizer
// Transform & Light Hardware Rasterizer
// Reference Rasterizer
- char deviceName[40]; // One of above name
- D3DDEVTYPE deviceType; // D3DDEVTYPE_HAL or D3DDEVTYPE_REF
+ char deviceName[40]; // One of above name
+ D3DDEVTYPE deviceType; // D3DDEVTYPE_HAL or D3DDEVTYPE_REF
BOOL desktopCompatible; // Can render in desktop mode
BOOL fullscreenCompatible; // Can render in fullscreen mode
// using current desktop mode setting
-
+ //issue 135 - adding device info
+ char* deviceVendor;
+ char* deviceRenderer;
+ char* deviceVersion;
+
// each bitmask correspond to the support of
// D3DMULTISAMPLE_i_SAMPLES type, i = 2...16
DWORD multiSampleSupport;
@@ -43,11 +47,14 @@ public:
// max z buffer depth support
UINT maxZBufferDepthSize;
- // Max vetex count support for each primitive
+ // Max vertex count support for each primitive
DWORD maxVertexCount[GEO_TYPE_INDEXED_LINE_STRIP_SET+1];
+ BOOL supportShaders11;
BOOL isHardware;
BOOL isHardwareTnL;
+ BOOL supportDepthBias;
+ BOOL supportRasterPresImmediate;
BOOL canRenderWindowed;
BOOL supportMipmap;
BOOL texturePow2Only;
@@ -66,19 +73,23 @@ public:
DWORD maxActiveLights;
DWORD maxPointSize;
DWORD rangeFogEnable;
- D3DRENDERSTATETYPE fogMode;
+ D3DRENDERSTATETYPE fogMode;
int texMask;
int maxAnisotropy;
+ BOOL supportStreamOffset;
+
D3dDeviceInfo();
~D3dDeviceInfo();
// set capabilities of this device
- VOID setCaps(D3DCAPS8 *d3dCaps);
+ VOID setCaps(D3DCAPS9 *d3dCaps);
BOOL supportAntialiasing();
D3DMULTISAMPLE_TYPE getBestMultiSampleType();
int getTextureFeaturesMask();
void findDepthStencilFormat(int minZDepth);
+
+
};
#endif
diff --git a/src/native/d3d/D3dDisplayList.cpp b/src/native/d3d/D3dDisplayList.cpp
index 73c0fd2..48eaf34 100644
--- a/src/native/d3d/D3dDisplayList.cpp
+++ b/src/native/d3d/D3dDisplayList.cpp
@@ -19,7 +19,7 @@ D3dDisplayList::D3dDisplayList()
D3dDisplayList::~D3dDisplayList()
{
- for (D3dVertexBuffer **p = vBufferVec.begin();
+ for (ITER_LPD3DVERTEXBUFFER p = vBufferVec.begin();
p != vBufferVec.end(); p++) {
SafeDelete(*p);
}
@@ -28,7 +28,7 @@ D3dDisplayList::~D3dDisplayList()
VOID D3dDisplayList::render(D3dCtx *d3dCtx)
{
- for (D3dVertexBuffer **p = vBufferVec.begin();
+ for (ITER_LPD3DVERTEXBUFFER p = vBufferVec.begin();
p != vBufferVec.end(); p++) {
(*p)->render(d3dCtx);
}
@@ -49,17 +49,17 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx)
{
D3dVertexBufferVector vCloneBufferVec;
- D3dVertexBuffer **r = vBufferVec.begin();
-
- for (; r != vBufferVec.end(); r++) {
+ D3dVertexBuffer **r = &(*vBufferVec.begin());
+
+ for (; r != &(*vBufferVec.end()); r++) {
vCloneBufferVec.push_back(*r);
}
vBufferVec.erase(vBufferVec.begin(), vBufferVec.end());
- D3dVertexBuffer **vbegin = vCloneBufferVec.begin();
- D3dVertexBuffer **vend = vCloneBufferVec.end();
+ D3dVertexBuffer **vbegin = &(*vCloneBufferVec.begin());
+ D3dVertexBuffer **vend = &(*vCloneBufferVec.end());
D3dVertexBuffer **q = vbegin;
D3dVertexBuffer **p;
int primitiveType, vcounts, climit;
@@ -92,7 +92,7 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx)
((*p)->isIndexPrimitive == isIndexPrimitive) &&
(isQuad(*p) == quadFlag) &&
((*p)->isPointFlagUsed == isPointFlagUsed) &&
- // This means Mutliple VBs already use
+ // This means Mutliple VBs already use
((*p)->totalVertexCount == (*p)->vcount)) {
vcounts += (*p)->totalVertexCount;
if ((*p)->indexBuffer != NULL) {
@@ -106,7 +106,7 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx)
} else {
break;
}
- }
+ }
if (merge) {
mergedVB = createMergedVB(d3dCtx, q, p, vcounts, indexCounts);
@@ -119,8 +119,8 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx)
for (r = q; r != p; r++) {
vBufferVec.push_back(*r);
}
- }
- } else {
+ }
+ } else {
vBufferVec.push_back(*q);
}
q = p;
@@ -131,13 +131,14 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx)
+
LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx,
D3dVertexBuffer **vstart,
D3dVertexBuffer **vend,
DWORD vcount,
DWORD indexCount)
{
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice;
D3dVertexBuffer **r;
UINT i;
HRESULT hr;
@@ -158,43 +159,46 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx,
D3DUSAGE_WRITEONLY,
vb->vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
} else {
hr = device->CreateVertexBuffer(vb->stride*vcount,
D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS,
vb->vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
}
if (FAILED(hr)) {
return NULL;
}
+ BYTE *bdst = NULL;
+ WORD *wdst = NULL;
+ UINT *idst = NULL;
- BYTE *bdst = NULL;
- WORD *wdst = NULL;
- UINT *idst = NULL;
-
- hr = vb->buffer->Lock(0, 0, (BYTE**) &bdst, 0);
+ hr = vb->buffer->Lock(0, 0,(VOID**) &bdst , 0);
if (FAILED(hr)) {
SafeRelease(vb->buffer);
return NULL;
}
if (indexCount > 0) {
- if (indexCount <= 0xffff) {
+ if (indexCount < 0xffff) {
hr = device->CreateIndexBuffer(indexCount*sizeof(WORD),
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16,
D3DPOOL_DEFAULT,
- &vb->indexBuffer);
-
+ &vb->indexBuffer,
+ NULL);
+
} else {
hr = device->CreateIndexBuffer(indexCount*sizeof(UINT),
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX32,
D3DPOOL_DEFAULT,
- &vb->indexBuffer);
+ &vb->indexBuffer,
+ NULL);
}
if (FAILED(hr)) {
vb->buffer->Unlock();
@@ -202,9 +206,9 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx,
return NULL;
}
if (indexCount <= 0xffff) {
- hr = vb->indexBuffer->Lock(0, 0, (BYTE**) &wdst, 0);
+ hr = vb->indexBuffer->Lock(0, 0,(VOID**) &wdst, 0);
} else {
- hr = vb->indexBuffer->Lock(0, 0, (BYTE**) &idst, 0);
+ hr = vb->indexBuffer->Lock(0, 0,(VOID**) &idst, 0);
}
if (FAILED(hr)) {
vb->buffer->Unlock();
@@ -214,10 +218,10 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx,
}
}
- BYTE *bsrc = NULL;
- WORD *wsrc = NULL;
- UINT *isrc = NULL;
- UINT offset = 0;
+ BYTE *bsrc = NULL;
+ WORD *wsrc = NULL;
+ UINT *isrc = NULL;
+ UINT offset = 0;
DWORD len;
BOOL stripType = true;
@@ -233,16 +237,16 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx,
vb->numVerticesLen = 1;
vb->stripLen = 1;
stripType = false;
- }
+ }
for (r = vstart; r != vend; r++) {
- hr = (*r)->buffer->Lock(0, 0, (BYTE **) &bsrc, 0);
+ hr = (*r)->buffer->Lock(0, 0,(VOID**) &bsrc, 0);
if (FAILED(hr)) {
vb->buffer->Unlock();
if (indexCount > 0) {
vb->indexBuffer->Unlock();
- }
+ }
SafeRelease(vb->buffer);
SafeRelease(vb->indexBuffer);
return NULL;
@@ -250,9 +254,9 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx,
if (indexCount > 0) {
if (indexCount <= 0xffff) {
- hr = (*r)->indexBuffer->Lock(0, 0, (BYTE**) &wsrc, 0);
+ hr = (*r)->indexBuffer->Lock(0, 0, (VOID**)&wsrc, 0);
} else {
- hr = (*r)->indexBuffer->Lock(0, 0, (BYTE**) &isrc, 0);
+ hr = (*r)->indexBuffer->Lock(0, 0,(VOID**) &isrc, 0);
}
if (FAILED(hr)) {
(*r)->buffer->Unlock();
diff --git a/src/native/d3d/D3dDriverInfo.cpp b/src/native/d3d/D3dDriverInfo.cpp
index 01a3694..a2d848f 100644
--- a/src/native/d3d/D3dDriverInfo.cpp
+++ b/src/native/d3d/D3dDriverInfo.cpp
@@ -47,7 +47,7 @@ D3DFORMAT d3dDepthFormat[D3DDEPTHFORMATSIZE] = {D3DFMT_D15S1,
// This should match the depth bit in the above array
int d3dDepthTable[D3DDEPTHFORMATSIZE] = {15, 24, 24, 16, 16, 32};
-D3DLIGHT8 ambientLight;
+D3DLIGHT9 ambientLight;
D3dDriverInfo::D3dDriverInfo()
{
@@ -97,7 +97,41 @@ VOID computeRGBDepth(D3dDriverInfo *pDriver)
}
-VOID buildDriverList(LPDIRECT3D8 pD3D)
+
+VOID setInfo(D3dDeviceInfo* pDevice,D3DADAPTER_IDENTIFIER9 *identifier)
+{
+ char* str = (char *)"UNKNOW Vendor ";
+
+ switch( identifier->VendorId )
+ {
+ // A more complete list can be found from http://www.pcidatabase.com/vendors.php?sort=id
+ case 0x1002: str = (char *) "ATI Technologies Inc."; break;
+ case 0x1013: str = (char *) "Cirrus Logic."; break;
+ case 0x1023: str = (char *) "Trident Microsistems."; break;
+ case 0x102B: str = (char *) "Matrox Electronic Systems Ltd."; break;
+ case 0x108E: str = (char *) "Sun Microsystems."; break;
+ case 0x10DE: str = (char *) "NVIDIA Corporation"; break;
+ case 0x121A: str = (char *) "3dfx Interactive Inc"; break;
+ case 0x3D3D: str = (char *) "3Dlabs Inc, Ltd."; break;
+ case 0x5333: str = (char *) "S3 Graphics Co., Ltd."; break;
+ case 0x8086: str = (char *) "Intel Corporation"; break;
+ default: sprintf( str, "vendor ID %x.",identifier->VendorId);
+ break;
+ }
+ pDevice->deviceVendor = str;
+
+ pDevice->deviceRenderer = identifier->Description;
+
+ char version[ 128 ];
+ sprintf( version, "%d.%d.%d.%d", HIWORD( identifier->DriverVersion.HighPart ),
+ LOWORD( identifier->DriverVersion.HighPart ),
+ HIWORD( identifier->DriverVersion.LowPart ),
+ LOWORD( identifier->DriverVersion.LowPart ) );
+ pDevice->deviceVersion = (char *)version;
+}
+
+
+VOID buildDriverList(LPDIRECT3D9 pD3D)
{
numDriver = pD3D->GetAdapterCount();
@@ -120,16 +154,17 @@ VOID buildDriverList(LPDIRECT3D8 pD3D)
{
pDriver = new D3dDriverInfo();
d3dDriverList[i] = pDriver;
- pD3D->GetAdapterIdentifier(i, D3DENUM_NO_WHQL_LEVEL,
+ pD3D->GetAdapterIdentifier(i, 0,
&pDriver->adapterIdentifier);
pD3D->GetAdapterDisplayMode(i, &pDriver->desktopMode);
computeRGBDepth(pDriver);
pDriver->hMonitor = pD3D->GetAdapterMonitor(i);
pDriver->iAdapter = i;
+
for (int j = 0; j < numDeviceTypes; j++ )
{
- D3DCAPS8 d3dCaps;
+ D3DCAPS9 d3dCaps;
D3dDeviceInfo* pDevice = pDriver->d3dDeviceList[j];
pDevice->deviceType = deviceTypes[j];
pD3D->GetDeviceCaps(i, deviceTypes[j], &d3dCaps);
@@ -152,7 +187,9 @@ VOID buildDriverList(LPDIRECT3D8 pD3D)
strcpy(pDevice->deviceName, "Hardware Rasterizer");
} else {
strcpy(pDevice->deviceName, "Reference Rasterizer");
- }
+ }
+ //issue 135 put here info about vendor and device model
+ setInfo(pDevice, &pDriver->adapterIdentifier);
for (int k=0; k < D3DDEPTHFORMATSIZE; k++) {
pDevice->depthFormatSupport[k] =
@@ -176,12 +213,13 @@ VOID buildDriverList(LPDIRECT3D8 pD3D)
DWORD bitmask = 1 << 2;
pDevice->multiSampleSupport = 0;
for (int mtype = D3DMULTISAMPLE_2_SAMPLES;
- mtype <= D3DMULTISAMPLE_16_SAMPLES; mtype++) {
+ mtype <= D3DMULTISAMPLE_16_SAMPLES; mtype++) {
// consider desktop mode only for multisampling
if (SUCCEEDED(pD3D->CheckDeviceMultiSampleType(i, deviceTypes[j],
pDriver->desktopMode.Format,
TRUE,
- (D3DMULTISAMPLE_TYPE) mtype))) {
+ (D3DMULTISAMPLE_TYPE) mtype,NULL)
+ )) {
pDevice->multiSampleSupport |= bitmask;
}
bitmask <<= 1;
@@ -204,7 +242,7 @@ VOID D3dDriverInfo::release()
VOID printInfo()
{
- printf("Java 3D 1.3.3, Windows version is %d.%d ",
+ printf("Java 3D 1.4, Windows version is %d.%d ",
osvi.dwMajorVersion, osvi.dwMinorVersion);
printf("Build: %d, ", LOWORD(osvi.dwBuildNumber));
@@ -217,7 +255,7 @@ VOID printInfo()
printf("Windows 95/98");
break;
case VER_PLATFORM_WIN32_NT:
- printf("Windows NT");
+ printf("Windows NT/2000/XP");
break;
}
@@ -226,7 +264,7 @@ VOID printInfo()
D3dDriverInfo *pDriver;
for (int i=0; i < numDriver; i++) {
pDriver = d3dDriverList[i];
- D3DADAPTER_IDENTIFIER8 *id = &pDriver->adapterIdentifier;
+ D3DADAPTER_IDENTIFIER9 *id = &pDriver->adapterIdentifier;
D3DDISPLAYMODE *dm = &pDriver->desktopMode;
printf("\n[Display Driver] %s, %s, Product %d\n",
id->Driver, id->Description,
@@ -234,8 +272,9 @@ VOID printInfo()
printf(" Version %d.%d, Build %d, VendorId %d\n",
LOWORD(id->DriverVersion.HighPart),
HIWORD(id->DriverVersion.LowPart),
- LOWORD(id->DriverVersion.LowPart));
- printf(" DeviceId 0x%x, SubSysId 0x%x, Revision 0x%d\n",
+ LOWORD(id->DriverVersion.LowPart),
+ id->VendorId);
+ printf(" DeviceId %d, SubSysId %d, Revision %d\n",
id->VendorId, id->DeviceId,
id->SubSysId, id->Revision);
printf(" [Desktop Mode] %dx%d ",
@@ -262,19 +301,22 @@ VOID printInfo()
// Construct the D3dDriverList by enumerate all the drivers
VOID D3dDriverInfo::initialize(JNIEnv *env)
{
- HINSTANCE hD3D8DLL = LoadLibrary( "D3D8.DLL" );
+ HINSTANCE hD3D9DLL = LoadLibrary( "D3D9.DLL" );
- // Simply see if D3D8.dll exists.
- if ( hD3D8DLL == NULL )
+ // Simply see if D3D9.dll exists.
+ if ( hD3D9DLL == NULL )
{
D3dCtx::d3dError(D3DNOTFOUND);
return;
}
- FreeLibrary(hD3D8DLL);
-
+ FreeLibrary(hD3D9DLL);
- LPDIRECT3D8 pD3D = Direct3DCreate8( D3D_SDK_VERSION );
+ LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION );
+ printf("[Java3D] Using DirectX D3D 9.0 or higher.\n");
+ if (debug){
+ printf("[Java3D] DirectX D3D renderer build 1.4.2005.10.10\n");
+ }
if (pD3D == NULL) {
D3dCtx::d3dError(D3DNOTFOUND);
return;
@@ -317,4 +359,3 @@ VOID D3dDriverInfo::initialize(JNIEnv *env)
-
diff --git a/src/native/d3d/D3dDriverInfo.hpp b/src/native/d3d/D3dDriverInfo.hpp
index e164fe8..5c5f0ca 100644
--- a/src/native/d3d/D3dDriverInfo.hpp
+++ b/src/native/d3d/D3dDriverInfo.hpp
@@ -26,7 +26,7 @@ extern int d3dDepthTable[D3DDEPTHFORMATSIZE];
class D3dDriverInfo {
public:
// DDraw Driver info
- D3DADAPTER_IDENTIFIER8 adapterIdentifier;
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
// Desktop display mode for this adapter
D3DDISPLAYMODE desktopMode;
// monitor handle for this adapter
@@ -56,6 +56,6 @@ extern const DWORD numDeviceTypes;
extern const D3DDEVTYPE deviceTypes[2];
extern int requiredDeviceID; // force to use HAL/REF or exit
extern int requiredDriverID; // force to use specific adapte
-extern D3DLIGHT8 ambientLight; // constant ambient light
+extern D3DLIGHT9 ambientLight; // constant ambient light
extern BOOL implicitMultisample;
#endif
diff --git a/src/native/d3d/D3dImageComponent.cpp b/src/native/d3d/D3dImageComponent.cpp
index 0b15c16..64031bb 100644
--- a/src/native/d3d/D3dImageComponent.cpp
+++ b/src/native/d3d/D3dImageComponent.cpp
@@ -20,7 +20,7 @@ D3dImageComponent::D3dImageComponent()
D3dImageComponent::D3dImageComponent(D3dCtx *_ctx,
int _hashCode,
- LPDIRECT3DTEXTURE8 _surf)
+ LPDIRECT3DTEXTURE9 _surf)
{
ctx = _ctx;
hashCode = _hashCode;
@@ -46,7 +46,7 @@ VOID D3dImageComponent::init()
D3dImageComponent* D3dImageComponent::add(D3dImageComponent *list,
D3dCtx *ctx,
int hashCode,
- LPDIRECT3DTEXTURE8 surf)
+ LPDIRECT3DTEXTURE9 surf)
{
D3dImageComponent *p = list->next;
diff --git a/src/native/d3d/D3dImageComponent.hpp b/src/native/d3d/D3dImageComponent.hpp
index 0fb9743..4abedd3 100644
--- a/src/native/d3d/D3dImageComponent.hpp
+++ b/src/native/d3d/D3dImageComponent.hpp
@@ -18,7 +18,7 @@
class D3dImageComponent {
public:
- LPDIRECT3DTEXTURE8 surf;
+ LPDIRECT3DTEXTURE9 surf;
D3dCtx *ctx;
int hashCode;
D3dImageComponent *next;
@@ -26,7 +26,7 @@ public:
D3dImageComponent();
D3dImageComponent(D3dCtx *ctx, int hashCode,
- LPDIRECT3DTEXTURE8 surf);
+ LPDIRECT3DTEXTURE9 surf);
~D3dImageComponent();
@@ -37,7 +37,7 @@ public:
static D3dImageComponent* add(D3dImageComponent *list,
D3dCtx *ctx, int hashCode,
- LPDIRECT3DTEXTURE8 surf);
+ LPDIRECT3DTEXTURE9 surf);
static VOID remove(D3dImageComponent *list, D3dCtx *ctx, int hashCode);
static VOID remove(D3dImageComponent *list, D3dCtx *ctx);
diff --git a/src/native/d3d/D3dUtil.cpp b/src/native/d3d/D3dUtil.cpp
index 117c623..81d2182 100644
--- a/src/native/d3d/D3dUtil.cpp
+++ b/src/native/d3d/D3dUtil.cpp
@@ -20,7 +20,7 @@ HANDLE backgroundSema = CreateSemaphore(NULL, 1, 1,
HANDLE geometrySema = CreateSemaphore(NULL, 1, 1,
"Java3d_GeometryArrayLock");
HANDLE surfaceListSema = CreateSemaphore(NULL, 1, 1, "Java3d_SurfaceListLock");
-
+
BOOL firstError = true;
BOOL firstWarning = true;
BOOL debug;
@@ -33,7 +33,7 @@ BOOL useFreePointerList0 = true;
char *D3dErrorMessage[] = {
"Can't found 3D Driver !",
"Current display driver did not support renderer inside window. Now switch to full screen mode...",
- "DirectX 8.0 or above is required for this version of Java3D.",
+ "DirectX 9.0 or above is required for this version of Java3D.",
"Your graphics card did not support >= 16 bit color mode which Java 3D required.",
"Please switch your display mode to at least 16 bit color depth.",
"No compatible device found, please switch to other display mode and try again !",
@@ -47,7 +47,7 @@ char *D3dErrorMessage[] = {
"Graphics card did not support Hardware acceleration",
"Graphics card did not support Transform and light hardware acceleration",
"No Stencil buffer found in current display mode. DecalGroup may not work correctly.",
- "Can't found a valid texture format, please try to use reference mode",
+ "Can't found a valid texture format, please try to use reference mode. DirectX SDK must be installed to use reference mode",
"Fail to create offscreen image for background",
"Fail to create Vertex Buffer",
"Fail to Reset() D3D device, try Recreate device again.",
@@ -94,7 +94,7 @@ D3DFORMAT d3dFormatTable[] = {
D3DFMT_X8L8V8U8,
D3DFMT_Q8W8V8U8,
D3DFMT_V16U16,
- D3DFMT_W11V11U10,
+// D3DFMT_W11V11U10,
D3DFMT_UYVY,
D3DFMT_YUY2,
D3DFMT_DXT1,
@@ -116,7 +116,7 @@ D3DFORMAT d3dFormatTable[] = {
char *d3dFormatTableChar[] = {
"D3DFMT_UNKNOWN",
- "D3DFMT_R8G8B8",
+ "D3DFMT_R8G8B8",
"D3DFMT_A8R8G8B8",
"D3DFMT_X8R8G8B8",
"D3DFMT_R5G6B5",
@@ -137,7 +137,7 @@ char *d3dFormatTableChar[] = {
"D3DFMT_X8L8V8U8",
"D3DFMT_Q8W8V8U8",
"D3DFMT_V16U16",
- "D3DFMT_W11V11U10",
+ // "D3DFMT_W11V11U10",
"D3DFMT_UYVY",
"D3DFMT_YUY2",
"D3DFMT_DXT1",
@@ -200,9 +200,9 @@ D3DCUBEMAP_FACES textureCubeMapFace[] = {
typedef struct _PIXELFORMAT {
DWORD dwRGBBitCount;
DWORD dwRBitMask;
- DWORD dwGBitMask;
- DWORD dwBBitMask;
- DWORD dwRGBAlphaBitMask;
+ DWORD dwGBitMask;
+ DWORD dwBBitMask;
+ DWORD dwRGBAlphaBitMask;
BOOL noAlpha;
} PIXELFORMAT;
@@ -213,7 +213,7 @@ typedef struct _DEPTHPIXELFORMAT {
} DEPTHPIXELFORMAT;
-char *getSwapEffectName(D3DSWAPEFFECT swapEffect)
+char *getSwapEffectName(D3DSWAPEFFECT swapEffect)
{
int t = (int) swapEffect;
if ((t < 0) || (t > 4)) {
@@ -222,7 +222,7 @@ char *getSwapEffectName(D3DSWAPEFFECT swapEffect)
return swapEffectTable[t];
}
-char *getMultiSampleName(D3DMULTISAMPLE_TYPE mtype)
+char *getMultiSampleName(D3DMULTISAMPLE_TYPE mtype)
{
int t = (int) mtype;
if ((t < 0) || (t > 16)) {
@@ -238,7 +238,7 @@ char* getPixelFormatName(D3DFORMAT f)
if (f == d3dFormatTable[i]) {
return d3dFormatTableChar[i];
}
- }
+ }
// should not happen
return d3dFormatTableChar[0];
}
@@ -246,7 +246,7 @@ char* getPixelFormatName(D3DFORMAT f)
// If there is a new D3DFORMAT, just add it here and
// our copy procedures can handle any format specific
// as bit mask.
-VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format)
+VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format)
{
switch (format) {
case D3DFMT_R8G8B8:
@@ -257,7 +257,7 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format)
ddpf->dwBBitMask = 0x000000ff;
ddpf->noAlpha = true;
break;
- case D3DFMT_A8R8G8B8:
+ case D3DFMT_A8R8G8B8:
ddpf->dwRGBBitCount = 32;
ddpf->dwRGBAlphaBitMask = 0xff000000;
ddpf->dwRBitMask = 0x00ff0000;
@@ -289,7 +289,7 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format)
ddpf->dwBBitMask = 0x001f;
ddpf->noAlpha = true;
break;
- case D3DFMT_A1R5G5B5:
+ case D3DFMT_A1R5G5B5:
ddpf->dwRGBBitCount = 16;
ddpf->dwRGBAlphaBitMask = 0x8000;
ddpf->dwRBitMask = 0x7c00;
@@ -361,7 +361,7 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format)
ddpf->dwBBitMask = 0;
ddpf->noAlpha = false;
break;
- default:
+ default:
printf("Unsupport format %d\n ", format);
ddpf->dwRGBBitCount = 8;
ddpf->dwRGBAlphaBitMask = 0;
@@ -376,12 +376,12 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format)
/*
- * Right now only format D3DFMT_D16_LOCKABLE
+ * Right now only format D3DFMT_D16_LOCKABLE
* is lockable by application. So can't use
* with stencil buffer (in DecalGroup) together
*/
-VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf,
- D3DFORMAT format)
+VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf,
+ D3DFORMAT format)
{
switch (format) {
case D3DFMT_D16_LOCKABLE:
@@ -392,17 +392,17 @@ VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf,
case D3DFMT_D15S1:
ddpf->dwZBufferBitDepth = 16;
ddpf->dwZBitMask = 0xfffe;
- break;
+ break;
case D3DFMT_D32:
ddpf->dwZBufferBitDepth = 32;
ddpf->dwZBitMask = 0xffffffff;
- break;
+ break;
case D3DFMT_D24S8:
case D3DFMT_D24X8:
case D3DFMT_D24X4S4:
ddpf->dwZBufferBitDepth = 32;
ddpf->dwZBitMask = 0xffffff00;
- break;
+ break;
default:
printf("Unknown depth buffer format %d\n", format);
}
@@ -412,13 +412,13 @@ VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf,
/*
* Set the correct D3DTSS_TEXTURETRANSFORMFLAGS
*/
-void setTexTransformStageFlag(D3dCtx* d3dCtx,
- LPDIRECT3DDEVICE8 device,
- int tus, int ts, int genMode)
+void setTexTransformStageFlag(D3dCtx* d3dCtx,
+ LPDIRECT3DDEVICE9 device,
+ int tus, int ts, int genMode)
{
/*
* In case of automatic texture generation, disable
- * texture unit transform stage will cause crash in
+ * texture unit transform stage will cause crash in
* reference device mode.
*/
if ((!d3dCtx->texTransformSet[tus]) &&
@@ -428,7 +428,7 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx,
D3DTTFF_DISABLE);
} else {
D3DXMATRIX *m;
-
+
switch (ts) {
case 2:
// Adjust for 2D texture transform in D3D
@@ -463,18 +463,18 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx,
m = &d3dCtx->texTransform[tus];
(*m)._31 = (*m)._41;
(*m)._32 = (*m)._42;
- device->SetTransform((D3DTRANSFORMSTATETYPE)
+ device->SetTransform((D3DTRANSFORMSTATETYPE)
(D3DTS_TEXTURE0 + tus), m);
d3dCtx->texTranslateSet[tus] = true;
}
device->SetTextureStageState(tus,
- D3DTSS_TEXTURETRANSFORMFLAGS,
+ D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT2);
break;
case 3:
device->SetTextureStageState(tus,
- D3DTSS_TEXTURETRANSFORMFLAGS,
+ D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT3);
break;
case 4:
@@ -482,15 +482,15 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx,
// The texture transform matrix is funky that only the
// upper 3x3 matrix is used if we are not using
// automatic texture generation. In case of Object
- // Linear we are need to workaround by doing our
+ // Linear we are need to workaround by doing our
// own texture transform when generate texture
// coordinate.
device->SetTextureStageState(tus,
D3DTSS_TEXTURETRANSFORMFLAGS,
- D3DTTFF_DISABLE);
- } else {
+ D3DTTFF_DISABLE);
+ } else {
device->SetTextureStageState(tus,
- D3DTSS_TEXTURETRANSFORMFLAGS,
+ D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT4|D3DTTFF_PROJECTED);
}
break;
@@ -503,18 +503,18 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx,
}
/*
- * Set the corresponding D3D texture coordinate
+ * Set the corresponding D3D texture coordinate
* mapping mode.
*/
inline int setTextureStage(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
int mapTexStage,
jint texStage)
{
DWORD mode = 0;
int genMode = d3dCtx->texGenMode[mapTexStage];
- // printf("Set TexStage mapTexStage = %d, texStage = %d, genMode = %d\n",
+ // printf("Set TexStage mapTexStage = %d, texStage = %d, genMode = %d\n",
// mapTexStage, texStage, genMode);
switch (genMode) {
@@ -523,10 +523,10 @@ inline int setTextureStage(D3dCtx *d3dCtx,
case TEX_GEN_INVALID:
// optimize for general case
device->SetTextureStageState(mapTexStage,
- D3DTSS_TEXCOORDINDEX,
+ D3DTSS_TEXCOORDINDEX,
texStage);
return genMode;
- case TEX_EYE_LINEAR:
+ case TEX_EYE_LINEAR:
mode = D3DTSS_TCI_CAMERASPACEPOSITION;
break;
case TEX_SPHERE_MAP:
@@ -547,21 +547,21 @@ inline int setTextureStage(D3dCtx *d3dCtx,
// there is no texture coordinate defined in that texStage in VB.
// This also clear the texStage previously set.
device->SetTextureStageState(mapTexStage,
- D3DTSS_TEXCOORDINDEX,
+ D3DTSS_TEXCOORDINDEX,
mode | texStage);
return TEX_GEN_AUTO;
}
-void getTexWidthHeight(D3dDeviceInfo *deviceInfo,
+void getTexWidthHeight(D3dDeviceInfo *deviceInfo,
jint* width, jint *height)
{
int texWidth, texHeight;
-
+
texWidth = *width;
texHeight = *height;
-
+
// Found a texture bigger than width/height
if (deviceInfo->texturePow2Only) {
@@ -620,7 +620,7 @@ D3DFORMAT getTexFormat(jint internalFormat) {
default:
printf("CreateTextureSurface: Unknown internal Format %d \n", internalFormat);
return D3DFMT_UNKNOWN;
- }
+ }
}
@@ -628,7 +628,7 @@ D3dCtx* findCtx(HWND hwnd)
{
D3dCtx *ctx = NULL;
- for (D3dCtx **p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) {
+ for (ITER_D3dCtxVector p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) {
if ((*p)->hwnd == hwnd) {
ctx = *p;
break;
@@ -638,7 +638,7 @@ D3dCtx* findCtx(HWND hwnd)
}
-inline VOID lock()
+inline VOID lock()
{
if (hSema != NULL) {
WaitForSingleObject(hSema, INFINITE);
@@ -653,7 +653,7 @@ inline VOID unlock()
}
-inline VOID lockSurfaceList()
+inline VOID lockSurfaceList()
{
if (surfaceListSema != NULL) {
WaitForSingleObject(surfaceListSema, INFINITE);
@@ -681,7 +681,7 @@ inline VOID unlockBackground()
}
}
-inline VOID lockImage()
+inline VOID lockImage()
{
if (imageSema != NULL) {
WaitForSingleObject(imageSema, INFINITE);
@@ -697,7 +697,7 @@ inline VOID unlockImage()
-inline VOID lockGeometry()
+inline VOID lockGeometry()
{
if (geometrySema != NULL) {
WaitForSingleObject(geometrySema, INFINITE);
@@ -711,28 +711,28 @@ inline VOID unlockGeometry()
}
}
-VOID freePointer(void * ptr)
+VOID freePointer(void * ptr)
{
if (ptr != NULL) {
lockSurfaceList();
if (useFreePointerList0) {
freePointerList0.push_back(ptr);
} else {
- freePointerList1.push_back(ptr);
+ freePointerList1.push_back(ptr);
}
unlockSurfaceList();
}
}
-char *getErrorMessage(int idx)
+char *getErrorMessage(int idx)
{
return D3dErrorMessage[idx];
}
-HWND getTopWindow(HWND hwnd)
+HWND getTopWindow(HWND hwnd)
{
HWND desktop = GetDesktopWindow();
HWND parent = GetParent(hwnd);
@@ -745,7 +745,7 @@ HWND getTopWindow(HWND hwnd)
}
-DWORD firstBit(DWORD mask)
+DWORD firstBit(DWORD mask)
{
int i;
@@ -760,23 +760,23 @@ DWORD firstBit(DWORD mask)
}
// create a DirectDraw Texture surface of specific width and height
-LPDIRECT3DTEXTURE8 createTextureSurface(D3dCtx *d3dCtx,
+LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
- jint width, jint height)
+ jint width, jint height)
{
- LPDIRECT3DTEXTURE8 pTexture;
+ LPDIRECT3DTEXTURE9 pTexture;
D3DFORMAT format;
HRESULT hr;
- LPDIRECT3DDEVICE8 pDevice = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice;
D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo;
if (!deviceInfo->supportMipmap) {
numLevels = 1;
- }
+ }
- getTexWidthHeight(deviceInfo, &width, &height);
+ getTexWidthHeight(deviceInfo, &width, &height);
format = getTexFormat(internalFormat);
// If format not support, the utility function will adjust the
@@ -787,29 +787,29 @@ LPDIRECT3DTEXTURE8 createTextureSurface(D3dCtx *d3dCtx,
if (FAILED(hr)) {
printf("Fail to create texture surface %dx%d, format %d, level %d : %s\n",
- width, height, format, numLevels, DXGetErrorString8(hr));
+ width, height, format, numLevels, DXGetErrorString9(hr));
return NULL;
}
-
+
return pTexture;
}
// create a DirectDraw Texture surface of specific width and height
-LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx,
+LPDIRECT3DVOLUMETEXTURE9 createVolumeTexture(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
- jint width,
+ jint width,
jint height,
- jint depth)
+ jint depth)
{
- LPDIRECT3DVOLUMETEXTURE8 pTexture;
+ LPDIRECT3DVOLUMETEXTURE9 pTexture;
int texWidth, texHeight, texDepth;
D3DFORMAT format;
HRESULT hr;
- LPDIRECT3DDEVICE8 pDevice = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice;
D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo;
texWidth = width;
@@ -819,7 +819,7 @@ LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx,
if (!deviceInfo->supportMipmap) {
numLevels = 1;
- }
+ }
// Found a texture bigger than width/height
@@ -887,25 +887,25 @@ LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx,
if (debug) {
printf("Fail to create volume texture %dx%dx%d, format %d, level %d : %s\n",
texWidth, texHeight, texDepth, format, numLevels,
- DXGetErrorString8(hr));
+ DXGetErrorString9(hr));
}
return NULL;
}
-
+
return pTexture;
}
// copy data from DirectDraw surface to memory
// and reverse the Y axis
-void copyDataFromSurface(jint internalFormat,
+void copyDataFromSurface(jint internalFormat,
jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
- jbyte *data,
- LPDIRECT3DSURFACE8 surf)
+ jbyte *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
PIXELFORMAT ddpf;
HRESULT hr;
@@ -929,7 +929,7 @@ void copyDataFromSurface(jint internalFormat,
D3DLOCK_READONLY);
if (FAILED(hr)) {
- printf("Fail to lock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -941,9 +941,9 @@ void copyDataFromSurface(jint internalFormat,
unsigned char *destRow = (unsigned char *) data;
unsigned char *srcRow = ((unsigned char *) lockedRect.pBits) +
- xoffset*((int) ceil((float) ddpf.dwRGBBitCount/8.0)) +
+ xoffset*((int) ceil((float) ddpf.dwRGBBitCount/8.0)) +
(yoffset*lockedRect.Pitch);
-
+
if ((internalFormat == FORMAT_BYTE_RGBA) ||
(internalFormat == FORMAT_BYTE_RGB)) {
@@ -969,7 +969,7 @@ void copyDataFromSurface(jint internalFormat,
*src++;
*dst++ = (byte) 0xff;
}
- srcRow += lockedRect.Pitch;
+ srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
} else {
@@ -985,21 +985,21 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = b1;
*dst++ = *src++;
}
- srcRow += lockedRect.Pitch;
+ srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
}
} else { // handle less common format
int rshift = firstBit(ddpf.dwRBitMask) +
- countBits(ddpf.dwRBitMask) - 8;
- int gshift = firstBit(ddpf.dwGBitMask) +
- countBits(ddpf.dwGBitMask) - 8;
+ ucountBits(ddpf.dwRBitMask) - 8;
+ int gshift = firstBit(ddpf.dwGBitMask) +
+ ucountBits(ddpf.dwGBitMask) - 8;
int bshift = firstBit(ddpf.dwBBitMask) +
- countBits(ddpf.dwBBitMask) - 8;
+ ucountBits(ddpf.dwBBitMask) - 8;
int ashift = firstBit(ddpf.dwRGBAlphaBitMask) +
- countBits(ddpf.dwRGBAlphaBitMask) - 8;
+ ucountBits(ddpf.dwRGBAlphaBitMask) - 8;
- if ((ddpf.dwRGBBitCount <= 32) &&
+ if ((ddpf.dwRGBBitCount <= 32) &&
(ddpf.dwRGBBitCount > 24)) {
for (int i=yoffset; i < ylimit; i++) {
@@ -1028,7 +1028,7 @@ void copyDataFromSurface(jint internalFormat,
}
if (bshift >= 0) {
*dst++ = (byte) ((mask & ddpf.dwBBitMask) >>
- bshift);
+ bshift);
} else {
t = (mask & ddpf.dwBBitMask) << -bshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
@@ -1048,7 +1048,7 @@ void copyDataFromSurface(jint internalFormat,
srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
- } else if ((ddpf.dwRGBBitCount <= 24) &&
+ } else if ((ddpf.dwRGBBitCount <= 24) &&
(ddpf.dwRGBBitCount > 16)) {
for (int i=yoffset; i < ylimit; i++) {
src = srcRow;
@@ -1094,7 +1094,7 @@ void copyDataFromSurface(jint internalFormat,
srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
- } else if ((ddpf.dwRGBBitCount <= 16) &&
+ } else if ((ddpf.dwRGBBitCount <= 16) &&
(ddpf.dwRGBBitCount > 8)) {
for (int i=yoffset; i < ylimit; i++) {
@@ -1111,7 +1111,7 @@ void copyDataFromSurface(jint internalFormat,
t = (mask & ddpf.dwRBitMask) << -rshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
-
+
if (gshift >= 0) {
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
@@ -1121,7 +1121,7 @@ void copyDataFromSurface(jint internalFormat,
}
if (bshift >= 0) {
*dst++ = (byte) ((mask & ddpf.dwBBitMask) >>
- bshift);
+ bshift);
} else {
t = (mask & ddpf.dwBBitMask) << -bshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
@@ -1155,7 +1155,7 @@ void copyDataFromSurface(jint internalFormat,
t = (mask & ddpf.dwRBitMask) << -rshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
-
+
if (gshift >= 0) {
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
@@ -1165,7 +1165,7 @@ void copyDataFromSurface(jint internalFormat,
}
if (bshift >= 0) {
*dst++ = (byte) ((mask & ddpf.dwBBitMask) >>
- bshift);
+ bshift);
} else {
t = (mask & ddpf.dwBBitMask) << -bshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
@@ -1186,12 +1186,12 @@ void copyDataFromSurface(jint internalFormat,
destRow -= dstPitch;
}
}
- }
+ }
} else if (internalFormat == FORMAT_BYTE_LA) {
- int gshift = firstBit(ddpf.dwGBitMask) +
- countBits(ddpf.dwGBitMask) - 8;
+ int gshift = firstBit(ddpf.dwGBitMask) +
+ ucountBits(ddpf.dwGBitMask) - 8;
int ashift = firstBit(ddpf.dwRGBAlphaBitMask) +
- countBits(ddpf.dwRGBAlphaBitMask) - 8;
+ ucountBits(ddpf.dwRGBAlphaBitMask) - 8;
dstPitch = subWidth << 1;
destRow += (subHeight-1)*dstPitch;
@@ -1215,13 +1215,13 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = *src++;
}
}
- srcRow += lockedRect.Pitch;
+ srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
} else { // handle less common format
- int gshift = firstBit(ddpf.dwGBitMask) +
- countBits(ddpf.dwGBitMask) - 8;
- if ((ddpf.dwRGBBitCount <= 32) &&
+ int gshift = firstBit(ddpf.dwGBitMask) +
+ ucountBits(ddpf.dwGBitMask) - 8;
+ if ((ddpf.dwRGBBitCount <= 32) &&
(ddpf.dwRGBBitCount > 24)) {
for (int i=yoffset; i < ylimit; i++) {
@@ -1237,7 +1237,7 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
if (ddpf.noAlpha) {
@@ -1255,7 +1255,7 @@ void copyDataFromSurface(jint internalFormat,
srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
- } else if ((ddpf.dwRGBBitCount <= 24) &&
+ } else if ((ddpf.dwRGBBitCount <= 24) &&
(ddpf.dwRGBBitCount > 16)) {
for (int i=yoffset; i < ylimit; i++) {
src = srcRow;
@@ -1269,7 +1269,7 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
if (ddpf.noAlpha) {
@@ -1287,7 +1287,7 @@ void copyDataFromSurface(jint internalFormat,
srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
- } else if ((ddpf.dwRGBBitCount <= 16) &&
+ } else if ((ddpf.dwRGBBitCount <= 16) &&
(ddpf.dwRGBBitCount > 8)) {
for (int i=yoffset; i < ylimit; i++) {
src = srcRow;
@@ -1300,7 +1300,7 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
if (ddpf.noAlpha) {
@@ -1328,7 +1328,7 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
if (ddpf.noAlpha) {
@@ -1347,11 +1347,11 @@ void copyDataFromSurface(jint internalFormat,
destRow -= dstPitch;
}
}
- }
+ }
} else if (internalFormat == FORMAT_BYTE_GRAY) {
- int gshift = firstBit(ddpf.dwGBitMask) +
- countBits(ddpf.dwGBitMask) - 8;
+ int gshift = firstBit(ddpf.dwGBitMask) +
+ ucountBits(ddpf.dwGBitMask) - 8;
dstPitch = subWidth;
destRow += (subHeight-1)*dstPitch;
@@ -1370,13 +1370,13 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = b2;
*src++;
}
- srcRow += lockedRect.Pitch;
+ srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
} else { // handle less common format
- int gshift = firstBit(ddpf.dwGBitMask) +
- countBits(ddpf.dwGBitMask) - 8;
- if ((ddpf.dwRGBBitCount <= 32) &&
+ int gshift = firstBit(ddpf.dwGBitMask) +
+ ucountBits(ddpf.dwGBitMask) - 8;
+ if ((ddpf.dwRGBBitCount <= 32) &&
(ddpf.dwRGBBitCount > 24)) {
for (int i=yoffset; i < ylimit; i++) {
@@ -1392,14 +1392,14 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
}
srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
- } else if ((ddpf.dwRGBBitCount <= 24) &&
+ } else if ((ddpf.dwRGBBitCount <= 24) &&
(ddpf.dwRGBBitCount > 16)) {
for (int i=yoffset; i < ylimit; i++) {
src = srcRow;
@@ -1413,14 +1413,14 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
}
srcRow += lockedRect.Pitch;
destRow -= dstPitch;
}
- } else if ((ddpf.dwRGBBitCount <= 16) &&
+ } else if ((ddpf.dwRGBBitCount <= 16) &&
(ddpf.dwRGBBitCount > 8)) {
for (int i=yoffset; i < ylimit; i++) {
src = srcRow;
@@ -1433,7 +1433,7 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
}
@@ -1450,7 +1450,7 @@ void copyDataFromSurface(jint internalFormat,
*dst++ = (byte) ((mask & ddpf.dwGBitMask) >>
gshift);
} else {
- t = (mask & ddpf.dwGBitMask) << -gshift;
+ t = (mask & ddpf.dwGBitMask) << -gshift;
*dst++ = (t <= 0xff ? (byte) t : 0xff);
}
}
@@ -1458,7 +1458,7 @@ void copyDataFromSurface(jint internalFormat,
destRow -= dstPitch;
}
}
- }
+ }
} else {
// FORMAT_USHORT_GRAY
@@ -1468,21 +1468,21 @@ void copyDataFromSurface(jint internalFormat,
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr));
return;
}
}
-void copyDataToSurfaceABGR(jint internalFormat,
+void copyDataToSurfaceABGR(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -1510,7 +1510,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = a;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -1529,20 +1529,20 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (a << 4) | r;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -1569,7 +1569,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -1577,7 +1577,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -1606,14 +1606,14 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -1642,13 +1642,13 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -1676,31 +1676,31 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -1710,7 +1710,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -1730,7 +1730,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -1738,7 +1738,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -1750,7 +1750,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -1770,14 +1770,14 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -1789,7 +1789,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -1809,13 +1809,13 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -1826,7 +1826,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -1846,22 +1846,22 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -1881,7 +1881,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -1902,7 +1902,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -1922,7 +1922,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -1939,26 +1939,26 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -1987,7 +1987,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -1995,7 +1995,7 @@ void copyDataToSurfaceABGR(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2026,14 +2026,14 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -2064,13 +2064,13 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -2100,16 +2100,16 @@ void copyDataToSurfaceABGR(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -2118,14 +2118,14 @@ void copyDataToSurfaceABGR(jint internalFormat,
}
-void copyDataToSurfaceBGR(jint internalFormat,
+void copyDataToSurfaceBGR(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -2153,7 +2153,7 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = 0xff;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
@@ -2172,18 +2172,18 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = 0xf0 | r;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -2205,15 +2205,15 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2237,14 +2237,14 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -2268,13 +2268,13 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -2297,29 +2297,29 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask);
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -2344,15 +2344,15 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2379,14 +2379,14 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -2413,13 +2413,13 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -2445,23 +2445,23 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
- (b << bshift) |ddpf->dwRGBAlphaBitMask);
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ (b << bshift) |ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
+ } else if (internalFormat == ALPHA) {
byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff);
byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff);
byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff);
byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff);
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -2475,7 +2475,7 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = m4;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2490,7 +2490,7 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = m3;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -2504,7 +2504,7 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = m2;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -2516,23 +2516,23 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -2556,7 +2556,7 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -2564,7 +2564,7 @@ void copyDataToSurfaceBGR(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2590,14 +2590,14 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -2623,13 +2623,13 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -2654,16 +2654,16 @@ void copyDataToSurfaceBGR(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
- ddpf->dwRGBAlphaBitMask);
+ ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -2676,14 +2676,14 @@ void copyDataToSurfaceBGR(jint internalFormat,
* but the pixel is written in the destination buffer
* from right to left. This is used for CubeMapping.
*/
-void copyDataToSurfaceRGBARev(jint internalFormat,
+void copyDataToSurfaceRGBARev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -2716,7 +2716,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -2736,19 +2736,19 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -2775,7 +2775,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -2784,7 +2784,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2814,14 +2814,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -2850,13 +2850,13 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit-1);
@@ -2884,31 +2884,31 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) -1);
for (int i=yoffset; i < ylimit; i++) {
@@ -2921,7 +2921,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -2938,7 +2938,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
@@ -2947,7 +2947,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -2962,7 +2962,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -2979,14 +2979,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3001,7 +3001,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -3018,13 +3018,13 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -3038,7 +3038,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -3055,22 +3055,22 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -3090,7 +3090,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -3111,7 +3111,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3131,7 +3131,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit-1);
@@ -3148,25 +3148,25 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -3195,7 +3195,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -3203,7 +3203,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -3234,14 +3234,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3272,13 +3272,13 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit-1);
@@ -3308,16 +3308,16 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -3327,14 +3327,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat,
-void copyDataToSurfaceABGRRev(jint internalFormat,
+void copyDataToSurfaceABGRRev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -3365,7 +3365,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -3384,20 +3384,20 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (g << 4) | b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -3424,7 +3424,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -3432,7 +3432,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -3461,14 +3461,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3497,13 +3497,13 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit-1);
@@ -3531,31 +3531,31 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -3565,7 +3565,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -3585,7 +3585,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -3593,7 +3593,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -3605,7 +3605,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -3625,14 +3625,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3644,7 +3644,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -3664,13 +3664,13 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -3681,7 +3681,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
src++;
src++;
@@ -3701,22 +3701,22 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -3737,7 +3737,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -3758,7 +3758,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3778,7 +3778,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xlimit;
@@ -3795,26 +3795,26 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -3843,7 +3843,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -3851,7 +3851,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -3882,14 +3882,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -3920,13 +3920,13 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -3956,16 +3956,16 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -3975,14 +3975,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat,
}
-void copyDataToSurfaceBGRRev(jint internalFormat,
+void copyDataToSurfaceBGRRev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -4013,7 +4013,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
*dst-- = b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
@@ -4032,18 +4032,18 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
*dst-- = (g << 4) | b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4065,15 +4065,15 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4097,14 +4097,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4128,13 +4128,13 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4157,29 +4157,29 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
r = (*src++) << -rDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask);
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4204,15 +4204,15 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4239,14 +4239,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4273,13 +4273,13 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4305,23 +4305,23 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
- (b << bshift) |ddpf->dwRGBAlphaBitMask);
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ (b << bshift) |ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
+ } else if (internalFormat == ALPHA) {
byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff);
byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff);
byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff);
byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff);
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4335,7 +4335,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4350,7 +4350,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4364,7 +4364,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4376,23 +4376,23 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4416,7 +4416,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -4425,7 +4425,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4451,14 +4451,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4484,13 +4484,13 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4515,16 +4515,16 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
- ddpf->dwRGBAlphaBitMask);
+ ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -4533,14 +4533,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat,
}
-void copyDataToSurfaceRGBRev(jint internalFormat,
+void copyDataToSurfaceRGBRev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -4573,7 +4573,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -4591,18 +4591,18 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = (g << 4) | b;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4624,15 +4624,15 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4656,14 +4656,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4687,13 +4687,13 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4716,29 +4716,29 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4763,7 +4763,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -4771,7 +4771,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4798,14 +4798,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4832,13 +4832,13 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4864,23 +4864,23 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
+ } else if (internalFormat == ALPHA) {
byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff);
byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff);
byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff);
byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff);
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4894,7 +4894,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -4909,7 +4909,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -4923,7 +4923,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -4935,23 +4935,23 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -4976,7 +4976,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -4984,7 +4984,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5011,14 +5011,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5045,13 +5045,13 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5077,16 +5077,16 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -5094,14 +5094,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat,
}
}
-void copyDataToSurfaceLARev(jint internalFormat,
+void copyDataToSurfaceLARev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -5132,7 +5132,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = l;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -5149,20 +5149,20 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (l << 4) | l;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -5179,7 +5179,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -5187,7 +5187,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5206,14 +5206,14 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5232,13 +5232,13 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5256,32 +5256,32 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- *dst-- = (byte) ((l << rshift) | (l << gshift) |
+ *dst-- = (byte) ((l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -5292,7 +5292,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5309,7 +5309,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
@@ -5318,7 +5318,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5331,7 +5331,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5348,14 +5348,14 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5368,7 +5368,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5385,13 +5385,13 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5403,7 +5403,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5420,22 +5420,22 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -5455,7 +5455,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5476,7 +5476,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5496,7 +5496,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5513,25 +5513,25 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -5560,7 +5560,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -5568,7 +5568,7 @@ void copyDataToSurfaceLARev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5599,14 +5599,14 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5637,13 +5637,13 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5673,16 +5673,16 @@ void copyDataToSurfaceLARev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -5690,14 +5690,14 @@ void copyDataToSurfaceLARev(jint internalFormat,
}
}
-void copyDataToSurfaceGrayRev(jint internalFormat,
+void copyDataToSurfaceGrayRev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -5728,7 +5728,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = l;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -5744,18 +5744,18 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (l << 4) | l;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -5767,7 +5767,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -5775,7 +5775,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5789,14 +5789,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5810,13 +5810,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | ddpf->dwRGBAlphaBitMask;
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5829,32 +5829,32 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- *dst-- = (byte) ((l << rshift) | (l << gshift) |
- (l << bshift) | ddpf->dwRGBAlphaBitMask);
+ *dst-- = (byte) ((l << rshift) | (l << gshift) |
+ (l << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -5865,7 +5865,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5882,7 +5882,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -5890,7 +5890,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -5903,7 +5903,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5920,14 +5920,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -5940,7 +5940,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5957,13 +5957,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -5975,7 +5975,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -5992,22 +5992,22 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst-- = (byte) ((r << rshift) | (g << gshift) |
+ *dst-- = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -6026,7 +6026,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6046,7 +6046,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -6065,7 +6065,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -6081,25 +6081,25 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -6127,7 +6127,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -6135,7 +6135,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6165,14 +6165,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -6202,13 +6202,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -6237,16 +6237,16 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -6255,14 +6255,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
}
-void copyDataToSurfaceGrayRev(jint internalFormat,
+void copyDataToSurfaceGrayRev(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jshort *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -6272,12 +6272,12 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
unsigned char *destRow = pRect + rectPitch*yoffset;
- if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -6297,7 +6297,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6318,7 +6318,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -6338,7 +6338,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -6355,25 +6355,25 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += ((xlimit << 2) - 1);
for (int i=yoffset; i < ylimit; i++) {
@@ -6402,7 +6402,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 24) & 0xff);
*dst-- = (byte) ((mask >> 16) & 0xff);
@@ -6410,7 +6410,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6441,14 +6441,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 16) & 0xff);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -6479,13 +6479,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst-- = (byte) ((mask >> 8) & 0xff);
*dst-- = (byte) (mask & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += (xlimit - 1);
@@ -6515,47 +6515,47 @@ void copyDataToSurfaceGrayRev(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst-- = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst-- = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
printf("Texture format %d not support.\n", internalFormat);
- }
+ }
}
/*
* Copy data to Texture memory surface *pRect
- * with pitch = rectPitch
+ * with pitch = rectPitch
* Note that rectPitch >= surface width since
* D3D may allocate extra width in texture memory
* for other purpose or for alignment. Addional
- * offset = (xoffset, yoffset) is added to copy
- * data in texture memory.
+ * offset = (xoffset, yoffset) is added to copy
+ * data in texture memory.
*
* The source image has width = subWidth and
* pointer *data.
- *
+ *
*
*/
-void copyDataToSurfaceRGBA(jint internalFormat,
+void copyDataToSurfaceRGBA(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -6588,7 +6588,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = *src++;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -6607,20 +6607,20 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (a << 4) | r;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -6647,7 +6647,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -6655,7 +6655,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6684,14 +6684,14 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -6720,13 +6720,13 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -6754,32 +6754,32 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -6792,7 +6792,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -6809,7 +6809,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -6817,7 +6817,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6832,7 +6832,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -6849,14 +6849,14 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -6871,7 +6871,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -6888,13 +6888,13 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -6908,7 +6908,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -6925,22 +6925,22 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -6960,7 +6960,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -6981,7 +6981,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7001,7 +7001,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7018,25 +7018,25 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7065,7 +7065,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -7073,7 +7073,7 @@ void copyDataToSurfaceRGBA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7104,14 +7104,14 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7142,13 +7142,13 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7178,16 +7178,16 @@ void copyDataToSurfaceRGBA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -7196,14 +7196,14 @@ void copyDataToSurfaceRGBA(jint internalFormat,
}
-void copyDataToSurfaceRGB(jint internalFormat,
+void copyDataToSurfaceRGB(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -7237,7 +7237,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -7255,18 +7255,18 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = 0xf0 | r;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
- int gshift = firstBit(ddpf->dwGBitMask);
- int bshift = firstBit(ddpf->dwBBitMask);
+ int gshift = firstBit(ddpf->dwGBitMask);
+ int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7288,15 +7288,15 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7320,14 +7320,14 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
- (b << bshift) | ddpf->dwRGBAlphaBitMask;
+ mask = (r << rshift) | (g << gshift) |
+ (b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7351,13 +7351,13 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7380,29 +7380,29 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = (*src++) >> -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7427,7 +7427,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -7435,7 +7435,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7462,14 +7462,14 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7496,13 +7496,13 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7528,23 +7528,23 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
+ } else if (internalFormat == ALPHA) {
byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff);
byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff);
byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff);
byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff);
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7558,7 +7558,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = m4;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7573,7 +7573,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = m3;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7587,7 +7587,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = m2;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7599,23 +7599,23 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = m1;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7640,7 +7640,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -7648,7 +7648,7 @@ void copyDataToSurfaceRGB(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7675,14 +7675,14 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7709,13 +7709,13 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7741,16 +7741,16 @@ void copyDataToSurfaceRGB(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -7759,14 +7759,14 @@ void copyDataToSurfaceRGB(jint internalFormat,
}
-void copyDataToSurfaceLA(jint internalFormat,
+void copyDataToSurfaceLA(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -7797,7 +7797,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = *src++;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -7814,20 +7814,20 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (a << 4) | l;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7844,7 +7844,7 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -7852,7 +7852,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7871,14 +7871,14 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -7897,13 +7897,13 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -7921,32 +7921,32 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = (*src++) >> -aDiscard;
}
- *dst++ = (byte) ((l << rshift) | (l << gshift) |
+ *dst++ = (byte) ((l << rshift) | (l << gshift) |
(l << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -7957,7 +7957,7 @@ void copyDataToSurfaceLA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -7974,7 +7974,7 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -7982,7 +7982,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -7995,7 +7995,7 @@ void copyDataToSurfaceLA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8012,14 +8012,14 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8032,7 +8032,7 @@ void copyDataToSurfaceLA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8049,13 +8049,13 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8067,7 +8067,7 @@ void copyDataToSurfaceLA(jint internalFormat,
if (aDiscard >= 0) {
a = (*src++) >> aDiscard;
} else {
- a = (*src++) << -aDiscard;
+ a = (*src++) << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8084,22 +8084,22 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -8119,7 +8119,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -8140,7 +8140,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8160,7 +8160,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8177,25 +8177,25 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -8224,7 +8224,7 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -8232,7 +8232,7 @@ void copyDataToSurfaceLA(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -8263,14 +8263,14 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8301,13 +8301,13 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8337,16 +8337,16 @@ void copyDataToSurfaceLA(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -8354,14 +8354,14 @@ void copyDataToSurfaceLA(jint internalFormat,
}
}
-void copyDataToSurfaceGray(jint internalFormat,
+void copyDataToSurfaceGray(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jbyte *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -8393,7 +8393,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = 0xff;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount == 16) &&
(ddpf->dwRBitMask == 0xf00) &&
@@ -8409,18 +8409,18 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = 0xf0 | l;
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else { // handle less common (even weird) format
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -8432,7 +8432,7 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -8440,7 +8440,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -8454,14 +8454,14 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8475,13 +8475,13 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- mask = (l << rshift) | (l << gshift) |
+ mask = (l << rshift) | (l << gshift) |
(l << bshift) | ddpf->dwRGBAlphaBitMask;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8494,32 +8494,32 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
l = (*src++) << -rDiscard;
}
- *dst++ = (byte) ((l << rshift) | (l << gshift) |
- (l << bshift) | ddpf->dwRGBAlphaBitMask);
+ *dst++ = (byte) ((l << rshift) | (l << gshift) |
+ (l << bshift) | ddpf->dwRGBAlphaBitMask);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
}
} else if (internalFormat == LUMINANCE_ALPHA) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -8530,7 +8530,7 @@ void copyDataToSurfaceGray(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8547,7 +8547,7 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -8555,7 +8555,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -8568,7 +8568,7 @@ void copyDataToSurfaceGray(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8585,14 +8585,14 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8605,7 +8605,7 @@ void copyDataToSurfaceGray(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8622,13 +8622,13 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
b = l << -bDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8640,7 +8640,7 @@ void copyDataToSurfaceGray(jint internalFormat,
if (aDiscard >= 0) {
a = l >> aDiscard;
} else {
- a = l << -aDiscard;
+ a = l << -aDiscard;
}
if (rDiscard >= 0) {
r = l >> rDiscard;
@@ -8657,22 +8657,22 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
b = l << -bDiscard;
}
- *dst++ = (byte) ((r << rshift) | (g << gshift) |
+ *dst++ = (byte) ((r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
- } else if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ } else if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -8691,7 +8691,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -8711,7 +8711,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8730,7 +8730,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8746,25 +8746,25 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
-
- if ((ddpf->dwRGBBitCount <= 32) &&
+
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -8792,7 +8792,7 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -8800,7 +8800,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -8830,14 +8830,14 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -8867,13 +8867,13 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -8902,16 +8902,16 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
@@ -8925,28 +8925,28 @@ void copyDataToSurfaceGray(jint internalFormat,
* Copy data from memory to DirectDraw surface
*
* Source image with WIDTH = tilew, the subimage with
- * dimension (subWidth, subHeight) is copy with
+ * dimension (subWidth, subHeight) is copy with
* offset = (imgXOffset, imgYOffset) from the start
* pointer *data.
*
- * Destination frame buffer is copy with
+ * Destination frame buffer is copy with
* offset = (xoffset, yoffset)
*
*/
void copyDataToSurface(jint storedFormat,
- jint internalFormat,
+ jint internalFormat,
jint xoffset, jint yoffset,
jint imgXOffset, jint imgYOffset,
jint subWidth, jint subHeight,
- jint tilew, jbyte *data,
- LPDIRECT3DTEXTURE8 surf,
- jint level)
+ jint tilew, jbyte *data,
+ LPDIRECT3DTEXTURE9 surf,
+ jint level)
{
D3DSURFACE_DESC ddsd;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
PIXELFORMAT ddpf;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -8971,58 +8971,58 @@ void copyDataToSurface(jint storedFormat,
if (FAILED(hr)) {
- printf("Fail to lock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock surface: %s\n", DXGetErrorString9(hr));
return;
}
int offset = tilew*imgYOffset + imgXOffset;
switch (storedFormat) {
case FORMAT_BYTE_RGBA :
// This is the one we use when byReference = false
- copyDataToSurfaceRGBA(internalFormat, &ddpf,
+ copyDataToSurfaceRGBA(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 2),
- xoffset, yoffset,
+ data + (offset << 2),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
break;
case FORMAT_BYTE_RGB:
- copyDataToSurfaceRGB(internalFormat, &ddpf,
+ copyDataToSurfaceRGB(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + 3*offset,
- xoffset, yoffset,
+ data + 3*offset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
break;
case FORMAT_BYTE_ABGR:
- copyDataToSurfaceABGR(internalFormat, &ddpf,
+ copyDataToSurfaceABGR(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 2),
- xoffset, yoffset,
+ data + (offset << 2),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
break;
case FORMAT_BYTE_BGR:
- copyDataToSurfaceBGR(internalFormat, &ddpf,
+ copyDataToSurfaceBGR(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + 3*offset,
- xoffset, yoffset,
+ data + 3*offset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
break;
case FORMAT_BYTE_LA:
- copyDataToSurfaceLA(internalFormat, &ddpf,
+ copyDataToSurfaceLA(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 1),
- xoffset, yoffset,
+ data + (offset << 1),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
break;
case FORMAT_BYTE_GRAY:
copyDataToSurfaceGray(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + offset,
- xoffset, yoffset,
+ data + offset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
break;
default: // should not happen
@@ -9032,21 +9032,21 @@ void copyDataToSurface(jint storedFormat,
hr = surf->UnlockRect(level);
if (FAILED(hr)) {
- printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr));
return;
}
}
-void copyDataToSurfaceGray(jint internalFormat,
+void copyDataToSurfaceGray(jint internalFormat,
PIXELFORMAT *ddpf,
unsigned char* pRect,
DWORD rectPitch,
jshort *data,
jint xoffset, jint yoffset,
- DWORD xlimit, DWORD ylimit,
- jint subWidth)
+ DWORD xlimit, DWORD ylimit,
+ jint subWidth)
{
unsigned char *src;
unsigned char *dst;
@@ -9056,12 +9056,12 @@ void copyDataToSurfaceGray(jint internalFormat,
unsigned char *destRow = pRect + rectPitch*yoffset;
- if (internalFormat == ALPHA) {
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ if (internalFormat == ALPHA) {
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -9081,7 +9081,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -9102,7 +9102,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -9122,7 +9122,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -9139,26 +9139,26 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) (a << ashift);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else if ((internalFormat == LUMINANCE) ||
(internalFormat == INTENSITY)) {
- int rDiscard = 8-countBits(ddpf->dwRBitMask);
- int gDiscard = 8-countBits(ddpf->dwGBitMask);
- int bDiscard = 8-countBits(ddpf->dwBBitMask);
- int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask);
+ int rDiscard = 8-ucountBits(ddpf->dwRBitMask);
+ int gDiscard = 8-ucountBits(ddpf->dwGBitMask);
+ int bDiscard = 8-ucountBits(ddpf->dwBBitMask);
+ int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask);
int rshift = firstBit(ddpf->dwRBitMask);
int gshift = firstBit(ddpf->dwGBitMask);
int bshift = firstBit(ddpf->dwBBitMask);
- int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
+ int ashift = firstBit(ddpf->dwRGBAlphaBitMask);
DWORD mask;
- if ((ddpf->dwRGBBitCount <= 32) &&
+ if ((ddpf->dwRGBBitCount <= 32) &&
(ddpf->dwRGBBitCount > 24)) {
destRow += (xoffset << 2);
for (int i=yoffset; i < ylimit; i++) {
@@ -9187,7 +9187,7 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
@@ -9195,7 +9195,7 @@ void copyDataToSurfaceGray(jint internalFormat,
*dst++ = (byte) ((mask >> 24) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 24) &&
(ddpf->dwRGBBitCount > 16)) {
@@ -9226,14 +9226,14 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if ((ddpf->dwRGBBitCount <= 16) &&
(ddpf->dwRGBBitCount > 8)) {
@@ -9264,13 +9264,13 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- mask = (r << rshift) | (g << gshift) |
+ mask = (r << rshift) | (g << gshift) |
(b << bshift) | (a << ashift);
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else if (ddpf->dwRGBBitCount <= 8) {
destRow += xoffset;
@@ -9300,21 +9300,21 @@ void copyDataToSurfaceGray(jint internalFormat,
} else {
a = l << -aDiscard;
}
- *dst++ = (byte) ((r << rshift) |
- (g << gshift) |
+ *dst++ = (byte) ((r << rshift) |
+ (g << gshift) |
(b << bshift) |
(a << ashift));
}
srcRow += srcPitch;
- destRow += rectPitch;
+ destRow += rectPitch;
}
} else {
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf->dwRGBBitCount);
}
} else {
printf("Texture format %d not support.\n", internalFormat);
- }
+ }
}
@@ -9325,14 +9325,14 @@ void copyDataToSurface(jint storedFormat,
jint imgXOffset, jint imgYOffset,
jint subWidth, jint subHeight,
jint tilew, jshort *data,
- LPDIRECT3DTEXTURE8 surf,
+ LPDIRECT3DTEXTURE9 surf,
jint level)
{
D3DSURFACE_DESC ddsd;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
PIXELFORMAT ddpf;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -9351,22 +9351,22 @@ void copyDataToSurface(jint storedFormat,
hr = surf->LockRect(level, &lockedRect, NULL, 0);
if (FAILED(hr)) {
- printf("Fail to lock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock surface: %s\n", DXGetErrorString9(hr));
return;
}
int offset = tilew*imgYOffset + imgXOffset;
- copyDataToSurfaceGray(internalFormat, &ddpf,
+ copyDataToSurfaceGray(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 1),
- xoffset, yoffset,
+ data + (offset << 1),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
-
+
hr = surf->UnlockRect(level);
if (FAILED(hr)) {
- printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -9376,14 +9376,14 @@ void copyDataToSurface(jint storedFormat,
// and reverse the Y axis
void copyDepthFromSurface(jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
- jint *data,
- LPDIRECT3DSURFACE8 surf)
+ jint *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
DEPTHPIXELFORMAT ddpf;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -9403,7 +9403,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr));
}
return;
}
@@ -9414,7 +9414,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
jint *dst;
unsigned char *src;
unsigned char *srcRow = ((unsigned char *) lockedRect.pBits) +
- xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) +
+ xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) +
(yoffset*lockedRect.Pitch);
int zshift = firstBit(ddpf.dwZBitMask);
@@ -9432,7 +9432,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
b2 = *src++;
b3 = *src++;
b4 = *src++;
- mask = (b4 << 24) | (b3 << 16) |
+ mask = (b4 << 24) | (b3 << 16) |
(b2 << 8) | b1;
*dst++ = (mask & ddpf.dwZBitMask) >> zshift;
}
@@ -9480,13 +9480,13 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
}
} else {
// This is not support by D3D 8 either
- printf("[Java 3D] %d bit Z buffer not support !\n",
+ printf("[Java 3D] %d bit Z buffer not support !\n",
ddpf.dwZBufferBitDepth);
}
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -9496,14 +9496,14 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
// and reverse the Y axis
void copyDepthFromSurface(jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
- jfloat *data,
- LPDIRECT3DSURFACE8 surf)
+ jfloat *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
DEPTHPIXELFORMAT ddpf;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -9524,7 +9524,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr));
}
return;
}
@@ -9535,11 +9535,11 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
jfloat *dst;
unsigned char *src;
unsigned char *srcRow = ((unsigned char *) lockedRect.pBits) +
- xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) +
+ xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) +
(yoffset*lockedRect.Pitch);
int zshift = firstBit(ddpf.dwZBitMask);
- float maxdepth = 1 << ddpf.dwZBufferBitDepth;
+ float maxdepth = float( 1 << ddpf.dwZBufferBitDepth);
destRow += (subHeight-1)*subWidth;
@@ -9554,7 +9554,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
b2 = *src++;
b3 = *src++;
b4 = *src++;
- mask = (b4 << 24) | (b3 << 16) |
+ mask = (b4 << 24) | (b3 << 16) |
(b2 << 8) | b1;
*dst++ = (((mask & ddpf.dwZBitMask) >>
zshift))/ maxdepth;
@@ -9606,13 +9606,13 @@ void copyDepthFromSurface(jint xoffset, jint yoffset,
}
} else {
// This is not support by D3D 8 either
- printf("[Java 3D] %d bit Z buffer not support !\n",
+ printf("[Java 3D] %d bit Z buffer not support !\n",
ddpf.dwZBufferBitDepth);
}
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -9624,14 +9624,14 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
- jint *data,
- LPDIRECT3DSURFACE8 surf)
+ jint *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
DEPTHPIXELFORMAT ddpf;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -9652,12 +9652,12 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr));
}
return;
}
jint *src;
- jint *srcRow = data + src_xoffset +
+ jint *srcRow = data + src_xoffset +
(src_yoffset + subHeight-1)*src_width;
unsigned char *dst;
unsigned char *destRow = ((unsigned char *) lockedRect.pBits) +
@@ -9677,7 +9677,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
for (int j=dst_xoffset; j < xlimit; j++) {
mask = *src++;
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9698,7 +9698,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
for (int j=dst_xoffset; j < xlimit; j++) {
mask = *src++;
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9718,7 +9718,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
for (int j=dst_xoffset; j < xlimit; j++) {
mask = *src++;
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9749,7 +9749,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -9762,14 +9762,14 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
- jfloat *data,
- LPDIRECT3DSURFACE8 surf)
+ jfloat *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
DEPTHPIXELFORMAT ddpf;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -9791,12 +9791,12 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr));
}
return;
}
jfloat *src;
- jfloat *srcRow = data + src_xoffset +
+ jfloat *srcRow = data + src_xoffset +
(src_yoffset + subHeight-1)*src_width;
unsigned char *dst;
unsigned char *destRow = ((unsigned char *) lockedRect.pBits) +
@@ -9805,7 +9805,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
int zshift = firstBit(ddpf.dwZBitMask);
DWORD mask;
int maxValue = ddpf.dwZBitMask >> zshift;
- float maxdepth = 1 << ddpf.dwZBufferBitDepth;
+ float maxdepth = float( 1 << ddpf.dwZBufferBitDepth);
if ((ddpf.dwZBufferBitDepth <= 32) &&
(ddpf.dwZBufferBitDepth > 24)) {
@@ -9814,9 +9814,9 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
src = srcRow;
dst = destRow;
for (int j=dst_xoffset; j < xlimit; j++) {
- mask = (DWORD) (*src++)*maxdepth;
+ mask = DWORD((*src++)*maxdepth);
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9835,9 +9835,9 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
src = srcRow;
dst = destRow;
for (int j=dst_xoffset; j < xlimit; j++) {
- mask = (DWORD) (*src++)*maxdepth;
+ mask = DWORD((*src++)*maxdepth);
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9855,9 +9855,9 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
src = srcRow;
dst = destRow;
for (int j=dst_xoffset; j < xlimit; j++) {
- mask = (DWORD) (*src++)*maxdepth;
+ mask = DWORD((*src++)*maxdepth);
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9873,7 +9873,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
src = srcRow;
dst = destRow;
for (int j=dst_xoffset; j < xlimit; j++) {
- mask = (DWORD) (*src++)*maxdepth;
+ mask = DWORD((*src++)*maxdepth);
if (mask < maxValue) {
*dst++ = (byte) ((mask << zshift) & 0xff);
} else {
@@ -9888,7 +9888,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset,
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -9900,14 +9900,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
- jint *data,
- LPDIRECT3DSURFACE8 surf)
+ jint *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
DEPTHPIXELFORMAT ddpf;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -9929,13 +9929,13 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr));
}
return;
}
jint *src;
- jint *srcRow = data + src_xoffset +
+ jint *srcRow = data + src_xoffset +
(src_yoffset + subHeight-1)*src_width;
unsigned char *dst;
unsigned char *destRow = ((unsigned char *) lockedRect.pBits) +
@@ -9960,14 +9960,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
b2 = *dst++;
b3 = *dst++;
b4 = *dst++;
- zmask = (b4 << 24) | (b3 << 16) |
+ zmask = (b4 << 24) | (b3 << 16) |
(b2 << 8) | b1;
zmask = (zmask & ddpf.dwZBitMask) >> zshift;
mask = *src++;
- if (mask < zmask) {
+ if (mask < zmask) {
// z depth test pass
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -9976,7 +9976,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
*dst++ = (byte) ((mask >> 24) & 0xff);
- }
+ }
}
srcRow -= src_width;
destRow += lockedRect.Pitch;
@@ -9991,16 +9991,16 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
b1 = *dst++;
b2 = *dst++;
b3 = *dst++;
- zmask = (b3 << 16) | (b2 << 8) | b1;
+ zmask = (b3 << 16) | (b2 << 8) | b1;
zmask = (zmask & ddpf.dwZBitMask) >> zshift;
mask = *src++;
- if (mask < zmask) {
+ if (mask < zmask) {
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
- dst -= 3;
+ dst -= 3;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
@@ -10018,12 +10018,12 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
for (int j=dst_xoffset; j < xlimit; j++) {
b1 = *dst++;
b2 = *dst++;
- zmask = (b2 << 8) | b1;
+ zmask = (b2 << 8) | b1;
zmask = (zmask & ddpf.dwZBitMask) >> zshift;
mask = *src++;
- if (mask < zmask) {
+ if (mask < zmask) {
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -10043,7 +10043,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
for (int j=dst_xoffset; j < xlimit; j++) {
zmask = (*dst++ & ddpf.dwZBitMask) >> zshift;
mask = *src++;
- if (mask < zmask) {
+ if (mask < zmask) {
dst--;
if (mask < maxValue) {
*dst++ = (byte) ((mask << zshift) & 0xff);
@@ -10060,7 +10060,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -10073,14 +10073,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
- jfloat *data,
- LPDIRECT3DSURFACE8 surf)
+ jfloat *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
DEPTHPIXELFORMAT ddpf;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -10102,12 +10102,12 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
if (FAILED(hr)) {
if (debug) {
- printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr));
}
return;
}
jfloat *src;
- jfloat *srcRow = data + src_xoffset +
+ jfloat *srcRow = data + src_xoffset +
(src_yoffset + subHeight-1)*src_width;
unsigned char *dst;
unsigned char *destRow = ((unsigned char *) lockedRect.pBits) +
@@ -10118,7 +10118,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
DWORD b1, b2, b3, b4;
DWORD zmask;
int maxValue = ddpf.dwZBitMask >> zshift;
- float maxdepth = 1 << ddpf.dwZBufferBitDepth;
+ float maxdepth = float(1 << ddpf.dwZBufferBitDepth);
if ((ddpf.dwZBufferBitDepth <= 32) &&
(ddpf.dwZBufferBitDepth > 24)) {
@@ -10131,14 +10131,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
b2 = *dst++;
b3 = *dst++;
b4 = *dst++;
- zmask = (b4 << 24) | (b3 << 16) |
+ zmask = (b4 << 24) | (b3 << 16) |
(b2 << 8) | b1;
zmask = (zmask & ddpf.dwZBitMask) >> zshift;
- mask = (DWORD) (*src++)*maxdepth;
- if (mask < zmask) {
+ mask = DWORD((*src++)*maxdepth);
+ if (mask < zmask) {
// z depth test pass
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -10147,7 +10147,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
*dst++ = (byte) ((mask >> 24) & 0xff);
- }
+ }
}
srcRow -= src_width;
destRow += lockedRect.Pitch;
@@ -10162,16 +10162,16 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
b1 = *dst++;
b2 = *dst++;
b3 = *dst++;
- zmask = (b3 << 16) | (b2 << 8) | b1;
+ zmask = (b3 << 16) | (b2 << 8) | b1;
zmask = (zmask & ddpf.dwZBitMask) >> zshift;
- mask = (DWORD) (*src++)*maxdepth;
- if (mask < zmask) {
+ mask = DWORD((*src++)*maxdepth);
+ if (mask < zmask) {
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
- dst -= 3;
+ dst -= 3;
*dst++ = (byte) (mask & 0xff);
*dst++ = (byte) ((mask >> 8) & 0xff);
*dst++ = (byte) ((mask >> 16) & 0xff);
@@ -10189,12 +10189,12 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
for (int j=dst_xoffset; j < xlimit; j++) {
b1 = *dst++;
b2 = *dst++;
- zmask = (b2 << 8) | b1;
+ zmask = (b2 << 8) | b1;
zmask = (zmask & ddpf.dwZBitMask) >> zshift;
- mask = (DWORD) (*src++)*maxdepth;
- if (mask < zmask) {
+ mask = DWORD((*src++)*maxdepth);
+ if (mask < zmask) {
if (mask < maxValue) {
- mask = mask << zshift;
+ mask = mask << zshift;
} else {
mask = ddpf.dwZBitMask;
}
@@ -10213,8 +10213,8 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
dst = destRow;
for (int j=dst_xoffset; j < xlimit; j++) {
zmask = (*dst++ & ddpf.dwZBitMask) >> zshift;
- mask = (DWORD) (*src++)*maxdepth;
- if (mask < zmask) {
+ mask = DWORD((*src++)*maxdepth);
+ if (mask < zmask) {
dst--;
if (mask < maxValue) {
*dst++ = (byte) ((mask << zshift) & 0xff);
@@ -10231,7 +10231,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -10240,13 +10240,13 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset,
// copy data to DirectDraw depth surface from memory
// and reverse the Y axis
void copyDepthToSurface(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
- jint *data,
- LPDIRECT3DSURFACE8 surf)
+ jint *data,
+ LPDIRECT3DSURFACE9 surf)
{
if (!d3dCtx->zWriteEnable) {
@@ -10260,7 +10260,7 @@ void copyDepthToSurface(D3dCtx *d3dCtx,
src_width, src_height,
data, surf);
} else {
- // Currently ZFUNC must be D3DCMP_LESS
+ // Currently ZFUNC must be D3DCMP_LESS
copyDepthToSurfaceCmp(dst_xoffset, dst_yoffset,
src_xoffset, src_yoffset,
subWidth, subHeight,
@@ -10273,13 +10273,13 @@ void copyDepthToSurface(D3dCtx *d3dCtx,
// copy data to DirectDraw depth surface from memory
// and reverse the Y axis
void copyDepthToSurface(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
- jfloat *data,
- LPDIRECT3DSURFACE8 surf)
+ jfloat *data,
+ LPDIRECT3DSURFACE9 surf)
{
if (!d3dCtx->zWriteEnable) {
return;
@@ -10292,7 +10292,7 @@ void copyDepthToSurface(D3dCtx *d3dCtx,
src_width, src_height,
data, surf);
} else {
- // Currently ZFUNC must be D3DCMP_LESS
+ // Currently ZFUNC must be D3DCMP_LESS
copyDepthToSurfaceCmp(dst_xoffset, dst_yoffset,
src_xoffset, src_yoffset,
subWidth, subHeight,
@@ -10305,12 +10305,12 @@ void copyDepthToSurface(D3dCtx *d3dCtx,
void compositeDataToSurface(jint px, jint py,
jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
- jint dataWidth,
- jbyte *data,
- LPDIRECT3DSURFACE8 surf)
+ jint dataWidth,
+ jbyte *data,
+ LPDIRECT3DSURFACE9 surf)
{
D3DSURFACE_DESC ddsd;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
PIXELFORMAT ddpf;
HRESULT hr;
@@ -10334,7 +10334,7 @@ void compositeDataToSurface(jint px, jint py,
hr = surf->LockRect(&lockedRect, NULL, 0);
if (FAILED(hr)) {
- printf("Fail to lock rendering surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock rendering surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -10344,8 +10344,8 @@ void compositeDataToSurface(jint px, jint py,
DWORD srcPitch;
int offset = (xoffset + yoffset*dataWidth) << 2;
unsigned char *srcRow = (unsigned char *) data + offset;
- unsigned char *destRow = ((unsigned char *) lockedRect.pBits) +
- ((px + xoffset) << 2) + (py + yoffset)*lockedRect.Pitch;
+ unsigned char *destRow = ((unsigned char *) lockedRect.pBits) +
+ ((px + xoffset) << 2) + (py + yoffset)*lockedRect.Pitch;
unsigned char a2;
float inv = 1.0f/255.0f;
ddpf.noAlpha = true;
@@ -10353,7 +10353,7 @@ void compositeDataToSurface(jint px, jint py,
if (ddpf.dwRGBAlphaBitMask != 0) {
ddpf.noAlpha = false;
}
-
+
srcPitch = dataWidth << 2;
if ((ddpf.dwRGBBitCount == 32) &&
@@ -10378,13 +10378,13 @@ void compositeDataToSurface(jint px, jint py,
*dst++ = 0xff;
} else {
a2 = 255-a;
- *dst++ = (*dst * a2 + b * a)*inv;
- *dst++ = (*dst * a2 + g * a)*inv;
- *dst++ = (*dst * a2 + r * a)*inv;
+ *dst++ = (unsigned char)((*dst * a2 + b * a)*inv);
+ *dst++ = (unsigned char)((*dst * a2 + g * a)*inv);
+ *dst++ = (unsigned char)((*dst * a2 + r * a)*inv);
if (ddpf.noAlpha) {
*dst++ = a;
} else {
- *dst++ = (*dst * a2 + a * a)*inv;
+ *dst++ = (unsigned char)((*dst * a2 + a * a)*inv);
}
}
} else {
@@ -10392,22 +10392,22 @@ void compositeDataToSurface(jint px, jint py,
}
}
srcRow += srcPitch;
- destRow += lockedRect.Pitch;
+ destRow += lockedRect.Pitch;
}
} else { // handle less common (even weird) format
int rshift = firstBit(ddpf.dwRBitMask) +
- countBits(ddpf.dwRBitMask) - 8;
- int gshift = firstBit(ddpf.dwGBitMask) +
- countBits(ddpf.dwGBitMask) - 8;
+ ucountBits(ddpf.dwRBitMask) - 8;
+ int gshift = firstBit(ddpf.dwGBitMask) +
+ ucountBits(ddpf.dwGBitMask) - 8;
int bshift = firstBit(ddpf.dwBBitMask) +
- countBits(ddpf.dwBBitMask) - 8;
+ ucountBits(ddpf.dwBBitMask) - 8;
int ashift = firstBit(ddpf.dwRGBAlphaBitMask) +
- countBits(ddpf.dwRGBAlphaBitMask) - 8;
+ ucountBits(ddpf.dwRGBAlphaBitMask) - 8;
DWORD mask, dmask;
DWORD dr, dg, db, da;
- if ((ddpf.dwRGBBitCount <= 32) &&
+ if ((ddpf.dwRGBBitCount <= 32) &&
(ddpf.dwRGBBitCount > 24)) {
for (int i=yoffset; i < ylimit; i++) {
src = srcRow;
@@ -10422,7 +10422,7 @@ void compositeDataToSurface(jint px, jint py,
if (a != 0xff) {
dmask = (*(dst+3) << 24) |
(*(dst+2) << 16) |
- (*(dst+1) << 8) |
+ (*(dst+1) << 8) |
*dst;
if (rshift >= 0) {
dr = (byte) ((dmask & ddpf.dwRBitMask) >>
@@ -10454,12 +10454,12 @@ void compositeDataToSurface(jint px, jint py,
da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) <<
-ashift);
}
- a = (da * a2 + a * a)*inv;
+ a = DWORD((da * a2 + a * a)*inv);
}
- g = (dg * a2 + g * a)*inv;
- b = (db * a2 + b * a)*inv;
- r = (dr * a2 + r * a)*inv;
+ g = DWORD((dg * a2 + g * a)*inv);
+ b = DWORD((db * a2 + b * a)*inv);
+ r = DWORD((dr * a2 + r * a)*inv);
}
if (rshift >= 0) {
mask = (r << rshift) & ddpf.dwRBitMask;
@@ -10492,7 +10492,7 @@ void compositeDataToSurface(jint px, jint py,
}
}
srcRow += srcPitch;
- destRow += lockedRect.Pitch;
+ destRow += lockedRect.Pitch;
}
} else if ((ddpf.dwRGBBitCount <= 24) &&
(ddpf.dwRGBBitCount > 16)) {
@@ -10539,11 +10539,11 @@ void compositeDataToSurface(jint px, jint py,
da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) <<
-ashift);
}
- a = (da * a2 + a * a)*inv;
+ a = DWORD((da * a2 + a * a)*inv);
}
- g = (dg * a2 + g * a)*inv;
- b = (db * a2 + b * a)*inv;
- r = (dr * a2 + r * a)*inv;
+ g = DWORD((dg * a2 + g * a)*inv);
+ b = DWORD((db * a2 + b * a)*inv);
+ r = DWORD((dr * a2 + r * a)*inv);
}
if (rshift >= 0) {
mask = (r << rshift) & ddpf.dwRBitMask;
@@ -10575,7 +10575,7 @@ void compositeDataToSurface(jint px, jint py,
}
}
srcRow += srcPitch;
- destRow += lockedRect.Pitch;
+ destRow += lockedRect.Pitch;
}
} else if ((ddpf.dwRGBBitCount <= 16) &&
(ddpf.dwRGBBitCount > 8)) {
@@ -10624,12 +10624,12 @@ void compositeDataToSurface(jint px, jint py,
da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) <<
-ashift);
}
- a = (da * a2 + a * a)*inv;
- }
+ a = DWORD( (da * a2 + a * a)*inv);
+ }
- g = (dg * a2 + g * a)*inv;
- b = (db * a2 + b * a)*inv;
- r = (dr * a2 + r * a)*inv;
+ g = DWORD((dg * a2 + g * a)*inv);
+ b = DWORD((db * a2 + b * a)*inv);
+ r = DWORD((dr * a2 + r * a)*inv);
}
if (rshift >= 0) {
@@ -10662,7 +10662,7 @@ void compositeDataToSurface(jint px, jint py,
}
}
srcRow += srcPitch;
- destRow += lockedRect.Pitch;
+ destRow += lockedRect.Pitch;
}
} else if (ddpf.dwRGBBitCount <= 8) {
for (int i=yoffset; i < ylimit; i++) {
@@ -10706,12 +10706,12 @@ void compositeDataToSurface(jint px, jint py,
da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) <<
-ashift);
}
- a = (da * a2 + a * a)*inv;
+ a = DWORD((da * a2 + a * a)*inv);
}
- g = (dg * a2 + g * a)*inv;
- b = (db * a2 + b * a)*inv;
- r = (dr * a2 + r * a)*inv;
+ g = DWORD((dg * a2 + g * a)*inv);
+ b = DWORD((db * a2 + b * a)*inv);
+ r = DWORD((dr * a2 + r * a)*inv);
}
if (rshift >= 0) {
mask = (r << rshift) & ddpf.dwRBitMask;
@@ -10741,19 +10741,19 @@ void compositeDataToSurface(jint px, jint py,
}
}
srcRow += srcPitch;
- destRow += lockedRect.Pitch;
+ destRow += lockedRect.Pitch;
}
- } else {
- // should not happen, RGBBitCount > 32. Even DirectX
+ } else {
+ // should not happen, RGBBitCount > 32. Even DirectX
// RGB mask can't address it.
- printf("Texture memory with RGBBitCount = %d not support. \n",
+ printf("Texture memory with RGBBitCount = %d not support. \n",
ddpf.dwRGBBitCount);
}
}
hr = surf->UnlockRect();
if (FAILED(hr)) {
- printf("Fail to unlock rendering surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock rendering surface: %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -10767,13 +10767,13 @@ void copyDataToVolume(jint storedFormat,
jint imgZOffset,
jint subWidth, jint subHeight, jint subDepth,
jint tilew, jint tileh,
- jbyte* data,
- LPDIRECT3DVOLUMETEXTURE8 surf,
+ jbyte* data,
+ LPDIRECT3DVOLUMETEXTURE9 surf,
jint level)
{
D3DVOLUME_DESC ddsd;
- D3DLOCKED_BOX lockedBox;
+ D3DLOCKED_BOX lockedBox;
PIXELFORMAT ddpf;
HRESULT hr;
UINT i;
@@ -10792,7 +10792,7 @@ void copyDataToVolume(jint storedFormat,
// case the hardware memory buffer may smaller than the
// texture pass in.
- if ((xoffset >= width) ||
+ if ((xoffset >= width) ||
(yoffset >= height) ||
(zoffset >= depth)) {
return;
@@ -10806,7 +10806,7 @@ void copyDataToVolume(jint storedFormat,
if (FAILED(hr)) {
- printf("Fail to lock volume: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock volume: %s\n", DXGetErrorString9(hr));
return;
}
@@ -10824,12 +10824,12 @@ void copyDataToVolume(jint storedFormat,
srcSlicePitch <<= 2;
for (i = zoffset; i < zlimit; i++) {
- copyDataToSurfaceRGBA(internalFormat, &ddpf,
+ copyDataToSurfaceRGBA(internalFormat, &ddpf,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
- xlimit, ylimit,
+ xoffset, yoffset,
+ xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
data += srcSlicePitch;
@@ -10841,12 +10841,12 @@ void copyDataToVolume(jint storedFormat,
srcSlicePitch *= 3;
for (i = zoffset; i < zlimit; i++) {
- copyDataToSurfaceRGB(internalFormat, &ddpf,
+ copyDataToSurfaceRGB(internalFormat, &ddpf,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
- xlimit, ylimit,
+ xoffset, yoffset,
+ xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
data += srcSlicePitch;
@@ -10857,12 +10857,12 @@ void copyDataToVolume(jint storedFormat,
srcSlicePitch <<= 2;
for (i = zoffset; i < zlimit; i++) {
- copyDataToSurfaceABGR(internalFormat, &ddpf,
+ copyDataToSurfaceABGR(internalFormat, &ddpf,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
- xlimit, ylimit,
+ xoffset, yoffset,
+ xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
data += srcSlicePitch;
@@ -10873,11 +10873,11 @@ void copyDataToVolume(jint storedFormat,
srcSlicePitch *= 3;
for (i = zoffset; i < zlimit; i++) {
- copyDataToSurfaceBGR(internalFormat, &ddpf,
+ copyDataToSurfaceBGR(internalFormat, &ddpf,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
+ xoffset, yoffset,
xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
@@ -10889,12 +10889,12 @@ void copyDataToVolume(jint storedFormat,
srcSlicePitch <<= 1;
for (i = zoffset; i < zlimit; i++) {
- copyDataToSurfaceLA(internalFormat, &ddpf,
+ copyDataToSurfaceLA(internalFormat, &ddpf,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
- xlimit, ylimit,
+ xoffset, yoffset,
+ xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
data += srcSlicePitch;
@@ -10908,8 +10908,8 @@ void copyDataToVolume(jint storedFormat,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
- xlimit, ylimit,
+ xoffset, yoffset,
+ xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
data += srcSlicePitch;
@@ -10922,7 +10922,7 @@ void copyDataToVolume(jint storedFormat,
hr = surf->UnlockBox(level);
if (FAILED(hr)) {
- printf("Fail to unlock volume: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock volume: %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -10936,12 +10936,12 @@ void copyDataToVolume(jint storedFormat,
jint imgZOffset,
jint subWidth, jint subHeight, jint subDepth,
jint tilew, jint tileh,
- jshort* data,
- LPDIRECT3DVOLUMETEXTURE8 surf,
+ jshort* data,
+ LPDIRECT3DVOLUMETEXTURE9 surf,
jint level)
{
D3DVOLUME_DESC ddsd;
- D3DLOCKED_BOX lockedBox;
+ D3DLOCKED_BOX lockedBox;
PIXELFORMAT ddpf;
HRESULT hr;
UINT i;
@@ -10958,7 +10958,7 @@ void copyDataToVolume(jint storedFormat,
computePixelFormat(&ddpf, ddsd.Format);
- if ((xoffset >= width) ||
+ if ((xoffset >= width) ||
(yoffset >= height) ||
(zoffset >= depth)) {
return;
@@ -10972,7 +10972,7 @@ void copyDataToVolume(jint storedFormat,
hr = surf->LockBox(level, &lockedBox, NULL, 0);
if (FAILED(hr)) {
- printf("Fail to lock volume: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock volume: %s\n", DXGetErrorString9(hr));
return;
}
@@ -10984,12 +10984,12 @@ void copyDataToVolume(jint storedFormat,
data += (imgOffset << 1);
for (i = zoffset; i < zlimit; i++) {
- copyDataToSurfaceGray(internalFormat, &ddpf,
+ copyDataToSurfaceGray(internalFormat, &ddpf,
p,
lockedBox.RowPitch,
data,
- xoffset, yoffset,
- xlimit, ylimit,
+ xoffset, yoffset,
+ xlimit, ylimit,
tilew);
p += lockedBox.SlicePitch;
data += srcSlicePitch;
@@ -10997,13 +10997,13 @@ void copyDataToVolume(jint storedFormat,
hr = surf->UnlockBox(level);
if (FAILED(hr)) {
- printf("Fail to unlock volume: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock volume: %s\n", DXGetErrorString9(hr));
return;
}
}
-LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env,
+LPDIRECT3DTEXTURE9 createSurfaceFromImage(JNIEnv *env,
jobject pa2d,
jlong ctx,
int width,
@@ -11033,22 +11033,22 @@ LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env,
internalFormat = LUMINANCE_ALPHA;
break;
case FORMAT_BYTE_GRAY:
- case FORMAT_USHORT_GRAY:
+ case FORMAT_USHORT_GRAY:
internalFormat = LUMINANCE;
break;
default:
printf("Format %d not support for Image Component\n", internalFormat);
return NULL;
}
-
- LPDIRECT3DTEXTURE8 surf;
- surf = createTextureSurface(d3dCtx, 1, internalFormat,
+ LPDIRECT3DTEXTURE9 surf;
+
+ surf = createTextureSurface(d3dCtx, 1, internalFormat,
width, height);
if (surf == NULL) {
- return NULL;
+ return NULL;
}
if (imageYdown != NULL) {
@@ -11058,7 +11058,7 @@ LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env,
copyDataToSurface(storedFormat, internalFormat, 0, 0, 0, 0,
width, height, width, byteData, surf, 0);
env->ReleasePrimitiveArrayCritical(imageYdown, byteData, 0);
-
+
} else {
jshort *shortData = (jshort *)(env->GetPrimitiveArrayCritical(
imageYdown, NULL));
@@ -11070,23 +11070,24 @@ LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env,
return surf;
}
-VOID createLineModeIndexBuffer(D3dCtx *d3dCtx)
+VOID createLineModeIndexBuffer(D3dCtx *d3dCtx)
{
HRESULT hr;
WORD *wptr;
hr = d3dCtx->pDevice->CreateIndexBuffer(6*sizeof(WORD),
D3DUSAGE_WRITEONLY,
- D3DFMT_INDEX16,
+ D3DFMT_INDEX16,
D3DPOOL_DEFAULT,
- &d3dCtx->lineModeIndexBuffer);
+ &d3dCtx->lineModeIndexBuffer,
+ NULL);
if (FAILED(hr)) {
D3dCtx::d3dWarning(CREATEINDEXVBFAIL, hr);
return;
}
- hr = d3dCtx->lineModeIndexBuffer->Lock(0, 0, (BYTE **) &wptr, 0);
+ hr = d3dCtx->lineModeIndexBuffer->Lock(0, 0, (VOID **) &wptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr);
return;
@@ -11101,12 +11102,12 @@ VOID createLineModeIndexBuffer(D3dCtx *d3dCtx)
d3dCtx->lineModeIndexBuffer->Unlock();
}
-// Return TRUE if index is adjust smaller
-BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount)
+// Return TRUE if index is adjust smaller
+BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount)
{
- DWORD dwIndexCount = (vcount*3) >> 1;
+ DWORD dwIndexCount = (vcount*3) >> 1;
WORD *q;
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice;
HRESULT hr;
BOOL adjustIdx = FALSE;
@@ -11119,31 +11120,33 @@ BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount)
if (dwIndexCount > d3dCtx->quadIndexBufferSize) {
d3dCtx->freeResource(d3dCtx->quadIndexBuffer);
- hr = device->CreateIndexBuffer(dwIndexCount*sizeof(WORD),
+ hr = device->CreateIndexBuffer(dwIndexCount*sizeof(WORD),
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16,
D3DPOOL_MANAGED,
- &d3dCtx->quadIndexBuffer);
+ &d3dCtx->quadIndexBuffer,
+ NULL);
if (FAILED(hr)) {
+ printf("[Java3D] Error CREATEINDEXVBFAIL \n");
D3dCtx::d3dWarning(CREATEINDEXVBFAIL, hr);
- d3dCtx->quadIndexBufferSize = 0;
+ d3dCtx->quadIndexBufferSize = 0;
d3dCtx->quadIndexBuffer = NULL;
- if (d3dCtx->quadIndexBufferSize > 0) {
+ if (d3dCtx->quadIndexBufferSize > 0) {
// indices has successfully set before, we prevent
// setting this when indices did not set before.
// It is becasue there is a bug in Nvidia driver which
// will crash in this case.
- device->SetIndices(NULL, 0);
+ device->SetIndices(NULL);
}
return adjustIdx;
- }
+ }
d3dCtx->quadIndexBufferSize = dwIndexCount;
- hr = d3dCtx->quadIndexBuffer->Lock(0, 0, (BYTE **) &q, 0);
+ hr = d3dCtx->quadIndexBuffer->Lock(0, 0, (VOID **) &q, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr);
- if (d3dCtx->quadIndexBufferSize > 0) {
- device->SetIndices(NULL, 0);
+ if (d3dCtx->quadIndexBufferSize > 0) {
+ device->SetIndices(NULL);
}
return adjustIdx;
}
@@ -11153,10 +11156,10 @@ BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount)
while (j < dwIndexCount) {
q[j++] = ++i; // q[0] = 0
q[j++] = i+1; // q[1] = 1
- q[j++] = i+2; // q[2] = 2
- q[j++] = i++; // q[3] = 0
- q[j++] = ++i; // q[4] = 2
- q[j++] = ++i; // q[5] = 3
+ q[j++] = i+2; // q[2] = 2
+ q[j++] = i++; // q[3] = 0
+ q[j++] = ++i; // q[4] = 2
+ q[j++] = ++i; // q[5] = 3
}
d3dCtx->quadIndexBuffer->Unlock();
@@ -11189,27 +11192,27 @@ int getPrimitiveNum(int primitive, int vcount)
/*
- * Note that tThe condition width == height always holds
+ * Note that tThe condition width == height always holds
* when this function is invoked.
*/
-LPDIRECT3DCUBETEXTURE8 createCubeMapTexture(D3dCtx *d3dCtx,
+LPDIRECT3DCUBETEXTURE9 createCubeMapTexture(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
- jint width,
+ jint width,
jint height)
{
- LPDIRECT3DCUBETEXTURE8 pTexture;
+ LPDIRECT3DCUBETEXTURE9 pTexture;
D3DFORMAT format;
HRESULT hr;
- LPDIRECT3DDEVICE8 pDevice = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice;
D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo;
if (!deviceInfo->supportMipmap) {
numLevels = 1;
- }
+ }
- getTexWidthHeight(deviceInfo, &width, &height);
+ getTexWidthHeight(deviceInfo, &width, &height);
format = getTexFormat(internalFormat);
// If format not support, the utility function will adjust the
@@ -11221,30 +11224,30 @@ LPDIRECT3DCUBETEXTURE8 createCubeMapTexture(D3dCtx *d3dCtx,
if (FAILED(hr)) {
if (debug) {
printf("Fail to create cube texture surface %dx%d, format %d, level %d : %s\n",
- width, height, format, numLevels, DXGetErrorString8(hr));
+ width, height, format, numLevels, DXGetErrorString9(hr));
}
return NULL;
}
-
+
return pTexture;
}
-void copyDataToCubeMap(jint storedFormat,
+void copyDataToCubeMap(jint storedFormat,
jint internalFormat,
jint xoffset, jint yoffset,
jint imgXOffset, jint imgYOffset,
jint subWidth, jint subHeight,
- jint tilew,
- jshort *data, LPDIRECT3DCUBETEXTURE8 surf,
+ jint tilew,
+ jshort *data, LPDIRECT3DCUBETEXTURE9 surf,
jint level,
jint face)
{
D3DSURFACE_DESC ddsd;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
PIXELFORMAT ddpf;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -11260,11 +11263,11 @@ void copyDataToCubeMap(jint storedFormat,
DWORD xlimit = min(xoffset + subWidth, width);
DWORD ylimit = min(yoffset + subHeight, height);
- hr = surf->LockRect(textureCubeMapFace[face], level,
+ hr = surf->LockRect(textureCubeMapFace[face], level,
&lockedRect, NULL, 0);
if (FAILED(hr)) {
- printf("Fail to lock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock surface: %s\n", DXGetErrorString9(hr));
return;
}
@@ -11272,25 +11275,25 @@ void copyDataToCubeMap(jint storedFormat,
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
(face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
- copyDataToSurfaceGray(internalFormat, &ddpf,
+ copyDataToSurfaceGray(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
- ((offset+tilew*(ylimit-yoffset)) << 1),
- xoffset, yoffset,
+ data +
+ ((offset+tilew*(ylimit-yoffset)) << 1),
+ xoffset, yoffset,
xlimit, ylimit, -tilew);
} else {
- copyDataToSurfaceGrayRev(internalFormat, &ddpf,
+ copyDataToSurfaceGrayRev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 1),
- xoffset, yoffset,
+ data + (offset << 1),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
hr = surf->UnlockRect(textureCubeMapFace[face], level);
if (FAILED(hr)) {
- printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -11301,17 +11304,17 @@ void copyDataToCubeMap(jint storedFormat,
jint xoffset, jint yoffset,
jint imgXOffset, jint imgYOffset,
jint subWidth, jint subHeight,
- jint tilew,
- jbyte* data,
- LPDIRECT3DCUBETEXTURE8 surf,
+ jint tilew,
+ jbyte* data,
+ LPDIRECT3DCUBETEXTURE9 surf,
jint level,
jint face)
{
D3DSURFACE_DESC ddsd;
- D3DLOCKED_RECT lockedRect;
+ D3DLOCKED_RECT lockedRect;
PIXELFORMAT ddpf;
HRESULT hr;
-
+
if (surf == NULL) {
return;
}
@@ -11337,7 +11340,7 @@ void copyDataToCubeMap(jint storedFormat,
if (FAILED(hr)) {
- printf("Fail to lock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to lock surface: %s\n", DXGetErrorString9(hr));
return;
}
int offset = tilew*imgYOffset + imgXOffset;
@@ -11347,118 +11350,118 @@ void copyDataToCubeMap(jint storedFormat,
// This is the one we use when byReference = false
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
(face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
- // Copy the pixel from bottom to up and
+ // Copy the pixel from bottom to up and
// left to right in this case to match OGL definition
- copyDataToSurfaceRGBA(internalFormat, &ddpf,
+ copyDataToSurfaceRGBA(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
+ data +
((offset + tilew*(ylimit-yoffset-1)) << 2),
- xoffset, yoffset,
+ xoffset, yoffset,
xlimit, ylimit, -tilew);
} else {
- // Copy the pixel from up to bottom and
+ // Copy the pixel from up to bottom and
// right to left in this case to match OGL definition
- copyDataToSurfaceRGBARev(internalFormat, &ddpf,
+ copyDataToSurfaceRGBARev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
data + (offset << 2),
- xoffset, yoffset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
break;
case FORMAT_BYTE_RGB:
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
(face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
- copyDataToSurfaceRGB(internalFormat, &ddpf,
+ copyDataToSurfaceRGB(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
+ data +
3*(offset + tilew*(ylimit-yoffset-1)),
- xoffset, yoffset,
+ xoffset, yoffset,
xlimit, ylimit, -tilew);
} else {
- copyDataToSurfaceRGBRev(internalFormat, &ddpf,
+ copyDataToSurfaceRGBRev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
data + 3*offset,
- xoffset, yoffset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
break;
case FORMAT_BYTE_ABGR:
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
(face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
- copyDataToSurfaceABGR(internalFormat, &ddpf,
+ copyDataToSurfaceABGR(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
- ((offset+tilew*(ylimit-yoffset-1)) << 2),
- xoffset, yoffset,
+ data +
+ ((offset+tilew*(ylimit-yoffset-1)) << 2),
+ xoffset, yoffset,
xlimit, ylimit, -tilew);
} else {
- copyDataToSurfaceABGRRev(internalFormat, &ddpf,
+ copyDataToSurfaceABGRRev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 2),
- xoffset, yoffset,
+ data + (offset << 2),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
break;
case FORMAT_BYTE_BGR:
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
(face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
- copyDataToSurfaceBGR(internalFormat, &ddpf,
+ copyDataToSurfaceBGR(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
+ data +
3*(offset + tilew*(ylimit-yoffset-1)),
- xoffset, yoffset,
+ xoffset, yoffset,
xlimit, ylimit, -tilew);
} else {
- copyDataToSurfaceBGRRev(internalFormat, &ddpf,
+ copyDataToSurfaceBGRRev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + 3*offset,
- xoffset, yoffset,
+ data + 3*offset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
break;
case FORMAT_BYTE_LA:
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
(face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
- copyDataToSurfaceLA(internalFormat, &ddpf,
+ copyDataToSurfaceLA(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
- ((offset+tilew*(ylimit-yoffset-1)) << 1),
- xoffset, yoffset,
- xlimit, ylimit, -tilew);
+ data +
+ ((offset+tilew*(ylimit-yoffset-1)) << 1),
+ xoffset, yoffset,
+ xlimit, ylimit, -tilew);
} else {
- copyDataToSurfaceLARev(internalFormat, &ddpf,
+ copyDataToSurfaceLARev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + (offset << 1),
- xoffset, yoffset,
+ data + (offset << 1),
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
break;
case FORMAT_BYTE_GRAY:
if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) ||
- (face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
+ (face == D3DCUBEMAP_FACE_POSITIVE_Y)) {
copyDataToSurfaceGray(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data +
- offset + tilew*(ylimit-yoffset-1),
- xoffset, yoffset,
+ data +
+ offset + tilew*(ylimit-yoffset-1),
+ xoffset, yoffset,
xlimit, ylimit, -tilew);
} else {
copyDataToSurfaceGrayRev(internalFormat, &ddpf,
(unsigned char *) lockedRect.pBits,
lockedRect.Pitch,
- data + offset,
- xoffset, yoffset,
+ data + offset,
+ xoffset, yoffset,
xlimit, ylimit, tilew);
}
break;
@@ -11469,54 +11472,57 @@ void copyDataToCubeMap(jint storedFormat,
hr = surf->UnlockRect(textureCubeMapFace[face], level);
if (FAILED(hr)) {
- printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr));
+ printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr));
return;
}
}
void drawTextureRect(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
- LPDIRECT3DTEXTURE8 surf,
+ LPDIRECT3DDEVICE9 device,
+ LPDIRECT3DTEXTURE9 surf,
D3DTLVERTEX screenCoord,
- int startx, int starty,
+ int startx, int starty,
int endx, int endy,
int scaleWidth, int scaleHeight,
- boolean texModeRepeat)
+ boolean texModeRepeat)
{
- LPDIRECT3DTEXTURE8 texture = NULL;
+ LPDIRECT3DTEXTURE9 texture = NULL;
DWORD transflag, minstate, magstate, texcoordstate;
DWORD wrapU, wrapV;
DWORD colorOp, colorArg, alphaOp, alphaArg;
D3DMATRIX m;
+ magstate = 1;
+ minstate = 1;
+
int h = endy - starty;
int w = endx - startx;
device->SetRenderState(D3DRS_SPECULARENABLE, FALSE);
- device->GetTexture(0, (LPDIRECT3DBASETEXTURE8 *) &texture);
+ device->GetTexture(0, (LPDIRECT3DBASETEXTURE9 *) &texture);
device->GetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,
&transflag);
if (transflag != D3DTTFF_DISABLE) {
device->GetTransform(D3DTS_TEXTURE0, &m);
}
-
- device->GetTextureStageState(0, D3DTSS_MINFILTER, &minstate);
- device->GetTextureStageState(0, D3DTSS_MAGFILTER, &magstate);
+ //alessandro
+ //device->GetTextureStageState(0, D3DTSS_MINFILTER, &minstate);
+ //device->GetTextureStageState(0, D3DTSS_MAGFILTER, &magstate);
device->GetTextureStageState(0, D3DTSS_TEXCOORDINDEX, &texcoordstate);
device->SetTexture(0, surf);
device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_DISABLE);
if ((w == scaleWidth) && (h == scaleHeight)) {
- device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT);
- device->SetTextureStageState(0, D3DTSS_MAGFILTER,
- D3DTEXF_POINT);
+ // alessandro
+ // device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT);
+ // device->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
} else {
- device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
- device->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
+ // device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
+ // device->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
}
device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
@@ -11550,10 +11556,10 @@ void drawTextureRect(D3dCtx *d3dCtx,
// no need to draw multiple time
tumax = scaleWidth/(float) ddsd.Width;
tvmax = scaleHeight/(float) ddsd.Height;
- device->GetTextureStageState(0, D3DTSS_ADDRESSU, &wrapU);
- device->GetTextureStageState(0, D3DTSS_ADDRESSV, &wrapV);
- device->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
- device->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
+ device->GetSamplerState (0, D3DSAMP_ADDRESSU, &wrapU);
+ device->GetSamplerState (0, D3DSAMP_ADDRESSV, &wrapV);
+ device->SetSamplerState (0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
+ device->SetSamplerState (0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
multipleDraw = false;
} else {
tumax = endx/(float) ddsd.Width;
@@ -11562,7 +11568,7 @@ void drawTextureRect(D3dCtx *d3dCtx,
}
} else {
tumax = endx/(float) ddsd.Width;
- tvmax = endy/(float) ddsd.Height;
+ tvmax = endy/(float) ddsd.Height;
multipleDraw = false;
}
@@ -11571,11 +11577,11 @@ void drawTextureRect(D3dCtx *d3dCtx,
d3dCtx->rasterRect[0].tv = tvmax;
d3dCtx->rasterRect[1].tu = tumin;
d3dCtx->rasterRect[1].tv = tvmin;
- d3dCtx->rasterRect[2].tu = tumax;
- d3dCtx->rasterRect[2].tv = tvmax;
- d3dCtx->rasterRect[3].tu = tumax;
+ d3dCtx->rasterRect[2].tu = tumax;
+ d3dCtx->rasterRect[2].tv = tvmax;
+ d3dCtx->rasterRect[3].tu = tumax;
d3dCtx->rasterRect[3].tv = tvmin;
-
+
d3dCtx->rasterRect[0].sx = screenCoord.sx;
d3dCtx->rasterRect[0].sz = screenCoord.sz;
d3dCtx->rasterRect[0].rhw = screenCoord.rhw;
@@ -11593,7 +11599,11 @@ void drawTextureRect(D3dCtx *d3dCtx,
d3dCtx->rasterRect[3].rhw = screenCoord.rhw;
if ((h > 0) && (w > 0)) {
- device->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1);
+ //device->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1);
+ //device->SetVertexShader(vertexFormat);
+ device->SetVertexShader(NULL);
+ device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
+
if (!multipleDraw) {
d3dCtx->rasterRect[0].sy = screenCoord.sy + scaleHeight;
d3dCtx->rasterRect[2].sx = screenCoord.sx + scaleWidth;
@@ -11601,7 +11611,7 @@ void drawTextureRect(D3dCtx *d3dCtx,
d3dCtx->rasterRect[3].sx = screenCoord.sx + scaleWidth;
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,
2,
- d3dCtx->rasterRect,
+ d3dCtx->rasterRect,
sizeof(D3DTLVERTEX));
} else {
d3dCtx->rasterRect[0].sy = screenCoord.sy + h;
@@ -11612,7 +11622,7 @@ void drawTextureRect(D3dCtx *d3dCtx,
for (int j=0; j < ceil(scaleWidth/((double) w)); j++) {
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,
2,
- d3dCtx->rasterRect,
+ d3dCtx->rasterRect,
sizeof(D3DTLVERTEX));
d3dCtx->rasterRect[0].sx += w;
d3dCtx->rasterRect[1].sx += w;
@@ -11648,8 +11658,8 @@ void drawTextureRect(D3dCtx *d3dCtx,
if (d3dCtx->fillMode != D3DFILL_SOLID) {
device->SetRenderState(D3DRS_FILLMODE, d3dCtx->fillMode);
}
- device->SetTextureStageState(0, D3DTSS_MINFILTER, minstate);
- device->SetTextureStageState(0, D3DTSS_MAGFILTER, magstate);
+ //device->SetTextureStageState(0, D3DTSS_MINFILTER, minstate);
+ //device->SetTextureStageState(0, D3DTSS_MAGFILTER, magstate);
device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, texcoordstate);
device->SetTextureStageState(0, D3DTSS_COLOROP, colorOp);
@@ -11658,9 +11668,23 @@ void drawTextureRect(D3dCtx *d3dCtx,
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, alphaArg);
if (texModeRepeat && !multipleDraw) {
- device->SetTextureStageState(0, D3DTSS_ADDRESSU, wrapU);
- device->SetTextureStageState(0, D3DTSS_ADDRESSV, wrapV);
+ device->SetSamplerState (0, D3DSAMP_ADDRESSU, wrapU);
+ device->SetSamplerState (0, D3DSAMP_ADDRESSV, wrapV);
}
device->SetRenderState(D3DRS_CULLMODE, d3dCtx->cullMode);
device->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
}
+
+DWORD ucountBits(DWORD mask)
+{
+ DWORD count = 0;
+ int i;
+
+ for (i=sizeof(DWORD)*8-1; i >=0 ; i--) {
+ if ((mask & 0x01) > 0) {
+ count++;
+ }
+ mask >>= 1;
+ }
+ return count;
+}
diff --git a/src/native/d3d/D3dUtil.hpp b/src/native/d3d/D3dUtil.hpp
index c91b26f..cb340d9 100644
--- a/src/native/d3d/D3dUtil.hpp
+++ b/src/native/d3d/D3dUtil.hpp
@@ -70,7 +70,7 @@
#define GetDevice() \
GetCtx() \
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; \
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; \
if (device == NULL) return;
#define GetCtx2() \
@@ -80,7 +80,7 @@
#define GetDevice2() \
GetCtx2(); \
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; \
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; \
if (device == NULL) return 0;
#define CopyColor(c, red, green, blue, alpha) \
@@ -118,6 +118,9 @@ extern vector<void *> freePointerList0;
extern vector<void *> freePointerList1;
extern BOOL useFreePointerList0;
+//ISSUE 135 a iterator to void *
+typedef vector<void *>::iterator ITER_VOID;
+
extern HANDLE hSema; // handle to semaphore
extern BOOL firstError;
extern BOOL debug;
@@ -136,21 +139,21 @@ extern VOID lockGeometry();
extern VOID unlockGeometry();
extern VOID lockSurfaceList();
extern VOID unlockSurfaceList();
-extern VOID freeSurface(LPDIRECT3DBASETEXTURE8 surf);
+extern VOID freeSurface(LPDIRECT3DBASETEXTURE9 surf);
extern VOID freePointer(void* surf);
extern VOID freePointerList();
extern VOID setWindowCallback(HWND topHwnd, HWND hwnd);
extern char* getErrorMessage(int idx);
extern HWND getTopWindow(HWND hwnd);
-extern LPDIRECT3DTEXTURE8 createTextureSurface(D3dCtx *d3dCtx,
+extern LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
jint width,
jint height);
-extern LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx,
+extern LPDIRECT3DVOLUMETEXTURE9 createVolumeTexture(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
jint width,
@@ -158,7 +161,7 @@ extern LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx,
jint depth);
-extern LPDIRECT3DCUBETEXTURE8 createCubeMapTexture(D3dCtx *d3dCtx,
+extern LPDIRECT3DCUBETEXTURE9 createCubeMapTexture(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
jint width,
@@ -170,7 +173,7 @@ extern void copyDataToSurface(jint format,
jint xoffset, jint yoffset,
jint imgXOffset, jint imgYOffset,
jint width, jint height, jint tilew,
- jshort *data, LPDIRECT3DTEXTURE8 surf,
+ jshort *data, LPDIRECT3DTEXTURE9 surf,
jint level);
extern void copyDataToSurface(jint format,
@@ -179,7 +182,7 @@ extern void copyDataToSurface(jint format,
jint imgXOffset, jint imgYOffset,
jint width, jint height, jint tilew,
jbyte* data,
- LPDIRECT3DTEXTURE8 surf,
+ LPDIRECT3DTEXTURE9 surf,
jint level);
extern void copyDataToVolume(jint format,
@@ -190,7 +193,7 @@ extern void copyDataToVolume(jint format,
jint imgZOffset,
jint width, jint height, jint depth,
jint tilew, jint tileh,
- jshort *data, LPDIRECT3DVOLUMETEXTURE8 surf,
+ jshort *data, LPDIRECT3DVOLUMETEXTURE9 surf,
jint level);
@@ -203,7 +206,7 @@ extern void copyDataToVolume(jint format,
jint width, jint height, jint depth,
jint tilew, jint tileh,
jbyte* data,
- LPDIRECT3DVOLUMETEXTURE8 surf,
+ LPDIRECT3DVOLUMETEXTURE9 surf,
jint level);
extern void copyDataToCubeMap(jint format,
@@ -212,7 +215,7 @@ extern void copyDataToCubeMap(jint format,
jint imgXOffset, jint imgYOffset,
jint width, jint height,
jint tilew,
- jshort *data, LPDIRECT3DCUBETEXTURE8 surf,
+ jshort *data, LPDIRECT3DCUBETEXTURE9 surf,
jint level,
jint face);
@@ -224,7 +227,7 @@ extern void copyDataToCubeMap(jint format,
jint width, jint height,
jint tilew,
jbyte* data,
- LPDIRECT3DCUBETEXTURE8 surf,
+ LPDIRECT3DCUBETEXTURE9 surf,
jint level,
jint face);
@@ -232,50 +235,50 @@ extern void copyDataToCubeMap(jint format,
extern void copyDepthFromSurface(jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
jint *data,
- LPDIRECT3DSURFACE8 surf);
+ LPDIRECT3DSURFACE9 surf);
extern void copyDepthFromSurface(jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
jfloat *data,
- LPDIRECT3DSURFACE8 surf);
+ LPDIRECT3DSURFACE9 surf);
extern void copyDepthToSurface(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
jint *data,
- LPDIRECT3DSURFACE8 surf);
+ LPDIRECT3DSURFACE9 surf);
extern void copyDepthToSurface(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
jint dst_xoffset, jint dst_yoffset,
jint src_xoffset, jint src_yoffset,
jint subWidth, jint subHeight,
jint src_width, jint src_height,
jfloat *data,
- LPDIRECT3DSURFACE8 surf);
+ LPDIRECT3DSURFACE9 surf);
extern void copyDataFromSurface(jint internalFormat,
jint xoffset, jint yoffset,
jint width, jint height,
- jbyte *data, LPDIRECT3DSURFACE8 surf);
+ jbyte *data, LPDIRECT3DSURFACE9 surf);
void compositeDataToSurface(jint px, jint py,
jint xoffset, jint yoffset,
jint subWidth, jint subHeight,
jint dataWidth,
jbyte *data,
- LPDIRECT3DSURFACE8 surf);
+ LPDIRECT3DSURFACE9 surf);
// extern BOOL isIdentity(jdouble *matrix);
-extern void CopyTextureStage(LPDIRECT3DDEVICE8 device,
+extern void CopyTextureStage(LPDIRECT3DDEVICE9 device,
int fromLevel, int toLevel);
-extern LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env,
+extern LPDIRECT3DTEXTURE9 createSurfaceFromImage(JNIEnv *env,
jobject pa2d,
jlong ctx,
int width,
@@ -292,19 +295,20 @@ extern char *getSwapEffectName(D3DSWAPEFFECT swapEffect);
extern int getPrimitiveNum(int primitive, int vcount);
extern int getMaxNumVertex(int primitive, int vcount);
extern void drawTextureRect(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
- LPDIRECT3DTEXTURE8 tex,
+ LPDIRECT3DDEVICE9 device,
+ LPDIRECT3DTEXTURE9 tex,
D3DTLVERTEX screenCoord,
int startx, int starty,
int endx, int endy,
int scaleWidth, int scaleHeight,
boolean texModeRepeat);
extern int setTextureStage(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
int mapTexStage,
jint texStage);
extern void setTexTransformStageFlag(D3dCtx* d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
int tus, int ts, int genMode);
+DWORD ucountBits(DWORD mask) ;
#endif
diff --git a/src/native/d3d/D3dVertexBuffer.cpp b/src/native/d3d/D3dVertexBuffer.cpp
index a29cf09..45688ee 100644
--- a/src/native/d3d/D3dVertexBuffer.cpp
+++ b/src/native/d3d/D3dVertexBuffer.cpp
@@ -62,7 +62,7 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx)
if ((buffer != NULL) && (numVertices != NULL)) {
// device is already check for NULL in callDisplayList
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice;
BOOL setAmbientLight = false;
if (((vertexFormat & D3DFVF_DIFFUSE) == 0) &&
@@ -95,9 +95,10 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx)
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
if (d3dCtx->deviceInfo->maxPointSize < d3dCtx->pointSize) {
// Use software vertex processing mode
- device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
- TRUE);
+ //device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
+ device->SetSoftwareVertexProcessing(TRUE);
}
+
oldPrimitiveType = primitiveType;
// For Polygon D3DFill_POINT mode we need to
// temporary switch primitive to point list
@@ -106,9 +107,11 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx)
}
}
- device->SetStreamSource(0, buffer, stride);
- device->SetVertexShader(vertexFormat);
-
+ device->SetStreamSource(0, buffer,0, stride);
+ //device->SetVertexShader(vertexFormat);
+ device->SetVertexShader(NULL);
+ device->SetFVF(vertexFormat);
+
int startIdx=0;
int vc, i;
@@ -123,10 +126,10 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx)
}
} else {
if (indexBuffer != NULL) {
- device->SetIndices(indexBuffer, 0);
+ device->SetIndices(indexBuffer);
for (i = 0; i < stripLen; i++) {
vc = numVertices[i];
- device->DrawIndexedPrimitive(primitiveType,
+ device->DrawIndexedPrimitive(primitiveType,0,
0,
vcount,
startIdx,
@@ -136,9 +139,9 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx)
} else {
if (d3dCtx->quadIndexBufferSize > 0) {
// Index is successfully set
- device->SetIndices(d3dCtx->quadIndexBuffer, 0);
- device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
- 0,
+ device->SetIndices(d3dCtx->quadIndexBuffer);
+ device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,
+ 0,
numVertices[0],
0,
numVertices[0] >> 1);
@@ -156,8 +159,10 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx)
if (renderPoint) {
device->SetRenderState(D3DRS_CULLMODE, d3dCtx->cullMode);
device->SetRenderState(D3DRS_FILLMODE, d3dCtx->fillMode);
- device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
+ /** device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING,
d3dCtx->softwareVertexProcessing);
+ **/
+ device->SetSoftwareVertexProcessing(d3dCtx->softwareVertexProcessing);
primitiveType = oldPrimitiveType;
} else if (restorePointSize) {
device->SetRenderState(D3DRS_POINTSIZE,
diff --git a/src/native/d3d/D3dVertexBuffer.hpp b/src/native/d3d/D3dVertexBuffer.hpp
index cef8f4a..4cb6b9e 100644
--- a/src/native/d3d/D3dVertexBuffer.hpp
+++ b/src/native/d3d/D3dVertexBuffer.hpp
@@ -22,15 +22,17 @@ class D3dVertexBuffer;
typedef D3dVertexBuffer* LPD3DVERTEXBUFFER;
typedef vector<LPD3DVERTEXBUFFER> D3dVertexBufferVector;
+//ISSUE 135 iterator for D3dVertexBuffer
+typedef vector<LPD3DVERTEXBUFFER>::iterator ITER_LPD3DVERTEXBUFFER;
class D3dVertexBuffer {
public:
// Actual buffer memory to hold all the vertices
- LPDIRECT3DVERTEXBUFFER8 buffer;
+ LPDIRECT3DVERTEXBUFFER9 buffer;
// Indexed buffer for rendering IndexedGeometry
- LPDIRECT3DINDEXBUFFER8 indexBuffer;
+ LPDIRECT3DINDEXBUFFER9 indexBuffer;
// D3D type of this Vertex Buffer
D3DPRIMITIVETYPE primitiveType;
@@ -56,6 +58,11 @@ public:
// compute from above vertexFormat
UINT stride;
+ UINT numCoorTexSupported;
+
+
+
+
// Number of strips used for StripGeometryArray
// For each strip i the number of vertex is
// numVertices[i]
diff --git a/src/native/d3d/GeometryArrayRetained.cpp b/src/native/d3d/GeometryArrayRetained.cpp
index 50c6507..681395c 100644
--- a/src/native/d3d/GeometryArrayRetained.cpp
+++ b/src/native/d3d/GeometryArrayRetained.cpp
@@ -22,6 +22,7 @@
/*
* This correspond to the constant in d3dtypes.h
* under D3D 7.0/8.0 header and may not portable :
+ * Still valid with D3D 9.0 (aces)
* D3DFVF_TEXTUREFORMAT1 3
* D3DFVF_TEXTUREFORMAT2 0
* D3DFVF_TEXTUREFORMAT3 1
@@ -62,12 +63,12 @@ void copyIndexVertexToVB(D3dCtx *d3dCtx,
if (cDirty & javax_media_j3d_GeometryArrayRetained_INDEX_CHANGED) {
jint *src = strideData->indexPtr + strideData->initialIndexIndex;
- LPDIRECT3DINDEXBUFFER8 indexBuffer = d3dCtx->pVB->indexBuffer;
+ LPDIRECT3DINDEXBUFFER9 indexBuffer = d3dCtx->pVB->indexBuffer;
D3DINDEXBUFFER_DESC desc;
BYTE *bptr;
indexBuffer->GetDesc(&desc);
- hr = indexBuffer->Lock(0, 0, &bptr, 0);
+ hr = indexBuffer->Lock(0, 0, (VOID**)&bptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr);
return;
@@ -359,7 +360,7 @@ void copyVertexToVB(D3dCtx *d3dCtx,
// buildGA() & modeulateAlpha
// Currently buildGA() will not use byte color
// so this code should never execute.
- jbyte alpha = (jbyte) 255*strideData->alpha;
+ jbyte alpha = (jbyte)(255*strideData->alpha);
if (strideData->useAlpha) {
srcStride = strideData->diffuseStride - 3;
while (wdst < wendptr) {
@@ -1066,7 +1067,7 @@ void copyOneVertexToVB(D3dCtx *d3dCtx,
float* allocateVB(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
int vcount,
int maxVertexLimit,
jint *cdirty)
@@ -1111,13 +1112,15 @@ float* allocateVB(D3dCtx *d3dCtx,
D3DUSAGE_WRITEONLY,
vb->vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
} else {
hr = device->CreateVertexBuffer(vb->stride*vcount,
D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS,
vb->vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
}
if (FAILED(hr)) {
vb->buffer = NULL;
@@ -1129,7 +1132,7 @@ float* allocateVB(D3dCtx *d3dCtx,
*cdirty = javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED;
}
- hr = vb->buffer->Lock(0, 0, (BYTE**) &ptr, 0);
+ hr = vb->buffer->Lock(0, 0,(VOID**) &ptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
@@ -1147,7 +1150,7 @@ float* allocateVB(D3dCtx *d3dCtx,
BOOL createCopyVBVertex(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
D3DDRAWPRIMITIVESTRIDEDDATA *strideData,
int vcount, jint cDirty,
jdouble* xform,
@@ -1170,7 +1173,7 @@ BOOL createCopyVBVertex(D3dCtx *d3dCtx,
} else {
// use the same VB
HRESULT hr;
- hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0);
+ hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
@@ -1210,7 +1213,7 @@ void splitVertexToMultipleVB(D3dCtx *d3dCtx,
float* oldTexCoords[D3DDP_MAXTEXCOORD];
int vc;
int texSetUsed = d3dCtx->texSetUsed;
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice;
jfloat fr, fg, fb, fa;
jbyte br, bg, bb, ba;
boolean success;
@@ -1508,7 +1511,7 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx,
{
LPD3DVERTEXBUFFER vb = d3dCtx->pVB;
HRESULT hr;
- LPDIRECT3DDEVICE8 device = d3dCtx->pDevice;
+ LPDIRECT3DDEVICE9 device = d3dCtx->pDevice;
int vbSize;
@@ -1558,13 +1561,15 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx,
D3DUSAGE_WRITEONLY,
vb->vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
} else {
hr = device->CreateVertexBuffer(vb->stride*vbSize,
D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS,
vb->vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
vb->isPointFlagUsed = true;
}
@@ -1588,13 +1593,15 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx,
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16,
D3DPOOL_DEFAULT,
- &vb->indexBuffer);
+ &vb->indexBuffer,
+ NULL);
} else {
hr = device->CreateIndexBuffer(vbSize*sizeof(UINT),
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX32,
D3DPOOL_DEFAULT,
- &vb->indexBuffer);
+ &vb->indexBuffer,
+ NULL);
}
if (FAILED(hr)) {
@@ -1610,7 +1617,7 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx,
float *vbptr;
// Note that DWORD (use for color) is of same size
// as float (use for vertex/normal)
- hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0);
+ hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
// recreate it next time
@@ -1628,7 +1635,7 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx,
BYTE *bptr;
vb->indexBuffer->GetDesc(&desc);
- hr = vb->indexBuffer->Lock(0, 0, &bptr, 0);
+ hr = vb->indexBuffer->Lock(0, 0, (VOID**)&bptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr);
vb->buffer->Unlock();
@@ -1848,35 +1855,37 @@ void splitIndexVertexToMultipleVB(D3dCtx *d3dCtx,
// This is used by quad polygon line mode
void DrawPolygonLine(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
DWORD vertexFormat,
D3DDRAWPRIMITIVESTRIDEDDATA *strideData)
{
HRESULT hr;
float *vbptr;
- hr = d3dCtx->pVB->buffer->Lock(0, 0, (BYTE**) &vbptr, 0 );
+ hr = d3dCtx->pVB->buffer->Lock(0, 0, (VOID**) &vbptr, 0 );
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
return;
}
// DisplayList will not use in this case, so xform = nxform = NULL
copyVertexToVB(d3dCtx, strideData, 4, &vbptr,
- javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED, true,
- NULL, NULL);
+ javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED, true,
+ NULL, NULL);
d3dCtx->pVB->buffer->Unlock();
- device->SetStreamSource(0, d3dCtx->pVB->buffer,
- d3dCtx->pVB->stride);
- device->SetIndices(d3dCtx->lineModeIndexBuffer, 0);
- device->SetVertexShader(vertexFormat);
-
- device->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 4, 0, 4);
+ device->SetStreamSource(0, d3dCtx->pVB->buffer, 0,
+ d3dCtx->pVB->stride);
+ device->SetIndices(d3dCtx->lineModeIndexBuffer);
+ //device->SetVertexShader(vertexFormat);
+ device->SetVertexShader(NULL);
+ device->SetFVF(vertexFormat);
+
+ device->DrawIndexedPrimitive(D3DPT_LINESTRIP,0, 0, 4, 0, 4);
}
// This is used by indexed quad polygon line mode
void DrawIndexPolygonLine(D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
DWORD vertexFormat,
D3DDRAWPRIMITIVESTRIDEDDATA *strideData,
jint idx0, jint idx1, jint idx2, jint idx3)
@@ -1884,7 +1893,7 @@ void DrawIndexPolygonLine(D3dCtx *d3dCtx,
HRESULT hr;
float *vbptr;
- hr = d3dCtx->pVB->buffer->Lock(0, 0, (BYTE**) &vbptr, 0 );
+ hr = d3dCtx->pVB->buffer->Lock(0, 0, (VOID**) &vbptr, 0 );
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
return;
@@ -1904,18 +1913,21 @@ void DrawIndexPolygonLine(D3dCtx *d3dCtx,
NULL, NULL);
d3dCtx->pVB->buffer->Unlock();
- device->SetStreamSource(0, d3dCtx->pVB->buffer,
- d3dCtx->pVB->stride);
- device->SetVertexShader(vertexFormat);
- device->SetIndices(d3dCtx->lineModeIndexBuffer, 0);
+ device->SetStreamSource(0, d3dCtx->pVB->buffer, 0,
+ d3dCtx->pVB->stride);
+ //device->SetVertexShader(vertexFormat);
+ device->SetVertexShader(NULL);
+ device->SetFVF(vertexFormat);
+
+ device->SetIndices(d3dCtx->lineModeIndexBuffer);
- device->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 4, 0, 4);
+ device->DrawIndexedPrimitive(D3DPT_LINESTRIP,0, 0, 4, 0, 4);
}
void renderGeometry(JNIEnv *env,
D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
jobject geo,
jint geo_type,
D3DDRAWPRIMITIVESTRIDEDDATA *strideData,
@@ -1998,9 +2010,9 @@ void renderGeometry(JNIEnv *env,
} else {
// Found the vb in the list of vbVector
- for (LPD3DVERTEXBUFFER *s = vbVector->begin();
+ for (ITER_LPD3DVERTEXBUFFER s = vbVector->begin();
s != vbVector->end(); ++s) {
- if ((*s)->ctx == d3dCtx) {
+ if ((*s)->ctx == d3dCtx) {
vb = *s;
break;
}
@@ -2061,13 +2073,15 @@ void renderGeometry(JNIEnv *env,
D3DUSAGE_WRITEONLY,
vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
} else {
hr = device->CreateVertexBuffer(vb->stride*vb->vcount,
D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS,
vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
vb->isPointFlagUsed = true;
}
@@ -2122,7 +2136,7 @@ void renderGeometry(JNIEnv *env,
// Note that DWORD (use for color) is of same size
// as float (use for vertex/normal)
- hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0);
+ hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
// recreate it next time
@@ -2573,7 +2587,7 @@ void renderGeometry(JNIEnv *env,
void renderIndexGeometry(JNIEnv *env,
D3dCtx *d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
jobject geo,
jint geo_type,
D3DDRAWPRIMITIVESTRIDEDDATA *strideData,
@@ -2638,8 +2652,8 @@ void renderIndexGeometry(JNIEnv *env,
env->SetLongField(geo, fieldID, reinterpret_cast<long>(vbVector));
} else {
// Found the vb in the list of vbVector
- for (LPD3DVERTEXBUFFER *s = vbVector->begin();
- s != vbVector->end(); ++s) {
+ for (ITER_LPD3DVERTEXBUFFER s = vbVector->begin();
+ s != vbVector->end(); ++s) {
if ((*s)->ctx == d3dCtx) {
vb = *s;
break;
@@ -2704,13 +2718,15 @@ void renderIndexGeometry(JNIEnv *env,
D3DUSAGE_WRITEONLY,
vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
} else {
hr = device->CreateVertexBuffer(vb->stride*vb->vcount,
D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS,
vertexFormat,
D3DPOOL_DEFAULT,
- &vb->buffer);
+ &vb->buffer,
+ NULL);
vb->isPointFlagUsed = true;
}
@@ -2745,13 +2761,15 @@ void renderIndexGeometry(JNIEnv *env,
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16,
D3DPOOL_DEFAULT,
- &vb->indexBuffer);
+ &vb->indexBuffer,
+ NULL);
} else {
hr = device->CreateIndexBuffer(vb->indexCount*sizeof(UINT),
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX32,
D3DPOOL_DEFAULT,
- &vb->indexBuffer);
+ &vb->indexBuffer,
+ NULL);
}
if (FAILED(hr)) {
@@ -2799,7 +2817,7 @@ void renderIndexGeometry(JNIEnv *env,
// Note that DWORD (use for color) is of same size
// as float (use for vertex/normal)
- hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0);
+ hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0);
if (FAILED(hr)) {
D3dCtx::d3dWarning(LOCKVBFAIL, hr);
// recreate it next time
@@ -2927,7 +2945,10 @@ void renderIndexGeometry(JNIEnv *env,
renderTypeSet = true;
expandQuadIndex = true;
// fall through
- } else { // polygon line mode
+ }
+ // start quad WireFrame
+ else {
+ // polygon line mode
// we don't want to see extra line appear in the
// diagonal of quads if it splits into two
// triangles. This is REALLY SLOW !!!
@@ -3037,6 +3058,9 @@ void renderIndexGeometry(JNIEnv *env,
// Don't call vb->Renderer() at the end
return;
}
+
+ //end Quad WireFrame
+
// fall through
case GEO_TYPE_INDEXED_TRI_SET:
if (renderTypeSet == false) {
@@ -3151,7 +3175,7 @@ inline void setDefaultTextureCoordPointers(D3dCtx *d3dCtx,
*/
void setTextureCoordPointers(JNIEnv *env,
D3dCtx* d3dCtx,
- LPDIRECT3DDEVICE8 device,
+ LPDIRECT3DDEVICE9 device,
D3DDRAWPRIMITIVESTRIDEDDATA *strideData,
jint pass,
jint texoff,
@@ -3647,9 +3671,9 @@ void executeGeometryArrayVA(
/* execute geometry array with java array format */
extern "C" JNIEXPORT
void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer(
- JNIEnv *env,
+ JNIEnv *env,
jobject obj,
- jlong ctx,
+ jlong ctxInfo,
jobject geo,
jint geo_type,
jboolean isNonUniformScale,
@@ -3666,6 +3690,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer(
jbyteArray cbdata,
jint initialNormalIndex,
jobject ndata,
+ jint vertexAttrCount,
+ jintArray vertexAttrSizes,
+ jintArray vertexAttrIndices,
+ jobjectArray vertexAttrData,
jint pass,
jint texCoordMapLength,
jintArray tcoordsetmap,
@@ -3741,13 +3769,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer(
}
}
- executeGeometryArrayVA(env, obj, ctx, geo, geo_type,
- isNonUniformScale, false, 0,
- multiScreen, ignoreVertexColors,
+ executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type,
+ isNonUniformScale, false, 0, multiScreen, ignoreVertexColors,
vcount, vformat, vdefined, initialCoordIndex,
fverts, dverts, initialColorIndex,
fclrs, bclrs, initialNormalIndex,
- norms, pass, texCoordMapLength,
+ norms,
+ pass, texCoordMapLength,
tcoordsetmap,numActiveTexUnit, tunitstatemap,
texindices,texStride,texCoordPointer, NULL,
NULL, cdirty);
@@ -3763,12 +3791,12 @@ extern "C" JNIEXPORT
void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA(
JNIEnv *env,
jobject obj,
- jlong ctx,
+ jlong ctxInfo,
jobject geo,
jint geo_type,
jboolean isNonUniformScale,
jboolean multiScreen,
- jboolean ignoreVertexColors,
+ jboolean ignoreVertexColors,
jint vcount,
jint vformat,
jint vdefined,
@@ -3780,7 +3808,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA(
jbyteArray cbdata,
jint initialNormalIndex,
jfloatArray ndata,
- jint pass, // or texUnitIndex
+ jint vertexAttrCount,
+ jintArray vertexAttrSizes,
+ jintArray vertexAttrIndices,
+ jobjectArray vertexAttrData,
+ jint pass,
jint texCoordMapLength,
jintArray tcoordsetmap,
jint numActiveTexUnit,
@@ -3788,7 +3820,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA(
jintArray texindices,
jint texStride,
jobjectArray texCoords,
- jint cDirty)
+ jint cdirty)
{
jfloat *fverts = NULL;
@@ -3847,7 +3879,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA(
}
}
- executeGeometryArrayVA(env, obj, ctx, geo, geo_type,
+ executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type,
isNonUniformScale, false, 0,
multiScreen, ignoreVertexColors,
vcount, vformat, vdefined, initialCoordIndex,
@@ -3856,7 +3888,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA(
norms, pass, texCoordMapLength,
tcoordsetmap,numActiveTexUnit, tunitstatemap,
texindices,texStride,texCoordPointer,
- NULL, NULL, cDirty);
+ NULL, NULL, cdirty);
if (floatCoordDefined) {
env->ReleasePrimitiveArrayCritical( vfcoords, fverts, 0);
@@ -3910,12 +3942,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_disableGlobalAlpha(
extern "C" JNIEXPORT
void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat(
- JNIEnv *env,
+ JNIEnv *env,
jobject obj,
+ jlong ctxInfo,
jint vformat,
jboolean useAlpha,
- jboolean ignoreVertexColors,
- jlong ctx)
+ jboolean ignoreVertexColors)
{
// not use in D3D
}
@@ -4100,17 +4132,24 @@ void executeGeometryArray(JNIEnv *env,
}
+/*
+ * Class: javax_media_j3d_GeometryArrayRetained
+ * Method: buildGA
+ * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[II[II[I[D[D[F)V
+ */
extern "C" JNIEXPORT
void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env,
- jobject obj, jlong ctx, jobject geo, jint geo_type,
- jboolean isNonUniformScale, jboolean updateAlpha, float alpha,
+ jobject obj, jlong ctx, jobject geo,
+ jint geo_type,
+ jboolean isNonUniformScale, jboolean updateAlpha, float alpha,
jboolean ignoreVertexColors,
jint startVIndex,
- jint vcount, jint vformat,
+ jint vcount, jint vformat,
jint texCoordSetCount,
- jintArray texCoordSetMapArray,
+ jintArray texCoordSetMapArray,
jint texCoordMapLength,
jintArray texUnitOffset,
+ jint vertexAttrCount, jintArray vertexAttrSizes,
jdoubleArray xform, jdoubleArray nxform,
jfloatArray varray)
{
@@ -4160,8 +4199,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env,
extern "C" JNIEXPORT
void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env,
- jobject obj, jlong ctx,
- jobject geo, jint geo_type,
+ jobject obj, jlong ctx,jobject geo, jint geo_type,
jboolean isNonUniformScale, jboolean useAlpha,
jboolean multiScreen,
jboolean ignoreVertexColors,
@@ -4169,10 +4207,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env,
jint vcount, jint vformat, jint texCoordSetCount,
jintArray texCoordSetMapArray,
jint texCoordMapLength, jintArray texUnitOffset,
- jint numActiveTexUnit,
- jintArray tunitstatemap,
+ jint numActiveTexUnit,
+ jintArray tunitstatemap,
+ jint vertexAttrCount, jintArray vertexAttrSizes,
jfloatArray varray, jfloatArray carray,
- jint texUnitIndex, jint cDirty)
+ jint texUnitIndex, jint cDirty)
{
jfloat *verts = NULL;
@@ -4260,13 +4299,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_freeD3DArray
if (vbVector != NULL) {
// clearLive() invoke this in Renderer thread
- for (LPD3DVERTEXBUFFER *s = vbVector->begin();
+ for (ITER_LPD3DVERTEXBUFFER s = vbVector->begin();
s != vbVector->end(); ++s) {
// This notify vb that parent vector is already free
// so there is no need to remove itself from vbVector
(*s)->vbVector = NULL;
(*s)->ctx->freeVB(*s);
- }
+ }
env->SetLongField(geo, fieldID, 0);
vbVector->clear();
delete vbVector;
@@ -4466,7 +4505,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo
jint initialIndexIndex,
jint indexCount,
jint vcount,
- jint vformat, jint texCoordSetCount,
+ jint vformat,
+ jint vertexAttrCount, jintArray vertexAttrSizes,
+ jint texCoordSetCount,
jintArray texCoordSetMapArray,
jint texCoordMapLength, jintArray texUnitOffset,
jint numActiveTexUnit,
@@ -4573,6 +4614,8 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome
jint indexCount,
jint vertexCount,
jint vformat,
+ jint vertexAttrCount,
+ jintArray vertexAttrSizes,
jint texCoordSetCount,
jintArray texCoordSetMapArray,
jint texCoordMapLength,
@@ -4773,6 +4816,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo
jfloatArray cfdata,
jbyteArray cbdata,
jfloatArray ndata,
+ jint vertexAttrCount,
+ jintArray vertexAttrSizes,
+ jobjectArray vertexAttrData,
jint pass,
jint texCoordMapLength,
jintArray tcoordsetmap,
@@ -4917,6 +4963,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo
jfloatArray cfdata,
jbyteArray cbdata,
jobject ndata,
+ jint vertexAttrCount,
+ jintArray vertexAttrSizes,
+ jobjectArray vertexAttrData,
jint pass,
jint texCoordMapLength,
jintArray tcoordsetmap,
@@ -5124,6 +5173,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer(
javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED);
}
+/* execute geometry array with java array format */
+/*
+ * Class: javax_media_j3d_GeometryArrayRetained
+ * Method: buildGAForByRef
+ * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[F[DI[F[BI[FI[I[I[[FI[I[II[Ljava/lang/Object;[D[D)V
+ */
extern "C" JNIEXPORT
void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef(
@@ -5147,7 +5202,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef(
jbyteArray cbdata,
jint initialNormalIndex,
jfloatArray ndata,
- jint texCoordMapLength,
+ jint vertexAttrCount,
+ jintArray vertexAttrSizes,
+ jintArray vertexAttrIndices,
+ jobjectArray vertexAttrData,
+ jint texCoordMapLength,
jintArray tcoordsetmap,
jintArray texindices,
jint texStride,
diff --git a/src/native/d3d/GraphicsContext3D.cpp b/src/native/d3d/GraphicsContext3D.cpp
index e1fa7db..fc33970 100644
--- a/src/native/d3d/GraphicsContext3D.cpp
+++ b/src/native/d3d/GraphicsContext3D.cpp
@@ -49,9 +49,9 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative(
d3dCtx->createFrontBuffer())) {
- HRESULT hr = device->GetFrontBuffer(d3dCtx->frontSurface);
+ HRESULT hr = device->GetFrontBufferData(0,d3dCtx->frontSurface);//iSwapChain as 0
if (FAILED(hr)) {
- printf("GetFrontBuffer fail %s\n", DXGetErrorString8(hr));
+ printf("GetFrontBuffer fail %s\n", DXGetErrorString9(hr));
return;
}
@@ -77,10 +77,10 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative(
}
} else {
if (d3dCtx->backSurface == NULL) {
- HRESULT hr = device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO,
+ HRESULT hr = device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO, //isSwapChain as 0
&d3dCtx->backSurface);
if (FAILED(hr)) {
- printf("GetBackBuffer fail %s\n", DXGetErrorString8(hr));
+ printf("GetBackBuffer fail %s\n", DXGetErrorString9(hr));
return;
}
}
@@ -114,7 +114,7 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative(
if (FAILED(hr)) {
if (debug) {
printf("[Java3D] Fail to get depth stencil surface %s\n",
- DXGetErrorString8(hr));
+ DXGetErrorString9(hr));
}
return;
}
diff --git a/src/native/d3d/Lights.cpp b/src/native/d3d/Lights.cpp
index 322ccd1..9a790a8 100644
--- a/src/native/d3d/Lights.cpp
+++ b/src/native/d3d/Lights.cpp
@@ -27,7 +27,7 @@ void JNICALL Java_javax_media_j3d_DirectionalLightRetained_updateLight(
jfloat diry,
jfloat dirz)
{
- D3DLIGHT8 d3dLight;
+ D3DLIGHT9 d3dLight;
GetDevice();
@@ -71,7 +71,7 @@ void JNICALL Java_javax_media_j3d_PointLightRetained_updateLight(
jfloat posy,
jfloat posz)
{
- D3DLIGHT8 d3dLight;
+ D3DLIGHT9 d3dLight;
GetDevice();
@@ -119,7 +119,7 @@ void JNICALL Java_javax_media_j3d_SpotLightRetained_updateLight(
jfloat diry,
jfloat dirz)
{
- D3DLIGHT8 d3dLight;
+ D3DLIGHT9 d3dLight;
GetDevice();
diff --git a/src/native/d3d/NativeAPIInfo.c b/src/native/d3d/NativeAPIInfo.c
index 8286a7b..ddca7af 100644
--- a/src/native/d3d/NativeAPIInfo.c
+++ b/src/native/d3d/NativeAPIInfo.c
@@ -13,11 +13,11 @@
#include <jni.h>
#include "javax_media_j3d_MasterControl.h"
-
+#include "javax_media_j3d_NativeAPIInfo.h"
JNIEXPORT
jint JNICALL Java_javax_media_j3d_NativeAPIInfo_getRenderingAPI(
JNIEnv *env, jobject obj)
-{
+{
return (jint)javax_media_j3d_MasterControl_RENDER_DIRECT3D;
}
diff --git a/src/native/d3d/NativeConfigTemplate3D.cpp b/src/native/d3d/NativeConfigTemplate3D.cpp
index d115c14..c18134b 100644
--- a/src/native/d3d/NativeConfigTemplate3D.cpp
+++ b/src/native/d3d/NativeConfigTemplate3D.cpp
@@ -131,3 +131,18 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
return retValue;
}
+
+
+/*
+ * Class: javax_media_j3d_NativeConfigTemplate3D
+ * Method: getStencilSize
+ * Signature: (JZ)I
+ * @TODO: FIX THIS !!!!!
+ */
+JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_getStencilSize
+ (JNIEnv *, jobject, jlong, jboolean)
+{
+ // dummy value
+
+ return 8;
+}
diff --git a/src/native/d3d/RasterRetained.cpp b/src/native/d3d/RasterRetained.cpp
index 7886868..a1606f3 100644
--- a/src/native/d3d/RasterRetained.cpp
+++ b/src/native/d3d/RasterRetained.cpp
@@ -102,7 +102,7 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env,
D3dImageComponent* d3dImage =
D3dImageComponent::find(&RasterList, d3dCtx, hashCode);
- LPDIRECT3DTEXTURE8 surf = NULL ;
+ LPDIRECT3DTEXTURE9 surf = NULL ;
if ((d3dImage == NULL) || (d3dImage->surf == NULL)) {
@@ -200,7 +200,7 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env,
if (FAILED(hr)) {
if (debug) {
printf("[Java3D] Fail to get depth stencil surface %s\n",
- DXGetErrorString8(hr));
+ DXGetErrorString9(hr));
}
return;
}
@@ -213,8 +213,8 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env,
intData_array, NULL);
copyDepthToSurface(d3dCtx,
device,
- screenCoord.sx,
- screenCoord.sy,
+ (int)(screenCoord.sx),
+ (int)(screenCoord.sy),
x_offset, y_offset,
w, h,width, height,
intData, d3dCtx->depthStencilSurface);
@@ -230,8 +230,8 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env,
floatData_array, NULL);
copyDepthToSurface(d3dCtx,
device,
- screenCoord.sx,
- screenCoord.sy,
+ (jint)(screenCoord.sx),
+ (jint)(screenCoord.sy),
x_offset, y_offset,
w, h, width, height,
floatData, d3dCtx->depthStencilSurface);
diff --git a/src/native/d3d/StdAfx.h b/src/native/d3d/StdAfx.h
index 020e69e..d653594 100644
--- a/src/native/d3d/StdAfx.h
+++ b/src/native/d3d/StdAfx.h
@@ -7,12 +7,20 @@
*
* $Revision$
* $Date$
- * $State$
+ * $State$_WIN32_WINNT
*/
#if !defined(AFX_STDAFX_H)
#define AFX_STDAFX_H
+#ifndef WINVER
+#define WINVER 0x0501
+#endif
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
+
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
@@ -35,9 +43,9 @@
#include <jni.h>
#include <math.h>
#define D3D_OVERLOADS
-#include <d3d8.h>
-#include <dxerr8.h>
-#include <d3dx8.h>
+#include <d3d9.h>
+#include <dxerr9.h>
+#include <d3dx9.h>
#include <vector>
#include <algorithm>
using namespace std ;
@@ -52,3 +60,4 @@ using namespace std ;
#include "D3dDisplayList.hpp"
#include "D3dImageComponent.hpp"
#endif
+
diff --git a/src/native/d3d/build-windows-i586-vc.xml b/src/native/d3d/build-windows-i586-vc.xml
index 9f05f23..a73c4ca 100644
--- a/src/native/d3d/build-windows-i586-vc.xml
+++ b/src/native/d3d/build-windows-i586-vc.xml
@@ -36,12 +36,13 @@
<!-- Compile the c source files-->
<exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="cl">
- <arg line="-I&quot;${javaInclude}&quot; -I&quot;${javaWin32Include}&quot; -I&quot;${src}/native/ogl&quot; -I&quot;${javahCoreTarget}&quot; -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} -DD3D -DJ3D_BUILDVERTICES -c &quot;${oglsrc}/DrawingSurfaceObjectAWT.c&quot; &quot;${oglsrc}/MasterControl.c&quot; &quot;${d3dsrc}/D3dVertexBuffer.cpp&quot; &quot;${d3dsrc}/D3dDisplayList.cpp&quot; &quot;${d3dsrc}/D3dDriverInfo.cpp&quot; &quot;${d3dsrc}/D3dDeviceInfo.cpp&quot; &quot;${d3dsrc}/D3dCtx.cpp&quot; &quot;${d3dsrc}/D3dUtil.cpp&quot; &quot;${d3dsrc}/D3dImageComponent.cpp&quot; &quot;${d3dsrc}/GeometryArrayRetained.cpp&quot; &quot;${d3dsrc}/Canvas3D.cpp&quot; &quot;${d3dsrc}/GraphicsContext3D.cpp&quot; &quot;${d3dsrc}/CompressedGeometryRetained.cpp&quot; &quot;${d3dsrc}/Attributes.cpp&quot; &quot;${d3dsrc}/Lights.cpp&quot; &quot;${d3dsrc}/NativeConfigTemplate3D.cpp&quot; &quot;${d3dsrc}/NativeWSInfo.cpp&quot; &quot;${d3dsrc}/NativeAPIInfo.c&quot; &quot;${d3dsrc}/RasterRetained.cpp&quot;"/>
+ <arg line="-Ox -Og -O2 -Ob2 -Os -Oi -GT -GL /nologo -I&quot;${javaInclude}&quot; -I&quot;${javaWin32Include}&quot; -I&quot;${src}/native/ogl&quot; -I&quot;${javahCoreTarget}&quot; /D &quot;NDEBUG&quot; /D &quot;_WINDOWS&quot; /D &quot;_MBCS&quot; /D &quot;_USRDLL&quot; /D &quot;J3DDX90PORT_EXPORTS&quot; /D &quot;WIN32&quot; /D &quot;D3D&quot; /D &quot;J3D_BUILDVERTICES&quot; /D &quot;NVIDIA_DEBUG&quot; /FD /EHsc /MT /Fp&quot;J3dDX90Port.pch&quot; /W2 /c /TP &quot;${oglsrc}/DrawingSurfaceObjectAWT.c&quot; &quot;${oglsrc}/MasterControl.c&quot; &quot;${d3dsrc}/D3dVertexBuffer.cpp&quot; &quot;${d3dsrc}/D3dDisplayList.cpp&quot; &quot;${d3dsrc}/D3dDriverInfo.cpp&quot; &quot;${d3dsrc}/D3dDeviceInfo.cpp&quot; &quot;${d3dsrc}/D3dCtx.cpp&quot; &quot;${d3dsrc}/D3dUtil.cpp&quot; &quot;${d3dsrc}/D3dImageComponent.cpp&quot; &quot;${d3dsrc}/GeometryArrayRetained.cpp&quot; &quot;${d3dsrc}/Canvas3D.cpp&quot; &quot;${d3dsrc}/GraphicsContext3D.cpp&quot; &quot;${d3dsrc}/Attributes.cpp&quot; &quot;${d3dsrc}/Lights.cpp&quot; &quot;${d3dsrc}/NativeConfigTemplate3D.cpp&quot; &quot;${d3dsrc}/NativeWSInfo.cpp&quot; &quot;${d3dsrc}/NativeAPIInfo.c&quot; &quot;${d3dsrc}/RasterRetained.cpp&quot; "/>
</exec>
+
<!-- Create the library file-->
<exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="link">
- <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 /ignore:4089 -out:j3dcore-d3d.dll D3dVertexBuffer.obj D3dDisplayList.obj D3dDriverInfo.obj D3dDeviceInfo.obj D3dCtx.obj D3dUtil.obj D3dImageComponent.obj GeometryArrayRetained.obj Canvas3D.obj GraphicsContext3D.obj CompressedGeometryRetained.obj Attributes.obj Lights.obj NativeConfigTemplate3D.obj NativeWSInfo.obj NativeAPIInfo.obj RasterRetained.obj DrawingSurfaceObjectAWT.obj MasterControl.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ddraw.lib d3d8.lib d3dx8.lib dxerr8.lib dxguid.lib user32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:&quot;${java.home}\..\lib&quot; jawt.lib"/>
+ <arg line="/OUT:&quot;j3dcore-d3d.dll&quot; /nologo -DLL -DELAYLOAD:jawt.dll -IMPLIB:&quot;j3dcore-d3d.lib&quot; -MACHINE:X86 -LTCG /ignore:4089 ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib Attributes.obj Canvas3D.obj D3dCtx.obj D3dDeviceInfo.obj D3dDisplayList.obj D3dDriverInfo.obj D3dImageComponent.obj D3dUtil.obj D3dVertexBuffer.obj DrawingSurfaceObjectAWT.obj GeometryArrayRetained.obj GraphicsContext3D.obj Lights.obj MasterControl.obj NativeAPIInfo.obj NativeConfigTemplate3D.obj NativeWSInfo.obj RasterRetained.obj ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib -LIBPATH:&quot;${java.home}\..\lib&quot; jawt.lib"/>
</exec>
<!-- Copy the copyright library file -->