//===================================================================================== // RenderGouraudPoly //===================================================================================== static void RenderGouraudPoly(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera) { geVec3d Verts[30], *pVert; GE_LVertex *pLVert; geVec3d Dest1[30], Dest2[30], *pDest1, *pDest2, *pDest3; Surf_TexVert Tex1[30], Tex2[30]; Surf_TexVert *pTex1, *pTex2; DRV_TLVertex Clipped1[90]; int32 Length1, Length2; GFX_Plane *pFPlanes; int32 i, p; uint32 RenderFlags; assert(geWorld_PolyIsValid(Poly)); pFPlanes = FInfo->Planes; pVert = Verts; pLVert = Poly->Verts; pTex1 = Tex1; for (i=0; i< Poly->NumVerts; i++) { pVert->X = pLVert->X; pVert->Y = pLVert->Y; pVert->Z = pLVert->Z; pTex1->r = pLVert->r; pTex1->g = pLVert->g; pTex1->b = pLVert->b; pVert++; pLVert++; pTex1++; } pDest1 = Verts; pDest2 = Dest2; pTex1 = Tex1; pTex2 = Tex2; Length1 = Poly->NumVerts; for (p=0; p< 4; p++) { if (!Frustum_ClipToPlaneRGB(&pFPlanes[p], pDest1, pDest2, pTex1, pTex2, Length1, &Length2)) return; if (pDest1 == Dest2) { pDest1 = Dest1; pDest2 = Dest2; pTex1 = Tex1; pTex2 = Tex2; } else { pDest1 = Dest2; pDest2 = Dest1; pTex1 = Tex2; pTex2 = Tex1; } Length1 = Length2; } if (Length1 < 3) return; pDest3 = pDest2; for (i=0; i< Length1; i++) { //geXForm3d_Transform(&Camera->XForm, pDest1, pDest2); geCamera_Transform(Camera, pDest1, pDest2); pDest1++; pDest2++; } Frustum_ProjectRGB(pDest3, pTex1, Clipped1, Length1, Camera); Clipped1[0].a = Poly->Verts[0].a; if(Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS) { RenderFlags = DRV_RENDER_NO_ZWRITE; } else { RenderFlags = 0; } if(Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF) { RenderFlags |= DRV_RENDER_NO_ZMASK; } if (Clipped1[0].a != 255.0f) RenderFlags |= DRV_RENDER_ALPHA; // Render it... RDriver->RenderGouraudPoly(Clipped1, Length1, RenderFlags); }
//===================================================================================== // RenderTexturedPoly //===================================================================================== static void RenderTexturedPoly(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera) { geVec3d Dest1[30], Dest2[30], *pDest1, *pDest2, *pDest3, *pTempDest; GE_LVertex *pLVert; Surf_TexVert Tex1[30], Tex2[30]; Surf_TexVert *pTex1, *pTex2, *pTempTex; DRV_TLVertex Clipped1[90]; int32 Length1, Length2; geBitmap *pBitmap; GFX_Plane *pFPlanes; int32 i, p; uint32 RenderFlags; // skydome int32 plan; // FILE *fp; assert(geWorld_PolyIsValid(Poly)); pFPlanes = FInfo->Planes; pDest1 = Dest1; pTex1 = Tex1; pLVert = Poly->Verts; for (i=0; i< Poly->NumVerts; i++) { pDest1->X = pLVert->X; pDest1->Y = pLVert->Y; pDest1->Z = pLVert->Z; pTex1->u = pLVert->u; pTex1->v = pLVert->v; pTex1->r = pLVert->r; pTex1->g = pLVert->g; pTex1->b = pLVert->b; pDest1++; pLVert++; pTex1++; } pDest1 = Dest1; pDest2 = Dest2; pTex1 = Tex1; pTex2 = Tex2; Length1 = Poly->NumVerts; // skydome plan = FInfo->NumPlanes; // changed QD Clipping // if (((Poly->RenderFlags & GE_RENDER_NO_CLIP)==GE_RENDER_NO_CLIP) && plan==5) if (((Poly->RenderFlags & GE_RENDER_NO_CLIP)==GE_RENDER_NO_CLIP) && plan==6) plan -= 1; for (p=0; p< plan; p++, pFPlanes++) { if (!Frustum_ClipToPlaneUVRGB(pFPlanes, pDest1, pDest2, pTex1, pTex2, Length1, &Length2)) return; // Swap them pTempDest = pDest1; pDest1 = pDest2; pDest2 = pTempDest; pTempTex = pTex1; pTex1 = pTex2; pTex2 = pTempTex; Length1 = Length2; } if (Length1 < 3) return; pDest3 = pDest2; for (i=0; i< Length1; i++) { //geXForm3d_Transform(&Camera->XForm, pDest1, pDest2); geCamera_Transform(Camera,pDest1,pDest2); pDest1++; pDest2++; } Frustum_ProjectRGB(pDest3, pTex1, Clipped1, Length1, Camera); pBitmap = Poly->Bitmap; Clipped1[0].a = Poly->Verts[0].a; if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS) { RenderFlags = DRV_RENDER_NO_ZWRITE; } else RenderFlags = 0; if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF) { RenderFlags |= DRV_RENDER_NO_ZMASK; } if (Clipped1[0].a != 255.0f) { RenderFlags |= DRV_RENDER_ALPHA; } /* 01/30/2003 Wendell Buckner Driver render flush is probably causing a slow down! */ if (Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF) { RenderFlags |= DRV_RENDER_FLUSH; } if (Poly->RenderFlags & GE_RENDER_CLAMP_UV) { RenderFlags |= DRV_RENDER_CLAMP_UV; } if (Poly->RenderFlags & GE_RENDER_NO_FOG) // skybox fog { RenderFlags |= DRV_RENDER_POLY_NO_FOG; } // Render it... assert(geWorld_HasBitmap(gWorld, pBitmap)); assert(geBitmap_GetTHandle(pBitmap)); /* 08/08/2004 Wendell Buckner BUG FIX: Allways call geBitmap_SetRenderFlags() before calling a textured rendering function(for embm, dot3, & etc...). */ geBitmap_SetRenderFlags(pBitmap, &RenderFlags); RDriver->RenderMiscTexturePoly(Clipped1, Length1, geBitmap_GetTHandle(pBitmap), RenderFlags); }
//===================================================================================== // RenderTexturedPoly //===================================================================================== static void RenderTexturedPoly(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera) { geVec3d Dest1[30], Dest2[30], *pDest1, *pDest2, *pDest3, *pTempDest; GE_LVertex *pLVert; Surf_TexVert Tex1[30], Tex2[30]; Surf_TexVert *pTex1, *pTex2, *pTempTex; DRV_TLVertex Clipped1[90]; int32 Length1, Length2; geBitmap *pBitmap; GFX_Plane *pFPlanes; int32 i, p; uint32 RenderFlags; // skydome int32 plan; assert(geWorld_PolyIsValid(Poly)); pFPlanes = FInfo->Planes; pDest1 = Dest1; pTex1 = Tex1; pLVert = Poly->Verts; for (i=0; i< Poly->NumVerts; i++) { pDest1->X = pLVert->X; pDest1->Y = pLVert->Y; pDest1->Z = pLVert->Z; pTex1->u = pLVert->u; pTex1->v = pLVert->v; pTex1->r = pLVert->r; pTex1->g = pLVert->g; pTex1->b = pLVert->b; pDest1++; pLVert++; pTex1++; } pDest1 = Dest1; pDest2 = Dest2; pTex1 = Tex1; pTex2 = Tex2; Length1 = Poly->NumVerts; // skydome plan = FInfo->NumPlanes; if (((Poly->RenderFlags & GE_RENDER_NO_CLIP)==GE_RENDER_NO_CLIP) && plan==5) plan -= 1; for (p=0; p< plan; p++, pFPlanes++) { if (!Frustum_ClipToPlaneUVRGB(pFPlanes, pDest1, pDest2, pTex1, pTex2, Length1, &Length2)) return; // Swap them pTempDest = pDest1; pDest1 = pDest2; pDest2 = pTempDest; pTempTex = pTex1; pTex1 = pTex2; pTex2 = pTempTex; Length1 = Length2; } if (Length1 < 3) return; pDest3 = pDest2; for (i=0; i< Length1; i++) { //geXForm3d_Transform(&Camera->XForm, pDest1, pDest2); geCamera_Transform(Camera,pDest1,pDest2); pDest1++; pDest2++; } Frustum_ProjectRGB(pDest3, pTex1, Clipped1, Length1, Camera); pBitmap = Poly->Bitmap; Clipped1[0].a = Poly->Verts[0].a; if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS) RenderFlags = DRV_RENDER_NO_ZWRITE; else RenderFlags = 0; if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF) RenderFlags |= DRV_RENDER_NO_ZMASK; if (Clipped1[0].a != 255.0f) RenderFlags |= DRV_RENDER_ALPHA; if (Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF) RenderFlags |= DRV_RENDER_FLUSH; if (Poly->RenderFlags & GE_RENDER_CLAMP_UV) RenderFlags |= DRV_RENDER_CLAMP_UV; if (Poly->RenderFlags & GE_RENDER_NO_FOG) // skybox fog RenderFlags |= DRV_RENDER_POLY_NO_FOG; // Render it... assert(geWorld_HasBitmap(gWorld, pBitmap)); assert(geBitmap_GetTHandle(pBitmap)); RDriver->RenderMiscTexturePoly(Clipped1, Length1, geBitmap_GetTHandle(pBitmap), RenderFlags); }