Use batched draw call to draw lines.
This commit is contained in:
parent
4e9f199008
commit
b286069108
@ -541,8 +541,6 @@ void draw3DLine(const core::vector3df& start,
|
|||||||
glUseProgram(UtilShader::ColoredLine::Program);
|
glUseProgram(UtilShader::ColoredLine::Program);
|
||||||
UtilShader::ColoredLine::setUniforms(color);
|
UtilShader::ColoredLine::setUniforms(color);
|
||||||
glDrawArrays(GL_LINES, 0, 2);
|
glDrawArrays(GL_LINES, 0, 2);
|
||||||
glBindVertexArray(0);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
glGetError();
|
glGetError();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,9 @@
|
|||||||
|
|
||||||
STKInstancedSceneNode *InstancedBox = 0;
|
STKInstancedSceneNode *InstancedBox = 0;
|
||||||
|
|
||||||
|
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
|
||||||
|
|
||||||
void IrrDriver::renderGLSL(float dt)
|
void IrrDriver::renderGLSL(float dt)
|
||||||
{
|
{
|
||||||
World *world = World::getWorld(); // Never NULL.
|
World *world = World::getWorld(); // Never NULL.
|
||||||
@ -207,11 +210,20 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
std::map<video::SColor, std::vector<float>>::const_iterator it;
|
std::map<video::SColor, std::vector<float>>::const_iterator it;
|
||||||
for (it = lines.begin(); it != lines.end(); it++)
|
for (it = lines.begin(); it != lines.end(); it++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < it->second.size(); i += 6)
|
for (int i = 0; i < it->second.size(); i += 6 * 1024)
|
||||||
{
|
{
|
||||||
draw3DLine(core::vector3df(it->second[i], it->second[i + 1], it->second[i + 2]),
|
unsigned count = MIN2(it->second.size() - i, 6 * 1024);
|
||||||
|
glBindVertexArray(UtilShader::ColoredLine::vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::vbo);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, 0, count, &(it->second.data()[i]));
|
||||||
|
|
||||||
|
glUseProgram(UtilShader::ColoredLine::Program);
|
||||||
|
UtilShader::ColoredLine::setUniforms(it->first);
|
||||||
|
glDrawArrays(GL_LINES, 0, count / 6);
|
||||||
|
|
||||||
|
/* draw3DLine(core::vector3df(it->second[i], it->second[i + 1], it->second[i + 2]),
|
||||||
core::vector3df(it->second[i + 3], it->second[i + 4], it->second[i + 5]),
|
core::vector3df(it->second[i + 3], it->second[i + 4], it->second[i + 5]),
|
||||||
it->first);
|
it->first);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -755,8 +767,7 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
|
|
||||||
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
|
|
||||||
static LightShader::PointLightInfo PointLightsInfo[MAXLIGHT];
|
static LightShader::PointLightInfo PointLightsInfo[MAXLIGHT];
|
||||||
|
|
||||||
static void renderPointLights(unsigned count)
|
static void renderPointLights(unsigned count)
|
||||||
|
@ -421,8 +421,7 @@ namespace UtilShader
|
|||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
glGenBuffers(1, &vbo);
|
glGenBuffers(1, &vbo);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
float vertex[6] = {};
|
glBufferData(GL_ARRAY_BUFFER, 6 * 1024, 0, GL_DYNAMIC_DRAW);
|
||||||
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), vertex, GL_DYNAMIC_DRAW);
|
|
||||||
GLuint attrib_position = glGetAttribLocation(Program, "Position");
|
GLuint attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
glEnableVertexAttribArray(attrib_position);
|
glEnableVertexAttribArray(attrib_position);
|
||||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
|
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user