sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

Image stops rendering in window after closing another

Open tadashibashi opened this issue 2 years ago • 4 comments

I'm running into an issue where one window stops showing blitted images after closing another one. What's strange is that this only happens when the first opened window is closed that the second's images disappear, and not the other way around.

To close windows, I'm calling SDL_DestroyWindow and GPU_FreeTarget on the target. And I've made sure to call GPU_MakeCurrent on the correct window before loading each GPU_Image. The loaded matrix appears to be unaffected at this point. Images are rendered with GPU_BlitRectX, and it appears that the parameters I'm passing are unchanged.

(Also the secondary window is opened using SDL_CreateWindow and GPU_CreateTargetFromWindow, although I've tried opening both this way after creating a dummy window with GPU_InitRenderer, but the problem persists.)

I'm out of ideas. Would anyone have any clue what might be causing this? Thank you.

tadashibashi avatar May 18 '22 10:05 tadashibashi

I think I've seen this too. Are you able to put together a minimal repro case? This should be a high priority fix.

grimfang4 avatar May 18 '22 16:05 grimfang4

I'm glad to hear that. It might take some time since all the calls are wrapped in other objects, but I can put one together. Would you prefer I make a repository with SDL_gpu as a submodule and share it here?

Also, I forgot to mention–during my attempt to figure out how to handle multiple windows, I added a null check inside SetActiveTarget in src/renderer_GL_Common.inl, that I think fixed a crash case where the GPU_Renderer's current_context_target was null after a window closed, and the function was attempting to access its members. I'm not sure if that rightly solved the issue or if it's contributing to any other problems since I'm not familiar with the code. Would making a pull request be the best way to share this change? I could just submodule the fork in the minimal repro case.

tadashibashi avatar May 18 '22 21:05 tadashibashi

@tadashibashi Whatever works for you. A pull request, a snippet, or a repo are good options.

grimfang4 avatar Jun 14 '22 18:06 grimfang4

@grimfang4 Thanks for the clarification. I just wanted to update that my computer, which is an intel Mac, is under repairs, so I'm running on a Windows 10 machine now, and strangely, the issue entirely disappeared, so I'm thinking it could be some platform-specific issue. I'll start working on the repro case when I can get the computer back.

tadashibashi avatar Jun 18 '22 23:06 tadashibashi