mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Ignore framebuffer alpha in preview, often 0.
This commit is contained in:
parent
6f6013a6f8
commit
2a75ad2ebf
3 changed files with 30 additions and 18 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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_;
|
||||
};
|
Loading…
Add table
Reference in a new issue