Skip to content

Commit 105fd8c

Browse files
committed
Cleanup.
1 parent 913dd02 commit 105fd8c

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

examples/30-picking/picking.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ class ExamplePicking : public entry::AppI
381381
}
382382

383383
// Start a new readback?
384-
if (!m_reading
385-
&& m_mouseState.m_buttons[entry::MouseButton::Left])
384+
if (!ImGui::MouseOverArea()
385+
&& !m_reading
386+
&& m_mouseState.m_buttons[entry::MouseButton::Left]
387+
)
386388
{
387389
// Blit and read
388390
bgfx::blit(RENDER_PASS_BLIT, m_blitTex, 0, 0, m_pickingRT);

examples/38-bloom/bloom.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,30 @@ class ExampleBloom : public entry::AppI
395395
m_texChainFb[ii] = bgfx::createFrameBuffer(
396396
(uint16_t)(m_width >> ii)
397397
, (uint16_t)(m_height >> ii)
398-
, bgfx::TextureFormat::RGBA32F
398+
, bgfx::TextureFormat::RGBA16F
399399
, tsFlags
400400
);
401401
}
402402

403403
bgfx::TextureHandle gbufferTex[] =
404404
{
405-
bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::RGBA32F, tsFlags),
405+
bgfx::createTexture2D(
406+
uint16_t(m_width)
407+
, uint16_t(m_height)
408+
, false
409+
, 1
410+
, bgfx::TextureFormat::RGBA16F
411+
, tsFlags
412+
),
406413
bgfx::getTexture(m_texChainFb[0]),
407-
bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::D32F, tsFlags),
414+
bgfx::createTexture2D(
415+
uint16_t(m_width)
416+
, uint16_t(m_height)
417+
, false
418+
, 1
419+
, bgfx::TextureFormat::D32F
420+
, tsFlags
421+
),
408422
};
409423

410424
m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(gbufferTex), gbufferTex, true);

src/bgfx_p.h

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -287,26 +287,16 @@ namespace bgfx
287287
{
288288
constexpr uint32_t kChunkMagicTex = BX_MAKEFOURCC('T', 'E', 'X', 0x0);
289289

290-
inline constexpr uint32_t toAbgr8(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 0xff)
291-
{
292-
return 0
293-
| (uint32_t(_r) << 24)
294-
| (uint32_t(_g) << 16)
295-
| (uint32_t(_b) << 8)
296-
| (uint32_t(_a))
297-
;
298-
}
299-
300290
// Palette:
301291
// https://colorkit.co/color-palette-generator/a8e6cf-dcedc1-ffd3b6-76b4bd-bdeaee-8874a3-ff0000-ff8b94/
302-
constexpr uint32_t kColorFrame = toAbgr8(0xa8, 0xe6, 0xcf);
303-
constexpr uint32_t kColorSubmit = toAbgr8(0xdc, 0xed, 0xc1);
304-
constexpr uint32_t kColorView = toAbgr8(0xff, 0xd3, 0xb6);
305-
constexpr uint32_t kColorDraw = toAbgr8(0x76, 0xb4, 0xbd);
306-
constexpr uint32_t kColorCompute = toAbgr8(0xbd, 0xea, 0xee);
307-
constexpr uint32_t kColorResource = toAbgr8(0x88, 0x74, 0xa3);
308-
constexpr uint32_t kColorMarker = toAbgr8(0xff, 0x00, 0x00);
309-
constexpr uint32_t kColorWait = toAbgr8(0xff, 0x8b, 0x94);
292+
constexpr uint32_t kColorFrame = 0xa8'e6'cf'ff;
293+
constexpr uint32_t kColorSubmit = 0xdc'ed'c1'ff;
294+
constexpr uint32_t kColorView = 0xff'd3'b6'ff;
295+
constexpr uint32_t kColorDraw = 0x76'b4'bd'ff;
296+
constexpr uint32_t kColorCompute = 0xbd'ea'ee'ff;
297+
constexpr uint32_t kColorResource = 0x88'74'a3'ff;
298+
constexpr uint32_t kColorMarker = 0xff'00'00'ff;
299+
constexpr uint32_t kColorWait = 0xff'8b'94'ff;
310300

311301
extern InternalData g_internalData;
312302
extern PlatformData g_platformData;
@@ -627,25 +617,25 @@ namespace bgfx
627617
release( (const Memory*)_mem);
628618
}
629619

630-
inline uint64_t packStencil(uint32_t _fstencil, uint32_t _bstencil)
620+
inline constexpr uint64_t packStencil(uint32_t _fstencil, uint32_t _bstencil)
631621
{
632622
return (uint64_t(_bstencil)<<32)|uint64_t(_fstencil);
633623
}
634624

635-
inline uint32_t unpackStencil(uint8_t _0or1, uint64_t _stencil)
625+
inline constexpr uint32_t unpackStencil(uint8_t _0or1, uint64_t _stencil)
636626
{
637627
return uint32_t( (_stencil >> (32*_0or1) ) );
638628
}
639629

640-
inline bool needBorderColor(uint64_t _flags)
630+
inline constexpr bool needBorderColor(uint64_t _flags)
641631
{
642632
return BGFX_SAMPLER_U_BORDER == (_flags & BGFX_SAMPLER_U_BORDER)
643633
|| BGFX_SAMPLER_V_BORDER == (_flags & BGFX_SAMPLER_V_BORDER)
644634
|| BGFX_SAMPLER_W_BORDER == (_flags & BGFX_SAMPLER_W_BORDER)
645635
;
646636
}
647637

648-
inline uint8_t calcNumMips(bool _hasMips, uint16_t _width, uint16_t _height, uint16_t _depth = 1)
638+
inline constexpr uint8_t calcNumMips(bool _hasMips, uint16_t _width, uint16_t _height, uint16_t _depth = 1)
649639
{
650640
if (_hasMips)
651641
{

0 commit comments

Comments
 (0)