added an option to render directx video plugin inside the main frame

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@15 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-07-17 09:18:03 +00:00
parent 009a452fbf
commit b503d023bc
11 changed files with 910 additions and 859 deletions

View File

@ -62,6 +62,7 @@ struct TabDirect3D : public W32Util::Tab
CheckDlgButton(hDlg, IDC_FULLSCREENENABLE, g_Config.bFullscreen ? TRUE : FALSE); CheckDlgButton(hDlg, IDC_FULLSCREENENABLE, g_Config.bFullscreen ? TRUE : FALSE);
CheckDlgButton(hDlg, IDC_VSYNC, g_Config.bVsync ? TRUE : FALSE); CheckDlgButton(hDlg, IDC_VSYNC, g_Config.bVsync ? TRUE : FALSE);
CheckDlgButton(hDlg, IDC_RENDER_IN_MAINWINDOW, g_Config.renderInMainframe ? TRUE : FALSE);
} }
void Command(HWND hDlg,WPARAM wParam) void Command(HWND hDlg,WPARAM wParam)
@ -83,6 +84,8 @@ struct TabDirect3D : public W32Util::Tab
g_Config.iFSResolution = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_RESOLUTION)); g_Config.iFSResolution = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_RESOLUTION));
g_Config.bFullscreen = Button_GetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE)) ? true : false; g_Config.bFullscreen = Button_GetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE)) ? true : false;
g_Config.bVsync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false; g_Config.bVsync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false;
g_Config.renderInMainframe = Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_IN_MAINWINDOW)) ? true : false;
g_Config.Save();
} }
}; };

View File

@ -6,17 +6,23 @@
namespace EmuWindow namespace EmuWindow
{ {
HWND m_hWnd; HWND m_hWnd = NULL;
HINSTANCE m_hInstance; HWND m_hParent = NULL;
HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass; WNDCLASSEX wndClass;
const TCHAR m_szClassName[] = "DolphinEmuWnd"; const TCHAR m_szClassName[] = "DolphinEmuWnd";
int g_winstyle;
HWND GetWnd() HWND GetWnd()
{ {
return m_hWnd; return m_hWnd;
} }
HWND GetParentWnd()
{
return m_hParent;
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{ {
HDC hdc; HDC hdc;
@ -80,23 +86,42 @@ namespace EmuWindow
m_hInstance = hInstance; m_hInstance = hInstance;
RegisterClassEx( &wndClass ); RegisterClassEx( &wndClass );
DWORD style = windowed ? WS_OVERLAPPEDWINDOW : WS_POPUP; if (parent && windowed)
{
m_hWnd = CreateWindow(m_szClassName, title,
WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,
parent, NULL, hInstance, NULL );
RECT rc = {0, 0, width, height}; m_hParent = parent;
AdjustWindowRect(&rc, style, false);
int w = rc.right - rc.left; ShowWindow(m_hWnd, SW_SHOWMAXIMIZED);
int h = rc.bottom - rc.top; }
else
{
DWORD style = windowed ? WS_OVERLAPPEDWINDOW : WS_POPUP;
rc.left = (1280 - w)/2; RECT rc = {0, 0, width, height};
rc.right = rc.left + w; AdjustWindowRect(&rc, style, false);
rc.top = (1024 - h)/2;
rc.bottom = rc.top + h;
m_hWnd = CreateWindow(m_szClassName, title, int w = rc.right - rc.left;
style, int h = rc.bottom - rc.top;
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
parent, NULL, hInstance, NULL ); rc.left = (1280 - w)/2;
rc.right = rc.left + w;
rc.top = (1024 - h)/2;
rc.bottom = rc.top + h;
m_hWnd = CreateWindow(m_szClassName, title,
style,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
parent, NULL, hInstance, NULL );
g_winstyle = GetWindowLong( m_hWnd, GWL_STYLE );
g_winstyle &= ~WS_MAXIMIZE & ~WS_MINIMIZE; // remove minimize/maximize style
}
return m_hWnd; return m_hWnd;
} }

View File

@ -6,6 +6,7 @@
namespace EmuWindow namespace EmuWindow
{ {
HWND GetWnd(); HWND GetWnd();
HWND GetParentWnd();
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title); HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
void Show(); void Show();
void Close(); void Close();

View File

@ -15,6 +15,7 @@ void Config::Load()
iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0); iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0);
iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0); iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0);
iniFile.Get("Hardware", "RenderInMainframe", &renderInMainframe, true);
iniFile.Get("Hardware", "VSync", &bVsync, 0); iniFile.Get("Hardware", "VSync", &bVsync, 0);
if (iAdapter == -1) if (iAdapter == -1)
iAdapter = 0; iAdapter = 0;
@ -40,6 +41,7 @@ void Config::Save()
iniFile.Set("Hardware", "FullscreenRes", iFSResolution); iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen); iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "VSync", bVsync); iniFile.Set("Hardware", "VSync", bVsync);
iniFile.Set("Hardware", "RenderInMainframe", renderInMainframe);
iniFile.Set("Settings", "OverlayStats", bOverlayStats); iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "OverlayStats", bOverlayStats); iniFile.Set("Settings", "OverlayStats", bOverlayStats);

View File

@ -16,6 +16,7 @@ struct Config
int iPostprocessEffect; int iPostprocessEffect;
int iCompileDLsLevel; int iCompileDLsLevel;
bool renderInMainframe;
bool bFullscreen; bool bFullscreen;
bool bVsync; bool bVsync;
bool bWireFrame; bool bWireFrame;

