Sign in to follow this  

Rendering BSPs

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

If you intended to correct an error in the post then please contact us.

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[i].type != 1)
			{
				continue;
			}

			firstVertex = bsp.m_pFaces[i].startVertIndex;
			vertexCount = bsp.m_pFaces[i].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

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this