Skip to content

Commit

Permalink
Merge pull request #492 from Armada651/master
Browse files Browse the repository at this point in the history
Remove EmuWindow
  • Loading branch information
delroth committed Jun 15, 2014
2 parents a6395ae + f2759ff commit 020b4fd
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 284 deletions.
5 changes: 0 additions & 5 deletions Source/Core/Core/Core.cpp
Expand Up @@ -6,7 +6,6 @@

#ifdef _WIN32
#include <windows.h>
#include "VideoCommon/EmuWindow.h"
#endif

#include "AudioCommon/AudioCommon.h"
Expand Down Expand Up @@ -267,10 +266,6 @@ void Stop() // - Hammertime!

INFO_LOG(CONSOLE, "%s", StopMessage(true, "Main Emu thread stopped").c_str());

#ifdef _WIN32
EmuWindow::Close();
#endif

// Clear on screen messages that haven't expired
g_video_backend->Video_ClearMessages();

Expand Down
33 changes: 14 additions & 19 deletions Source/Core/DolphinWX/GLInterface/WGL.cpp
Expand Up @@ -8,7 +8,6 @@

#include "DolphinWX/GLInterface/GLInterface.h"

#include "VideoCommon/EmuWindow.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
Expand Down Expand Up @@ -59,34 +58,29 @@ bool cInterfaceWGL::PeekMessages()
// Show the current FPS
void cInterfaceWGL::UpdateFPSDisplay(const std::string& text)
{
EmuWindow::SetWindowText(text);
SetWindowTextA((HWND)m_window_handle, text.c_str());
}

// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceWGL::Create(void *&window_handle)
{
if (window_handle == nullptr)
return false;

int _tx, _ty, _twidth, _theight;
Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight);

// Control window size and picture scaling
s_backbuffer_width = _twidth;
s_backbuffer_height = _theight;

m_window_handle = window_handle;

#ifdef _WIN32
dllHandle = LoadLibrary(TEXT("OpenGL32.dll"));
#endif

window_handle = (void*)EmuWindow::Create((HWND)window_handle, GetModuleHandle(0), _T("Please wait..."));
if (window_handle == nullptr)
{
Host_SysMessage("failed to create window");
return false;
}

// Show the window
EmuWindow::Show();

PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
Expand All @@ -111,7 +105,7 @@ bool cInterfaceWGL::Create(void *&window_handle)

int PixelFormat; // Holds The Results After Searching For A Match

