From 2a75ad2ebfc2853ee3309cfcd48b6b0d6bf9856b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 27 Sep 2013 23:52:06 -0700 Subject: [PATCH] Ignore framebuffer alpha in preview, often 0. --- Windows/GEDebugger/GEDebugger.cpp | 8 ++++---- Windows/GEDebugger/SimpleGLWindow.cpp | 21 +++++++++++++-------- Windows/GEDebugger/SimpleGLWindow.h | 19 +++++++++++++------ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 96e581281f..189ee1899e 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -119,13 +119,13 @@ CGEDebugger::~CGEDebugger() { void CGEDebugger::SetupPreviews() { if (frameWindow == NULL) { frameWindow = SimpleGLWindow::GetFrom(GetDlgItem(m_hDlg, IDC_GEDBG_FRAME)); - frameWindow->Initialize(); + frameWindow->Initialize(SimpleGLWindow::ALPHA_IGNORE | SimpleGLWindow::RESIZE_SHRINK_CENTER); // TODO: Why doesn't this work? frameWindow->Clear(); } if (texWindow == NULL) { texWindow = SimpleGLWindow::GetFrom(GetDlgItem(m_hDlg, IDC_GEDBG_TEX)); - texWindow->Initialize(); + texWindow->Initialize(SimpleGLWindow::ALPHA_BLEND | SimpleGLWindow::RESIZE_SHRINK_CENTER); // TODO: Why doesn't this work? texWindow->Clear(); } @@ -139,7 +139,7 @@ void CGEDebugger::UpdatePreviews() { if (bufferResult) { auto fmt = SimpleGLWindow::Format(bufferFrame.GetFormat()); - frameWindow->Draw(bufferFrame.GetData(), bufferFrame.GetStride(), bufferFrame.GetHeight(), bufferFrame.GetFlipped(), fmt, SimpleGLWindow::RESIZE_SHRINK_CENTER); + frameWindow->Draw(bufferFrame.GetData(), bufferFrame.GetStride(), bufferFrame.GetHeight(), bufferFrame.GetFlipped(), fmt); } else { ERROR_LOG(COMMON, "Unable to get framebuffer."); frameWindow->Clear(); @@ -150,7 +150,7 @@ void CGEDebugger::UpdatePreviews() { if (bufferResult) { auto fmt = SimpleGLWindow::Format(bufferTex.GetFormat()); - texWindow->Draw(bufferTex.GetData(), bufferTex.GetStride(), bufferTex.GetHeight(), bufferTex.GetFlipped(), fmt, SimpleGLWindow::RESIZE_SHRINK_CENTER); + texWindow->Draw(bufferTex.GetData(), bufferTex.GetStride(), bufferTex.GetHeight(), bufferTex.GetFlipped(), fmt); } else { ERROR_LOG(COMMON, "Unable to get texture."); texWindow->Clear(); diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index fc1d57f8d2..efdb7cacf9 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -65,7 +65,7 @@ static const char basic_vs[] = "}\n"; SimpleGLWindow::SimpleGLWindow(HWND wnd) - : hWnd_(wnd), valid_(false), drawProgram_(NULL), tex_(0) { + : hWnd_(wnd), valid_(false), drawProgram_(NULL), tex_(0), flags_(0) { SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG) this); } @@ -79,10 +79,11 @@ SimpleGLWindow::~SimpleGLWindow() { } }; -void SimpleGLWindow::Initialize() { +void SimpleGLWindow::Initialize(u32 flags) { RECT rect; GetWindowRect(hWnd_, &rect); + SetFlags(flags); SetupGL(); ResizeGL(rect.right-rect.left,rect.bottom-rect.top); CreateProgram(); @@ -200,12 +201,16 @@ void SimpleGLWindow::DrawChecker() { glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices); } -void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt, ResizeType resize) { +void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt) { DrawChecker(); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBlendEquation(GL_FUNC_ADD); + if (flags_ & ALPHA_BLEND) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendEquation(GL_FUNC_ADD); + } else { + glDisable(GL_BLEND); + } glViewport(0, 0, w_, h_); glScissor(0, 0, w_, h_); @@ -237,7 +242,7 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt, Resi float fw = (float)w, fh = (float)h; float x = 0.0f, y = 0.0f; - if (resize == RESIZE_SHRINK_FIT || resize == RESIZE_SHRINK_CENTER) { + if (flags_ & (RESIZE_SHRINK_FIT | RESIZE_SHRINK_CENTER)) { float wscale = fw / w_, hscale = fh / h_; // Too wide, and width is the biggest problem, so scale based on that. @@ -249,7 +254,7 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt, Resi fh = (float)h_; } - if (resize == RESIZE_SHRINK_CENTER) { + if (flags_ & RESIZE_SHRINK_CENTER) { x = ((float)w_ - fw) / 2; y = ((float)h_ - fh) / 2; } diff --git a/Windows/GEDebugger/SimpleGLWindow.h b/Windows/GEDebugger/SimpleGLWindow.h index f0cff60f43..390698805d 100644 --- a/Windows/GEDebugger/SimpleGLWindow.h +++ b/Windows/GEDebugger/SimpleGLWindow.h @@ -31,21 +31,27 @@ struct SimpleGLWindow { FORMAT_8888 = 3, }; - enum ResizeType { - RESIZE_NONE, - RESIZE_SHRINK_FIT, - RESIZE_SHRINK_CENTER, + enum Flags { + RESIZE_NONE = 0x00, + RESIZE_SHRINK_FIT = 0x01, + RESIZE_SHRINK_CENTER = 0x02, + ALPHA_IGNORE = 0x00, + ALPHA_BLEND = 0x04, }; SimpleGLWindow(HWND wnd); ~SimpleGLWindow(); void Clear(); - void Draw(u8 *data, int w, int h, bool flipped = false, Format = FORMAT_8888, ResizeType resize = RESIZE_NONE); - void Initialize(); + void Draw(u8 *data, int w, int h, bool flipped = false, Format = FORMAT_8888); + void Initialize(u32 flags); static SimpleGLWindow *GetFrom(HWND hwnd); static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + void SetFlags(u32 flags) { + flags_ = flags; + } + void Swap() { SwapBuffers(hDC_); } @@ -68,4 +74,5 @@ protected: GLSLProgram *drawProgram_; GLuint checker_; GLuint tex_; + u32 flags_; }; \ No newline at end of file