From 2f58755f6dd3d5dd9dda08af02fbe9d168e40681 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Wed, 4 Mar 2020 15:12:48 +0000 Subject: [PATCH] Keep debug text colours the same with sRGB backbuffer on/off --- src/bgfx.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 20fe6b4f0..03a8f95a9 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -711,7 +711,7 @@ namespace bgfx float m_v; }; - static uint32_t palette[] = + static uint32_t paletteSrgb[] = { 0x0, // Black 0xffa46534, // Blue @@ -730,7 +730,28 @@ namespace bgfx 0xff4fe9fc, // Yellow 0xffeceeee, // White }; - BX_STATIC_ASSERT(BX_COUNTOF(palette) == 16); + BX_STATIC_ASSERT(BX_COUNTOF(paletteSrgb) == 16); + + static uint32_t paletteLinear[] = + { + 0x0, // Black + 0xff5e2108, // Blue + 0xff005213, // Green + 0xff525000, // Cyan + 0xff000099, // Red + 0xff32142d, // Magenta + 0xff00598c, // Brown + 0xff9fada6, // Light Gray + 0xff161817, // Dark Gray + 0xff9f582a, // Light Blue + 0xff08c140, // Light Green + 0xffc1c108, // Light Cyan + 0xff0505dc, // Light Red + 0xff63366a, // Light Magenta + 0xff13cff8, // Yellow + 0xffd5dada // White + }; + BX_STATIC_ASSERT(BX_COUNTOF(paletteLinear) == 16); uint32_t yy = 0; uint32_t xx = 0; @@ -745,6 +766,11 @@ namespace bgfx _renderCtx->blitSetup(_blitter); + uint32_t *palette = paletteSrgb; + if (s_ctx->m_init.resolution.reset & BGFX_RESET_SRGB_BACKBUFFER) { + palette = paletteLinear; + } + for (;yy < _mem.m_height;) { Vertex* vertex = (Vertex*)_blitter.m_vb->data;