forked from Mirrors/openclonk
particles: fixed some particles not rendering under certain conditions
Some particles were visibly missing. The reason was apparently that the VAO was initialized with an IBO that was yet too small (because not all particles were created yet).
To be honest, I don't know why the IBO needs to be rebound as the identifier itself does not change(?) but maybe OpenGL optimizes some stuff and needs the size fixed?
Steps to reproduce: In OneMillionParticles.ocs, make Test3 be the first test (otherwise the IBO would have been large enough). You would now not see all of the fireworks.
The issue was introduced in e13cda4bd0
directional-lights
parent
29333ef87a
commit
6bacdfcbb6
|
@ -1062,7 +1062,6 @@ void C4ParticleChunk::Draw(C4TargetFacet cgo, C4Object *obj, C4ShaderCall& call,
|
|||
if (!has_vao)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ::Particles.GetIBO(particleCount));
|
||||
pGL->ObjectLabel(GL_VERTEX_ARRAY, vao, -1, "<particles>/VAO");
|
||||
|
||||
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Position));
|
||||
|
@ -1073,6 +1072,9 @@ void C4ParticleChunk::Draw(C4TargetFacet cgo, C4Object *obj, C4ShaderCall& call,
|
|||
glVertexAttribPointer(call.GetAttribute(C4SSA_Color), 4, GL_FLOAT, GL_FALSE, stride, reinterpret_cast<GLvoid*>(offsetof(C4Particle::DrawingData::Vertex, r)));
|
||||
}
|
||||
|
||||
// We need to always bind the ibo, because it might change its size.
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ::Particles.GetIBO(particleCount));
|
||||
|
||||
glDrawElements(GL_TRIANGLE_STRIP, static_cast<GLsizei> (5 * particleCount), GL_UNSIGNED_INT, 0);
|
||||
|
||||
// reset buffer data
|
||||
|
|
Loading…
Reference in New Issue