-
-
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
Big endian and amigaos4 support #5190
Conversation
Thank you for the PR! #ifndef IM_COL32_R_SHIFT
..
#endif In order to allow any combination ( |
No problem :) LITTLE/BIG_ENDIAN allows any platform to automatically adapt the code but your solution is ok for me and i don't have finally patch every time imgui to be used on my amiga projects :) |
Just enclose the block with _SHIFT and_MASK declaration under e.g.
block that's all it needs. |
Something like this? (without tabs if you don't like them) ` #ifdef IMGUI_USE_BGRA_PACKED_COLOR
#else
#endif (sorry for bad code display but github do something weird with multiple #ifdefs) |
You need to use For example: (Click to expand)```cpp
#ifdef IMGUI_USE_BGRA_PACKED_COLOR
#ifndef IM_COL32_R_SHIFT
#define IM_COL32_R_SHIFT 16
#define IM_COL32_G_SHIFT 8
#define IM_COL32_B_SHIFT 0
#define IM_COL32_A_SHIFT 24
#define IM_COL32_A_MASK 0xFF000000
#endif
#else
#ifndef IM_COL32_R_SHIFT
#define IM_COL32_R_SHIFT 0
#define IM_COL32_G_SHIFT 8
#define IM_COL32_B_SHIFT 16
#define IM_COL32_A_SHIFT 24
#define IM_COL32_A_MASK 0xFF000000
#endif
#endif
``` becomes #ifdef IMGUI_USE_BGRA_PACKED_COLOR
#ifndef IM_COL32_R_SHIFT
#define IM_COL32_R_SHIFT 16
#define IM_COL32_G_SHIFT 8
#define IM_COL32_B_SHIFT 0
#define IM_COL32_A_SHIFT 24
#define IM_COL32_A_MASK 0xFF000000
#endif
#else
#ifndef IM_COL32_R_SHIFT
#define IM_COL32_R_SHIFT 0
#define IM_COL32_G_SHIFT 8
#define IM_COL32_B_SHIFT 16
#define IM_COL32_A_SHIFT 24
#define IM_COL32_A_MASK 0xFF000000
#endif
#endif |
So how about not duplicating an ifndef that doesn't need to be duplicated ? |
Squashed, tweaked and merged as 14ca75d |
I think it would still be nice if default |
dhewm#625 (comment) confirms that it's broken for the fix, see ocornut/imgui#6732 (comment) ocornut/imgui#5190
dhewm#625 (comment) confirms that it's broken for the fix, see ocornut/imgui#6732 (comment) ocornut/imgui#5190
dhewm#625 (comment) confirms that it's broken for the fix, see ocornut/imgui#6732 (comment) ocornut/imgui#5190
Well, all modern C library has already something to detect if the system is big or little endian at compile time. It is not so impossible |
You can just |
I haven't tried it (and I don't have a Big Endian machine myself so I'd have to ask dhewm3 users to test it), but as far as I can tell from the code it wouldn't help (or even work on any platform, when using OpenGL without modifying the backend)? It does not change any settings in the rendering backends (for how to interpret color values or whatever; Update: Except for the DX9 backend), the only thing it does is redefining Apparently it does depend on system endianess, as it's always the Big Endian users who complain that the colors are wrong (both in the dhewm3 bugtracker and, as far as I can tell, the ImGui bugtracker) - though it might also depend on the used rendering API. I think the general problem is that Dear ImGui views pixels/colors as 32bit unsigned integer, where Red is in the 8 least significant bits and alpha in the 8 most significant bits - but apparently the rendering APIs (at least OpenGL with GL_RGBA and GL_UNSIGNED_BYTE) view a RGBA pixel as 4 bytes with R in the first byte and A in the last byte - so when feeding it uint32_t data, how it ends up looking is endian-specific. Update: I briefly looked at other rendering backends.
|
Not impossible, but at least a PITA, as it's not standardized in the C standard:
|
from stackoverflow:
|
This pull requests allow big endian systems to use ImgUi
And related to this added also amigaos4 support