From baa8666a03a6d6dbbb6f745c44a7bbc129f701ea Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 20 Jan 2021 23:42:00 +0100 Subject: [PATCH] some fixing; may have to revisit matfx again in the future... --- src/d3d/d3d9matfx.cpp | 7 ++++--- src/d3d/d3ddevice.cpp | 17 ++++++++++++++++- src/gl/gl3matfx.cpp | 6 ++++-- src/rwobjects.h | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/d3d/d3d9matfx.cpp b/src/d3d/d3d9matfx.cpp index 70009eb..80a3703 100644 --- a/src/d3d/d3d9matfx.cpp +++ b/src/d3d/d3d9matfx.cpp @@ -79,9 +79,10 @@ uploadEnvMatrix(Frame *frame) frame = engine->currentCamera->getFrame(); // cache the matrix across multiple meshes - if(frame == lastEnvFrame) - return; - lastEnvFrame = frame; +// can't do it, frame matrix may change +// if(frame == lastEnvFrame) +// return; +// lastEnvFrame = frame; RawMatrix envMtx, invMtx; Matrix::invert(&invMat, frame->getLTM()); diff --git a/src/d3d/d3ddevice.cpp b/src/d3d/d3ddevice.cpp index 2f39ac8..8ff8e7a 100644 --- a/src/d3d/d3ddevice.cpp +++ b/src/d3d/d3ddevice.cpp @@ -97,6 +97,7 @@ struct RwStateCache { static RwStateCache rwStateCache; void *constantVertexStream; +static IDirect3DTexture9 *whiteTex; D3dShaderState d3dShaderState; @@ -457,7 +458,7 @@ setRasterStage(uint32 stage, Raster *raster) d3ddevice->SetTexture(stage, (IDirect3DTexture9*)d3draster->texture); alpha = d3draster->hasAlpha; }else{ - d3ddevice->SetTexture(stage, nil); + d3ddevice->SetTexture(stage, whiteTex); alpha = 0; } if(stage == 0){ @@ -1830,6 +1831,17 @@ initD3D(void) setAddressV(t, Texture::WRAP); } + IDirect3DSurface9 *surf; + D3DLOCKED_RECT lr; + uint8 whitepixel[4] = {0xFF, 0xFF, 0xFF, 0xFF}; + whiteTex = (IDirect3DTexture9*)createTexture(1, 1, 1, 0, D3DFMT_X8R8G8B8); + whiteTex->GetSurfaceLevel(0, &surf); + HRESULT res = surf->LockRect(&lr, 0, D3DLOCK_NOSYSLOCK); + assert(res == D3D_OK); + memcpy(lr.pBits, whitepixel, 4); + surf->UnlockRect(); + surf->Release(); + openIm2D(); openIm3D(); @@ -1842,6 +1854,9 @@ termD3D(void) destroyVertexBuffer(constantVertexStream); constantVertexStream = nil; + destroyTexture(whiteTex); + whiteTex = nil; + closeIm3D(); closeIm2D(); diff --git a/src/gl/gl3matfx.cpp b/src/gl/gl3matfx.cpp index acd3121..657489c 100644 --- a/src/gl/gl3matfx.cpp +++ b/src/gl/gl3matfx.cpp @@ -68,8 +68,10 @@ uploadEnvMatrix(Frame *frame) // cache the matrix across multiple meshes static RawMatrix envMtx; - if(frame != lastEnvFrame){ - lastEnvFrame = frame; +// can't do it, frame matrix may change +// if(frame != lastEnvFrame){ +// lastEnvFrame = frame; + { RawMatrix invMtx; Matrix::invert(&invMat, frame->getLTM()); diff --git a/src/rwobjects.h b/src/rwobjects.h index 622b376..84435dc 100644 --- a/src/rwobjects.h +++ b/src/rwobjects.h @@ -748,7 +748,7 @@ struct Camera Raster *frameBuffer; Raster *zBuffer; - // Device dependant view and projection matrices + // Device dependent view and projection matrices // optional RawMatrix devView; RawMatrix devProj;