From: David Gow Date: Wed, 13 Aug 2014 08:05:38 +0000 (+0800) Subject: I am an idiot: the quadtree code is now fixed. X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=commitdiff_plain;h=04ab3830f779fdb92697a6b5101214ea462b765a;hp=4f60a4a972fa76800580f8731aba54a8fe94e1fb I am an idiot: the quadtree code is now fixed. tl;dr: needed more * by 2. iab;wtd*: The index buffers on the GPU contain _two_ elements per object, one for the top left of the object's bounding box, one for the bottom-right. We were taking that into account when computing the number of indices to give the DrawElements() call, but not when calculating the offset into the buffer. Oops. *: I am bored; want tedious detail --- diff --git a/src/objectrenderer.cpp b/src/objectrenderer.cpp index 998b62f..76aba52 100644 --- a/src/objectrenderer.cpp +++ b/src/objectrenderer.cpp @@ -42,7 +42,7 @@ void ObjectRenderer::RenderUsingGPU(unsigned first_obj_id, unsigned last_obj_id) m_shader_program.Use(); m_ibo.Bind(); - glDrawElements(GL_LINES, (last_index-first_index)*2, GL_UNSIGNED_INT, (GLvoid*)(first_index*sizeof(uint32_t))); + glDrawElements(GL_LINES, (last_index-first_index)*2, GL_UNSIGNED_INT, (GLvoid*)(2*first_index*sizeof(uint32_t))); } @@ -328,7 +328,7 @@ void BezierRenderer::RenderUsingGPU(unsigned first_obj_id, unsigned last_obj_id) glUniform1i(m_shader_program.GetUniformLocation("bezier_buffer_texture"), 0); glUniform1i(m_shader_program.GetUniformLocation("bezier_id_buffer_texture"), 1); m_ibo.Bind(); - glDrawElements(GL_LINES, (last_index-first_index)*2, GL_UNSIGNED_INT, (GLvoid*)(first_index*sizeof(uint32_t))); + glDrawElements(GL_LINES, (last_index-first_index)*2, GL_UNSIGNED_INT, (GLvoid*)(2*first_index*sizeof(uint32_t))); } /**