diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 1cf70b4dc9..b37d031445 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -184,6 +184,8 @@ void CreateXWindow (void) wmProtocols[2] = XInternAtom(GLWin.dpy, "_NET_WM_STATE_FULLSCREEN", False); XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 3); XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL); + XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask | + StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask ); XMapRaised(GLWin.dpy, GLWin.win); XSync(GLWin.dpy, True); #if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) @@ -674,24 +676,15 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight return true; } -bool OpenGL_MakeCurrent() +bool OpenGL_Initialize() { -#if defined(USE_WX) && USE_WX - GLWin.glCanvas->SetCurrent(*GLWin.glCtxt); -#elif defined(HAVE_COCOA) && HAVE_COCOA - cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin); -#elif defined(_WIN32) - if (!wglMakeCurrent(hDC,hRC)) { - PanicAlert("(5) Can't Activate The GL Rendering Context."); + bool success = OpenGL_MakeCurrent(); + if (!success) + { + PanicAlert("Can't Activate The GL Rendering Context."); return false; } -#elif defined(HAVE_X11) && HAVE_X11 - Window winDummy; - unsigned int borderDummy; - // connect the glx-context to the window - glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); - XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y, - &GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth); +#if defined(HAVE_X11) && HAVE_X11 NOTICE_LOG(VIDEO, "GLWin Depth %d", GLWin.depth) if (glXIsDirect(GLWin.dpy, GLWin.ctx)) { NOTICE_LOG(VIDEO, "detected direct rendering"); @@ -715,15 +708,26 @@ bool OpenGL_MakeCurrent() // Hide the cursor now if (g_Config.bHideCursor) XDefineCursor (GLWin.dpy, GLWin.win, GLWin.blankCursor); +#endif + return success; - // better for pad plugin key input (thc) - XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask | - StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask ); +} + +bool OpenGL_MakeCurrent() +{ + // connect the glx-context to the window +#if defined(USE_WX) && USE_WX + GLWin.glCanvas->SetCurrent(*GLWin.glCtxt); +#elif defined(HAVE_COCOA) && HAVE_COCOA + cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin); +#elif defined(_WIN32) + return wglMakeCurrent(hDC,hRC) +#elif defined(HAVE_X11) && HAVE_X11 + return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); #endif return true; } - // Update window width, size and etc. Called from Render.cpp void OpenGL_Update() { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index 61d12abc66..855ed2765d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -135,6 +135,7 @@ extern GLWindow GLWin; bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); void OpenGL_Shutdown(); void OpenGL_Update(); +bool OpenGL_Initialize(); bool OpenGL_MakeCurrent(); void OpenGL_SwapBuffers(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 245d146841..83070999cd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -355,6 +355,9 @@ void Initialize(void *init) } void DoState(unsigned char **ptr, int mode) { +#if defined(HAVE_X11) && HAVE_X11 + OpenGL_MakeCurrent(); +#endif // Clear all caches that touch RAM TextureMngr::Invalidate(false); VertexLoaderManager::MarkAllDirty(); @@ -378,7 +381,7 @@ void EmuStateChange(PLUGIN_EMUSTATE newState) // This is called after Video_Initialize() from the Core void Video_Prepare(void) { - OpenGL_MakeCurrent(); + OpenGL_Initialize(); if (!Renderer::Init()) { g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE); PanicAlert("Can't create opengl renderer. You might be missing some required opengl extensions, check the logs for more info");