Support render res. above 1x in ge debugger.

This commit is contained in:
Unknown W. Brackets 2013-09-22 20:03:47 -07:00
parent a7f9723528
commit 6073317591
4 changed files with 22 additions and 5 deletions

View file

@ -1327,11 +1327,11 @@ bool FramebufferManager::GetCurrentFramebuffer(GPUDebugBuffer &buffer)
return true;
}
buffer.Allocate(vfb->fb_stride, vfb->height, GE_FORMAT_8888);
buffer.Allocate(vfb->renderWidth, vfb->renderHeight, GE_FORMAT_8888);
fbo_bind_for_read(vfb->fbo);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glReadPixels(0, 0, vfb->fb_stride, vfb->height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.GetData());
glReadPixels(0, 0, vfb->renderWidth, vfb->renderHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.GetData());
return true;
}

View file

@ -145,7 +145,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
if (bufferResult) {
if (buffer.GetFormat() == GE_FORMAT_8888) {
frameWindow->Draw(buffer.GetData(), buffer.GetStride(), buffer.GetHeight());
frameWindow->Draw(buffer.GetData(), buffer.GetStride(), buffer.GetHeight(), SimpleGLWindow::RESIZE_SHRINK_FIT);
} else {
ERROR_LOG(COMMON, "Non-8888 buffers not yet supported.");
frameWindow->Clear();

View file

@ -140,7 +140,7 @@ void SimpleGLWindow::CreateProgram() {
glsl_unbind();
}
void SimpleGLWindow::Draw(u8 *data, int w, int h) {
void SimpleGLWindow::Draw(u8 *data, int w, int h, ResizeType resize) {
wglMakeCurrent(hDC_, hGLRC_);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -160,6 +160,18 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h) {
glsl_bind(drawProgram_);
float fw = (float)w, fh = (float)h;
if (resize == RESIZE_SHRINK_FIT) {
float wscale = fw / w_, hscale = fh / h_;
// Too wide, and width is the biggest problem, so scale based on that.
if (wscale > 1.0f && wscale > hscale) {
fw = (float)w_;
fh /= wscale;
} else if (hscale > 1.0f) {
fw /= hscale;
fh = (float)h_;
}
}
const float pos[12] = {0,0,0, fw,0,0, fw,fh,0, 0,fh,0};
const float texCoords[8] = {0,1, 1,1, 1,0, 0,0};
const GLubyte indices[4] = {0,1,3,2};

View file

@ -24,6 +24,11 @@
struct SimpleGLWindow {
static const PTCHAR windowClass;
enum ResizeType {
RESIZE_NONE,
RESIZE_SHRINK_FIT,
};
SimpleGLWindow(HINSTANCE hInstance, HWND hParent, int x, int y, int w, int h);
~SimpleGLWindow() {
if (drawProgram_ != NULL) {
@ -41,7 +46,7 @@ struct SimpleGLWindow {
void CreateProgram();
void Clear();
void Draw(u8 *data, int w, int h);
void Draw(u8 *data, int w, int h, ResizeType resize = RESIZE_NONE);
void Swap() {
SwapBuffers(hDC_);