# Ogre Render Lines completely wrong

I'm trying to render line list using indices of triangles as follow

float *vertices = static_cast<float *>(vertexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));

for (int i = 0; i < out.numberofpoints; i++)
{
vertices[(i*3)] = out.pointlist[(i*3)];
vertices[(i*3)+1] = out.pointlist[(3*i)+1];
vertices[(i*3) + 2] = out.pointlist[(3*i)+2];

}

vertexBuffer->unlock();

int  l, t;
int numTriangles = out.numberoftrifaces*3*sizeof(uint16_t);
for (l = 0, t = 0; t<numTriangles; t += 3) {
// Each vertex has to be listed twice
indices[l] = out.trifacelist[t];      l++;
indices[l] = out.trifacelist[t + 1];    l++;
indices[l] = out.trifacelist[t + 2];    l++;
indices[l] = out.trifacelist[t + 2];    l++;
indices[l] = out.trifacelist[t + 1];    l++;
indices[l] = out.trifacelist[t];      l++;
}

indexBuffer->unlock();


The problem that ogre renders broken triangles and it's completely wrong. I'm not doing anything wrong regarding rendering the lines that the triangles are composed

I'm using ogre 1.9

• Can you post an image? – Bálint Jan 18 '18 at 9:39
• @Bálint I posted an image. – andre ahmed Jan 18 '18 at 9:43

The triangles you're drawing per iteration of the loop are the triangles:

t, t + 1, t + 1


And

t + 2, t + 2, t


These are degenerate triangles, presumably you want:

t, t + 1, t + 2
t + 2, t + 1, t

• Thanks for your fast reply. and how much would be the size of line index ? – andre ahmed Jan 18 '18 at 9:43
• This should draw triangles or line list ? – andre ahmed Jan 18 '18 at 9:44
• I attached the picture, still broken triangles – andre ahmed Jan 18 '18 at 9:47