View File

@ -100,6 +100,20 @@ void Renderer::ReinitView()
void Renderer::SwapBuffers(void) void Renderer::SwapBuffers(void)
{ {
// center window again
if (EmuWindow::GetParentWnd())
{
RECT rcWindow;
GetWindowRect(EmuWindow::GetParentWnd(), &rcWindow);
int width = rcWindow.right - rcWindow.left;
int height = rcWindow.bottom - rcWindow.top;
::MoveWindow(EmuWindow::GetWnd(), 0,0,width,height, FALSE);
// nBackbufferWidth = width;
// nBackbufferHeight = height;
}
//Finish up the current frame, print some stats //Finish up the current frame, print some stats
Postprocess::FinalizeFrame(); Postprocess::FinalizeFrame();
if (g_Config.bOverlayStats) if (g_Config.bOverlayStats)

View File

@ -66,25 +66,28 @@ void UpdateFPSDisplay(const char *text)
bool Init() bool Init()
{ {
g_Config.Load();
if (initCount==0) if (initCount==0)
{ {
// create the window // create the window
// if( g_VideoInitialize.pWindowHandle == NULL ) // ignore parent for this plugin if( !g_Config.renderInMainframe || g_VideoInitialize.pWindowHandle == NULL ) // ignore parent for this plugin
{ {
// create the window
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, "Please wait..."); g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, "Please wait...");
if( g_VideoInitialize.pWindowHandle == NULL ) {
MessageBox(GetActiveWindow(), "failed to create window", "Fatal Error", MB_OK);
return false;
}
g_VideoInitialize.pPeekMessages = Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = UpdateFPSDisplay;
EmuWindow::Show();
} }
else
{
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, "Please wait...");
}
if( g_VideoInitialize.pPeekMessages == NULL ) if( g_VideoInitialize.pWindowHandle == NULL ) {
return false; MessageBox(GetActiveWindow(), "failed to create window", "Fatal Error", MB_OK);
return false;
}
EmuWindow::Show();
g_VideoInitialize.pPeekMessages = Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = UpdateFPSDisplay;
if (FAILED(D3D::Init())) if (FAILED(D3D::Init()))
{ {
@ -95,7 +98,6 @@ bool Init()
} }
initCount++; initCount++;
g_Config.Load();
return true; return true;
} }

View File

@ -17,6 +17,8 @@
#define IDC_FULLSCREENENABLE2 1003 #define IDC_FULLSCREENENABLE2 1003
#define IDC_VSYNC 1003 #define IDC_VSYNC 1003
#define IDC_DEBUGSTEP 1004 #define IDC_DEBUGSTEP 1004
#define IDC_VSYNC2 1004
#define IDC_RENDER_IN_MAINWINDOW 1004
#define IDC_REGISTERS 1005 #define IDC_REGISTERS 1005
#define IDC_ENABLEDEBUGGING 1006 #define IDC_ENABLEDEBUGGING 1006
#define IDC_TAB1 1007 #define IDC_TAB1 1007

View File

@ -81,16 +81,17 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
LTEXT "&Graphics card:",IDC_STATIC,7,9,61,8 LTEXT "&Graphics card:",IDC_STATIC,7,9,61,8
COMBOBOX IDC_ADAPTER,68,7,156,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_ADAPTER,68,7,156,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Fullscreen video mode:",IDC_STATIC,7,55,74,8 LTEXT "&Fullscreen video mode:",IDC_STATIC,7,63,74,8
COMBOBOX IDC_RESOLUTION,87,54,137,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_RESOLUTION,87,62,137,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Antialias mode:",IDC_STATIC,7,114,61,8 LTEXT "&Antialias mode:",IDC_STATIC,7,122,61,8
COMBOBOX IDC_ANTIALIASMODE,68,113,156,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_ANTIALIASMODE,68,121,156,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&Rotate windowed mode 90 degrees (for Ikaruga)",IDC_CHECK1, CONTROL "&Rotate windowed mode 90 degrees (for Ikaruga)",IDC_CHECK1,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,87,89,137,17 "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,87,97,137,17
LTEXT "&Windowed resolution:",IDC_STATIC,7,74,74,8 LTEXT "&Windowed resolution:",IDC_STATIC,7,82,74,8
COMBOBOX IDC_RESOLUTIONWINDOWED,87,73,137,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_RESOLUTIONWINDOWED,87,81,137,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&Fullscreen",IDC_FULLSCREENENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,141,8 CONTROL "&Fullscreen",IDC_FULLSCREENENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,141,8
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,38,141,8 CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,38,141,8
CONTROL "&Render in main window",IDC_RENDER_IN_MAINWINDOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,50,141,8
END END
IDD_DEBUGGER DIALOGEX 0, 0, 234, 254 IDD_DEBUGGER DIALOGEX 0, 0, 234, 254

View File

@ -23,9 +23,9 @@
namespace EmuWindow namespace EmuWindow
{ {
HWND m_hWnd; HWND m_hWnd = NULL;
HWND m_hParent = NULL; HWND m_hParent = NULL;
HINSTANCE m_hInstance; HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass; WNDCLASSEX wndClass;
const TCHAR m_szClassName[] = "DolphinEmuWnd"; const TCHAR m_szClassName[] = "DolphinEmuWnd";
int g_winstyle; int g_winstyle;