Hopefully fix screenshots

This commit is contained in:
def 2014-03-29 17:04:06 +01:00
parent 9a43558c8c
commit 2db9e5c7b0
2 changed files with 5 additions and 16 deletions

View file

@ -452,27 +452,17 @@ void CGraphics_Threaded::KickCommandBuffer()
void CGraphics_Threaded::ScreenshotDirect() void CGraphics_Threaded::ScreenshotDirect()
{ {
void *ScreenshotThread = thread_create(ScreenshotDirectThread, this);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)ScreenshotThread);
#endif
}
void CGraphics_Threaded::ScreenshotDirectThread(void *pData)
{
CGraphics_Threaded *pGraphics = (CGraphics_Threaded *) pData;
// add swap command // add swap command
CImageInfo Image; CImageInfo Image;
mem_zero(&Image, sizeof(Image)); mem_zero(&Image, sizeof(Image));
CCommandBuffer::SCommand_Screenshot Cmd; CCommandBuffer::SCommand_Screenshot Cmd;
Cmd.m_pImage = &Image; Cmd.m_pImage = &Image;
pGraphics->m_pCommandBuffer->AddCommand(Cmd); m_pCommandBuffer->AddCommand(Cmd);
// kick the buffer and wait for the result // kick the buffer and wait for the result
pGraphics->KickCommandBuffer(); KickCommandBuffer();
thread_sleep(100); WaitForIdle();
if(Image.m_pData) if(Image.m_pData)
{ {
@ -480,14 +470,14 @@ void CGraphics_Threaded::ScreenshotDirectThread(void *pData)
char aWholePath[1024]; char aWholePath[1024];
png_t Png; // ignore_convention png_t Png; // ignore_convention
IOHANDLE File = pGraphics->m_pStorage->OpenFile(pGraphics->m_aScreenshotName, IOFLAG_WRITE, IStorage::TYPE_SAVE, aWholePath, sizeof(aWholePath)); IOHANDLE File = m_pStorage->OpenFile(m_aScreenshotName, IOFLAG_WRITE, IStorage::TYPE_SAVE, aWholePath, sizeof(aWholePath));
if(File) if(File)
io_close(File); io_close(File);
// save png // save png
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath); str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath);
pGraphics->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
png_open_file_write(&Png, aWholePath); // ignore_convention png_open_file_write(&Png, aWholePath); // ignore_convention
png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR, (unsigned char *)Image.m_pData); // ignore_convention png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR, (unsigned char *)Image.m_pData); // ignore_convention
png_close_file(&Png); // ignore_convention png_close_file(&Png); // ignore_convention

View file

@ -399,7 +399,6 @@ public:
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType); virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType);
void ScreenshotDirect(); void ScreenshotDirect();
static void ScreenshotDirectThread(void *pData);
virtual void TextureSet(int TextureID); virtual void TextureSet(int TextureID);