Go to the source code of this file.
Functions | |
| BOOL | PCache_InsertWorldPoly (DRV_TLVertex *Verts, int32 NumVerts, geRDriver_THandle *THandle, DRV_TexInfo *TexInfo, DRV_LInfo *LInfo, uint32 Flags) |
| BOOL | PCache_FlushWorldPolys (void) |
| BOOL | PCache_FlushMiscPolys (void) |
| BOOL | PCache_InsertMiscPoly (DRV_TLVertex *Verts, int32 NumVerts, geRDriver_THandle *THandle, uint32 Flags) |
| BOOL | PCache_Reset (void) |
Variables | |
| DRV_CacheInfo | CacheInfo |
|
|
Definition at line 814 of file D3D7xDrv/Pcache.cpp.
00815 {
00816 int32 i;
00817 Misc_Poly *pPoly;
00818
00819 if (!MiscCache.NumPolys)
00820 return TRUE;
00821
00822 if (!THandle_CheckCache())
00823 return GE_FALSE;
00824
00825 // Set the render states
00826 if (AppInfo.CanDoMultiTexture)
00827 {
00828 AppInfo.lpD3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
00829 AppInfo.lpD3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
00830 D3DSetTexture(1, NULL); // Reset texture stage 1
00831 }
00832
00833 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
00834
00835 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
00836 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
00837 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
00838 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
00839 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
00840 AppInfo.lpD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
00841
00842 D3DBlendFunc (D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
00843 D3DBlendEnable(TRUE);
00844
00845 // Sort the polys by handle
00846 SortMiscPolysByHandle();
00847
00848 for (i=0; i< MiscCache.NumPolys; i++)
00849 {
00850 pPoly = MiscCache.SortedPolys[i];
00851
00852 if (pPoly->Flags & DRV_RENDER_NO_ZMASK) // We are assuming that this is not going to change all that much
00853 D3DZEnable(FALSE);
00854 else
00855 D3DZEnable(TRUE);
00856
00857 if (pPoly->Flags & DRV_RENDER_NO_ZWRITE) // We are assuming that this is not going to change all that much
00858 D3DZWriteEnable(FALSE);
00859 else
00860 D3DZWriteEnable(TRUE);
00861
00862 if (pPoly->Flags & DRV_RENDER_CLAMP_UV)
00863 D3DTexWrap(0, FALSE);
00864 else
00865 D3DTexWrap(0, TRUE);
00866
00867 if (!SetupTexture(0, pPoly->THandle, pPoly->MipLevel))
00868 return GE_FALSE;
00869
00870 if ( (pPoly->Flags & DRV_RENDER_POLY_NO_FOG) && AppInfo.FogEnable) // poly fog
00871 AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE , FALSE);
00872
00873 D3DTexturedPoly(&MiscCache.Verts[pPoly->FirstVert], pPoly->NumVerts);
00874
00875 if ( (pPoly->Flags & DRV_RENDER_POLY_NO_FOG) && AppInfo.FogEnable) // poly fog
00876 AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE , TRUE);
00877 }
00878
00879 // Turn z stuff back on...
00880 D3DZWriteEnable (TRUE);
00881 D3DZEnable(TRUE);
00882
00883 MiscCache.NumPolys = 0;
00884 MiscCache.NumVerts = 0;
00885
00886 #ifdef SUPER_FLUSH
00887 /* 02/28/2001 Wendell Buckner
00888 These render states are unsupported d3d 7.0
00889 AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_FLUSHBATCH, 0);*/
00890 AppInfo.lpD3DDevice->EndScene();
00891 AppInfo.lpD3DDevice->BeginScene();
00892 #endif
00893
00894 return TRUE;
00895 }
|
|
|
Definition at line 310 of file D3D7xDrv/Pcache.cpp.
00311 {
00312 if (!WorldCache.NumPolys)
00313 return TRUE;
00314
00315 if (!THandle_CheckCache())
00316 return GE_FALSE;
00317
00318 if (AppInfo.CanDoMultiTexture)
00319 {
00320 RenderWorldPolys(RENDER_WORLD_POLYS_SINGLE_PASS);
00321 }
00322 else
00323 {
00324 // Render them as normal
00325 if (!RenderWorldPolys(RENDER_WORLD_POLYS_NORMAL))
00326 return GE_FALSE;
00327
00328 // Render them as lmaps
00329 RenderWorldPolys(RENDER_WORLD_POLYS_LMAP);
00330 }
00331
00332 ClearWorldCache();
00333
00334 return TRUE;
00335 }
|
|
||||||||||||||||||||
|
Definition at line 900 of file D3D7xDrv/Pcache.cpp.
00901 {
00902 int32 Mip;
00903 float ZRecip, u, v, ScaleU, ScaleV, InvScale;
00904 Misc_Poly *pCachePoly;
00905 DRV_TLVertex *pVerts;
00906 PCache_Vert *pD3DVerts;
00907 int32 i, SAlpha;
00908
00909 if ((MiscCache.NumVerts + NumVerts) >= MAX_MISC_POLY_VERTS)
00910 {
00911 // If the cache is full, we must flush it before going on...
00912 PCache_FlushMiscPolys();
00913 }
00914 else if (MiscCache.NumPolys+1 >= MAX_MISC_POLYS)
00915 {
00916 // If the cache is full, we must flush it before going on...
00917 PCache_FlushMiscPolys();
00918 }
00919
00920 Mip = GetMipLevel(Verts, NumVerts, (float)THandle->Width, (float)THandle->Height, THandle->NumMipLevels-1);
00921
00922 // Store info about this poly in the cache
00923 pCachePoly = &MiscCache.Polys[MiscCache.NumPolys];
00924
00925 pCachePoly->THandle = THandle;
00926 pCachePoly->Flags = Flags;
00927 pCachePoly->FirstVert = MiscCache.NumVerts;
00928 pCachePoly->NumVerts = NumVerts;
00929 pCachePoly->MipLevel = Mip;
00930 pCachePoly->SortKey = ((THandle - TextureHandles)<<4)+Mip;
00931
00932 // Get scale value for vertices
00933 //TCache_GetUVInvScale(Bitmap, Mip, &InvScale);
00934 InvScale = 1.0f / (float)((1<<THandle->Log));
00935
00936 // Convert them to take account that the vertices are allready from 0 to 1
00937 ScaleU = (float)THandle->Width * InvScale;
00938 ScaleV = (float)THandle->Height * InvScale;
00939
00940 // Precompute the alpha value...
00941 SAlpha = ((int32)Verts->a)<<24;
00942
00943 // Get a pointer to the original polys verts
00944 pVerts = Verts;
00945 // Get a pointer into the world verts
00946 pD3DVerts = &MiscCache.Verts[MiscCache.NumVerts];
00947
00948 for (i=0; i< NumVerts; i++)
00949 {
00950 ZRecip = 1/(pVerts->z);
00951
00952 pD3DVerts->x = pVerts->x;
00953 pD3DVerts->y = pVerts->y;
00954
00955 pD3DVerts->z = (1.0f - ZRecip); // ZBUFFER
00956 pD3DVerts->rhw = ZRecip;
00957
00958 u = pVerts->u * ScaleU;
00959 v = pVerts->v * ScaleV;
00960
00961 pD3DVerts->uv[0].u = u;
00962 pD3DVerts->uv[0].v = v;
00963
00964 pD3DVerts->color = SAlpha | ((int32)pVerts->r<<16) | ((int32)pVerts->g<<8) | (int32)pVerts->b;
00965
00966 if (AppInfo.FogEnable && !(Flags & DRV_RENDER_POLY_NO_FOG) ) // poly fog
00967 {
00968 DWORD FogVal;
00969 float Val;
00970
00971 Val = pVerts->z;
00972
00973 if (Val > AppInfo.FogEnd)
00974 Val = AppInfo.FogEnd;
00975
00976 FogVal = (DWORD)((AppInfo.FogEnd-Val)/(AppInfo.FogEnd-AppInfo.FogStart)*255.0f);
00977
00978 if (FogVal < 0)
00979 FogVal = 0;
00980 else if (FogVal > 255)
00981 FogVal = 255;
00982
00983 pD3DVerts->specular = (FogVal<<24); // Alpha component in specular is the fog value (0...255)
00984 }
00985 else
00986 pD3DVerts->specular = 0;
00987
00988 pVerts++;
00989 pD3DVerts++;
00990 }
00991
00992 // Update globals about the misc poly cache
00993 MiscCache.NumVerts += NumVerts;
00994 MiscCache.NumPolys++;
00995
00996 return TRUE;
00997 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 191 of file D3D7xDrv/Pcache.cpp.
00192 {
00193 int32 Mip;
00194 float ZRecip, DrawScaleU, DrawScaleV;
00195 World_Poly *pCachePoly;
00196 DRV_TLVertex *pVerts;
00197 PCache_TVert *pTVerts;
00198 PCache_Vert *pD3DVerts;
00199 int32 i;
00200 uint32 Alpha;
00201
00202 #ifdef _DEBUG
00203 if (LInfo)
00204 {
00205 assert(LInfo->THandle);
00206 }
00207 #endif
00208
00209 if ((WorldCache.NumVerts + NumVerts) >= MAX_WORLD_POLY_VERTS)
00210 {
00211 // If the cache is full, we must flush it before going on...
00212 if (!PCache_FlushWorldPolys())
00213 return GE_FALSE;
00214 }
00215 else if (WorldCache.NumPolys+1 >= MAX_WORLD_POLYS)
00216 {
00217 // If the cache is full, we must flush it before going on...
00218 if (!PCache_FlushWorldPolys())
00219 return GE_FALSE;
00220 }
00221
00222 DrawScaleU = 1.0f / TexInfo->DrawScaleU;
00223 DrawScaleV = 1.0f / TexInfo->DrawScaleV;
00224
00225 Mip = GetMipLevel(Verts, NumVerts, DrawScaleU, DrawScaleV, THandle->NumMipLevels-1);
00226
00227 // Get a pointer to the original polys verts
00228 pVerts = Verts;
00229
00230 // Store info about this poly in the cache
00231 pCachePoly = &WorldCache.Polys[WorldCache.NumPolys];
00232
00233 pCachePoly->THandle = THandle;
00234 pCachePoly->LInfo = LInfo;
00235 pCachePoly->Flags = Flags;
00236 pCachePoly->FirstVert = WorldCache.NumVerts;
00237 pCachePoly->NumVerts = NumVerts;
00238 pCachePoly->ShiftU = TexInfo->ShiftU;
00239 pCachePoly->ShiftV = TexInfo->ShiftV;
00240 pCachePoly->ScaleU = DrawScaleU;
00241 pCachePoly->ScaleV = DrawScaleV;
00242 pCachePoly->MipLevel = Mip;
00243
00244 // Don't forget the sort key:
00245 pCachePoly->SortKey = ((THandle - TextureHandles)<<4)+Mip;
00246
00247 // Get a pointer into the world verts
00248 pD3DVerts = &WorldCache.Verts[WorldCache.NumVerts];
00249 pTVerts = &WorldCache.TVerts[WorldCache.NumVerts];
00250
00251 if (Flags & DRV_RENDER_ALPHA)
00252 Alpha = (uint32)pVerts->a<<24;
00253 else
00254 Alpha = (uint32)(255<<24);
00255
00256 for (i=0; i< NumVerts; i++)
00257 {
00258 ZRecip = 1.0f/(pVerts->z);
00259
00260 pD3DVerts->x = pVerts->x;
00261 pD3DVerts->y = pVerts->y;
00262
00263 pD3DVerts->z = (1.0f - ZRecip); // ZBUFFER
00264 pD3DVerts->rhw = ZRecip;
00265
00266 if (AppInfo.FogEnable && !(Flags & DRV_RENDER_POLY_NO_FOG)) // poly fog
00267 {
00268 DWORD FogVal;
00269 float Val;
00270
00271 Val = pVerts->z;
00272
00273 if (Val > AppInfo.FogEnd)
00274 Val = AppInfo.FogEnd;
00275
00276 FogVal = (DWORD)((AppInfo.FogEnd-Val)/(AppInfo.FogEnd-AppInfo.FogStart)*255.0f);
00277
00278 if (FogVal < 0)
00279 FogVal = 0;
00280 else if (FogVal > 255)
00281 FogVal = 255;
00282
00283 pD3DVerts->specular = (FogVal<<24); // Alpha component in specular is the fog value (0...255)
00284 }
00285 else
00286 pD3DVerts->specular = 0;
00287
00288 // Store the uv's so the prep pass can use them...
00289 pTVerts->u = pVerts->u;
00290 pTVerts->v = pVerts->v;
00291
00292 pTVerts->Color = Alpha | ((uint32)pVerts->r<<16) | ((uint32)pVerts->g<<8) | (uint32)pVerts->b;
00293
00294 pTVerts++;
00295 pVerts++;
00296 pD3DVerts++;
00297
00298 }
00299
00300 // Update globals about the world poly cache
00301 WorldCache.NumVerts += NumVerts;
00302 WorldCache.NumPolys++;
00303
00304 return TRUE;
00305 }
|
|
|
Definition at line 1451 of file D3D7xDrv/Pcache.cpp.
01452 {
01453 WorldCache.NumPolys = 0;
01454 WorldCache.NumVerts = 0;
01455
01456 MiscCache.NumPolys = 0;
01457 MiscCache.NumVerts = 0;
01458
01459 return TRUE;
01460 }
|
|
|
Definition at line 25 of file D3D8Drv/Pcache.h. |
1.3.2