Unravel Engine C++ Reference
Loading...
Searching...
No Matches
debugdraw.h
Go to the documentation of this file.
1/*
2 * Copyright 2011-2023 Branimir Karadzic. All rights reserved.
3 * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
4 */
5
6#ifndef DEBUGDRAW_H_HEADER_GUARD
7#define DEBUGDRAW_H_HEADER_GUARD
8
9#include <bgfx/bgfx.h>
10#include <bx/allocator.h>
11#include <bx/bounds.h>
12
13struct Axis
14{
15 enum Enum
16 {
20
21 Count
22 };
23};
24
26{
27 float x, y, z;
28};
29
31{
32 uint16_t idx;
33};
34inline bool isValid(SpriteHandle _handle)
35{
36 return _handle.idx != UINT16_MAX;
37}
38
40{
41 uint16_t idx;
42};
43inline bool isValid(GeometryHandle _handle)
44{
45 return _handle.idx != UINT16_MAX;
46}
47
49void ddInit(bx::AllocatorI* _allocator = NULL);
50
52void ddShutdown();
53
55SpriteHandle ddCreateSprite(uint16_t _width, uint16_t _height, const void* _data);
56
58void ddDestroy(SpriteHandle _handle);
59
61GeometryHandle ddCreateGeometry(uint32_t _numVertices,
62 const DdVertex* _vertices,
63 uint32_t _numIndices = 0,
64 const void* _indices = NULL,
65 bool _index32 = false);
66
68void ddDestroy(GeometryHandle _handle);
69
72{
75
78
80 void begin(uint16_t _viewId, bool _depthTestLess = true, bgfx::Encoder* _encoder = NULL);
81
83 void end();
84
86 void push();
87
89 void pop();
90
92 void setDepthTestLess(bool _depthTestLess);
93
95 void setState(bool _depthTest, bool _depthWrite, bool _clockwise, bool _alphaWrite = false, bool _alphaBlend = true);
96
98 void setColor(uint32_t _abgr);
99
101 void setLod(uint8_t _lod);
102
104 void setWireframe(bool _wireframe);
105
107 void setStipple(bool _stipple, float _scale = 1.0f, float _offset = 0.0f);
108
110 void setSpin(float _spin);
111
113 void setTransform(const void* _mtx);
114
116 void setTranslate(float _x, float _y, float _z);
117
119 void pushTransform(const void* _mtx);
120
122 void popTransform();
123
124 void pushProgram(bgfx::ProgramHandle _handle);
125
126 void popProgram();
127
129 void moveTo(float _x, float _y, float _z = 0.0f);
130
132 void moveTo(const bx::Vec3& _pos);
133
135 void lineTo(float _x, float _y, float _z = 0.0f);
136
138 void lineTo(const bx::Vec3& _pos);
139
141 void close();
142
144 void draw(const bx::Aabb& _aabb);
145
147 void draw(const bx::Cylinder& _cylinder);
148
150 void draw(const bx::Capsule& _capsule);
151
153 void draw(const bx::Disk& _disk);
154
156 void draw(const bx::Obb& _obb);
157
159 void draw(const bx::Sphere& _sphere);
160
162 void draw(const bx::Triangle& _triangle);
163
165 void draw(const bx::Cone& _cone);
166
168 void draw(GeometryHandle _handle);
169
171 void drawLineList(uint32_t _numVertices,
172 const DdVertex* _vertices,
173 uint32_t _numIndices = 0,
174 const uint16_t* _indices = NULL);
175
177 void drawTriList(uint32_t _numVertices,
178 const DdVertex* _vertices,
179 uint32_t _numIndices = 0,
180 const uint16_t* _indices = NULL);
181
183 void drawFrustum(const void* _viewProj);
184
186 void drawArc(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _degrees);
187
189 void drawCircle(const bx::Vec3& _normal, const bx::Vec3& _center, float _radius, float _weight = 0.0f);
190
192 void drawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _weight = 0.0f);
193
195 void drawQuad(const bx::Vec3& _normal, const bx::Vec3& _center, float _size);
196
198 void drawQuad(SpriteHandle _handle, const bx::Vec3& _normal, const bx::Vec3& _center, float _size);
199
201 void drawQuad(bgfx::TextureHandle _handle, const bx::Vec3& _normal, const bx::Vec3& _center, float _size);
202
204 void drawCone(const bx::Vec3& _from, const bx::Vec3& _to, float _radius);
205
207 void drawCylinder(const bx::Vec3& _from, const bx::Vec3& _to, float _radius);
208
210 void drawCapsule(const bx::Vec3& _from, const bx::Vec3& _to, float _radius);
211
213 void drawAxis(float _x,
214 float _y,
215 float _z,
216 float _len = 1.0f,
217 Axis::Enum _highlight = Axis::Count,
218 float _thickness = 0.0f);
219
221 void drawGrid(const bx::Vec3& _normal, const bx::Vec3& _center, uint32_t _size = 20, float _step = 1.0f);
222
224 void drawGrid(Axis::Enum _axis, const bx::Vec3& _center, uint32_t _size = 20, float _step = 1.0f);
225
227 void drawOrb(float _x, float _y, float _z, float _radius, Axis::Enum _highlight = Axis::Count);
228
229 BX_ALIGN_DECL_CACHE_LINE(uint8_t) m_internal[50 << 10];
230};
231
234{
235public:
238
241
242private:
243 DebugDrawEncoder& m_dde;
244};
245
246#endif // DEBUGDRAW_H_HEADER_GUARD
DebugDrawEncoderScopePush(DebugDrawEncoder &_dde)
@ X
Definition debugdraw.h:17
@ Count
Definition debugdraw.h:21
@ Y
Definition debugdraw.h:18
@ Z
Definition debugdraw.h:19
float y
Definition debugdraw.h:27
float z
Definition debugdraw.h:27
float x
Definition debugdraw.h:27
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)
BX_ALIGN_DECL_CACHE_LINE(uint8_t) m_internal[50<< 10]
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)
uint16_t idx
Definition debugdraw.h:41
uint16_t idx
Definition debugdraw.h:32
bool isValid(SpriteHandle _handle)
Definition debugdraw.h:34
void ddInit(bx::AllocatorI *_allocator=NULL)
SpriteHandle ddCreateSprite(uint16_t _width, uint16_t _height, const void *_data)
void ddShutdown()
GeometryHandle ddCreateGeometry(uint32_t _numVertices, const DdVertex *_vertices, uint32_t _numIndices=0, const void *_indices=NULL, bool _index32=false)
void ddDestroy(SpriteHandle _handle)