From 9c85010cfb354e5aaa013d3d19e852b464704714 Mon Sep 17 00:00:00 2001 From: DJRobX Date: Wed, 7 Nov 2007 07:30:50 +0000 Subject: [PATCH] D3D update, use cximage library instead of direct inclusion in app --- VBA.sln | 9 +++ VBA.vcproj | 124 ----------------------------------------- src/win32/Direct3D.cpp | 44 +++++++++++---- 3 files changed, 41 insertions(+), 136 deletions(-) diff --git a/VBA.sln b/VBA.sln index a02aa9e2..3c4025ba 100644 --- a/VBA.sln +++ b/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}" ProjectSection(ProjectDependencies) = postProject {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} EndProjectSection EndProject @@ -10,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\win32\dependenc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "src\win32\dependencies\libpng\libpng.vcproj", "{96E945F7-0377-48DA-A5F8-1C192DE9F25F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "src\win32\dependencies\cximage\cximage.vcproj", "{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution 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}.Release|Win32.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VBA.vcproj b/VBA.vcproj index 861b63ea..cd851688 100644 --- a/VBA.vcproj +++ b/VBA.vcproj @@ -1183,130 +1183,6 @@ > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =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() { @@ -261,8 +287,9 @@ bool Direct3DDisplay::initialize() theApp.mode320Available = FALSE; theApp.mode640Available = FALSE; theApp.mode800Available = FALSE; + theApp.mode1024Available = FALSE; + theApp.mode1280Available = FALSE; - D3DDISPLAYMODE mode; pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &mode); screenFormat = mode.Format; @@ -316,15 +343,7 @@ bool Direct3DDisplay::initialize() // create device - ZeroMemory(&dpp, sizeof(dpp)); - 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; + setPresentationType(); HRESULT hret = pD3D->CreateDevice( D3DADAPTER_DEFAULT, @@ -584,12 +603,12 @@ void Direct3DDisplay::calculateDestRect() void Direct3DDisplay::setOption( const char *option, int value ) { if( !_tcscmp( option, _T("vsync") ) ) { - dpp.PresentationInterval = value ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; + theApp.vsync = true; resetDevice(); } if( !_tcscmp( option, _T("tripleBuffering") ) ) { - dpp.BackBufferCount = value ? 2 : 1; + theApp.tripleBuffering = true; resetDevice(); } @@ -618,6 +637,7 @@ bool Direct3DDisplay::resetDevice() HRESULT hr; destroyFont(); destroySurface(); + setPresentationType(); if( FAILED( hr = pDevice->Reset( &dpp ) ) ) { //DXTRACE_ERR_MSGBOX( _T("pDevice->Reset failed"), hr ); failed = true;