From 3b55c26367f4f4460e6b1caf7c86615543801ffd Mon Sep 17 00:00:00 2001 From: John Peterson Date: Mon, 8 Jun 2009 10:16:08 +0000 Subject: [PATCH] OpenGL: Changed the AVIDump framebuffer source to the same as for screenshots git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3374 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/MsgHandler.cpp | 4 +- Source/Core/VideoCommon/Src/AVIDump.cpp | 28 ++++++++++++-- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 37 ++++++++++++------- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/Source/Core/Common/Src/MsgHandler.cpp b/Source/Core/Common/Src/MsgHandler.cpp index 2282e76a8d..93ae6f6284 100644 --- a/Source/Core/Common/Src/MsgHandler.cpp +++ b/Source/Core/Common/Src/MsgHandler.cpp @@ -41,7 +41,6 @@ void SetEnableAlert(bool enable) { correct windows is shown */ bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...) { - // Read message and write it to the log char buffer[2048]; bool ret = true; @@ -53,7 +52,8 @@ bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, . ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer); - if (msg_handler && AlertEnabled) { + // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored + if (msg_handler && (AlertEnabled || yes_no)) { ret = msg_handler(caption, buffer, yes_no, Style); } return ret; diff --git a/Source/Core/VideoCommon/Src/AVIDump.cpp b/Source/Core/VideoCommon/Src/AVIDump.cpp index 6c4e66499c..3e00821ea1 100644 --- a/Source/Core/VideoCommon/Src/AVIDump.cpp +++ b/Source/Core/VideoCommon/Src/AVIDump.cpp @@ -23,6 +23,7 @@ #include #include +#include "FileUtil.h" #include "CommonPaths.h" #include "Log.h" @@ -52,35 +53,56 @@ bool AVIDump::Start(HWND hWnd, int w, int h) return CreateFile(); } -bool AVIDump::CreateFile() { +bool AVIDump::CreateFile() +{ m_totalBytes = 0; m_frameCount = 0; char movie_file_name[255]; sprintf(movie_file_name, "%s/framedump%d.avi", FULL_FRAMES_DIR, m_fileCount); + // Create path + File::CreateFullPath(movie_file_name); + + // Ask to delete file + if (File::Exists(movie_file_name)) + { + if (AskYesNo("Delete the existing file '%s'?", movie_file_name)) + File::Delete(movie_file_name); + } + AVIFileInit(); NOTICE_LOG(VIDEO, "Opening AVI file (%s) for dumping", movie_file_name); // TODO: Make this work with AVIFileOpenW without it throwing REGDB_E_CLASSNOTREG - if (FAILED(AVIFileOpenA(&m_file, movie_file_name, OF_WRITE | OF_CREATE, NULL))) { + HRESULT hr = AVIFileOpenA(&m_file, movie_file_name, OF_WRITE | OF_CREATE, NULL); + if (FAILED(hr)) { + if (hr == AVIERR_BADFORMAT) NOTICE_LOG(VIDEO, "The file couldn't be read, indicating a corrupt file or an unrecognized format."); + if (hr == AVIERR_MEMORY) NOTICE_LOG(VIDEO, "The file could not be opened because of insufficient memory."); + if (hr == AVIERR_FILEREAD) NOTICE_LOG(VIDEO, "A disk error occurred while reading the file."); + if (hr == AVIERR_FILEOPEN) NOTICE_LOG(VIDEO, "A disk error occurred while opening the file."); + if (hr == REGDB_E_CLASSNOTREG) NOTICE_LOG(VIDEO, "AVI class not registered"); Stop(); return false; } SetBitmapFormat(); NOTICE_LOG(VIDEO, "Setting video format..."); if (!SetVideoFormat()) { + NOTICE_LOG(VIDEO, "Setting video format failed"); Stop(); return false; } if (!m_fileCount) { if (!SetCompressionOptions()) { + NOTICE_LOG(VIDEO, "SetCompressionOptions failed"); Stop(); return false; } } if (FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) { + NOTICE_LOG(VIDEO, "AVIMakeCompressedStream failed"); Stop(); return false; } if (FAILED(AVIStreamSetFormat(m_streamCompressed, 0, &m_bitmap, m_bitmap.biSize))) { + NOTICE_LOG(VIDEO, "AVIStreamSetFormat failed"); Stop(); return false; } @@ -108,8 +130,8 @@ void AVIDump::CloseFile() void AVIDump::Stop() { CloseFile(); - m_fileCount = 0; + NOTICE_LOG(VIDEO, "Stop"); } void AVIDump::AddFrame(char *data) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 13ac2dfa28..1aa231ded5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -307,7 +307,7 @@ bool Renderer::Init() // This should really be grabbed from config rather than from OpenGL. // JP: Set these big enough to accomodate any potential 2x mode s_targetwidth = 1280; - s_targetheight = 1024; + s_targetheight = 960; // Compensate height of render target for scaling, so that we get something close to the correct number of // vertical pixels. @@ -990,35 +990,42 @@ void Renderer::Swap(const TRectangle& rc) s_sScreenshotName = ""; s_bScreenshot = false; s_criticalScreenshot.Leave(); - - // Switch to the window backbuffer, we'll draw debug text on top - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } + // It should not be necessary to read from the window backbuffer beyond this point + if (/*s_bHaveFramebufferBlit*/ s_MSAASamples > 1) + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Frame dumps are handled a little differently in Windows // ŻŻŻŻŻŻŻŻŻŻŻŻŻ #ifdef _WIN32 - if (g_Config.bDumpFrames) { + if (g_Config.bDumpFrames) + { + // Select source + if (s_MSAASamples > 1) + glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_uResolvedFramebuffer); + else + glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_uFramebuffer); + s_criticalScreenshot.Enter(); - int w = OpenGL_GetBackbufferWidth(); - int h = OpenGL_GetBackbufferHeight(); + int w = rc.right; + int h = rc.bottom; + int t = (int)(v_min); u8 *data = (u8 *) malloc(3 * w * h); glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0, 0, w, h, GL_BGR, GL_UNSIGNED_BYTE, data); + glReadPixels(0, t, w, h, GL_BGR, GL_UNSIGNED_BYTE, data); if (glGetError() == GL_NO_ERROR) { if (!s_bLastFrameDumped) { s_bAVIDumping = AVIDump::Start(EmuWindow::GetChildParentWnd(), w, h); if (!s_bAVIDumping) - PanicAlert("Error dumping frames to AVI."); + OSD::AddMessage("AVIDump Start failed", 2000); else { - char msg [255]; - sprintf(msg, "Dumping Frames to \"%s/framedump0.avi\" (%dx%d RGB24)", FULL_FRAMES_DIR, w, h); - OSD::AddMessage(msg, 2000); + OSD::AddMessage(StringFromFormat( + "Dumping Frames to \"%s/framedump0.avi\" (%dx%d RGB24)", FULL_FRAMES_DIR, w, h).c_str(), 2000); } } if (s_bAVIDumping) @@ -1026,6 +1033,10 @@ void Renderer::Swap(const TRectangle& rc) s_bLastFrameDumped = true; } + else + { + NOTICE_LOG(VIDEO, "Error reading framebuffer"); + } free(data); s_criticalScreenshot.Leave(); } @@ -1035,8 +1046,8 @@ void Renderer::Swap(const TRectangle& rc) { AVIDump::Stop(); s_bAVIDumping = false; + OSD::AddMessage("Stop dumping frames to AVI", 2000); } - s_bLastFrameDumped = false; } #else