mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-27 14:08:39 +01:00
Fixed overlay now showing on some games
In sanctum2, not writing in our own context makes the game crash.
This commit is contained in:
parent
1016e7f47f
commit
6ebc946607
2 changed files with 39 additions and 12 deletions
|
@ -60,6 +60,8 @@ void OpenGLX_Hook::resetRenderState()
|
||||||
X11_Hook::Inst()->resetRenderState();
|
X11_Hook::Inst()->resetRenderState();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
glXDestroyContext(display, context);
|
||||||
|
display = nullptr;
|
||||||
initialized = false;
|
initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +72,7 @@ void OpenGLX_Hook::prepareForOverlay(Display* display, GLXDrawable drawable)
|
||||||
PRINT_DEBUG("Called SwapBuffer hook");
|
PRINT_DEBUG("Called SwapBuffer hook");
|
||||||
|
|
||||||
if( (Window)drawable != X11_Hook::Inst()->get_game_wnd() )
|
if( (Window)drawable != X11_Hook::Inst()->get_game_wnd() )
|
||||||
resetRenderState();
|
X11_Hook::Inst()->resetRenderState();
|
||||||
|
|
||||||
if( ! initialized )
|
if( ! initialized )
|
||||||
{
|
{
|
||||||
|
@ -79,13 +81,34 @@ void OpenGLX_Hook::prepareForOverlay(Display* display, GLXDrawable drawable)
|
||||||
io.IniFilename = NULL;
|
io.IniFilename = NULL;
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Init();
|
ImGui_ImplOpenGL3_Init();
|
||||||
|
|
||||||
|
int attributes[] = { //can't be const b/c X11 doesn't like it. Not sure if that's intentional or just stupid.
|
||||||
|
GLX_RGBA, //apparently nothing comes after this?
|
||||||
|
GLX_RED_SIZE, 8,
|
||||||
|
GLX_GREEN_SIZE, 8,
|
||||||
|
GLX_BLUE_SIZE, 8,
|
||||||
|
GLX_ALPHA_SIZE, 8,
|
||||||
|
//Ideally, the size would be 32 (or at least 24), but I have actually seen
|
||||||
|
// this size (on a modern OS even).
|
||||||
|
GLX_DEPTH_SIZE, 16,
|
||||||
|
GLX_DOUBLEBUFFER, True,
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
XVisualInfo* visual_info = glXChooseVisual(display, DefaultScreen(display), attributes);
|
||||||
|
|
||||||
|
context = glXCreateContext(display, visual_info, nullptr, True);
|
||||||
|
this->display = display;
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( initialized )
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
auto oldContext = glXGetCurrentContext();
|
||||||
|
|
||||||
|
glXMakeCurrent(display, drawable, context);
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
X11_Hook::Inst()->prepareForOverlay(display, (Window)drawable);
|
X11_Hook::Inst()->prepareForOverlay(display, (Window)drawable);
|
||||||
|
|
||||||
|
@ -98,7 +121,8 @@ void OpenGLX_Hook::prepareForOverlay(Display* display, GLXDrawable drawable)
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
}
|
|
||||||
|
glXMakeCurrent(display, drawable, oldContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLX_Hook::MyglXSwapBuffers(Display* display, GLXDrawable drawable)
|
void OpenGLX_Hook::MyglXSwapBuffers(Display* display, GLXDrawable drawable)
|
||||||
|
@ -123,6 +147,7 @@ OpenGLX_Hook::~OpenGLX_Hook()
|
||||||
{
|
{
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
glXDestroyContext(display, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
//dlclose(_library);
|
//dlclose(_library);
|
||||||
|
|
|
@ -19,6 +19,8 @@ private:
|
||||||
// Variables
|
// Variables
|
||||||
bool hooked;
|
bool hooked;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
Display *display;
|
||||||
|
GLXContext context;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
OpenGLX_Hook();
|
OpenGLX_Hook();
|
||||||
|
|
Loading…
Reference in a new issue