Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Quake 3 Renderer and Index Buffers

This topic is 5285 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

"Oh no, not another Quake 3 renderer!" I can already hear you saying I''m going in for an interview next week and I''m hoping to add something a little more graphical to my dossier. But I''m having a little trouble getting the thing to render the maps. Right now I''m just testing stock BSP files I downloaded off the Web, and as far as I know they''re valid maps that work in Quake 3 (don''t own the game myself, unfortunately). I''m no stranger to working with Half-Life BSP files, so I can say with confidence that my problems aren''t coming from incorrectly loading and parsing the maps, because I''ve done it millions of times before with only slightly different formats. That, and I''ve verified the data that''s loaded. Looks perfect. Anyway, I''m trying to render it and all I get is a bunch or random triangles. I''m adapting the following OpenGL face render code:
const Face& curFace = face[visibleFace[f]];
static const stride = sizeof(Vertex); // BSP Vertex, not float[3]

const int offset    = face.firstVertex;

glVertexPointer(3, GL_FLOAT, stride, &(vertex[offset].position));

glTexCoordPointer(2, GL_FLOAT, stride, &(vertex[offset].textureCoord));

glTexCoordPointer(2, GL_FLOAT, stride, &(vertex[offset].lightmapCoord));

glDrawElements(GL_TRIANGLES, curFace.meshVertexesCount,
   GL_UNSIGNED_INT, &meshVertex[curFace.firstMeshVertex]);
So from what I can tell, meshVertex contains an array of indices relative to the face vertex offset, for each face. So if a meshVertex is 5, and the face vertex offset is 200, it really means vertex 205 in the global vertex array. Hopefully this is correct, but there''s a very good chance I''m wrong Using my newfound knowledge of vertex buffers and index buffers, I simply copy the global vertex array straight into the vertex buffer, and copy the meshVertex array straight into the index buffer. I then use the following call:
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, face.vertexIndex, 0, bspFile.Vertexes.Count - face.vertexIndex, face.meshVertIndex, face.numMeshVerts / 3);
From what I know about the map format and this function call (and it sure as sh*t took a while to find some good reference material), this should be correct. But this is really my first foray into Direct3D and Quake 3 maps. Any help is appreciated. I''m probably using DrawIndexedPrimitives wrong, or misinterpreting the map data.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I could be wrong, but i thing they must be rendered as triangle fans.


Share this post

Link to post
Share on other sites
Right, I read I can either use the fans or the meshes. However I couldn''t get the fans to work either, and since meshes are compatible with both mesh faces and polygon faces I decided to take that route.

Besides, I''d like to know what''s going wrong regardless

Share this post

Link to post
Share on other sites

  • 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!