Jump to content
  • Advertisement
Sign in to follow this  

Rendering BSPs

This topic is 4700 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.type != 1)

			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);

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!