Port colored lines too
This commit is contained in:
parent
db6600a687
commit
1c05d9ef68
@ -1,5 +1,13 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
uniform mat4 ModelMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
uniform mat4 InverseModelMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
|
||||
uniform mat4 TextureMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
|
@ -275,12 +275,12 @@ void draw3DLine(const core::vector3df& start,
|
||||
end.X, end.Y, end.Z
|
||||
};
|
||||
|
||||
glBindVertexArray(UtilShader::ColoredLine::vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::vbo);
|
||||
glBindVertexArray(UtilShader::ColoredLine::getInstance()->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::getInstance()->vbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, 6 * sizeof(float), vertex);
|
||||
|
||||
glUseProgram(UtilShader::ColoredLine::Program);
|
||||
UtilShader::ColoredLine::setUniforms(color);
|
||||
glUseProgram(UtilShader::ColoredLine::getInstance()->Program);
|
||||
UtilShader::ColoredLine::getInstance()->setUniforms(color);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
|
||||
glGetError();
|
||||
|
@ -191,10 +191,10 @@ void IrrDriver::renderGLSL(float dt)
|
||||
// Render bounding boxes
|
||||
if (irr_driver->getBoundingBoxesViz())
|
||||
{
|
||||
glUseProgram(UtilShader::ColoredLine::Program);
|
||||
glBindVertexArray(UtilShader::ColoredLine::vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::vbo);
|
||||
UtilShader::ColoredLine::setUniforms(SColor(255, 255, 0, 0));
|
||||
glUseProgram(UtilShader::ColoredLine::getInstance()->Program);
|
||||
glBindVertexArray(UtilShader::ColoredLine::getInstance()->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::getInstance()->vbo);
|
||||
UtilShader::ColoredLine::getInstance()->setUniforms(SColor(255, 255, 0, 0));
|
||||
const float *tmp = BoundingBoxes.data();
|
||||
for (unsigned int i = 0; i < BoundingBoxes.size(); i += 1024 * 6)
|
||||
{
|
||||
@ -220,13 +220,12 @@ void IrrDriver::renderGLSL(float dt)
|
||||
const std::map<video::SColor, std::vector<float> >& lines = debug_drawer->getLines();
|
||||
std::map<video::SColor, std::vector<float> >::const_iterator it;
|
||||
|
||||
|
||||
glUseProgram(UtilShader::ColoredLine::Program);
|
||||
glBindVertexArray(UtilShader::ColoredLine::vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::vbo);
|
||||
glUseProgram(UtilShader::ColoredLine::getInstance()->Program);
|
||||
glBindVertexArray(UtilShader::ColoredLine::getInstance()->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::getInstance()->vbo);
|
||||
for (it = lines.begin(); it != lines.end(); it++)
|
||||
{
|
||||
UtilShader::ColoredLine::setUniforms(it->first);
|
||||
UtilShader::ColoredLine::getInstance()->setUniforms(it->first);
|
||||
const std::vector<float> &vertex = it->second;
|
||||
const float *tmp = vertex.data();
|
||||
for (unsigned int i = 0; i < vertex.size(); i += 1024 * 6)
|
||||
|
@ -528,7 +528,6 @@ void Shaders::loadShaders()
|
||||
initFrustrumVBO();
|
||||
initShadowVPMUBO();
|
||||
initParticleQuadVBO();
|
||||
UtilShader::ColoredLine::init();
|
||||
}
|
||||
|
||||
void Shaders::killShaders()
|
||||
@ -579,33 +578,23 @@ void bypassUBO(GLuint Program)
|
||||
|
||||
namespace UtilShader
|
||||
{
|
||||
GLuint ColoredLine::Program;
|
||||
GLuint ColoredLine::uniform_color;
|
||||
GLuint ColoredLine::vao;
|
||||
GLuint ColoredLine::vbo;
|
||||
|
||||
void ColoredLine::init()
|
||||
ColoredLine::ColoredLine()
|
||||
{
|
||||
Program = LoadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
|
||||
|
||||
AssignUniforms("color");
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glGenBuffers(1, &vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 6 * 1024 * sizeof(float), 0, 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");
|
||||
}
|
||||
|
||||
void ColoredLine::setUniforms(const irr::video::SColor &col)
|
||||
{
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniform4i(uniform_color, col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
glUniformMatrix4fv(glGetUniformLocation(Program, "ModelMatrix"), 1, GL_FALSE, core::IdentityMatrix.pointer());
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
struct TexUnit
|
||||
|
@ -38,15 +38,12 @@ public:
|
||||
|
||||
namespace UtilShader
|
||||
{
|
||||
class ColoredLine
|
||||
class ColoredLine : public ShaderHelperSingleton<ColoredLine, video::SColor>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_color;
|
||||
static GLuint vao, vbo;
|
||||
GLuint vao, vbo;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const irr::video::SColor &);
|
||||
ColoredLine();
|
||||
};
|
||||
|
||||
class SpecularIBLGenerator : public ShaderHelperSingleton<SpecularIBLGenerator, core::matrix4, float >, public TextureRead<Trilinear_cubemap>
|
||||
|
Loading…
x
Reference in New Issue
Block a user