if (!(hDC=GetDC(EmuWindow::GetWnd()))) {
if (!(hDC = GetDC((HWND)window_handle))) {
PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
return false;
}
Expand Down Expand Up @@ -151,15 +145,16 @@ bool cInterfaceWGL::ClearCurrent()
void cInterfaceWGL::Update()
{
RECT rcWindow;
if (!EmuWindow::GetParentWnd())
HWND parent = GetParent((HWND)m_window_handle);
if (!parent)
{
// We are not rendering to a child window - use client size.
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
GetClientRect((HWND)m_window_handle, &rcWindow);
}
else
{
// We are rendering to a child window - use parent size.
GetWindowRect(EmuWindow::GetParentWnd(), &rcWindow);
GetWindowRect(parent, &rcWindow);
}

// Get the new window width and height
Expand All @@ -168,11 +163,11 @@ void cInterfaceWGL::Update()
int height = rcWindow.bottom - rcWindow.top;

// If we are rendering to a child window
if (EmuWindow::GetParentWnd() != 0 &&
if (GetParent((HWND)m_window_handle) != 0 &&
(s_backbuffer_width != width || s_backbuffer_height != height) &&
width >= 4 && height >= 4)
{
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
::MoveWindow((HWND)m_window_handle, 0, 0, width, height, FALSE);
s_backbuffer_width = width;
s_backbuffer_height = height;
}
Expand All @@ -192,7 +187,7 @@ void cInterfaceWGL::Shutdown()
hRC = nullptr;
}

if (hDC && !ReleaseDC(EmuWindow::GetWnd(), hDC))
if (hDC && !ReleaseDC((HWND)m_window_handle, hDC))
{
ERROR_LOG(VIDEO, "Attempt to release device context failed.");
hDC = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinWX/GLInterface/WGL.h
Expand Up @@ -21,4 +21,6 @@ class cInterfaceWGL : public cInterfaceBase

void Update();
bool PeekMessages();

void* m_window_handle;
};
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/D3D/D3DBase.h
Expand Up @@ -41,6 +41,7 @@ void Close();
extern ID3D11Device* device;
extern ID3D11DeviceContext* context;
extern IDXGISwapChain* swapchain;
extern HWND hWnd;
extern bool bFrameInProgress;

void Reset();
Expand Down
22 changes: 4 additions & 18 deletions Source/Core/VideoBackends/D3D/Render.cpp
Expand Up @@ -26,7 +26,6 @@

#include "VideoCommon/AVIDump.h"
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/EmuWindow.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/ImageWrite.h"
Expand Down Expand Up @@ -178,15 +177,15 @@ void CreateScreenshotTexture(const TargetRectangle& rc)
D3D::SetDebugObjectName((ID3D11DeviceChild*)s_screenshot_texture, "staging screenshot texture");
}

Renderer::Renderer()
Renderer::Renderer(void *&window_handle)
{
int x, y, w_temp, h_temp;

InitFPSCounter();

Host_GetRenderWindowSize(x, y, w_temp, h_temp);

D3D::Create(EmuWindow::GetWnd());
D3D::Create((HWND)window_handle);

s_backbuffer_width = D3D::GetBackBufferWidth();
s_backbuffer_height = D3D::GetBackBufferHeight();
Expand Down Expand Up @@ -275,21 +274,8 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
// size.
bool Renderer::CheckForResize()
{
while (EmuWindow::IsSizing())
Sleep(10);

if (EmuWindow::GetParentWnd())
{
// Re-stretch window to parent window size again, if it has a parent window.
RECT rcParentWindow;
GetWindowRect(EmuWindow::GetParentWnd(), &rcParentWindow);
int width = rcParentWindow.right - rcParentWindow.left;
int height = rcParentWindow.bottom - rcParentWindow.top;
if (width != Renderer::GetBackbufferWidth() || height != Renderer::GetBackbufferHeight())
MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
}
RECT rcWindow;
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
GetClientRect(D3D::hWnd, &rcWindow);
int client_width = rcWindow.right - rcWindow.left;
int client_height = rcWindow.bottom - rcWindow.top;

Expand Down Expand Up @@ -866,7 +852,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
{
s_recordWidth = GetTargetRectangle().GetWidth();
s_recordHeight = GetTargetRectangle().GetHeight();
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
bAVIDumping = AVIDump::Start(D3D::hWnd, s_recordWidth, s_recordHeight);
if (!bAVIDumping)
{
PanicAlert("Error dumping frames to AVI.");
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/Render.h
Expand Up @@ -9,7 +9,7 @@ namespace DX11
class Renderer : public ::Renderer
{
public:
Renderer();
Renderer(void *&window_handle);
~Renderer();

void SetColorMask() override;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/VideoBackends/D3D/VideoBackend.h
Expand Up @@ -21,6 +21,8 @@ class VideoBackend : public VideoBackendHardware

void UpdateFPSDisplay(const std::string&) override;
unsigned int PeekMessages() override;

void* m_window_handle;
};

}
Expand Down
16 changes: 7 additions & 9 deletions Source/Core/VideoBackends/D3D/main.cpp
Expand Up @@ -29,7 +29,6 @@

#include "VideoCommon/BPStructs.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/EmuWindow.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/IndexGenerator.h"
#include "VideoCommon/OnScreenDisplay.h"
Expand Down Expand Up @@ -58,7 +57,8 @@ unsigned int VideoBackend::PeekMessages()

void VideoBackend::UpdateFPSDisplay(const std::string& text)
{
EmuWindow::SetWindowText(StringFromFormat("%s | D3D | %s", scm_rev_str, text.c_str()));
std::string str = StringFromFormat("%s | D3D | %s", scm_rev_str, text.c_str());
SetWindowTextA((HWND)m_window_handle, str.c_str());
}

std::string VideoBackend::GetName() const
Expand Down Expand Up @@ -147,6 +147,9 @@ void VideoBackend::ShowConfig(void *_hParent)

bool VideoBackend::Initialize(void *&window_handle)
{
if (window_handle == nullptr)
return false;

InitializeShared();
InitBackendInfo();

Expand All @@ -158,12 +161,7 @@ bool VideoBackend::Initialize(void *&window_handle)
g_Config.VerifyValidity();
UpdateActiveConfig();

window_handle = (void*)EmuWindow::Create((HWND)window_handle, GetModuleHandle(0), _T("Loading - Please wait."));
if (window_handle == nullptr)
{
ERROR_LOG(VIDEO, "An error has occurred while trying to create the window.");
return false;
}
m_window_handle = window_handle;

s_BackendInitialized = true;

Expand All @@ -178,7 +176,7 @@ void VideoBackend::Video_Prepare()
s_swapRequested = FALSE;

// internal interfaces
g_renderer = new Renderer;
g_renderer = new Renderer(m_window_handle);
g_texture_cache = new TextureCache;
g_vertex_manager = new VertexManager;
g_perf_query = new PerfQuery;
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/VideoBackends/OGL/Render.cpp
Expand Up @@ -56,7 +56,6 @@
#endif

#ifdef _WIN32
#include "VideoCommon/EmuWindow.h"
#endif
#if defined _WIN32 || defined HAVE_LIBAV
#include "VideoCommon/AVIDump.h"
Expand Down Expand Up @@ -1461,7 +1460,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
if (!bLastFrameDumped)
{
#ifdef _WIN32
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), w, h);
bAVIDumping = AVIDump::Start((HWND)((cInterfaceWGL*)GLInterface)->m_window_handle, w, h);
#else
bAVIDumping = AVIDump::Start(w, h);
#endif
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/OGL/main.cpp
Expand Up @@ -80,7 +80,6 @@ Make AA apply instantly during gameplay if possible

#ifdef _WIN32
#include "Common/IniFile.h"
#include "VideoCommon/EmuWindow.h"
#endif

#if defined(HAVE_WX) && HAVE_WX
Expand Down

0 comments on commit 020b4fd

Please sign in to comment.