some fixing; may have to revisit matfx again in the future...

This commit is contained in:
aap 2021-01-20 23:42:00 +01:00
parent e9e2488834
commit baa8666a03
4 changed files with 25 additions and 7 deletions

View File

@ -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());

View File

@ -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();

View File

@ -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());

View File

@ -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;