D3D update, use cximage library instead of direct inclusion in app
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@26 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
245123095c
commit
f1c5e3fc54
9
VBA.sln
9
VBA.sln
|
@ -3,6 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VisualBoyAdvance", "VBA.vcproj", "{6D4C5EC8-933F-4C05-A1BF-498E658576DF}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VisualBoyAdvance", "VBA.vcproj", "{6D4C5EC8-933F-4C05-A1BF-498E658576DF}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{B938FBD9-C7F9-4BF7-8C27-68865D1FA092} = {B938FBD9-C7F9-4BF7-8C27-68865D1FA092}
|
{B938FBD9-C7F9-4BF7-8C27-68865D1FA092} = {B938FBD9-C7F9-4BF7-8C27-68865D1FA092}
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE} = {DB5C12E9-BCD3-4517-8708-475C0D1D88CE}
|
||||||
{96E945F7-0377-48DA-A5F8-1C192DE9F25F} = {96E945F7-0377-48DA-A5F8-1C192DE9F25F}
|
{96E945F7-0377-48DA-A5F8-1C192DE9F25F} = {96E945F7-0377-48DA-A5F8-1C192DE9F25F}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -10,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\win32\dependenc
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "src\win32\dependencies\libpng\libpng.vcproj", "{96E945F7-0377-48DA-A5F8-1C192DE9F25F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "src\win32\dependencies\libpng\libpng.vcproj", "{96E945F7-0377-48DA-A5F8-1C192DE9F25F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "src\win32\dependencies\cximage\cximage.vcproj", "{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
|
@ -35,6 +38,12 @@ Global
|
||||||
{96E945F7-0377-48DA-A5F8-1C192DE9F25F}.Optimized|Win32.Build.0 = Release|Win32
|
{96E945F7-0377-48DA-A5F8-1C192DE9F25F}.Optimized|Win32.Build.0 = Release|Win32
|
||||||
{96E945F7-0377-48DA-A5F8-1C192DE9F25F}.Release|Win32.ActiveCfg = Release|Win32
|
{96E945F7-0377-48DA-A5F8-1C192DE9F25F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{96E945F7-0377-48DA-A5F8-1C192DE9F25F}.Release|Win32.Build.0 = Release|Win32
|
{96E945F7-0377-48DA-A5F8-1C192DE9F25F}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Optimized|Win32.ActiveCfg = Release|Win32
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Optimized|Win32.Build.0 = Release|Win32
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
124
VBA.vcproj
124
VBA.vcproj
|
@ -1183,130 +1183,6 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="Cximage"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\tif_xfile.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximabmp.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximadsp.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximaenc.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximaexif.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximage.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximagif.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximahist.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximaico.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximainfo.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximaint.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximaj2k.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximajas.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximajbg.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximajpg.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximalpha.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximalyr.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximamng.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximapal.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximapcx.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximapng.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximasel.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximatga.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximath.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximatif.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximatran.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximawbmp.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximawmf.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\ximawnd.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\win32\dependencies\cximage\xmemfile.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header"
|
Name="Header"
|
||||||
|
|
|
@ -55,6 +55,7 @@ class Direct3DDisplay : public IDisplay {
|
||||||
private:
|
private:
|
||||||
LPDIRECT3D9 pD3D;
|
LPDIRECT3D9 pD3D;
|
||||||
LPDIRECT3DDEVICE9 pDevice;
|
LPDIRECT3DDEVICE9 pDevice;
|
||||||
|
D3DDISPLAYMODE mode;
|
||||||
D3DPRESENT_PARAMETERS dpp;
|
D3DPRESENT_PARAMETERS dpp;
|
||||||
D3DFORMAT screenFormat;
|
D3DFORMAT screenFormat;
|
||||||
LPDIRECT3DSURFACE9 emulatedImage;
|
LPDIRECT3DSURFACE9 emulatedImage;
|
||||||
|
@ -71,6 +72,7 @@ private:
|
||||||
void destroySurface();
|
void destroySurface();
|
||||||
void calculateDestRect();
|
void calculateDestRect();
|
||||||
bool resetDevice();
|
bool resetDevice();
|
||||||
|
void setPresentationType();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Direct3DDisplay();
|
Direct3DDisplay();
|
||||||
|
@ -109,6 +111,30 @@ Direct3DDisplay::~Direct3DDisplay()
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Direct3DDisplay::setPresentationType()
|
||||||
|
{
|
||||||
|
// Change display mode
|
||||||
|
memset(&dpp, 0, sizeof(dpp));
|
||||||
|
dpp.Windowed = !(theApp.videoOption>=VIDEO_320x240);
|
||||||
|
if (!dpp.Windowed)
|
||||||
|
dpp.BackBufferFormat =
|
||||||
|
(theApp.fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
|
||||||
|
else
|
||||||
|
dpp.BackBufferFormat = mode.Format;
|
||||||
|
dpp.BackBufferCount = 3;
|
||||||
|
dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||||
|
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
|
dpp.BackBufferWidth = !dpp.Windowed ? theApp.fsWidth : theApp.surfaceSizeX;
|
||||||
|
dpp.BackBufferHeight = !dpp.Windowed ? theApp.fsHeight : theApp.surfaceSizeY;
|
||||||
|
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
|
||||||
|
dpp.FullScreen_RefreshRateInHz = dpp.Windowed ? 0 : theApp.fsFrequency;
|
||||||
|
dpp.Flags = theApp.menuToggle ? D3DPRESENTFLAG_LOCKABLE_BACKBUFFER : 0;
|
||||||
|
if (theApp.vsync)
|
||||||
|
dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // VSync
|
||||||
|
else
|
||||||
|
dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // No Sync
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::cleanup()
|
void Direct3DDisplay::cleanup()
|
||||||
{
|
{
|
||||||
|
@ -261,8 +287,9 @@ bool Direct3DDisplay::initialize()
|
||||||
theApp.mode320Available = FALSE;
|
theApp.mode320Available = FALSE;
|
||||||
theApp.mode640Available = FALSE;
|
theApp.mode640Available = FALSE;
|
||||||
theApp.mode800Available = FALSE;
|
theApp.mode800Available = FALSE;
|
||||||
|
theApp.mode1024Available = FALSE;
|
||||||
|
theApp.mode1280Available = FALSE;
|
||||||
|
|
||||||
D3DDISPLAYMODE mode;
|
|
||||||
pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &mode);
|
pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &mode);
|
||||||
screenFormat = mode.Format;
|
screenFormat = mode.Format;
|
||||||
|
|
||||||
|
@ -316,15 +343,7 @@ bool Direct3DDisplay::initialize()
|
||||||
|
|
||||||
|
|
||||||
// create device
|
// create device
|
||||||
ZeroMemory(&dpp, sizeof(dpp));
|
setPresentationType();
|
||||||
dpp.Windowed = TRUE;
|
|
||||||
dpp.BackBufferFormat = mode.Format;
|
|
||||||
dpp.BackBufferCount = theApp.tripleBuffering ? 2 : 1;
|
|
||||||
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
||||||
dpp.BackBufferWidth = 0; // use width of hDeviceWindow
|
|
||||||
dpp.BackBufferHeight = 0; // use height of hDeviceWindow
|
|
||||||
dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
|
|
||||||
dpp.PresentationInterval = theApp.vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
|
||||||
|
|
||||||
HRESULT hret = pD3D->CreateDevice(
|
HRESULT hret = pD3D->CreateDevice(
|
||||||
D3DADAPTER_DEFAULT,
|
D3DADAPTER_DEFAULT,
|
||||||
|
@ -584,12 +603,12 @@ void Direct3DDisplay::calculateDestRect()
|
||||||
void Direct3DDisplay::setOption( const char *option, int value )
|
void Direct3DDisplay::setOption( const char *option, int value )
|
||||||
{
|
{
|
||||||
if( !_tcscmp( option, _T("vsync") ) ) {
|
if( !_tcscmp( option, _T("vsync") ) ) {
|
||||||
dpp.PresentationInterval = value ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
theApp.vsync = true;
|
||||||
resetDevice();
|
resetDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !_tcscmp( option, _T("tripleBuffering") ) ) {
|
if( !_tcscmp( option, _T("tripleBuffering") ) ) {
|
||||||
dpp.BackBufferCount = value ? 2 : 1;
|
theApp.tripleBuffering = true;
|
||||||
resetDevice();
|
resetDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,6 +637,7 @@ bool Direct3DDisplay::resetDevice()
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
destroyFont();
|
destroyFont();
|
||||||
destroySurface();
|
destroySurface();
|
||||||
|
setPresentationType();
|
||||||
if( FAILED( hr = pDevice->Reset( &dpp ) ) ) {
|
if( FAILED( hr = pDevice->Reset( &dpp ) ) ) {
|
||||||
//DXTRACE_ERR_MSGBOX( _T("pDevice->Reset failed"), hr );
|
//DXTRACE_ERR_MSGBOX( _T("pDevice->Reset failed"), hr );
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
Loading…
Reference in New Issue