mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Add ability to save content of frame buffer to file for debug purposes.
This commit is contained in:
parent
0c2c4d3c27
commit
217ef2557d
|
@ -5,6 +5,8 @@
|
|||
#include "VI.h"
|
||||
#include "Graphics/Context.h"
|
||||
#include "DisplayWindow.h"
|
||||
#include "PluginAPI.h"
|
||||
#include "FrameBuffer.h"
|
||||
|
||||
void DisplayWindow::start()
|
||||
{
|
||||
|
@ -56,6 +58,23 @@ void DisplayWindow::saveScreenshot()
|
|||
m_bCaptureScreen = false;
|
||||
}
|
||||
|
||||
void DisplayWindow::saveBufferContent(FrameBuffer * _pBuffer)
|
||||
{
|
||||
saveBufferContent(_pBuffer->m_FBO, _pBuffer->m_pTexture);
|
||||
}
|
||||
|
||||
void DisplayWindow::saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture)
|
||||
{
|
||||
if (wcslen(m_strScreenDirectory) == 0) {
|
||||
api().FindPluginPath(m_strScreenDirectory);
|
||||
std::wstring pluginPath(m_strScreenDirectory);
|
||||
if (pluginPath.back() != L'/')
|
||||
pluginPath += L'/';
|
||||
::wcsncpy(m_strScreenDirectory, pluginPath.c_str(), pluginPath.length() + 1);
|
||||
}
|
||||
_saveBufferContent(_fbo, _pTexture);
|
||||
}
|
||||
|
||||
bool DisplayWindow::changeWindow()
|
||||
{
|
||||
if (!m_bToggleFullscreen)
|
||||
|
|
|
@ -12,6 +12,8 @@ public:
|
|||
void restart();
|
||||
void swapBuffers();
|
||||
void saveScreenshot();
|
||||
void saveBufferContent(FrameBuffer * _pBuffer);
|
||||
void saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture);
|
||||
bool changeWindow();
|
||||
bool resizeWindow();
|
||||
void closeWindow();
|
||||
|
@ -71,6 +73,7 @@ private:
|
|||
virtual void _stop() = 0;
|
||||
virtual void _swapBuffers() = 0;
|
||||
virtual void _saveScreenshot() = 0;
|
||||
virtual void _saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture) = 0;
|
||||
virtual void _changeWindow() = 0;
|
||||
virtual bool _resizeWindow() = 0;
|
||||
virtual void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) = 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ private:
|
|||
void _stop() override;
|
||||
void _swapBuffers() override;
|
||||
void _saveScreenshot() override;
|
||||
void _saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture) override;
|
||||
bool _resizeWindow() override;
|
||||
void _changeWindow() override;
|
||||
void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) override {}
|
||||
|
@ -125,6 +126,10 @@ void DisplayWindowMupen64plus::_saveScreenshot()
|
|||
{
|
||||
}
|
||||
|
||||
void DisplayWindowMupen64plus::_saveBufferContent(graphics::ObjectHandle /*_fbo*/, CachedTexture* /*_pTexture*/)
|
||||
{
|
||||
}
|
||||
|
||||
bool DisplayWindowMupen64plus::_resizeWindow()
|
||||
{
|
||||
_setAttributes();
|
||||
|
|
|
@ -22,6 +22,7 @@ private:
|
|||
void _stop() override;
|
||||
void _swapBuffers() override;
|
||||
void _saveScreenshot() override;
|
||||
void _saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture) override;
|
||||
bool _resizeWindow() override;
|
||||
void _changeWindow() override;
|
||||
void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) override;
|
||||
|
@ -177,6 +178,24 @@ void DisplayWindowWindows::_saveScreenshot()
|
|||
free( pixelData );
|
||||
}
|
||||
|
||||
void DisplayWindowWindows::_saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture)
|
||||
{
|
||||
unsigned char * pixelData = NULL;
|
||||
GLint oldMode;
|
||||
glGetIntegerv(GL_READ_BUFFER, &oldMode);
|
||||
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, _fbo);
|
||||
pixelData = (unsigned char*)malloc(_pTexture->realWidth * _pTexture->realHeight * 3);
|
||||
glReadPixels(0, 0, _pTexture->realWidth, _pTexture->realHeight, GL_RGB, GL_UNSIGNED_BYTE, pixelData);
|
||||
if (graphics::BufferAttachmentParam(oldMode) == graphics::bufferAttachment::COLOR_ATTACHMENT0) {
|
||||
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||
if (pCurrentBuffer != nullptr)
|
||||
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, pCurrentBuffer->m_FBO);
|
||||
}
|
||||
glReadBuffer(oldMode);
|
||||
SaveScreenshot(m_strScreenDirectory, RSP.romname, _pTexture->realWidth, _pTexture->realHeight, pixelData);
|
||||
free(pixelData);
|
||||
}
|
||||
|
||||
void DisplayWindowWindows::_changeWindow()
|
||||
{
|
||||
static LONG windowedStyle;
|
||||
|
|
Loading…
Reference in New Issue
Block a user