void BSP_Render(void)
{
int i, j;
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
for(i=0;i.number);
if(surface.textype&SURF_SKY)
goto skip;
if(surface.textype&SURF_WARP)
goto skip;
if(surface.textype&SURF_NODRAW)
goto skip;
if(surface.textype&SURF_TRANS33)
goto skip;
if(surface.textype&SURF_TRANS66)
goto skip;
glBegin(surface.mode);
for(j=0;j<surface.numpoints;j++)
{
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, vertices[surface.firstpoint+j].t[0], vertices[surface.firstpoint+j].t[1]);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, vertices[surface.firstpoint+j].lm[0], vertices[surface.firstpoint+j].lm[1]);
glVertex3f(vertices[surface.firstpoint+j].v[0], vertices[surface.firstpoint+j].v[1], vertices[surface.firstpoint+j].v[2]);
}
glEnd();
skip:;
}
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
}
</pre>
And the vertices are cached like this:
(not the whole function do to length)
<pre>
for(i=0;i<numfaces;i++)
{
dface_t *face=&dfaces;
surf_t *surf=&surface;
dplane_t *plane=&dplanes[face->planenum];
int first=face->firstedge;
int last=face->firstedge+face->numedges;
int usepoly;
float mins[2], maxs[2], start[2];
usepoly=0;
surf->firstpoint=totalpoints;
surf->numpoints=face->numedges;
for(j=first;j<last;j++)
{
int sedge=dsurfedges[j];
if(sedge>0)
{
dedge_t *edge=&dedges[sedge];
dvertex_t *vert=&dvertexes[0];
vertices[totalpoints].v[0]=vert[edge->v[0]].point[0];
vertices[totalpoints].v[1]=vert[edge->v[0]].point[1];
vertices[totalpoints].v[2]=vert[edge->v[0]].point[2];
totalpoints++;
}
else
{
dedge_t *edge=&dedges[-sedge];
dvertex_t *vert=&dvertexes[0];
vertices[totalpoints].v[0]=vert[edge->v[1]].point[0];
vertices[totalpoints].v[1]=vert[edge->v[1]].point[1];
vertices[totalpoints].v[2]=vert[edge->v[1]].point[2];
usepoly++;
totalpoints++;
}
}
}
</pre>
Can anyone explain why I''m getting shering like that?
Could it be because I''m not doing hidden surface removal?
Thanks. </i>
Can anyone explain this?
screen shot:
http://mwill.hypermart.net/q2bspprob.jpg
I circled the problem areas.
here''s the rendering code:
while I admit to never writing a quake renderer before , I have looked through the code in one before, and it had some really weird polygon issues not too disimilar to what you are showing (it would make sense if you do not have backface culling enabled)... this issue with it was that it used GL_POLYGON throughout, after changing it to GL_TRIANGLE_STRIP (***MUCH FASTER***) and removing every second glvertex call (it really should be using arrays though) it was totally fixed. and looked good too. and ran about 3 times faster.
I doubt this would help though
I doubt this would help though
Thanks for the sugestion.
I''m going to try to switch to arrays soon (it''s only rendering the way it is now for testing).
I fixed the problem by setting the near Z plane to 1.0f rather than 0.001f, and that fixed the problem.
I''m going to try to switch to arrays soon (it''s only rendering the way it is now for testing).
I fixed the problem by setting the near Z plane to 1.0f rather than 0.001f, and that fixed the problem.
Ok.
I serious suggest you change to triangle strips.
Also, re-work the code so you pre-calculate 3 array sets, one for world data, one for 33% transparentcy, and and one for 66%. having those ifs in the code will slow it down probably to about 10% of what it is capable of, if not slower. then you can order into vis set groups, and hopefully if you use texture arrays (extension), you will be able to draw everything with only a few calls to DrawElements, leaving everything to the driver, and therefor the gpu, if you have one....
I serious suggest you change to triangle strips.
Also, re-work the code so you pre-calculate 3 array sets, one for world data, one for 33% transparentcy, and and one for 66%. having those ifs in the code will slow it down probably to about 10% of what it is capable of, if not slower. then you can order into vis set groups, and hopefully if you use texture arrays (extension), you will be able to draw everything with only a few calls to DrawElements, leaving everything to the driver, and therefor the gpu, if you have one....
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement