-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
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
Assorted SDL improvements #4927
Conversation
This is (kind of) an OpenGL-only function, which should be avoided when SDL2 isn't using OpenGL. The only alternative that is recommended is SDL_GetRendererOutputSize, which limits this fix to the SDL_Renderer backend. Still, I think it's better than nothing. I say that SDL_GL_GetDrawableSize is "kind of" OpenGL-only because it does technically work even when SDL2 isn't using OpenGL. It's just that it becomes a shim to SDL_GetWindowSize, which is not suitable for high-DPI usage because it reflects the size of the window in screen coordinates, not actual pixels, so it really should be avoided when not using OpenGL.
Hello, Thank you for the PR.
|
Thanks for the feedback! I'm not at a PC right now to make any changes, but I can respond to a few things here: I think the point of the SDL libc functions is to support platforms that don't have an adequate C standard library, or to avoid having the user's program become dependent on said library. An instance I saw where the libc replacement functions were recommended was for avoiding a dependency on a particular version of msvcr###.dll. Though, if Dear ImGui itself uses libc functions directly without any way of shimming them, then I guess using the SDL libc functions really is pointless. According to its documentation, SDL_GetRendererOutputSize was introduced in SDL 2.0.0, so I don't think it needs an ifdef. I'm not sure what can be done to add a general solution for when neither SDL_Renderer nor OpenGL are being used. I think that would have to be tackled in a separate PR by someone else. |
9aef59d
to
eb3fedc
Compare
The SDL libc commit has been reverted. Sorry for the delay. |
SDL_PIXELFORMAT_RGBA32 is intended for byte arrays where the channels are specifically in the RGBA order. However, this is not what GetTexDataAsRGBA32 does: rather, it constructs an array where each pixel is an unsigned int in ABGR order. On little-endian platforms, this does indeed result in an RGBA byte order, however, on big-endian platforms, this results in an ABGR byte order, which does not match the PIXELFORMAT enum. What should be used is the SDL_PIXELFORMAT_ABGR8888 enum, which specifies that the pixels are in native-endian ABGR, which they are.
`SDL_WINDOW_OPENGL` is only necessary when using OpenGL directly, bypassing SDL2's Renderer API. There's a similar flag for doing the same with Vulkan - `SDL_WINDOW_VULKAN`. I imagine that this flag was used because of the SDL backend's dependency on an OpenGL-specific function, but that has been eliminated as of ccf4c24.
…re (#4927) SDL_PIXELFORMAT_RGBA32 is intended for byte arrays where the channels are specifically in the RGBA order. However, this is not what GetTexDataAsRGBA32 does: rather, it constructs an array where each pixel is an unsigned int in ABGR order. On little-endian platforms, this does indeed result in an RGBA byte order, however, on big-endian platforms, this results in an ABGR byte order, which does not match the PIXELFORMAT enum. What should be used is the SDL_PIXELFORMAT_ABGR8888 enum, which specifies that the pixels are in native-endian ABGR, which they are.
…rSDLRenderer(). Use SDL_GetRendererOutputSize() instead of SDL_GL_GetDrawableSize() when bound to a SDL_Renderer. (#4927) This is (kind of) an OpenGL-only function, which should be avoided when SDL2 isn't using OpenGL. The only alternative that is recommended is SDL_GetRendererOutputSize, which limits this fix to the SDL_Renderer backend. Still, I think it's better than nothing. I say that SDL_GL_GetDrawableSize is "kind of" OpenGL-only because it does technically work even when SDL2 isn't using OpenGL. It's just that it becomes a shim to SDL_GetWindowSize, which is not suitable for high-DPI usage because it reflects the size of the window in screen coordinates, not actual pixels, so it really should be avoided when not using OpenGL.
…re (ocornut#4927) SDL_PIXELFORMAT_RGBA32 is intended for byte arrays where the channels are specifically in the RGBA order. However, this is not what GetTexDataAsRGBA32 does: rather, it constructs an array where each pixel is an unsigned int in ABGR order. On little-endian platforms, this does indeed result in an RGBA byte order, however, on big-endian platforms, this results in an ABGR byte order, which does not match the PIXELFORMAT enum. What should be used is the SDL_PIXELFORMAT_ABGR8888 enum, which specifies that the pixels are in native-endian ABGR, which they are.
…rSDLRenderer(). Use SDL_GetRendererOutputSize() instead of SDL_GL_GetDrawableSize() when bound to a SDL_Renderer. (ocornut#4927) This is (kind of) an OpenGL-only function, which should be avoided when SDL2 isn't using OpenGL. The only alternative that is recommended is SDL_GetRendererOutputSize, which limits this fix to the SDL_Renderer backend. Still, I think it's better than nothing. I say that SDL_GL_GetDrawableSize is "kind of" OpenGL-only because it does technically work even when SDL2 isn't using OpenGL. It's just that it becomes a shim to SDL_GetWindowSize, which is not suitable for high-DPI usage because it reflects the size of the window in screen coordinates, not actual pixels, so it really should be avoided when not using OpenGL.
No description provided.