Browse Source

debugdraw: Added solid fill alpha blend.

Branimir Karadžić 9 years ago
parent
commit
d2c6c79551
2 changed files with 6 additions and 4 deletions
  1. 2 2
      examples/29-debugdraw/debugdraw.cpp
  2. 4 2
      examples/common/debugdraw/debugdraw.cpp

+ 2 - 2
examples/29-debugdraw/debugdraw.cpp

@@ -152,12 +152,12 @@ class DebugDrawApp : public entry::AppI
 				ddDraw(sphere);
 				ddSetWireframe(false);
 
-				ddSetColor(0xf0ffc0ff);
+				ddSetColor(0xc0ffc0ff);
 				sphere.m_center[0] = -2.0f;
 				ddSetLod(2);
 				ddDraw(sphere);
 
-				ddSetColor(0xc0f0ffff);
+				ddSetColor(0xa0f0ffff);
 				sphere.m_center[0] = -4.0f;
 				ddSetLod(1);
 				ddDraw(sphere);

+ 4 - 2
examples/common/debugdraw/debugdraw.cpp

@@ -1546,6 +1546,7 @@ private:
 		}
 
 		const float flip = 0 == (attrib.m_state & BGFX_STATE_CULL_CCW) ? 1.0f : -1.0f;
+		const uint8_t alpha = attrib.m_abgr>>24;
 
 		float params[4][4] =
 		{
@@ -1571,7 +1572,7 @@ private:
 				( (attrib.m_abgr    )&0xff)/255.0f,
 				( (attrib.m_abgr>> 8)&0xff)/255.0f,
 				( (attrib.m_abgr>>16)&0xff)/255.0f,
-				( (attrib.m_abgr>>24)     )/255.0f,
+				(  alpha                  )/255.0f,
 			},
 		};
 
@@ -1583,7 +1584,8 @@ private:
 		bgfx::setVertexBuffer(m_vbh, mesh.m_startVertex, mesh.m_numVertices);
 		bgfx::setState(0
 				| attrib.m_state
-				| (_wireframe ? BGFX_STATE_PT_LINES|BGFX_STATE_LINEAA|BGFX_STATE_BLEND_ALPHA : 0)
+				| (_wireframe ? BGFX_STATE_PT_LINES|BGFX_STATE_LINEAA|BGFX_STATE_BLEND_ALPHA
+				: (alpha < 0xff) ? BGFX_STATE_BLEND_ALPHA : 0)
 				);
 		bgfx::submit(m_viewId, m_program[_wireframe ? Program::Fill : Program::FillLit]);
 	}