Skip to main content
gamedev.net
🔒 Locked

BSP Rendering Speed

Started by riksweeney Dec 11, 2005 at 6:41 AM 0 replies 550+ views
Original Post
riksweeney
riksweeney
Hi, I'm not getting very good performance when rendering my BSP. I'm guessing that this might be to do with using glVertex3fv to render the faces rather than glDrawElements. I am checking if the face is visible before I render it so unless my code for checking the visibility is wrong I don't think this is the problem. I did read that using glDrawElements wasn't possible for Type 1 faces when rendering BSPs, but perhaps they were wrong. Here's the code for rendering Type 1 and 3 faces.

		switch (bsp.faces.type)
		{
			case 1:
				meshIndex   = bsp.faces.meshVertIndex;
				meshCount   = bsp.faces.numMeshVerts;
				vertexIndex = bsp.faces.startVertIndex;

				glBegin(GL_TRIANGLES);

					for (j=0;j<meshCount;j++)
					{
						offset = bsp.meshIndices[meshIndex + j] + vertexIndex;
						glTexCoord2fv(&bsp.verts[offset].textureCoord.x);
						glVertex3fv(&bsp.verts[offset].position.x);
					}

				glEnd();
			break;

			case 3:
				offset = bsp.faces.startVertIndex;

				glEnableClientState(GL_VERTEX_ARRAY);

				glVertexPointer(3, GL_FLOAT, sizeof(BSPVertex), &bsp.verts[offset].position);
				glTexCoordPointer(2, GL_FLOAT, sizeof(BSPVertex), &bsp.verts[offset].textureCoord);

				glDrawElements(GL_TRIANGLES, bsp.faces.numMeshVerts, GL_UNSIGNED_INT, &bsp.meshIndices[bsp.faces.meshVertIndex]);

				glDisableClientState(GL_VERTEX_ARRAY);
			break;
		}

Any suggestions would be appreciated. Thanks Richard
Richy2k
Richy2k
How many triangles do you have in your BSP tree? And how poor is the performance? Also, what hardware are you running? Just asking as a lot of us have different views on "poor performance", i'd say anything less than 120FPS for something that doesn't look like Half-Life 2 is poor performance.

Anyways, BSPs aren't particularly useful for rendering now, was in the days of software rendering, but graphics hardware does a better and faster job of culling off geometry than doing it with a BSP tree typically does.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.