• 15
• 15
• 11
• 9
• 10

# Rendering BSPs

This topic is 4516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've got my BSP loading code working OK (as far as I know) and tried to render it using a for loop and GL_LINE_STRIP
	glBegin(GL_LINE_STRIP); /* Switch this for GL_TRIANGLES or GL_LINE_STRIP */

for (i=0;i<bsp.m_numOfFaces;i++)
{
if (bsp.m_pFaces.type != 1)
{
continue;
}

firstVertex = bsp.m_pFaces.startVertIndex;
vertexCount = bsp.m_pFaces.numOfVerts;

glColor3f(1.0f, 1.0f, 1.0f);

for (j=firstVertex;j<firstVertex + vertexCount;j++)
{
glVertex3f(bsp.m_pVerts[j].position.x, bsp.m_pVerts[j].position.y, bsp.m_pVerts[j].position.z);
}
}

glEnd();

m_pVerts is the BSP's list of vertices and m_pFaces is the BSP's list of faces This sort of works (I'm just rendering a single square room), but I've noticed that there are a couple of problems. I then decided to look into using glDrawElements instead. Unfortunately it crashes when I enable the GL_VERTEX_ARRAY. Here's what I'm trying to do in the drawing phase:
glVertexPointer(3, GL_FLOAT, sizeof(BSPVertex), &bsp.m_pVerts[firstVertex].position);

glDrawElements(GL_TRIANGLES, vertexCount, GL_UNSIGNED_INT, bsp.m_pVerts[firstVertex]);

At the moment I'm not too worried about the speed, I just want to make sure it renders correctly so I'm basically wondering if I have to use glDrawElements to achieve this or can I just use GL_TRIANGLES for the moment. Thanks Richard