-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugrenderer.cpp
More file actions
116 lines (100 loc) · 4.72 KB
/
debugrenderer.cpp
File metadata and controls
116 lines (100 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "debugrenderer.h"
DebugRenderer::DebugRenderer()
: m_debugMode(btIDebugDraw::DBG_NoDebug)
{
m_shader = QPointer<AssetShader>(new AssetShader());
m_shader->SetSrc(MathUtil::GetApplicationURL(), "assets/shaders/trans_frag.txt", "");
m_shader->SetS("id", "BulletPhysicsDebugShader");
m_shader->Load();
}
DebugRenderer::~DebugRenderer()
{
delete m_shader;
}
void DebugRenderer::drawLine(const btVector3& , const btVector3& , const btVector3& )
{
/*// These verts are in the physics engine's world-space, since we use the same units
// this is also world-space for our renderer which means we want an identity modelmatrix
// to avoid double applying the model to world space transform.
// Room Uniforms
MathUtil::RoomMatrix().setToIdentity();
// Object Uniforms
MathUtil::PushModelMatrix();
MathUtil::LoadModelIdentity();
m_shader->SetConstColour(QVector4D(color.getX(), color.getY(), color.getZ(), 1.0f));
m_shader->UpdateObjectUniforms();
MathUtil::PopModelMatrix();
// Material Uniforms
m_shader->SetUseClipPlane(false);
m_shader->SetUseLighting(false);
m_shader->SetUseTextureAll(false);
// Create VAO and VBO
float verts[6] = {from.getX(), from.getY(), from.getZ(),
to.getX(), to.getY(), to.getZ()};
GLuint line_vao;
MathUtil::glFuncs->glGenVertexArrays(1, &line_vao);
MathUtil::glFuncs->glBindVertexArray(line_vao);
GLuint line_vbo;
MathUtil::glFuncs->glGenBuffers(1, &line_vbo);
MathUtil::glFuncs->glBindBuffer(GL_ARRAY_BUFFER, line_vbo);
MathUtil::glFuncs->glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(GLfloat), &verts[0], GL_STATIC_DRAW);
MathUtil::glFuncs->glEnableVertexAttribArray((GLuint)VAO_ATTRIB::POSITION);
MathUtil::glFuncs->glVertexAttribPointer((GLuint)VAO_ATTRIB::POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// Render line
RendererInterface * renderer = RendererInterface::m_pimpl;
renderer->SetPolyMode(PolyMode::LINE);
renderer->PushAbstractRenderCommand(AbstractRenderCommand(PrimitiveType::LINES,
2,
1,
0,
0,
0,
line_vao,
m_shader,
m_shader->GetFrameUniforms(),
m_shader->GetRoomUniforms(),
m_shader->GetObjectUniforms(),
m_shader->GetMaterialUniforms(),
renderer->GetCurrentlyBoundTextures(),
FaceCullMode::DISABLED,
DepthFunc::ALWAYS,
DepthMask::DEPTH_WRITES_DISABLED,
StencilFunc(StencilTestFuncion::ALWAYS, StencilReferenceValue(0), StencilMask(0xffffffff)),
StencilOp(StencilOpAction::KEEP, StencilOpAction::KEEP, StencilOpAction::KEEP),
renderer->GetPolyMode(),
ColorMask::COLOR_WRITES_ENABLED,
BlendFunction::SRC_ALPHA,
BlendFunction::ONE_MINUS_SRC_ALPHA));
renderer->SetPolyMode(PolyMode::FILL);
// Clean up VAO and VBO
MathUtil::glFuncs->glDeleteVertexArrays(1, &line_vao);
MathUtil::glFuncs->glDeleteBuffers(1, &line_vbo);*/
}
void DebugRenderer::setDebugMode(int debugMode)
{
m_debugMode = debugMode;
}
int DebugRenderer::getDebugMode() const
{
return m_debugMode;
}
void DebugRenderer::drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color)
{
(void) PointOnB;
(void) normalOnB;
(void) distance;
(void) lifeTime;
(void) color;
// TODO
}
void DebugRenderer::reportErrorWarning(const char* warningString)
{
(void) warningString;
// TODO
}
void DebugRenderer::draw3dText(const btVector3& location, const char* textString)
{
(void) location;
(void) textString;
// TODO
}