summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp
diff options
context:
space:
mode:
author Branimir Karadžić <branimirkaradzic@gmail.com>2016-03-31 20:39:30 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2016-03-31 20:39:30 +0200
commit4172b54d844e4c1ff5626a8f22bf3f56e6c9dd94 (patch)
tree7592d25c86fc8beebbe2c26e56cdb71f45f96641 /3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp
parent5c34b1ba40a348a8f941423724acbf2a4b0feb8b (diff)
Update BGFX and BX (nw)
Diffstat (limited to '3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp b/3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp
index 741adb25433..87bc1e6530a 100644
--- a/3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp
+++ b/3rdparty/bgfx/examples/common/debugdraw/debugdraw.cpp
@@ -324,13 +324,15 @@ static bgfx::ShaderHandle createEmbeddedShader(bgfx::RendererType::Enum _type, u
struct DebugDraw
{
DebugDraw()
- : m_state(State::Count)
+ : m_depthTestLess(true)
+ , m_state(State::Count)
{
}
- void init(bx::AllocatorI* _allocator)
+ void init(bool _depthTestLess, bx::AllocatorI* _allocator)
{
m_allocator = _allocator;
+ m_depthTestLess = _depthTestLess;
#if BX_CONFIG_ALLOCATOR_CRT
if (NULL == _allocator)
@@ -502,9 +504,9 @@ struct DebugDraw
Attrib& attrib = m_attrib[0];
attrib.m_state = 0
| BGFX_STATE_RGB_WRITE
- | BGFX_STATE_DEPTH_TEST_LESS
- | BGFX_STATE_DEPTH_WRITE
+ | (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER)
| BGFX_STATE_CULL_CW
+ | BGFX_STATE_DEPTH_WRITE
;
attrib.m_scale = 1.0f;
attrib.m_offset = 0.0f;
@@ -533,7 +535,10 @@ struct DebugDraw
void pop()
{
BX_CHECK(State::Count != m_state);
- if (m_attrib[m_stack].m_stipple != m_attrib[m_stack-1].m_stipple)
+ const Attrib& curr = m_attrib[m_stack];
+ const Attrib& prev = m_attrib[m_stack-1];
+ if (curr.m_stipple != prev.m_stipple
+ || curr.m_state != prev.m_state)
{
flush();
}
@@ -570,15 +575,20 @@ struct DebugDraw
void setState(bool _depthTest, bool _depthWrite, bool _clockwise)
{
+ const uint64_t depthTest = m_depthTestLess
+ ? BGFX_STATE_DEPTH_TEST_LESS
+ : BGFX_STATE_DEPTH_TEST_GREATER
+ ;
+
m_attrib[m_stack].m_state &= ~(0
- | BGFX_STATE_DEPTH_TEST_LESS
+ | BGFX_STATE_DEPTH_TEST_MASK
| BGFX_STATE_DEPTH_WRITE
| BGFX_STATE_CULL_CW
| BGFX_STATE_CULL_CCW
);
m_attrib[m_stack].m_state |= _depthTest
- ? BGFX_STATE_DEPTH_TEST_LESS
+ ? depthTest
: 0
;
@@ -1266,7 +1276,7 @@ private:
bgfx::setState(0
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_PT_LINES
- | BGFX_STATE_DEPTH_TEST_LEQUAL
+ | (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LEQUAL : BGFX_STATE_DEPTH_TEST_GEQUAL)
| BGFX_STATE_DEPTH_WRITE
| BGFX_STATE_LINEAA
| BGFX_STATE_BLEND_ALPHA
@@ -1306,6 +1316,7 @@ private:
uint16_t m_vertexPos;
uint8_t m_viewId;
uint8_t m_stack;
+ bool m_depthTestLess;
struct Attrib
{
@@ -1335,9 +1346,9 @@ private:
static DebugDraw s_dd;
-void ddInit(bx::AllocatorI* _allocator)
+void ddInit(bool _depthTestLess, bx::AllocatorI* _allocator)
{
- s_dd.init(_allocator);
+ s_dd.init(_depthTestLess, _allocator);
}
void ddShutdown()