Introduce IMGUI_USE_BGRA_PACKED_COLOR in imconfig.h.
When IMGUI_USE_BGRA_PACKED_COLOR is defined packed color hold in ImU32 use BGRA format instead RGBA.
This commit is contained in:
parent
82dcdc9dfc
commit
d75d2b1871
@ -26,6 +26,9 @@
|
||||
//---- Don't define obsolete functions names
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Implement STB libraries in a namespace to avoid conflicts
|
||||
//#define IMGUI_STB_NAMESPACE ImGuiStb
|
||||
|
||||
|
14
imgui.cpp
14
imgui.cpp
@ -1195,16 +1195,20 @@ int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_e
|
||||
ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in)
|
||||
{
|
||||
float s = 1.0f/255.0f;
|
||||
return ImVec4((in & 0xFF) * s, ((in >> 8) & 0xFF) * s, ((in >> 16) & 0xFF) * s, (in >> 24) * s);
|
||||
return ImVec4(
|
||||
((in >> IM_COL32_R_SHIFT) & 0xFF) * s,
|
||||
((in >> IM_COL32_G_SHIFT) & 0xFF) * s,
|
||||
((in >> IM_COL32_B_SHIFT) & 0xFF) * s,
|
||||
((in >> IM_COL32_A_SHIFT) & 0xFF) * s);
|
||||
}
|
||||
|
||||
ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in)
|
||||
{
|
||||
ImU32 out;
|
||||
out = ((ImU32)IM_F32_TO_INT8_SAT(in.x));
|
||||
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << 8;
|
||||
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << 16;
|
||||
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << 24;
|
||||
out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT;
|
||||
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT;
|
||||
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT;
|
||||
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
13
imgui.h
13
imgui.h
@ -1091,7 +1091,18 @@ struct ImGuiListClipper
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Helpers macros to generate 32-bits encoded colors
|
||||
#define IM_COL32(R,G,B,A) (((ImU32)(A)<<24) | ((ImU32)(B)<<16) | ((ImU32)(G)<<8) | ((ImU32)(R)))
|
||||
#ifdef IMGUI_USE_BGRA_PACKED_COLOR
|
||||
#define IM_COL32_R_SHIFT 16
|
||||
#define IM_COL32_G_SHIFT 8
|
||||
#define IM_COL32_B_SHIFT 0
|
||||
#define IM_COL32_A_SHIFT 24
|
||||
#else
|
||||
#define IM_COL32_R_SHIFT 0
|
||||
#define IM_COL32_G_SHIFT 8
|
||||
#define IM_COL32_B_SHIFT 16
|
||||
#define IM_COL32_A_SHIFT 24
|
||||
#endif
|
||||
#define IM_COL32(R,G,B,A) (((ImU32)(A)<<IM_COL32_A_SHIFT) | ((ImU32)(B)<<IM_COL32_B_SHIFT) | ((ImU32)(G)<<IM_COL32_G_SHIFT) | ((ImU32)(R)<<IM_COL32_R_SHIFT))
|
||||
#define IM_COL32_WHITE (0xFFFFFFFF)
|
||||
#define IM_COL32_BLACK (0xFF000000)
|
||||
#define IM_COL32_BLACK_TRANS (0x00000000) // Transparent black
|
||||
|
Loading…
Reference in New Issue
Block a user