Sign in to follow this  
Rimio

Q3MAP2 Repost

Recommended Posts

I'm reposting this problem since it took me a long time to post some relevant code. So here it is: I was drawing faces like this:
glDrawArrays(GL_TRIANGLE_FAN, Scene.BSPMap.fFaces[i].Vertex + Scene.BSPMap.fMeshVerts[Scene.BSPMap.fFaces[i].MeshVert], Scene.BSPMap.fFaces[i].MeshVertCount);
which works ok for q3map compiled BSPs. On q3map2 compiled maps it looks weird (like triangles are missing, but actually is even more f***d up). I found out that in order to render a q3map2 BPS you should use the MeshVert array as an index to vertices you want to draw, which would produce a call like this:
glDrawElements(GL_TRIANGLES, Scene.BSPMap.fFaces[i].MeshVertCount, GL_INT, @Scene.BSPMap.fMeshVerts[Scene.BSPMap.fFaces[i].MeshVert]);
However this gives me a blank screen. This is an alternate solution:
glBegin(GL_TRIANGLES);
for aux := 0 to Scene.BSPMap.fFaces[i].MeshVertCount-1 do
glVertex3fv(@Scene.BSPMap.fVertices[Scene.BSPMap.fFaces[i].Vertex + Scene.BSPMap.fMeshVerts[Scene.BSPMap.fFaces[i].MeshVert] + aux].Position);
glEnd();
Which gives me errors the same way the triangle fan solution did. Any ideeas on what might go wrong?

Share this post


Link to post
Share on other sites
Fund problems:

1. GL_UNSIGNED_INT instead of GL_INT (opengl does not support negative indices). Worked ok with my signed int array though.

2. Aux was in the wrong place wrong. Right way is:


glVertex3fv(@Scene.BSPMap.fVertices[Scene.BSPMap.fFaces[i].Vertex +
Scene.BSPMap.fMeshVerts[Scene.BSPMap.fFaces[i].MeshVert + aux]].Position);

Share this post


Link to post
Share on other sites

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