Original Post
Ive seemed to fix my loading issues, but rendering poses a problem as well. Most references on the subject are very hard to find(any good ones). From the ones I have found I have pieced together something that resembles what it should do: Problem is it doesn't render anything....anyone have any idea why? Probley like my last problem....it was a stupid programming error heh. P.S. jw when will the search button be fixed?
/*
====================================================================================================================
void Renderer::RenderFace(bsp3_face *thisFace, vector<bsp3_Vertex*> mapVertList, vector<bsp3_index> mapIndexList)
====================================================================================================================
*/
void Renderer::RenderFace(bsp3_face *thisFace, vector<bsp3_Vertex> mapVertList, vector<bsp3_index> mapIndexList)
{
glBegin(GL_TRIANGLES);
for(int i = 0; i < thisFace->numOfVerts; i++)
{
int offset = mapIndexList.at(thisFace->startIndex + i) + thisFace->startVertIndex;
if(offset > mapVertList.size())
Sys_Error("RenderFace: offset is run out of bounds %d > %d\n",offset, mapVertList.size());
glNormal3fv(mapVertList.at(offset).normal);
glVertex3fv(mapVertList.at(offset).position);
}
glEnd();
}
/*
==================================================
void Renderer::RenderWorld(jmMapSystem *thisMap)
==================================================
*/
void Renderer::RenderWorld(jmMapSystem *thisMap)
{
vector<bsp3_index> mapIndexs = thisMap->map_Indexs;
vector<bsp3_Vertex> mapVerts = thisMap->map_Vertexs;
vector<bsp3_face *> map_Faces = thisMap->map_Faces;
int numVerts = thisMap->numVerts;
int numIndexs = thisMap->numIndex;
int numFaces = thisMap->numFaces;
// ive tried front/back face culling, and having culling off.
glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
// Set up the GL sysem for rendering
glVertexPointer(3, GL_FLOAT, sizeof(bsp3_Vertex), &mapVerts.at(0).position);
glTexCoordPointer(2, GL_FLOAT, sizeof(bsp3_Vertex), &mapVerts.at(0).texcoord);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
for(int i = 0; i < numFaces; i++)
{
switch(map_Faces.at(i)->type)
{
case BSP3_POLYGON:
RenderFace(map_Faces.at(i),mapVerts,mapIndexs);
break;
case BSP3_PATCH:
Sys_Print("WARNING: Dont know how to render type BSP3_PATCH\n");
break;
case BSP3_MESH:
Sys_Print("WARNING: Dont know how to render type BSP3_MESH\n");
break;
case BSP3_BILLBOARD:
Sys_Print("WARNING: Dont know how to render type BSP3_BILLBOARD\n");
break;
default:
Sys_Error("bsp3: invalid face type on face %d, type = %d\n",i,map_Faces.at(i)->type);
}
}
}