draw the new image on the old one instead vice versa

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@255 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2008-01-01 14:34:11 +00:00
parent 35354a3556
commit 0e6a4e7548
2 changed files with 29 additions and 16 deletions

View File

@ -1,7 +1,8 @@
Known Bugs: Known Bugs:
- Direct3D: fsMaxScale = 1 in fullscreen mode with visible menu results in too small height of the image - Direct3D: image is 1x1 pixel larger than it should be
- Linking: Doesnt work quite right yet. - Linking: Doesnt work quite right yet.
- OpenGL: Fragment shaders do not work quite as well as original test build (Mudlord) - OpenGL: Fragment shaders do not work quite as well as original test build (Mudlord)
- Audio core: assertation error occurs when disabling GB sound - Audio core: assertation error occurs when disabling GB sound
- x64: Needs optimizations (x64 native code, whatever) - x64: Needs optimizations (x64 native code, whatever)
- Wrong bit depth image is displayed for some frames when switching from/to Hq3x/4x ASM (most probably causes by 16bit to 32bit hack)

View File

@ -70,6 +70,7 @@ private:
D3DFORMAT screenFormat; D3DFORMAT screenFormat;
LPDIRECT3DTEXTURE9 emulatedImage[2]; LPDIRECT3DTEXTURE9 emulatedImage[2];
unsigned char mbCurrentTexture; // current texture for motion blur unsigned char mbCurrentTexture; // current texture for motion blur
bool mbTextureEmpty;
int width; int width;
int height; int height;
RECT destRect; RECT destRect;
@ -128,6 +129,7 @@ Direct3DDisplay::Direct3DDisplay()
emulatedImage[0] = NULL; emulatedImage[0] = NULL;
emulatedImage[1] = NULL; emulatedImage[1] = NULL;
mbCurrentTexture = 0; mbCurrentTexture = 0;
mbTextureEmpty = true;
} }
@ -409,22 +411,30 @@ void Direct3DDisplay::render()
} }
// set current emulatedImage as active texture if( !theApp.d3dMotionBlur ) {
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] ); // draw the current frame to the screen
// render textured triangles
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
if( theApp.d3dMotionBlur ) {
// set old emulatedImage as active texture
mbCurrentTexture ^= 1; // XOR 1 = switch 0/1
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] ); pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] );
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
// render textured triangles pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 ); } else {
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, transpVertices, sizeof(TRANSP_VERTEX) ); // Motion Blur enabled
if( !mbTextureEmpty ) {
// draw previous frame to the screen
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ^ 1 ] );
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
// draw the current frame with transparency to the screen
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] );
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 );
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, transpVertices, sizeof(TRANSP_VERTEX) );
} else {
mbTextureEmpty = false;
// draw the current frame to the screen
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] );
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
}
mbCurrentTexture ^= 1; // switch current texture
} }
@ -561,6 +571,8 @@ void Direct3DDisplay::createTexture()
DXTRACE_ERR_MSGBOX( _T("createTexture(1) failed"), hr ); DXTRACE_ERR_MSGBOX( _T("createTexture(1) failed"), hr );
return; return;
} }
mbTextureEmpty = true;
} }
} }