From 3b67df1b453bd3779a7dd224dcd098bf1bad9e84 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Thu, 27 Nov 2008 12:13:15 +0000 Subject: [PATCH] Fixed saving states in OGL Linux. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1313 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/State.cpp | 4 +-- .../Plugins/Plugin_VideoOGL/Src/BPStructs.cpp | 3 +- .../Plugin_VideoOGL/Src/TextureMngr.cpp | 18 +++++----- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 36 ++++++++++++------- 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 2dac44ddd8..12dbb7b043 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -70,8 +70,8 @@ void DoState(PointerWrap &p) return; } // Begin with video plugin, so that it gets a chance to clear it's caches and writeback modified things to RAM - PluginVideo::Video_DoState(p.GetPPtr(), p.GetMode()); - PluginDSP::DSP_DoState(p.GetPPtr(), p.GetMode()); + PluginVideo::Video_DoState(p.GetPPtr(), p.GetMode()); + PluginDSP::DSP_DoState(p.GetPPtr(), p.GetMode()); PowerPC::DoState(p); HW::DoState(p); CoreTiming::DoState(p); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp index 0eabc01cf9..3a7ad113d3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp @@ -93,7 +93,8 @@ void BPWritten(int addr, int changes, int newval) glEnable(GL_CULL_FACE); glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW); } - else glDisable(GL_CULL_FACE); + else if(glIsEnabled(GL_CULL_FACE) == GL_TRUE) + glDisable(GL_CULL_FACE); PixelShaderMngr::SetGenModeChanged(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index cd212226a1..b2bee4b544 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -108,15 +108,17 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode) void TextureMngr::TCacheEntry::Destroy() { + if(!texture) + return; glDeleteTextures(1, &texture); - if (!isRenderTarget) { - if (!g_Config.bSafeTextureCache) { - u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset * 4); - if (*ptr == hash) - *ptr = oldpixel; - } - } - texture = 0; + if (!isRenderTarget) { + if (!g_Config.bSafeTextureCache) { + u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset * 4); + if (*ptr == hash) + *ptr = oldpixel; + } + } + texture = 0; } void TextureMngr::Init() diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index c8d5e00693..48f155302a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -228,19 +228,29 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) } void Video_DoState(unsigned char **ptr, int mode) { - - // Clear all caches that touch RAM - TextureMngr::Invalidate(); - // DisplayListManager::Invalidate(); - - VertexLoaderManager::MarkAllDirty(); - - PointerWrap p(ptr, mode); - VideoCommon_DoState(p); - - // Refresh state. - if (mode == PointerWrap::MODE_READ) - BPReload(); +#ifdef _WIN32 + if (!wglMakeCurrent(hDC,hRC)) { + PanicAlert("Can't Activate The GL Rendering Context for saving"); + return false; + } +#elif defined(OSX64) + cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin); +#else // Linux + glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); +#endif + + // Clear all caches that touch RAM + TextureMngr::Invalidate(); + // DisplayListManager::Invalidate(); + + VertexLoaderManager::MarkAllDirty(); + + PointerWrap p(ptr, mode); + VideoCommon_DoState(p); + + // Refresh state. + if (mode == PointerWrap::MODE_READ) + BPReload(); } // This is called after Video_Initialize() from the Core