I've layered my sprite using GL_DEPTH (I change the z-value depending on what needs to be on top) and all of this seems to work but I can't figure ou how I should draw the DebugDraw from Box2D.
At the moment I have this for example:
I got this from a tutorial at iforce and I changed the glVertex2f() to a glVertex3f() so I can set a z-value. But no matter what value the z-value is the debuw draw never shows on top.
I am calling the mWorld->DrawDebugData() method so it's not that I forgot that. I don't know if this is a common problem so if I forgot something or you need more code to help me let me know. I hope this can be fixed and any help is appreciated.
At the moment I have this for example:
Code:
void DebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
glEnable(GL_DEPTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
glBegin(GL_TRIANGLE_FAN);
for (int32 i = 0; i < vertexCount; ++i)
{
glVertex3f(vertices[i].x, vertices[i].y, 0);
}
glEnd();
glDisable(GL_BLEND);
glColor4f(color.r, color.g, color.b, 1.0f);
glBegin(GL_LINE_LOOP);
for (int32 i = 0; i < vertexCount; ++i)
{
glVertex3f(vertices[i].x, vertices[i].y, 0);
}
glEnd();
}
{
glEnable(GL_DEPTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
glBegin(GL_TRIANGLE_FAN);
for (int32 i = 0; i < vertexCount; ++i)
{
glVertex3f(vertices[i].x, vertices[i].y, 0);
}
glEnd();
glDisable(GL_BLEND);
glColor4f(color.r, color.g, color.b, 1.0f);
glBegin(GL_LINE_LOOP);
for (int32 i = 0; i < vertexCount; ++i)
{
glVertex3f(vertices[i].x, vertices[i].y, 0);
}
glEnd();
}
I got this from a tutorial at iforce and I changed the glVertex2f() to a glVertex3f() so I can set a z-value. But no matter what value the z-value is the debuw draw never shows on top.
I am calling the mWorld->DrawDebugData() method so it's not that I forgot that. I don't know if this is a common problem so if I forgot something or you need more code to help me let me know. I hope this can be fixed and any help is appreciated.