We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello guys.
I currently try to implement ImGui in CS:GO (MacOS).
Therefor I hooked SDL_GL_SwapWindow from the Game itself. So far so good. All works fine and the hook is executing.
SDL_GL_SwapWindow
void SDLHook::HookSwapWindow() { uintptr_t swapwindowFn = reinterpret_cast<uintptr_t>(dlsym(RTLD_NEXT, "SDL_GL_SwapWindow")); swapwindow_ptr = reinterpret_cast<uintptr_t*>(CPatternScanner::Instance()->GetAbsoluteAddress("libSDL2-2.0.0.dylib", swapwindowFn, 0xF, 0x4)); swapwindow_original = *swapwindow_ptr; *swapwindow_ptr = reinterpret_cast<uintptr_t>(&SDLHook::SDLSwapWindow); }
The code of the hooked method:
void SDLHook::SDLSwapWindow(SDL_Window* window) { static oSDL_GL_SwapWindowFn oSDL_GL_SwapWindow = reinterpret_cast<oSDL_GL_SwapWindowFn>(swapwindow_original); static SDL_GLContext original_context = SDL_GL_GetCurrentContext(); static SDL_GLContext user_context = NULL; if (!user_context) { user_context = SDL_GL_CreateContext(window); SDL_GL_MakeCurrent(window, user_context); ImGui_ImplSdl_Init(window); } else { SDL_GL_MakeCurrent(window, user_context); } ImGui_ImplSdl_NewFrame(window); ImGui::SetNextWindowPos(ImVec2(10.f, 10.f)); ImGui::SetNextWindowSize(ImVec2(320.f, 240.f)); ImGui::Begin("Test Window"); ImGui::Text("Just a simple text"); ImGui::End(); ImGui::Render(); SDL_GL_MakeCurrent(window, original_context); oSDL_GL_SwapWindow(window); }
There are no crashes and the game is running well. But it's simply not drawing anything.
When I change the hooked method to:
void SDLHook::SDLSwapWindow(SDL_Window* window) { static oSDL_GL_SwapWindowFn oSDL_GL_SwapWindow = reinterpret_cast<oSDL_GL_SwapWindowFn>(swapwindow_original); static bool ImGuiInit = false; if (!ImGuiInit) { ImGuiInit = true; ImGui_ImplSdl_Init(window); } ImGui_ImplSdl_NewFrame(window); ImGui::SetNextWindowPos(ImVec2(10.f, 10.f)); ImGui::SetNextWindowSize(ImVec2(320.f, 240.f)); ImGui::Begin("Test Window"); ImGui::Text("Just a simple text"); ImGui::End(); ImGui::Render(); oSDL_GL_SwapWindow(window); }
The "Test Window" is drawing. But the game freezes.
Does someone have a clue why this happens?
The text was updated successfully, but these errors were encountered:
Maybe you are swapping the window before anything from CS:GO can render, therefore Windows sees the game as freezing because there is nothing drawing.
Sorry, something went wrong.
It's not windows... It's macOS ;-)
And no.. The Hook is the SwapWindow function. When ImGui Frame is executed I call the original funtction.
I think the problem is at the cocoa gl side.
I'm kinda late, but I've found the workaround: https://github.com/dwnste/imgui_sdl_osx
Sorry but #1586
No branches or pull requests
Hello guys.
I currently try to implement ImGui in CS:GO (MacOS).
Therefor I hooked
SDL_GL_SwapWindow
from the Game itself. So far so good. All works fine and the hook is executing.The code of the hooked method:
There are no crashes and the game is running well.
But it's simply not drawing anything.
When I change the hooked method to:
The "Test Window" is drawing. But the game freezes.
Does someone have a clue why this happens?
The text was updated successfully, but these errors were encountered: