10#include <bgfx/embedded_shader.h>
13#include <bx/handlealloc.h>
17#include <bx/uint32_t.h>
19#ifndef DEBUG_DRAW_CONFIG_MAX_GEOMETRY
20#define DEBUG_DRAW_CONFIG_MAX_GEOMETRY 256
34 .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
35 .add(bgfx::Attrib::TexCoord0, 1, bgfx::AttribType::Float)
36 .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8,
true)
57 .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
58 .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
59 .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8,
true)
78 .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
79 .add(bgfx::Attrib::Indices, 4, bgfx::AttribType::Uint8)
96 ms_layout.begin().add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float).end();
105 {-1.0f, 0.0f, 1.0f, {0, 0, 0, 0}},
106 {1.0f, 0.0f, 1.0f, {0, 0, 0, 0}},
107 {-1.0f, 0.0f, -1.0f, {0, 0, 0, 0}},
108 {1.0f, 0.0f, -1.0f, {0, 0, 0, 0}},
112static const uint16_t s_quadIndices[6] = {
122 {-1.0f, 1.0f, 1.0f, {0, 0, 0, 0}},
123 {1.0f, 1.0f, 1.0f, {0, 0, 0, 0}},
124 {-1.0f, -1.0f, 1.0f, {0, 0, 0, 0}},
125 {1.0f, -1.0f, 1.0f, {0, 0, 0, 0}},
126 {-1.0f, 1.0f, -1.0f, {0, 0, 0, 0}},
127 {1.0f, 1.0f, -1.0f, {0, 0, 0, 0}},
128 {-1.0f, -1.0f, -1.0f, {0, 0, 0, 0}},
129 {1.0f, -1.0f, -1.0f, {0, 0, 0, 0}},
132static const uint16_t s_cubeIndices[36] = {
142static const uint8_t s_circleLod[] = {
150static uint8_t getCircleLod(uint8_t _lod)
152 _lod = _lod > BX_COUNTOF(s_circleLod) - 1 ? BX_COUNTOF(s_circleLod) - 1 : _lod;
153 return s_circleLod[_lod];
156static void circle(
float* _out,
float _angle)
158 float sa = bx::sin(_angle);
159 float ca = bx::cos(_angle);
164static void squircle(
float* _out,
float _angle)
166 float sa = bx::sin(_angle);
167 float ca = bx::cos(_angle);
168 _out[0] = bx::sqrt(bx::abs(sa)) * bx::sign(sa);
169 _out[1] = bx::sqrt(bx::abs(ca)) * bx::sign(ca);
174 uint16_t _posStride0 = 0,
175 void* _normals0 = NULL,
176 uint16_t _normalStride0 = 0)
182 Gen(
void* _pos, uint16_t _posStride,
void* _normals, uint16_t _normalStride, uint8_t _subdiv)
183 : m_pos((uint8_t*)_pos)
184 , m_normals((uint8_t*)_normals)
185 , m_posStride(_posStride)
186 , m_normalStride(_normalStride)
188 static const float scale = 1.0f;
189 static const float golden = 1.6180339887f;
190 static const float len = bx::sqrt(golden * golden + 1.0f);
191 static const float ss = 1.0f / len *
scale;
192 static const float ll = ss * golden;
194 static const bx::Vec3 vv[] = {
213 triangle(vv[0], vv[4], vv[3],
scale, _subdiv);
214 triangle(vv[0], vv[10], vv[4],
scale, _subdiv);
215 triangle(vv[4], vv[10], vv[5],
scale, _subdiv);
216 triangle(vv[5], vv[10], vv[1],
scale, _subdiv);
217 triangle(vv[5], vv[1], vv[2],
scale, _subdiv);
218 triangle(vv[5], vv[2], vv[9],
scale, _subdiv);
219 triangle(vv[5], vv[9], vv[4],
scale, _subdiv);
220 triangle(vv[3], vv[4], vv[9],
scale, _subdiv);
222 triangle(vv[0], vv[3], vv[7],
scale, _subdiv);
223 triangle(vv[0], vv[7], vv[11],
scale, _subdiv);
224 triangle(vv[11], vv[7], vv[6],
scale, _subdiv);
225 triangle(vv[11], vv[6], vv[1],
scale, _subdiv);
226 triangle(vv[1], vv[6], vv[2],
scale, _subdiv);
227 triangle(vv[2], vv[6], vv[8],
scale, _subdiv);
228 triangle(vv[8], vv[6], vv[7],
scale, _subdiv);
229 triangle(vv[8], vv[7], vv[3],
scale, _subdiv);
231 triangle(vv[0], vv[11], vv[10],
scale, _subdiv);
232 triangle(vv[1], vv[10], vv[11],
scale, _subdiv);
233 triangle(vv[2], vv[8], vv[9],
scale, _subdiv);
234 triangle(vv[3], vv[9], vv[8],
scale, _subdiv);
237 void addVert(
const bx::Vec3& _v)
239 bx::store(m_pos, _v);
240 m_pos += m_posStride;
242 if(NULL != m_normals)
244 const bx::Vec3
normal = bx::normalize(_v);
245 bx::store(m_normals,
normal);
247 m_normals += m_normalStride;
253 void triangle(
const bx::Vec3& _v0,
const bx::Vec3& _v1,
const bx::Vec3& _v2,
float _scale, uint8_t _subdiv)
263 const bx::Vec3 v01 = bx::mul(bx::normalize(bx::add(_v0, _v1)), _scale);
264 const bx::Vec3 v12 = bx::mul(bx::normalize(bx::add(_v1, _v2)), _scale);
265 const bx::Vec3 v20 = bx::mul(bx::normalize(bx::add(_v2, _v0)), _scale);
268 triangle(_v0, v01, v20, _scale, _subdiv);
269 triangle(_v1, v12, v01, _scale, _subdiv);
270 triangle(_v2, v20, v12, _scale, _subdiv);
271 triangle(v01, v12, v20, _scale, _subdiv);
277 uint16_t m_posStride;
278 uint16_t m_normalStride;
279 uint32_t m_numVertices;
281 } gen(_pos0, _posStride0, _normals0, _normalStride0, _subdiv0);
284 uint32_t numVertices = 20 * 3 * bx::uint32_max(1, (uint32_t)bx::pow(4.0f, _subdiv0));
293 return {0.0f, _x, _y};
295 return {_y, 0.0f, _x};
300 return {_x, _y, 0.0f};
316static const bgfx::EmbeddedShader s_embeddedShaders[] = {BGFX_EMBEDDED_SHADER(vs_debugdraw_lines),
317 BGFX_EMBEDDED_SHADER(fs_debugdraw_lines),
318 BGFX_EMBEDDED_SHADER(vs_debugdraw_lines_stipple),
319 BGFX_EMBEDDED_SHADER(fs_debugdraw_lines_stipple),
320 BGFX_EMBEDDED_SHADER(vs_debugdraw_fill),
321 BGFX_EMBEDDED_SHADER(vs_debugdraw_fill_mesh),
322 BGFX_EMBEDDED_SHADER(fs_debugdraw_fill),
323 BGFX_EMBEDDED_SHADER(vs_debugdraw_fill_lit),
324 BGFX_EMBEDDED_SHADER(vs_debugdraw_fill_lit_mesh),
325 BGFX_EMBEDDED_SHADER(fs_debugdraw_fill_lit),
326 BGFX_EMBEDDED_SHADER(vs_debugdraw_fill_texture),
327 BGFX_EMBEDDED_SHADER(fs_debugdraw_fill_texture),
329 BGFX_EMBEDDED_SHADER_END()};
331#define SPRITE_TEXTURE_SIZE 1024
333template<u
int16_t MaxHandlesT = 256, u
int16_t TextureSizeT = 1024>
342 bx::MutexScope lock(
m_lock);
349 if(
m_ra.
find(_width, _height, pack))
385template<u
int16_t MaxHandlesT = DEBUG_DRAW_CONFIG_MAX_GEOMETRY>
394 uint32_t _numIndices,
395 const void* _indices,
398 BX_UNUSED(_numVertices, _vertices, _numIndices, _indices, _index32);
402 bx::MutexScope lock(
m_lock);
409 geometry.
m_vbh = bgfx::createVertexBuffer(bgfx::copy(_vertices, _numVertices *
sizeof(
DdVertex)),
413 geometry.
m_topologyNumIndices[1] = bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList,
420 const uint32_t indexSize = _index32 ?
sizeof(uint32_t) :
sizeof(uint16_t);
423 const bgfx::Memory* mem = bgfx::alloc(numIndices * indexSize);
424 uint8_t* indexData = mem->data;
426 bx::memCopy(indexData, _indices, _numIndices * indexSize);
427 bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList,
434 geometry.
m_ibh = bgfx::createIndexBuffer(mem, _index32 ? BGFX_BUFFER_INDEX32 : BGFX_BUFFER_NONE);
442 bx::MutexScope lock(
m_lock);
444 bgfx::destroy(geometry.
m_vbh);
445 bgfx::destroy(geometry.
m_ibh);
454 m_vbh.idx = bx::kInvalidHandle;
455 m_ibh.idx = bx::kInvalidHandle;
546 void init(bx::AllocatorI* _allocator)
548 if(NULL == _allocator)
550 static bx::DefaultAllocator allocator;
563 bgfx::RendererType::Enum
type = bgfx::getRendererType();
566 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_lines"),
567 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_lines"),
571 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_lines_stipple"),
572 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_lines_stipple"),
576 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_fill"),
577 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_fill"),
581 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_fill_mesh"),
582 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_fill"),
586 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_fill_lit"),
587 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_fill_lit"),
591 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_fill_lit_mesh"),
592 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_fill_lit"),
596 bgfx::createProgram(bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"vs_debugdraw_fill_texture"),
597 bgfx::createEmbeddedShader(s_embeddedShaders,
type,
"fs_debugdraw_fill_texture"),
600 u_params = bgfx::createUniform(
"u_params", bgfx::UniformType::Vec4, 4);
601 s_texColor = bgfx::createUniform(
"s_texColor", bgfx::UniformType::Sampler);
609 uint32_t startVertex = 0;
610 uint32_t startIndex = 0;
612 for(uint32_t mesh = 0; mesh < 4; ++mesh)
616 const uint8_t tess = uint8_t(3 - mesh);
617 const uint32_t numVertices =
genSphere(tess);
618 const uint32_t numIndices = numVertices;
620 vertices[id] = bx::alloc(
m_allocator, numVertices * stride);
621 bx::memSet(vertices[
id], 0, numVertices * stride);
624 uint16_t* trilist = (uint16_t*)bx::alloc(
m_allocator, numIndices *
sizeof(uint16_t));
625 for(uint32_t ii = 0; ii < numIndices; ++ii)
627 trilist[ii] = uint16_t(ii);
630 uint32_t numLineListIndices =
631 bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList, NULL, 0, trilist, numIndices,
false);
632 indices[id] = (uint16_t*)bx::alloc(
m_allocator, (numIndices + numLineListIndices) *
sizeof(uint16_t));
633 uint16_t* indicesOut = indices[id];
634 bx::memCopy(indicesOut, trilist, numIndices *
sizeof(uint16_t));
636 bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList,
637 &indicesOut[numIndices],
638 numLineListIndices *
sizeof(uint16_t),
650 startVertex += numVertices;
651 startIndex += numIndices + numLineListIndices;
656 for(uint32_t mesh = 0; mesh < 4; ++mesh)
660 const uint32_t num = getCircleLod(uint8_t(mesh));
661 const float step = bx::kPi * 2.0f / num;
663 const uint32_t numVertices = num + 1;
664 const uint32_t numIndices = num * 6;
665 const uint32_t numLineListIndices = num * 4;
667 vertices[id] = bx::alloc(
m_allocator, numVertices * stride);
668 indices[id] = (uint16_t*)bx::alloc(
m_allocator, (numIndices + numLineListIndices) *
sizeof(uint16_t));
669 bx::memSet(indices[
id], 0, (numIndices + numLineListIndices) *
sizeof(uint16_t));
672 uint16_t* index = indices[id];
674 vertex[num].
m_x = 0.0f;
675 vertex[num].
m_y = 0.0f;
676 vertex[num].
m_z = 0.0f;
679 for(uint32_t ii = 0; ii < num; ++ii)
681 const float angle = step * ii;
686 vertex[ii].
m_x = xy[1];
687 vertex[ii].
m_y = 0.0f;
688 vertex[ii].
m_z = xy[0];
691 index[ii * 3 + 0] = uint16_t(num);
692 index[ii * 3 + 1] = uint16_t((ii + 1) % num);
693 index[ii * 3 + 2] = uint16_t(ii);
695 index[num * 3 + ii * 3 + 0] = 0;
696 index[num * 3 + ii * 3 + 1] = uint16_t(ii);
697 index[num * 3 + ii * 3 + 2] = uint16_t((ii + 1) % num);
699 index[numIndices + ii * 2 + 0] = uint16_t(ii);
700 index[numIndices + ii * 2 + 1] = uint16_t(num);
702 index[numIndices + num * 2 + ii * 2 + 0] = uint16_t(ii);
703 index[numIndices + num * 2 + ii * 2 + 1] = uint16_t((ii + 1) % num);
713 startVertex += numVertices;
714 startIndex += numIndices + numLineListIndices;
717 for(uint32_t mesh = 0; mesh < 4; ++mesh)
721 const uint32_t num = getCircleLod(uint8_t(mesh));
722 const float step = bx::kPi * 2.0f / num;
724 const uint32_t numVertices = num * 2;
725 const uint32_t numIndices = num * 12;
726 const uint32_t numLineListIndices = num * 6;
728 vertices[id] = bx::alloc(
m_allocator, numVertices * stride);
729 indices[id] = (uint16_t*)bx::alloc(
m_allocator, (numIndices + numLineListIndices) *
sizeof(uint16_t));
730 bx::memSet(indices[
id], 0, (numIndices + numLineListIndices) *
sizeof(uint16_t));
733 uint16_t* index = indices[id];
735 for(uint32_t ii = 0; ii < num; ++ii)
737 const float angle = step * ii;
742 vertex[ii].
m_x = xy[1];
743 vertex[ii].
m_y = 0.0f;
744 vertex[ii].
m_z = xy[0];
747 vertex[ii + num].
m_x = xy[1];
748 vertex[ii + num].
m_y = 0.0f;
749 vertex[ii + num].
m_z = xy[0];
752 index[ii * 6 + 0] = uint16_t(ii + num);
753 index[ii * 6 + 1] = uint16_t((ii + 1) % num);
754 index[ii * 6 + 2] = uint16_t(ii);
755 index[ii * 6 + 3] = uint16_t(ii + num);
756 index[ii * 6 + 4] = uint16_t((ii + 1) % num + num);
757 index[ii * 6 + 5] = uint16_t((ii + 1) % num);
759 index[num * 6 + ii * 6 + 0] = uint16_t(0);
760 index[num * 6 + ii * 6 + 1] = uint16_t(ii);
761 index[num * 6 + ii * 6 + 2] = uint16_t((ii + 1) % num);
762 index[num * 6 + ii * 6 + 3] = uint16_t(num);
763 index[num * 6 + ii * 6 + 4] = uint16_t((ii + 1) % num + num);
764 index[num * 6 + ii * 6 + 5] = uint16_t(ii + num);
766 index[numIndices + ii * 2 + 0] = uint16_t(ii);
767 index[numIndices + ii * 2 + 1] = uint16_t(ii + num);
769 index[numIndices + num * 2 + ii * 2 + 0] = uint16_t(ii);
770 index[numIndices + num * 2 + ii * 2 + 1] = uint16_t((ii + 1) % num);
772 index[numIndices + num * 4 + ii * 2 + 0] = uint16_t(num + ii);
773 index[numIndices + num * 4 + ii * 2 + 1] = uint16_t(num + (ii + 1) % num);
783 startVertex += numVertices;
784 startIndex += numIndices + numLineListIndices;
787 for(uint32_t mesh = 0; mesh < 4; ++mesh)
791 const uint32_t num = getCircleLod(uint8_t(mesh));
792 const float step = bx::kPi * 2.0f / num;
794 const uint32_t numVertices = num * 2;
795 const uint32_t numIndices = num * 6;
796 const uint32_t numLineListIndices = num * 6;
798 vertices[id] = bx::alloc(
m_allocator, numVertices * stride);
799 indices[id] = (uint16_t*)bx::alloc(
m_allocator, (numIndices + numLineListIndices) *
sizeof(uint16_t));
800 bx::memSet(indices[
id], 0, (numIndices + numLineListIndices) *
sizeof(uint16_t));
803 uint16_t* index = indices[id];
805 for(uint32_t ii = 0; ii < num; ++ii)
807 const float angle = step * ii;
812 vertex[ii].
m_x = xy[1];
813 vertex[ii].
m_y = 0.0f;
814 vertex[ii].
m_z = xy[0];
817 vertex[ii + num].
m_x = xy[1];
818 vertex[ii + num].
m_y = 0.0f;
819 vertex[ii + num].
m_z = xy[0];
822 index[ii * 6 + 0] = uint16_t(ii + num);
823 index[ii * 6 + 1] = uint16_t((ii + 1) % num);
824 index[ii * 6 + 2] = uint16_t(ii);
825 index[ii * 6 + 3] = uint16_t(ii + num);
826 index[ii * 6 + 4] = uint16_t((ii + 1) % num + num);
827 index[ii * 6 + 5] = uint16_t((ii + 1) % num);
836 index[numIndices + ii * 2 + 0] = uint16_t(ii);
837 index[numIndices + ii * 2 + 1] = uint16_t(ii + num);
839 index[numIndices + num * 2 + ii * 2 + 0] = uint16_t(ii);
840 index[numIndices + num * 2 + ii * 2 + 1] = uint16_t((ii + 1) % num);
842 index[numIndices + num * 4 + ii * 2 + 0] = uint16_t(num + ii);
843 index[numIndices + num * 4 + ii * 2 + 1] = uint16_t(num + (ii + 1) % num);
853 startVertex += numVertices;
854 startIndex += numIndices + numLineListIndices;
863 startVertex += BX_COUNTOF(s_quadVertices);
864 startIndex += BX_COUNTOF(s_quadIndices);
875 const bgfx::Memory* vb = bgfx::alloc(startVertex * stride);
876 const bgfx::Memory* ib = bgfx::alloc(startIndex *
sizeof(uint16_t));
895 sizeof(s_quadIndices));
901 sizeof(s_cubeIndices));
904 m_ibh = bgfx::createIndexBuffer(ib);
909 bgfx::destroy(
m_ibh);
910 bgfx::destroy(
m_vbh);
947 uint32_t _numIndices,
948 const void* _indices,
951 return m_geometry.
create(_numVertices, _vertices, _numIndices, _indices, _index32);
986 void init(bgfx::Encoder* _encoder)
996 void begin(bgfx::ViewId _viewId,
bool _depthTestLess, bgfx::Encoder* _encoder)
1012 attrib.
m_state = 0 | BGFX_STATE_WRITE_RGB |
1013 (
m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER) |
1014 BGFX_STATE_CULL_CW | BGFX_STATE_WRITE_Z;
1018 attrib.
m_abgr = UINT32_MAX;
1030 program = {bgfx::kInvalidHandle};
1071 if(attrib.
m_state & BGFX_STATE_DEPTH_TEST_MASK)
1074 attrib.
m_state &= ~BGFX_STATE_DEPTH_TEST_MASK;
1075 attrib.
m_state |= _depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER;
1096 bgfx::Transform transform;
1097 stack.
mtx =
m_encoder->allocTransform(&transform, _num);
1099 stack.
data = transform.data;
1100 bx::memCopy(transform.data, _mtx, _num * 64);
1106 bx::mtxTranslate(mtx, _x, _y, _z);
1128 if(NULL == stack.
data)
1134 mtx = (
float*)BX_STACK_ALLOC(_num*64);
1135 for(uint16_t ii = 0; ii < _num; ++ii)
1137 const float* mtxTransform = (
const float*)_mtx;
1138 bx::mtxMul(&mtx[ii * 16], &mtxTransform[ii * 16], stack.
data);
1178 bx::mtxTranslate(mtx, _x, _y, _z);
1187 void setState(
bool _depthTest,
bool _depthWrite,
bool _clockwise,
bool _alphaWrite,
bool _alphaBlend)
1189 const uint64_t depthTest =
m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER;
1192 BGFX_STATE_CULL_CW | BGFX_STATE_CULL_CCW);
1194 state |= _depthTest ? depthTest : 0;
1196 state |= _depthWrite ? BGFX_STATE_WRITE_Z : 0;
1198 state |= _alphaWrite ? BGFX_STATE_WRITE_A : 0;
1200 state |= _clockwise ? BGFX_STATE_CULL_CW : BGFX_STATE_CULL_CCW;
1229 void setStipple(
bool _stipple,
float _scale = 1.0f,
float _offset = 0.0f)
1251 void moveTo(
float _x,
float _y,
float _z = 0.0f)
1274 moveTo(_pos.x, _pos.y, _pos.z);
1282 void lineTo(
float _x,
float _y,
float _z = 0.0f)
1293 uint32_t pos =
m_pos;
1299 if(vertexPos == pos)
1317 uint16_t prev =
m_pos - 1;
1318 uint16_t curr =
m_pos++;
1328 float len = bx::length(bx::sub(bx::load<bx::Vec3>(&vertex.
m_x), bx::load<bx::Vec3>(&
m_cache[prev].
m_x))) *
1339 lineTo(_pos.x, _pos.y, _pos.z);
1361 moveTo(_aabb.min.x, _aabb.min.y, _aabb.min.z);
1362 lineTo(_aabb.max.x, _aabb.min.y, _aabb.min.z);
1363 lineTo(_aabb.max.x, _aabb.max.y, _aabb.min.z);
1364 lineTo(_aabb.min.x, _aabb.max.y, _aabb.min.z);
1367 moveTo(_aabb.min.x, _aabb.min.y, _aabb.max.z);
1368 lineTo(_aabb.max.x, _aabb.min.y, _aabb.max.z);
1369 lineTo(_aabb.max.x, _aabb.max.y, _aabb.max.z);
1370 lineTo(_aabb.min.x, _aabb.max.y, _aabb.max.z);
1373 moveTo(_aabb.min.x, _aabb.min.y, _aabb.min.z);
1374 lineTo(_aabb.min.x, _aabb.min.y, _aabb.max.z);
1376 moveTo(_aabb.max.x, _aabb.min.y, _aabb.min.z);
1377 lineTo(_aabb.max.x, _aabb.min.y, _aabb.max.z);
1379 moveTo(_aabb.min.x, _aabb.max.y, _aabb.min.z);
1380 lineTo(_aabb.min.x, _aabb.max.y, _aabb.max.z);
1382 moveTo(_aabb.max.x, _aabb.max.y, _aabb.min.z);
1383 lineTo(_aabb.max.x, _aabb.max.y, _aabb.max.z);
1393 void draw(
const bx::Cylinder& _cylinder,
bool _capsule)
1395 drawCylinder(_cylinder.pos, _cylinder.end, _cylinder.radius, _capsule);
1400 drawCircle(_disk.normal, _disk.center, _disk.radius, 0.0f);
1410 moveTo(-1.0f, -1.0f, -1.0f);
1411 lineTo(1.0f, -1.0f, -1.0f);
1412 lineTo(1.0f, 1.0f, -1.0f);
1413 lineTo(-1.0f, 1.0f, -1.0f);
1416 moveTo(-1.0f, 1.0f, 1.0f);
1417 lineTo(1.0f, 1.0f, 1.0f);
1418 lineTo(1.0f, -1.0f, 1.0f);
1419 lineTo(-1.0f, -1.0f, 1.0f);
1422 moveTo(1.0f, -1.0f, -1.0f);
1423 lineTo(1.0f, -1.0f, 1.0f);
1425 moveTo(1.0f, 1.0f, -1.0f);
1426 lineTo(1.0f, 1.0f, 1.0f);
1428 moveTo(-1.0f, 1.0f, -1.0f);
1429 lineTo(-1.0f, 1.0f, 1.0f);
1431 moveTo(-1.0f, -1.0f, -1.0f);
1432 lineTo(-1.0f, -1.0f, 1.0f);
1442 void draw(
const bx::Sphere& _sphere)
1460 void draw(
const bx::Triangle& _triangle)
1472 static_assert(
sizeof(
DdVertex) ==
sizeof(bx::Vec3),
"");
1474 uint64_t old = attrib.
m_state;
1475 attrib.
m_state &= ~BGFX_STATE_CULL_MASK;
1477 draw(
false, 3,
reinterpret_cast<const DdVertex*
>(&_triangle.v0.x), 0, NULL);
1485 const float flip = 0 == (_attrib.
m_state & BGFX_STATE_CULL_CCW) ? 1.0f : -1.0f;
1486 const uint8_t alpha = _attrib.
m_abgr >> 24;
1489 float params[4][4] = {
1513 ((_attrib.
m_abgr) & 0xff) / 255.0f,
1514 ((_attrib.
m_abgr >> 8) & 0xff) / 255.0f,
1515 ((_attrib.
m_abgr >> 16) & 0xff) / 255.0f,
1520 bx::store(params[0], bx::normalize(bx::load<bx::Vec3>(params[0])));
1523 uint32_t blendFlags = alphaBlend ? BGFX_STATE_BLEND_ALPHA : 0;
1525 (_wireframe ? BGFX_STATE_PT_LINES | BGFX_STATE_LINEAA | blendFlags
1526 : (alpha < 0xff) ? blendFlags
1533 m_encoder->setVertexBuffer(0, geometry.m_vbh);
1541 m_encoder->setIndexBuffer(geometry.m_ibh,
1542 geometry.m_topologyNumIndices[0],
1543 geometry.m_topologyNumIndices[1]);
1545 else if(0 != geometry.m_topologyNumIndices[0])
1547 m_encoder->setIndexBuffer(geometry.m_ibh, 0, geometry.m_topologyNumIndices[0]);
1556 uint32_t _numVertices,
1558 uint32_t _numIndices,
1559 const uint16_t* _indices)
1565 bgfx::TransientVertexBuffer tvb;
1571 const bool wireframe = _lineList || attrib.
m_wireframe;
1576 uint32_t numIndices = _numIndices;
1577 bgfx::TransientIndexBuffer tib;
1578 if(!_lineList && wireframe)
1580 numIndices = bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList,
1587 bgfx::allocTransientIndexBuffer(&tib, numIndices);
1588 bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList,
1590 numIndices *
sizeof(uint16_t),
1597 bgfx::allocTransientIndexBuffer(&tib, numIndices);
1598 bx::memCopy(tib.data, _indices, numIndices *
sizeof(uint16_t));
1612 bx::Plane planes[6] = {bx::InitNone, bx::InitNone, bx::InitNone, bx::InitNone, bx::InitNone, bx::InitNone};
1613 buildFrustumPlanes(planes, _viewProj);
1615 const bx::Vec3 points[8] = {
1616 intersectPlanes(planes[0], planes[2], planes[4]),
1617 intersectPlanes(planes[0], planes[3], planes[4]),
1618 intersectPlanes(planes[0], planes[3], planes[5]),
1619 intersectPlanes(planes[0], planes[2], planes[5]),
1620 intersectPlanes(planes[1], planes[2], planes[4]),
1621 intersectPlanes(planes[1], planes[3], planes[4]),
1622 intersectPlanes(planes[1], planes[3], planes[5]),
1623 intersectPlanes(planes[1], planes[2], planes[5]),
1659 const uint32_t num = getCircleLod(attrib.
m_lod);
1660 const float step = bx::kPi * 2.0f / num;
1662 _degrees = bx::wrap(_degrees, 360.0f);
1664 bx::Vec3 pos =
getPoint(_axis, bx::sin(step * 0) * _radius, bx::cos(step * 0) * _radius);
1666 moveTo({pos.x + _x, pos.y + _y, pos.z + _z});
1668 uint32_t n = uint32_t(num * _degrees / 360.0f);
1670 for(uint32_t ii = 1; ii < n + 1; ++ii)
1672 pos =
getPoint(_axis, bx::sin(step * ii) * _radius, bx::cos(step * ii) * _radius);
1673 lineTo({pos.x + _x, pos.y + _y, pos.z + _z});
1677 pos =
getPoint(_axis, bx::sin(step * 0) * _radius, bx::cos(step * 0) * _radius);
1678 lineTo({pos.x + _x, pos.y + _y, pos.z + _z});
1680 pos =
getPoint(_axis, bx::sin(step * n) * _radius, bx::cos(step * n) * _radius);
1681 moveTo({pos.x + _x, pos.y + _y, pos.z + _z});
1685 void drawCircle(
const bx::Vec3& _normal,
const bx::Vec3& _center,
float _radius,
float _weight)
1688 const uint32_t num = getCircleLod(attrib.
m_lod);
1689 const float step = bx::kPi * 2.0f / num;
1690 _weight = bx::clamp(_weight, 0.0f, 2.0f);
1692 bx::Vec3 udir(bx::InitNone);
1693 bx::Vec3 vdir(bx::InitNone);
1694 bx::calcTangentFrame(udir, vdir, _normal, attrib.
m_spin);
1699 squircle(xy1, 0.0f);
1701 bx::Vec3 pos = bx::mul(udir, bx::lerp(xy0[0], xy1[0], _weight) * _radius);
1702 bx::Vec3 tmp0 = bx::mul(vdir, bx::lerp(xy0[1], xy1[1], _weight) * _radius);
1703 bx::Vec3 tmp1 = bx::add(pos, tmp0);
1704 bx::Vec3 tmp2 = bx::add(tmp1, _center);
1707 for(uint32_t ii = 1; ii < num; ++ii)
1709 float angle = step * ii;
1711 squircle(xy1, angle);
1713 pos = bx::mul(udir, bx::lerp(xy0[0], xy1[0], _weight) * _radius);
1714 tmp0 = bx::mul(vdir, bx::lerp(xy0[1], xy1[1], _weight) * _radius);
1715 tmp1 = bx::add(pos, tmp0);
1716 tmp2 = bx::add(tmp1, _center);
1726 const uint32_t num = getCircleLod(attrib.
m_lod);
1727 const float step = bx::kPi * 2.0f / num;
1728 _weight = bx::clamp(_weight, 0.0f, 2.0f);
1733 squircle(xy1, 0.0f);
1736 getPoint(_axis, bx::lerp(xy0[0], xy1[0], _weight) * _radius, bx::lerp(xy0[1], xy1[1], _weight) * _radius);
1738 moveTo({pos.x + _x, pos.y + _y, pos.z + _z});
1740 for(uint32_t ii = 1; ii < num; ++ii)
1742 float angle = step * ii;
1744 squircle(xy1, angle);
1747 bx::lerp(xy0[0], xy1[0], _weight) * _radius,
1748 bx::lerp(xy0[1], xy1[1], _weight) * _radius);
1749 lineTo({pos.x + _x, pos.y + _y, pos.z + _z});
1754 void drawQuad(
const bx::Vec3& _normal,
const bx::Vec3& _center,
float _size)
1759 bx::Vec3 udir(bx::InitNone);
1760 bx::Vec3 vdir(bx::InitNone);
1761 bx::calcTangentFrame(udir, vdir, _normal, attrib.
m_spin);
1763 const float halfExtent = _size * 0.5f;
1765 const bx::Vec3 umin = bx::mul(udir, -halfExtent);
1766 const bx::Vec3 umax = bx::mul(udir, halfExtent);
1767 const bx::Vec3 vmin = bx::mul(vdir, -halfExtent);
1768 const bx::Vec3 vmax = bx::mul(vdir, halfExtent);
1769 const bx::Vec3 center = _center;
1771 moveTo(bx::add(center, bx::add(umin, vmin)));
1772 lineTo(bx::add(center, bx::add(umax, vmin)));
1773 lineTo(bx::add(center, bx::add(umax, vmax)));
1774 lineTo(bx::add(center, bx::add(umin, vmax)));
1781 bx::mtxFromNormal(mtx, _normal, _size * 0.5f, _center, attrib.
m_spin);
1801 bx::Vec3 udir(bx::InitNone);
1802 bx::Vec3 vdir(bx::InitNone);
1803 bx::calcTangentFrame(udir, vdir, _normal, attrib.
m_spin);
1807 const float us = pack.
m_x * invTextureSize;
1808 const float vs = pack.
m_y * invTextureSize;
1809 const float ue = (pack.
m_x + pack.
m_width) * invTextureSize;
1810 const float ve = (pack.
m_y + pack.
m_height) * invTextureSize;
1813 const float halfExtentU = aspectRatio * _size * 0.5f;
1814 const float halfExtentV = 1.0f / aspectRatio * _size * 0.5f;
1816 const bx::Vec3 umin = bx::mul(udir, -halfExtentU);
1817 const bx::Vec3 umax = bx::mul(udir, halfExtentU);
1818 const bx::Vec3 vmin = bx::mul(vdir, -halfExtentV);
1819 const bx::Vec3 vmax = bx::mul(vdir, halfExtentV);
1820 const bx::Vec3 center = _center;
1825 bx::store(&vertex->
m_x, bx::add(center, bx::add(umin, vmin)));
1831 bx::store(&vertex->
m_x, bx::add(center, bx::add(umax, vmin)));
1837 bx::store(&vertex->
m_x, bx::add(center, bx::add(umin, vmax)));
1843 bx::store(&vertex->
m_x, bx::add(center, bx::add(umax, vmax)));
1850 void drawQuad(bgfx::TextureHandle _handle,
const bx::Vec3& _normal,
const bx::Vec3& _center,
float _size)
1864 attrib.
m_state |= BGFX_STATE_BLEND_ALPHA;
1866 bx::Vec3 udir(bx::InitNone);
1867 bx::Vec3 vdir(bx::InitNone);
1868 bx::calcTangentFrame(udir, vdir, _normal, attrib.
m_spin);
1870 const float us = 0.0f;
1871 const float vs = 0.0f;
1872 const float ue = 1.0f;
1873 const float ve = 1.0f;
1875 const float aspectRatio = 1.0f;
1876 const float halfExtentU = aspectRatio * _size * 0.5f;
1877 const float halfExtentV = 1.0f / aspectRatio * _size * 0.5f;
1879 const bx::Vec3 umin = bx::mul(udir, -halfExtentU);
1880 const bx::Vec3 umax = bx::mul(udir, halfExtentU);
1881 const bx::Vec3 vmin = bx::mul(vdir, -halfExtentV);
1882 const bx::Vec3 vmax = bx::mul(vdir, halfExtentV);
1883 const bx::Vec3 center = _center;
1888 bx::store(&vertex->
m_x, bx::add(center, bx::add(umin, vmin)));
1894 bx::store(&vertex->
m_x, bx::add(center, bx::add(umax, vmin)));
1900 bx::store(&vertex->
m_x, bx::add(center, bx::add(umin, vmax)));
1906 bx::store(&vertex->
m_x, bx::add(center, bx::add(umax, vmax)));
1916 attrib.
m_state &= ~BGFX_STATE_BLEND_ALPHA;
1921 void drawCone(
const bx::Vec3& _from,
const bx::Vec3& _to,
float _radius)
1925 const bx::Vec3
normal = bx::normalize(bx::sub(_from, _to));
1928 bx::mtxFromNormal(mtx[0],
normal, _radius, _from, attrib.
m_spin);
1930 bx::memCopy(mtx[1], mtx[0], 64);
1939 void drawCylinder(
const bx::Vec3& _from,
const bx::Vec3& _to,
float _radius,
bool _capsule)
1942 const bx::Vec3
normal = bx::normalize(bx::sub(_from, _to));
1945 bx::mtxFromNormal(mtx[0],
normal, _radius, _from, attrib.
m_spin);
1947 bx::memCopy(mtx[1], mtx[0], 64);
1958 sphere.center = _from;
1959 sphere.radius = _radius;
1962 sphere.center = _to;
1976 if(_thickness > 0.0f)
1978 const bx::Vec3 from = {_x, _y, _z};
1979 bx::Vec3 mid(bx::InitNone);
1980 bx::Vec3 to(bx::InitNone);
1983 mid = {_x + _len - _thickness, _y, _z};
1984 to = {_x + _len, _y, _z};
1989 mid = {_x, _y + _len - _thickness, _z};
1990 to = {_x, _y + _len, _z};
1995 mid = {_x, _y, _z + _len - _thickness};
1996 to = {_x, _y, _z + _len};
2004 lineTo(_x + _len, _y, _z);
2008 lineTo(_x, _y + _len, _z);
2012 lineTo(_x, _y, _z + _len);
2018 void drawGrid(
const bx::Vec3& _normal,
const bx::Vec3& _center, uint32_t _size,
float _step)
2022 bx::Vec3 udir(bx::InitNone);
2023 bx::Vec3 vdir(bx::InitNone);
2024 bx::calcTangentFrame(udir, vdir, _normal, attrib.
m_spin);
2026 udir = bx::mul(udir, _step);
2027 vdir = bx::mul(vdir, _step);
2029 const uint32_t num = (_size / 2) * 2 + 1;
2030 const float halfExtent = float(_size / 2);
2032 const bx::Vec3 umin = bx::mul(udir, -halfExtent);
2033 const bx::Vec3 umax = bx::mul(udir, halfExtent);
2034 const bx::Vec3 vmin = bx::mul(vdir, -halfExtent);
2035 const bx::Vec3 vmax = bx::mul(vdir, halfExtent);
2037 bx::Vec3 xs = bx::add(_center, bx::add(umin, vmin));
2038 bx::Vec3 xe = bx::add(_center, bx::add(umax, vmin));
2039 bx::Vec3 ys = bx::add(_center, bx::add(umin, vmin));
2040 bx::Vec3 ye = bx::add(_center, bx::add(umin, vmax));
2042 for(uint32_t ii = 0; ii < num; ++ii)
2046 xs = bx::add(xs, vdir);
2047 xe = bx::add(xe, vdir);
2051 ys = bx::add(ys, udir);
2052 ye = bx::add(ye, udir);
2061 const uint32_t num = (_size / 2) * 2 - 1;
2062 const float halfExtent = float(_size / 2) * _step;
2065 float yy = -halfExtent + _step;
2066 for(uint32_t ii = 0; ii < num; ++ii)
2068 moveTo(_axis, -halfExtent, yy);
2069 lineTo(_axis, halfExtent, yy);
2071 moveTo(_axis, yy, -halfExtent);
2072 lineTo(_axis, yy, halfExtent);
2078 moveTo(_axis, -halfExtent, -halfExtent);
2079 lineTo(_axis, -halfExtent, halfExtent);
2080 lineTo(_axis, halfExtent, halfExtent);
2081 lineTo(_axis, halfExtent, -halfExtent);
2084 moveTo(_axis, -halfExtent, 0.0f);
2085 lineTo(_axis, halfExtent, 0.0f);
2087 moveTo(_axis, 0.0f, -halfExtent);
2088 lineTo(_axis, 0.0f, halfExtent);
2147 bgfx::TransientVertexBuffer tvb;
2151 bgfx::TransientIndexBuffer tib;
2152 bgfx::allocTransientIndexBuffer(&tib,
m_indexPos);
2159 m_encoder->setState(0 | BGFX_STATE_WRITE_RGB | BGFX_STATE_PT_LINES | attrib.
m_state |
2160 BGFX_STATE_LINEAA | (attrib.
m_alphaBlend ? BGFX_STATE_BLEND_ALPHA : 0));
2177 const uint32_t numIndices =
m_posQuad / 4 * 6;
2180 bgfx::TransientVertexBuffer tvb;
2184 bgfx::TransientIndexBuffer tib;
2185 bgfx::allocTransientIndexBuffer(&tib, numIndices);
2186 uint16_t* indices = (uint16_t*)tib.data;
2187 for(uint16_t ii = 0, num =
m_posQuad / 4; ii < num; ++ii)
2189 uint16_t startVertex = ii * 4;
2190 indices[0] = startVertex + 0;
2191 indices[1] = startVertex + 1;
2192 indices[2] = startVertex + 2;
2193 indices[3] = startVertex + 1;
2194 indices[4] = startVertex + 3;
2195 indices[5] = startVertex + 2;
2236 static_assert(
kCacheSize >= 3,
"Cache must be at least 3 elements.");
2278static bool s_initted =
false;
2285 s_dds.
init(_allocator);
2286 s_dde.
init(bgfx::begin());
2310 uint32_t _numIndices,
2311 const void* _indices,
2314 return s_dds.
createGeometry(_numVertices, _vertices, _numIndices, _indices, _index32);
2322#define DEBUG_DRAW_ENCODER(_func) reinterpret_cast<DebugDrawEncoderImpl*>(this)->_func
2491 uint32_t _numIndices,
2492 const uint16_t* _indices)
2499 uint32_t _numIndices,
2500 const uint16_t* _indices)
2536 const bx::Vec3& _normal,
2537 const bx::Vec3& _center,
bool checkAvailTransientBuffers(uint32_t _numVertices, const bgfx::VertexLayout &_layout, uint32_t _numIndices)
~DebugDrawEncoderScopePush()
DebugDrawEncoderScopePush(DebugDrawEncoder &_dde)
bool find(uint16_t _width, uint16_t _height, Pack2D &_pack)
void clear(const Pack2D &_pack)
void draw(const bx::Aabb &_aabb)
void lineTo(float _x, float _y, float _z=0.0f)
void drawQuad(const bx::Vec3 &_normal, const bx::Vec3 &_center, float _size)
void drawCone(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius)
void setSpin(float _spin)
void drawCylinder(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius)
void setColor(uint32_t _abgr)
void drawAxis(float _x, float _y, float _z, float _len=1.0f, Axis::Enum _highlight=Axis::Count, float _thickness=0.0f)
void setWireframe(bool _wireframe)
void setTransform(const void *_mtx)
void begin(uint16_t _viewId, bool _depthTestLess=true, bgfx::Encoder *_encoder=NULL)
void drawGrid(const bx::Vec3 &_normal, const bx::Vec3 &_center, uint32_t _size=20, float _step=1.0f)
void setState(bool _depthTest, bool _depthWrite, bool _clockwise, bool _alphaWrite=false, bool _alphaBlend=true)
void pushTransform(const void *_mtx)
void drawArc(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _degrees)
void drawCapsule(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius)
void drawOrb(float _x, float _y, float _z, float _radius, Axis::Enum _highlight=Axis::Count)
void drawTriList(uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices=0, const uint16_t *_indices=NULL)
void drawLineList(uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices=0, const uint16_t *_indices=NULL)
void drawFrustum(const void *_viewProj)
void pushProgram(bgfx::ProgramHandle _handle)
void moveTo(float _x, float _y, float _z=0.0f)
void drawCircle(const bx::Vec3 &_normal, const bx::Vec3 &_center, float _radius, float _weight=0.0f)
void setTranslate(float _x, float _y, float _z)
void setDepthTestLess(bool _depthTestLess)
void setStipple(bool _stipple, float _scale=1.0f, float _offset=0.0f)
void setLod(uint8_t _lod)
static const uint32_t kCacheSize
void pushTranslate(float _x, float _y, float _z)
void drawAxis(float _x, float _y, float _z, float _len, Axis::Enum _highlight, float _thickness)
void setSpin(float _spin)
static const uint32_t kCacheQuadSize
void draw(const bx::Sphere &_sphere)
void drawCone(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius)
void draw(const bx::Triangle &_triangle)
void setDepthTestLess(bool _depthTestLess)
void drawGrid(const bx::Vec3 &_normal, const bx::Vec3 &_center, uint32_t _size, float _step)
void moveTo(Axis::Enum _axis, float _x, float _y)
void drawQuad(bgfx::TextureHandle _handle, const bx::Vec3 &_normal, const bx::Vec3 &_center, float _size)
void drawOrb(float _x, float _y, float _z, float _radius, Axis::Enum _hightlight)
void setColor(uint32_t _abgr)
void draw(bool _lineList, uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices, const uint16_t *_indices)
void draw(const bx::Disk &_disk)
void drawGrid(Axis::Enum _axis, const bx::Vec3 &_center, uint32_t _size, float _step)
void setState(bool _depthTest, bool _depthWrite, bool _clockwise, bool _alphaWrite, bool _alphaBlend)
MatrixStack m_mtxStack[32]
void pushTranslate(const bx::Vec3 &_pos)
Attrib m_attrib[kStackSize]
void init(bgfx::Encoder *_encoder)
void lineTo(float _x, float _y, float _z=0.0f)
void pushProgram(bgfx::ProgramHandle _handle)
void draw(const bx::Aabb &_aabb)
void moveTo(float _x, float _y, float _z=0.0f)
void draw(DebugMesh::Enum _mesh, const float *_mtx, uint16_t _num, bool _wireframe)
void setStipple(bool _stipple, float _scale=1.0f, float _offset=0.0f)
void lineTo(Axis::Enum _axis, float _x, float _y)
void popTransform(bool _flush=true)
DebugVertex m_cache[kCacheSize+1]
void drawArc(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _degrees)
uint32_t m_mtxStackCurrent
void pushTransform(const void *_mtx, uint16_t _num, bool _flush=true)
void setTransform(const void *_mtx, uint16_t _num=1, bool _flush=true)
bgfx::Encoder * m_encoder
void drawCircle(const bx::Vec3 &_normal, const bx::Vec3 &_center, float _radius, float _weight)
void lineTo(const bx::Vec3 &_pos)
void draw(GeometryHandle _handle)
void draw(const bx::Cylinder &_cylinder, bool _capsule)
void drawCylinder(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius, bool _capsule)
void setLod(uint8_t _lod)
void setUParams(const Attrib &_attrib, bool _wireframe)
void moveTo(const bx::Vec3 &_pos)
int8_t m_programStackCurrent
void drawFrustum(const float *_viewProj)
bgfx::Encoder * m_defaultEncoder
void drawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _weight)
static const uint32_t kStackSize
bgfx::ProgramHandle m_programStack[32]
uint16_t m_indices[kCacheSize *2]
void drawQuad(SpriteHandle _handle, const bx::Vec3 &_normal, const bx::Vec3 &_center, float _size)
void draw(const bx::Obb &_obb)
void drawFrustum(const void *_viewProj)
void drawQuad(const bx::Vec3 &_normal, const bx::Vec3 &_center, float _size)
DebugUvVertex m_cacheQuad[kCacheQuadSize]
void setTranslate(const float *_pos)
void setTranslate(float _x, float _y, float _z)
void begin(bgfx::ViewId _viewId, bool _depthTestLess, bgfx::Encoder *_encoder)
void setWireframe(bool _wireframe)
bgfx::TextureHandle m_texture
SpriteHandle createSprite(uint16_t _width, uint16_t _height, const void *_data)
bgfx::VertexBufferHandle m_vbh
void destroy(SpriteHandle _handle)
GeometryHandle createGeometry(uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices, const void *_indices, bool _index32)
bgfx::UniformHandle u_params
void init(bx::AllocatorI *_allocator)
bgfx::ProgramHandle m_program[Program::Count]
bx::AllocatorI * m_allocator
bgfx::IndexBufferHandle m_ibh
DebugMesh m_mesh[DebugMesh::Count]
bgfx::UniformHandle s_texColor
void destroy(GeometryHandle _handle)
static bgfx::VertexLayout ms_layout
static bgfx::VertexLayout ms_layout
static bgfx::VertexLayout ms_layout
static bgfx::VertexLayout ms_layout
bgfx::IndexBufferHandle m_ibh
uint32_t m_topologyNumIndices[2]
bgfx::VertexBufferHandle m_vbh
void destroy(GeometryHandle _handle)
bx::HandleAllocT< MaxHandlesT > m_handleAlloc
Geometry m_geometry[MaxHandlesT]
GeometryHandle create(uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices, const void *_indices, bool _index32)
bx::HandleAllocT< MaxHandlesT > m_handleAlloc
const Pack2D & get(SpriteHandle _sprite) const
Pack2D m_pack[MaxHandlesT]
void destroy(SpriteHandle _sprite)
SpriteHandle create(uint16_t _width, uint16_t _height)
uint32_t genSphere(uint8_t _subdiv0, void *_pos0=NULL, uint16_t _posStride0=0, void *_normals0=NULL, uint16_t _normalStride0=0)
#define SPRITE_TEXTURE_SIZE
#define DEBUG_DRAW_ENCODER(_func)
SpriteHandle ddCreateSprite(uint16_t _width, uint16_t _height, const void *_data)
void ddInit(bx::AllocatorI *_allocator)
SpriteT< 256, SPRITE_TEXTURE_SIZE > Sprite
bx::Vec3 getPoint(Axis::Enum _axis, float _x, float _y)
GeometryT< DEBUG_DRAW_CONFIG_MAX_GEOMETRY > Geometry
GeometryHandle ddCreateGeometry(uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices, const void *_indices, bool _index32)
void ddDestroy(SpriteHandle _handle)
bool isValid(SpriteHandle _handle)