Reenable physic debug mode
This commit is contained in:
parent
648d076e00
commit
46a832a67f
@ -521,6 +521,32 @@ unsigned GPUTimer::elapsedTimeus()
|
||||
return result / 1000;
|
||||
}
|
||||
|
||||
void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end, irr::video::SColor color)
|
||||
{
|
||||
if (!irr_driver->isGLSL()) {
|
||||
irr_driver->getVideoDriver()->draw3DLine(start, end, color);
|
||||
return;
|
||||
}
|
||||
|
||||
float vertex[6] = {
|
||||
start.X, start.Y, start.Z,
|
||||
end.X, end.Y, end.Z
|
||||
};
|
||||
|
||||
glBindVertexArray(UtilShader::ColoredLine::vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::vbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, 6 * sizeof(float), vertex);
|
||||
|
||||
glUseProgram(UtilShader::ColoredLine::Program);
|
||||
UtilShader::ColoredLine::setUniforms(color);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glGetError();
|
||||
}
|
||||
|
||||
static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height,
|
||||
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
|
||||
float tex_width, float tex_height)
|
||||
|
@ -186,6 +186,9 @@ bool loadCompressedTexture(const std::string& compressed_tex);
|
||||
void saveCompressedTexture(const std::string& compressed_tex);
|
||||
void blitFBO(GLuint Src, GLuint Dst, size_t width, size_t height);
|
||||
|
||||
void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end, irr::video::SColor color);
|
||||
|
||||
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
|
||||
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
||||
const irr::video::SColor &color, bool useAlphaChannelOfTexture);
|
||||
|
@ -364,6 +364,7 @@ void Shaders::loadShaders()
|
||||
UIShader::ColoredTextureRectShader::init();
|
||||
UIShader::TextureRectShader::init();
|
||||
UIShader::UniformColoredTextureRectShader::init();
|
||||
UtilShader::ColoredLine::init();
|
||||
}
|
||||
|
||||
Shaders::~Shaders()
|
||||
@ -404,6 +405,39 @@ static void bypassUBO(GLint Program)
|
||||
glUniformMatrix4fv(IPM, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||
}
|
||||
|
||||
namespace UtilShader
|
||||
{
|
||||
GLuint ColoredLine::Program;
|
||||
GLuint ColoredLine::uniform_color;
|
||||
GLuint ColoredLine::vao;
|
||||
GLuint ColoredLine::vbo;
|
||||
|
||||
void ColoredLine::init()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glGenBuffers(1, &vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
float vertex[6] = {};
|
||||
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), vertex, GL_DYNAMIC_DRAW);
|
||||
GLuint attrib_position = glGetAttribLocation(Program, "Position");
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
|
||||
uniform_color = glGetUniformLocation(Program, "color");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void ColoredLine::setUniforms(const irr::video::SColor &col)
|
||||
{
|
||||
glUniform4i(uniform_color, col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
glUniformMatrix4fv(glGetUniformLocation(Program, "ModelMatrix"), 1, GL_FALSE, core::IdentityMatrix.pointer());
|
||||
}
|
||||
}
|
||||
|
||||
namespace MeshShader
|
||||
{
|
||||
|
||||
|
@ -32,6 +32,21 @@ public:
|
||||
static GLuint cubevbo, cubeindexes;
|
||||
static GLuint ViewProjectionMatrixesUBO;
|
||||
};
|
||||
|
||||
namespace UtilShader
|
||||
{
|
||||
class ColoredLine
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_color;
|
||||
static GLuint vao, vbo;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const irr::video::SColor &);
|
||||
};
|
||||
}
|
||||
|
||||
namespace MeshShader
|
||||
{
|
||||
class ObjectPass1Shader
|
||||
|
@ -58,8 +58,7 @@ void IrrDebugDrawer::drawLine(const btVector3& from, const btVector3& to,
|
||||
{
|
||||
video::SColor c(255, (int)(color.getX()*255), (int)(color.getY()*255),
|
||||
(int)(color.getZ()*255) );
|
||||
irr_driver->getVideoDriver()->draw3DLine((const core::vector3df&)from,
|
||||
(const core::vector3df&)to, c);
|
||||
draw3DLine((const core::vector3df&)from, (const core::vector3df&)to, c);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define HEADER_IRR_DEBUG_DRAWER_HPP
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "graphics/glwrap.hpp"
|
||||
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user