Mercurial > mm7
comparison Render.cpp @ 2155:0a1438c16c2b
Render decoupling.
author | Nomad |
---|---|
date | Thu, 09 Jan 2014 17:29:17 +0200 |
parents | 9bd7522cdbbb |
children | 00bd098f6435 |
comparison
equal
deleted
inserted
replaced
2154:9bd7522cdbbb | 2155:0a1438c16c2b |
---|---|
26 #include "texts.h" | 26 #include "texts.h" |
27 #include "mm7_data.h" | 27 #include "mm7_data.h" |
28 #include "MM7.h" | 28 #include "MM7.h" |
29 #include "Lights.h" | 29 #include "Lights.h" |
30 #include "Level/Decoration.h" | 30 #include "Level/Decoration.h" |
31 #include "Vis.h" | |
31 | 32 |
32 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | 33 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") |
33 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | 34 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") |
34 | 35 |
35 struct IDirectDrawClipper *pDDrawClipper; | 36 struct IDirectDrawClipper *pDDrawClipper; |
119 pSurface1->Release(); | 120 pSurface1->Release(); |
120 pSurface2->Release(); | 121 pSurface2->Release(); |
121 return v0; | 122 return v0; |
122 } | 123 } |
123 | 124 |
124 void Render::sub_4A19B0() | |
125 { | |
126 char *result; // eax@1 | |
127 signed int v1; // ecx@1 | |
128 /* | |
129 result = (char *)&this->pBillboardRenderListD3D[0].uOpacity; | |
130 v1 = 1000; | |
131 do | |
132 { | |
133 *(_DWORD *)result = 0; | |
134 *((_DWORD *)result + 1) = -1; | |
135 *((_DWORD *)result + 3) = -1; | |
136 *((_DWORD *)result - 34) = 4; | |
137 result += 156; | |
138 --v1; | |
139 } | |
140 while ( v1 ); | |
141 */ | |
142 for( int i = 0; i < 1000; i++ ) | |
143 { | |
144 this->pBillboardRenderListD3D[i].uOpacity = (RenderBillboardD3D::OpacityType)0; | |
145 this->pBillboardRenderListD3D[i].field_90 = -1; | |
146 this->pBillboardRenderListD3D[i].sParentBillboardID = -1; | |
147 this->pBillboardRenderListD3D[i].uNumVertices = 4; | |
148 } | |
149 | |
150 return; | |
151 } | |
152 | 125 |
153 //----- (00440CB8) -------------------------------------------------------- | 126 //----- (00440CB8) -------------------------------------------------------- |
154 void Render::DrawBillboardList_BLV() | 127 void Render::DrawBillboardList_BLV() |
155 { | 128 { |
156 __int16 v2; // ax@3 | 129 __int16 v2; // ax@3 |
1913 v53 = v7; | 1886 v53 = v7; |
1914 v54 = v7->std__vector_000004_size; | 1887 v54 = v7->std__vector_000004_size; |
1915 if ( v7->std__vector_000004_size) | 1888 if ( v7->std__vector_000004_size) |
1916 a2 = -1; | 1889 a2 = -1; |
1917 pGame->AlterGamma_ODM(a4, &a2); | 1890 pGame->AlterGamma_ODM(a4, &a2); |
1918 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) | 1891 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
1919 { | 1892 { |
1920 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | 1893 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
1921 v7->DrawLightmaps(/*v8, 0*/); | 1894 v7->DrawLightmaps(/*v8, 0*/); |
1922 } | 1895 } |
1923 else | 1896 else |
2075 v1->bWindowMode = 1; | 2048 v1->bWindowMode = 1; |
2076 //nullsub_1(); | 2049 //nullsub_1(); |
2077 //nullsub_1(); | 2050 //nullsub_1(); |
2078 } | 2051 } |
2079 | 2052 |
2080 //----- (0049E756) -------------------------------------------------------- | |
2081 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
2082 { | |
2083 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
2084 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
2085 | |
2086 halCaps.dwSize = 380; | |
2087 refCaps.dwSize = 380; | |
2088 this_->GetCaps(&halCaps, &refCaps); | |
2089 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
2090 } | |
2091 | 2053 |
2092 //----- (0049E992) -------------------------------------------------------- | 2054 //----- (0049E992) -------------------------------------------------------- |
2093 Render::Render() | 2055 Render::Render() |
2094 { | 2056 { |
2095 Render *v1; // esi@1 | 2057 Render *v1; // esi@1 |
2145 uNumBillboardsToDraw = 0; | 2107 uNumBillboardsToDraw = 0; |
2146 bFogEnabled = false; | 2108 bFogEnabled = false; |
2147 | 2109 |
2148 hd_water_tile_id = -1; | 2110 hd_water_tile_id = -1; |
2149 hd_water_current_frame = 0; | 2111 hd_water_current_frame = 0; |
2150 sub_4A19B0(); | |
2151 } | 2112 } |
2152 | 2113 |
2153 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) | 2114 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
2154 { | 2115 { |
2155 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | 2116 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2358 free(lineRGB); | 2319 free(lineRGB); |
2359 fclose(pOutFile); | 2320 fclose(pOutFile); |
2360 } | 2321 } |
2361 } | 2322 } |
2362 } | 2323 } |
2363 // 4EFA80: using guessed type int dword_4EFA80; | |
2364 | 2324 |
2365 //----- (0049F1BC) -------------------------------------------------------- | 2325 //----- (0049F1BC) -------------------------------------------------------- |
2366 void Render::SaveWinnersCertificate(const char *a1) | 2326 void Render::SaveWinnersCertificate(const char *a1) |
2367 { | 2327 { |
2368 unsigned int v6; // eax@8 | 2328 unsigned int v6; // eax@8 |
2668 free(lineRGB); | 2628 free(lineRGB); |
2669 *(int *)packed_size = (char *)v9 - data_buff; | 2629 *(int *)packed_size = (char *)v9 - data_buff; |
2670 } | 2630 } |
2671 | 2631 |
2672 //----- (0049F8B5) -------------------------------------------------------- | 2632 //----- (0049F8B5) -------------------------------------------------------- |
2673 FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) | 2633 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
2674 { | 2634 { |
2675 FILE *result; // eax@1 | 2635 FILE *result; // eax@1 |
2676 FILE *pOutFile; // edi@4 | 2636 FILE *pOutFile; // edi@4 |
2677 unsigned short* v9; // eax@5 | 2637 unsigned short* v9; // eax@5 |
2678 int v10; // eax@7 | 2638 int v10; // eax@7 |
2784 fwrite(&pic_byte, 1, 1, pOutFile); | 2744 fwrite(&pic_byte, 1, 1, pOutFile); |
2785 } | 2745 } |
2786 v9 += width; | 2746 v9 += width; |
2787 } | 2747 } |
2788 free(lineRGB); | 2748 free(lineRGB); |
2789 result = (FILE *)fclose(pOutFile); | 2749 fclose(pOutFile); |
2790 } | 2750 } |
2791 return result; | |
2792 } | 2751 } |
2793 | 2752 |
2794 //----- (0049FBCD) -------------------------------------------------------- | 2753 //----- (0049FBCD) -------------------------------------------------------- |
2795 void Render::ClearTarget(unsigned int uColor) | 2754 void Render::ClearTarget(unsigned int uColor) |
2796 { | 2755 { |
2801 } | 2760 } |
2802 //else | 2761 //else |
2803 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | 2762 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); |
2804 } | 2763 } |
2805 | 2764 |
2806 //----- (0049FC23) -------------------------------------------------------- | |
2807 void Render::Release2() | |
2808 { | |
2809 Release(); | |
2810 bWindowMode = 1; | |
2811 } | |
2812 | 2765 |
2813 //----- (0049FC37) -------------------------------------------------------- | 2766 //----- (0049FC37) -------------------------------------------------------- |
2814 void Render::Present() | 2767 void Render::Present() |
2815 { | 2768 { |
2816 Render *v1; // esi@1 | 2769 Render *v1; // esi@1 |
3044 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | 2997 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) |
3045 { | 2998 { |
3046 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | 2999 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) |
3047 { | 3000 { |
3048 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | 3001 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) |
3049 if (src[x + y * src_pitch] != 0xFFF8FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) | 3002 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) |
3050 dst[x + y * dst_pitch] = src[x + y * src_pitch]; | 3003 dst[x + y * dst_pitch] = src[x + y * src_pitch]; |
3051 } | 3004 } |
3052 } | 3005 } |
3053 } | 3006 } |
3054 | 3007 |
4340 { | 4293 { |
4341 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | 4294 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) |
4342 pBackBuffer4->Restore(); | 4295 pBackBuffer4->Restore(); |
4343 } | 4296 } |
4344 | 4297 |
4345 //----- (004A1884) -------------------------------------------------------- | |
4346 void Render::PresentRect(RECT *a2, RECT *a3) | |
4347 { | |
4348 IDirectDrawSurface *pFront; // eax@3 | |
4349 HRESULT v4; // eax@5 | |
4350 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
4351 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
4352 DWORD v7; // [sp-14h] [bp-14h]@3 | |
4353 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
4354 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
4355 int v10; // [sp-8h] [bp-8h]@3 | |
4356 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
4357 | |
4358 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4359 { | |
4360 v11 = 0; | |
4361 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4362 v10 = 2657; | |
4363 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4364 v8 = 0; | |
4365 v7 = DDBLT_WAIT; | |
4366 v6 = a3; | |
4367 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4368 } | |
4369 /*else | |
4370 { | |
4371 v11 = 0; | |
4372 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4373 v10 = 2653; | |
4374 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
4375 v8 = 0; | |
4376 v7 = DDBLT_WAIT; | |
4377 v6 = a3; | |
4378 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4379 }*/ | |
4380 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
4381 } | |
4382 | |
4383 //----- (004A18F5) -------------------------------------------------------- | 4298 //----- (004A18F5) -------------------------------------------------------- |
4384 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | 4299 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) |
4385 { | 4300 { |
4386 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | 4301 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); |
4387 } | 4302 } |
4756 //v61 = pVertices; | 4671 //v61 = pVertices; |
4757 | 4672 |
4758 /* v9 = pGame->pLightmapBuilder; | 4673 /* v9 = pGame->pLightmapBuilder; |
4759 v65 = v9; | 4674 v65 = v9; |
4760 v10 = v9->std__vector_000004_size;*/ | 4675 v10 = v9->std__vector_000004_size;*/ |
4761 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) | 4676 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
4762 { | 4677 { |
4763 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | 4678 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
4764 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); | 4679 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); |
4765 } | 4680 } |
4766 else | 4681 else |
5392 if (GetTickCount() % 300 >= 150) | 5307 if (GetTickCount() % 300 >= 150) |
5393 uColor = sCorrectedColor = 0xFF20FF20; | 5308 uColor = sCorrectedColor = 0xFF20FF20; |
5394 else uColor = sCorrectedColor = 0xFF109010; | 5309 else uColor = sCorrectedColor = 0xFF109010; |
5395 } | 5310 } |
5396 | 5311 |
5397 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) | 5312 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
5398 { | 5313 { |
5399 __debugbreak(); | 5314 __debugbreak(); |
5400 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | 5315 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
5401 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | 5316 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
5402 for (uint i = 0; i < uNumVertices; ++i) | 5317 for (uint i = 0; i < uNumVertices; ++i) |
5578 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | 5493 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); |
5579 //v8 = dimming_level; | 5494 //v8 = dimming_level; |
5580 //v9 = v7; | 5495 //v9 = v7; |
5581 v28 = dimming_level & 0xFF000000; | 5496 v28 = dimming_level & 0xFF000000; |
5582 if ( dimming_level & 0xFF000000 ) | 5497 if ( dimming_level & 0xFF000000 ) |
5583 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; | 5498 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; |
5584 else | 5499 else |
5585 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; | 5500 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; |
5586 //v10 = a3; | 5501 //v10 = a3; |
5587 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | 5502 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; |
5588 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | 5503 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; |
5589 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; | 5504 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; |
5590 //v25 = pSoftBillboard->uScreenSpaceX; | 5505 //v25 = pSoftBillboard->uScreenSpaceX; |
5714 { | 5629 { |
5715 //v5 = (double)a2->zbuffer_depth; | 5630 //v5 = (double)a2->zbuffer_depth; |
5716 //v6 = v5; | 5631 //v6 = v5; |
5717 //v7 = v5; | 5632 //v7 = v5; |
5718 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | 5633 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
5719 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | 5634 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
5720 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | 5635 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5721 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | 5636 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
5722 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; | 5637 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
5723 //v9 = a2->uScreenSpaceX; | 5638 //v9 = a2->uScreenSpaceX; |
5724 //v10 = a2->uScreenSpaceY; | 5639 //v10 = a2->uScreenSpaceY; |
5887 { | 5802 { |
5888 v5 = (double)a2->zbuffer_depth; | 5803 v5 = (double)a2->zbuffer_depth; |
5889 v6 = v5; | 5804 v6 = v5; |
5890 v7 = v5; | 5805 v7 = v5; |
5891 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | 5806 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); |
5892 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | 5807 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; |
5893 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | 5808 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
5894 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | 5809 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
5895 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; | 5810 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
5896 v9 = a2->uScreenSpaceX; | 5811 v9 = a2->uScreenSpaceX; |
5897 v10 = a2->uScreenSpaceY; | 5812 v10 = a2->uScreenSpaceY; |
6107 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | 6022 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
6108 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | 6023 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
6109 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; | 6024 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; |
6110 | 6025 |
6111 if (a2->sTintColor & 0xFF000000) | 6026 if (a2->sTintColor & 0xFF000000) |
6112 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; | 6027 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; |
6113 else | 6028 else |
6114 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; | 6029 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; |
6115 } | 6030 } |
6116 | 6031 |
6117 | 6032 |
6118 //----- (004A49D0) -------------------------------------------------------- | 6033 //----- (004A49D0) -------------------------------------------------------- |
6119 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | 6034 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) |
6238 } | 6153 } |
6239 | 6154 |
6240 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | 6155 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); |
6241 pBillboardRenderListD3D[v5].field_90 = 0; | 6156 pBillboardRenderListD3D[v5].field_90 = 0; |
6242 pBillboardRenderListD3D[v5].sParentBillboardID = -1; | 6157 pBillboardRenderListD3D[v5].sParentBillboardID = -1; |
6243 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | 6158 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; |
6244 pBillboardRenderListD3D[v5].pTexture = 0; | 6159 pBillboardRenderListD3D[v5].pTexture = 0; |
6245 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | 6160 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; |
6246 pBillboardRenderListD3D[v5].z_order = depth; | 6161 pBillboardRenderListD3D[v5].z_order = depth; |
6247 | 6162 |
6248 for (uint i = 0; i < a1->uNumVertices; ++i) | 6163 for (uint i = 0; i < a1->uNumVertices; ++i) |
6494 } | 6409 } |
6495 } | 6410 } |
6496 } | 6411 } |
6497 } | 6412 } |
6498 | 6413 |
6499 //----- ( ) -------------------------------------------------------- | 6414 //----- (004A52F1) -------------------------------------------------------- |
6500 unsigned int Render::_4A52F1(unsigned int this_, float a3) | 6415 void Render::ScreenFade(unsigned int color, float t) |
6501 { | 6416 { |
6502 unsigned int v3; // esi@1 | 6417 unsigned int v3; // esi@1 |
6503 double v4; // st7@2 | 6418 //double v4; // st7@2 |
6504 double v5; // st7@6 | 6419 //double v5; // st7@6 |
6505 double v6; // st6@6 | 6420 double v6; // st6@6 |
6506 unsigned int v7; // eax@6 | 6421 unsigned int v7; // eax@6 |
6507 double v8; // st5@6 | 6422 double v8; // st5@6 |
6508 double v9; // st4@6 | 6423 double v9; // st4@6 |
6509 HRESULT v10; // eax@6 | 6424 HRESULT v10; // eax@6 |
6534 unsigned int v35; // [sp+8h] [bp-98h]@0 | 6449 unsigned int v35; // [sp+8h] [bp-98h]@0 |
6535 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | 6450 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 |
6536 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | 6451 unsigned int v37; // [sp+8Ch] [bp-14h]@7 |
6537 int v38; // [sp+90h] [bp-10h]@7 | 6452 int v38; // [sp+90h] [bp-10h]@7 |
6538 double v39; // [sp+94h] [bp-Ch]@6 | 6453 double v39; // [sp+94h] [bp-Ch]@6 |
6539 float v40; // [sp+9Ch] [bp-4h]@6 | 6454 int v40; // [sp+9Ch] [bp-4h]@6 |
6540 | 6455 |
6541 __debugbreak(); | |
6542 | |
6543 Render* ecx0 = this; | |
6544 v3 = 0; | 6456 v3 = 0; |
6545 | 6457 |
6546 if (!this->pRenderD3D) | |
6547 __debugbreak(); // sw render | |
6548 | |
6549 //{ | 6458 //{ |
6550 v4 = a3; | 6459 if (t > 1.0f) |
6551 if ( a3 <= 1.0 ) | 6460 t = 1.0f; |
6552 { | 6461 else if (t < 0.0f) |
6553 if ( v4 < 0.0 ) | 6462 t = 0.0f; |
6554 v4 = 0.0; | 6463 |
6555 } | 6464 v40 = (char)floorf(t * 255.0f + 0.5f); |
6556 else | 6465 //v5 = (double)(signed int)pViewport->uViewportTL_X; |
6557 { | 6466 v36[0].pos.x = pViewport->uViewportTL_X; |
6558 v4 = 1.0; | |
6559 } | |
6560 __debugbreak(); // banker's rounding again | |
6561 a3 = v4 * 255.0; | |
6562 v39 = a3 + 6.7553994e15; | |
6563 LODWORD(v40) = LODWORD(v39); | |
6564 v5 = (double)(signed int)pViewport->uViewportTL_X; | |
6565 v36[0].pos.x = v5; | |
6566 v6 = (double)(signed int)pViewport->uViewportTL_Y; | 6467 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
6567 v7 = this_ | (LODWORD(v39) << 24); | 6468 v7 = color | (v40 << 24); |
6568 this_ = pViewport->uViewportBR_Y + 1; | 6469 //this_ = pViewport->uViewportBR_Y + 1; |
6569 v36[0].specular = 0; | 6470 v36[0].specular = 0; |
6570 v36[0].pos.y = v6; | 6471 v36[0].pos.y = v6; |
6571 v36[0].diffuse = v7; | 6472 v36[0].diffuse = v7; |
6572 v36[1].diffuse = v7; | 6473 v36[1].diffuse = v7; |
6573 v36[0].pos.z = 0.0; | 6474 v36[0].pos.z = 0.0; |
6577 v36[1].specular = 0; | 6478 v36[1].specular = 0; |
6578 v36[0].texcoord.x = 0.0; | 6479 v36[0].texcoord.x = 0.0; |
6579 v36[2].specular = 0; | 6480 v36[2].specular = 0; |
6580 v36[3].specular = 0; | 6481 v36[3].specular = 0; |
6581 v36[0].texcoord.y = 0.0; | 6482 v36[0].texcoord.y = 0.0; |
6582 v36[1].pos.x = v5; | 6483 v36[1].pos.x = pViewport->uViewportTL_X; |
6583 v8 = (double)(pViewport->uViewportBR_Y + 1); | 6484 v8 = (double)(pViewport->uViewportBR_Y + 1); |
6584 v36[1].pos.y = v8; | 6485 v36[1].pos.y = v8; |
6585 v36[1].pos.z = 0.0; | 6486 v36[1].pos.z = 0.0; |
6586 v36[1].rhw = 1.0; | 6487 v36[1].rhw = 1.0; |
6587 v36[1].texcoord.x = 0.0; | 6488 v36[1].texcoord.x = 0.0; |
6704 v28 = v32 - 1; | 6605 v28 = v32 - 1; |
6705 } | 6606 } |
6706 while ( v32 != 1 ); | 6607 while ( v32 != 1 ); |
6707 } | 6608 } |
6708 }*/ | 6609 }*/ |
6709 return result; | |
6710 } | 6610 } |
6711 | 6611 |
6712 //----- (004A5B81) -------------------------------------------------------- | 6612 //----- (004A5B81) -------------------------------------------------------- |
6713 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) | 6613 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
6714 { | 6614 { |
6889 } | 6789 } |
6890 } | 6790 } |
6891 } | 6791 } |
6892 | 6792 |
6893 //----- (004A6E7E) -------------------------------------------------------- | 6793 //----- (004A6E7E) -------------------------------------------------------- |
6894 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | 6794 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) |
6895 { | 6795 { |
6896 //unsigned __int16 *v4; // eax@4 | 6796 //unsigned __int16 *v4; // eax@4 |
6897 int v5; // edx@4 | 6797 int v5; // edx@4 |
6898 unsigned int v6; // edi@4 | 6798 unsigned int v6; // edi@4 |
6899 unsigned int v7; // edx@5 | 6799 unsigned int v7; // edx@5 |
8683 | 8583 |
8684 }*/ | 8584 }*/ |
8685 | 8585 |
8686 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) | 8586 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) |
8687 { | 8587 { |
8688 if (pBillboardRenderListD3D[i].uOpacity != RenderBillboardD3D::NoBlend) | 8588 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) |
8689 SetBillboardBlendOptions(pBillboardRenderListD3D[i].uOpacity); | 8589 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); |
8690 | 8590 |
8691 | 8591 |
8692 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); | 8592 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); |
8693 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | 8593 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8694 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | 8594 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
9393 { | 9293 { |
9394 auto pixels = pRenderer->MakeScreenshot(150, 112); | 9294 auto pixels = pRenderer->MakeScreenshot(150, 112); |
9395 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | 9295 pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); |
9396 free(pixels); | 9296 free(pixels); |
9397 } | 9297 } |
9298 | |
9299 | |
9300 //----- (0046A7C8) -------------------------------------------------------- | |
9301 int Render::_46A6AC_spell_render_d3d(int a1, int a2, int a3) | |
9302 { | |
9303 unsigned int v3; // eax@2 | |
9304 unsigned int v5; // eax@2 | |
9305 unsigned int v6; // eax@4 | |
9306 int v10; // ecx@11 | |
9307 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
9308 int v15; // [sp+1Ch] [bp-8h]@1 | |
9309 unsigned int a1a; // [sp+20h] [bp-4h]@1 | |
9310 | |
9311 v15 = 0; | |
9312 v12 = GetBillboardDrawListSize(); | |
9313 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
9314 { | |
9315 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
9316 { | |
9317 v3 = GetParentBillboardID(a1a); | |
9318 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
9319 if ( PID_TYPE(v5) == OBJECT_Actor) | |
9320 { | |
9321 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) ) | |
9322 { | |
9323 v6 = PID_ID(v5); | |
9324 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed | |
9325 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) | |
9326 { | |
9327 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) ) | |
9328 { | |
9329 if ( v15 < a2 - 1 ) | |
9330 { | |
9331 __debugbreak();// *(int *)(a1 + 4 * v10) = v6; что это такое? | |
9332 v10 = v15++; | |
9333 *(int *)(a1 + 4 * v10) = v6; | |
9334 } | |
9335 } | |
9336 } | |
9337 } | |
9338 } | |
9339 } | |
9340 } | |
9341 return v15; | |
9342 } | |
9343 | |
9344 | |
9345 | |
9346 | |
9347 void Render::BeginLightmaps() | |
9348 { | |
9349 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9350 | |
9351 if (bUsingSpecular) | |
9352 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
9353 | |
9354 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9355 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9356 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9357 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9358 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9359 } | |
9360 | |
9361 void Render::EndLightmaps() | |
9362 { | |
9363 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9364 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9365 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9366 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9367 | |
9368 if (bUsingSpecular) | |
9369 { | |
9370 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9371 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
9372 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
9373 } | |
9374 } | |
9375 | |
9376 | |
9377 void Render::BeginLightmaps2() | |
9378 { | |
9379 if (bUsingSpecular) | |
9380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9381 | |
9382 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9383 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9384 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9385 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9386 | |
9387 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); | |
9388 | |
9389 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9390 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9391 } | |
9392 | |
9393 | |
9394 void Render::EndLightmaps2() | |
9395 { | |
9396 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9397 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9398 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9399 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9400 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9401 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9402 | |
9403 if (bUsingSpecular) | |
9404 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9405 } | |
9406 | |
9407 | |
9408 | |
9409 //----- (00437C96) -------------------------------------------------------- | |
9410 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
9411 { | |
9412 double v6; // st7@2 | |
9413 //IDirect3DDevice3 *v7; // eax@2 | |
9414 HRESULT v8; // eax@2 | |
9415 std::string v9; // [sp-18h] [bp-60h]@3 | |
9416 const char *v10; // [sp-Ch] [bp-54h]@2 | |
9417 const char *v11; // [sp-8h] [bp-50h]@2 | |
9418 int v12; // [sp-4h] [bp-4Ch]@2 | |
9419 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 | |
9420 | |
9421 //if ( pRenderer->pRenderD3D ) | |
9422 { | |
9423 v6 = 0.001 - z_stuff; | |
9424 memcpy(v13, pLineBegin, 0x20u); | |
9425 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
9426 v13[0].pos.z = v6; | |
9427 v13[1].pos.z = v6; | |
9428 v13[0].diffuse = sDiffuseBegin; | |
9429 v13[1].diffuse = sDiffuseEnd; | |
9430 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9431 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9432 D3DPT_LINELIST, | |
9433 452, | |
9434 v13, | |
9435 2, | |
9436 16)); | |
9437 } | |
9438 } | |
9439 | |
9440 | |
9441 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9442 { | |
9443 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9444 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
9445 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9446 (void *)vertices, | |
9447 num_vertices, | |
9448 D3DDP_DONOTLIGHT)); | |
9449 } | |
9450 | |
9451 | |
9452 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
9453 { | |
9454 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
9455 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
9456 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9457 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9458 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9459 | |
9460 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
9461 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9462 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9463 (void *)vertices, | |
9464 num_vertices, | |
9465 28)); | |
9466 | |
9467 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9470 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
9471 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9472 } | |
9473 | |
9474 | |
9475 void Render::BeginDecals() | |
9476 { | |
9477 // code chunk from 0049C304 | |
9478 if (bUsingSpecular) | |
9479 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9480 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
9481 | |
9482 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9483 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9484 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
9485 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9486 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9487 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9488 | |
9489 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); | |
9490 } | |
9491 | |
9492 | |
9493 void Render::EndDecals() | |
9494 { | |
9495 // code chunk from 0049C304 | |
9496 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
9497 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9498 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9499 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9500 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9501 | |
9502 if (bUsingSpecular) | |
9503 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
9504 } | |
9505 | |
9506 | |
9507 | |
9508 //----- (0049C095) -------------------------------------------------------- | |
9509 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
9510 { | |
9511 signed int v21; // [sp+Ch] [bp-864h]@15 | |
9512 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 | |
9513 | |
9514 if (pDecal->uNumVertices < 3) | |
9515 { | |
9516 Log::Warning(L"Decal has < 3 vertices"); | |
9517 return; | |
9518 } | |
9519 | |
9520 float color_mult; | |
9521 if ( pDecal->field_C1C & 1 ) | |
9522 color_mult = 1.0; | |
9523 else | |
9524 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
9525 | |
9526 for (uint i = 0; i < pDecal->uNumVertices; ++i) | |
9527 { | |
9528 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
9529 | |
9530 uint uTintR = (uTint >> 16) & 0xFF, | |
9531 uTintG = (uTint >> 8) & 0xFF, | |
9532 uTintB = uTint & 0xFF; | |
9533 | |
9534 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
9535 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
9536 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
9537 | |
9538 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
9539 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
9540 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
9541 | |
9542 | |
9543 float v15; | |
9544 if (fabs(z_bias) < 1e-5) | |
9545 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); | |
9546 else | |
9547 { | |
9548 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; | |
9549 if (v15 < 0.000099999997) | |
9550 v15 = 0.000099999997; | |
9551 } | |
9552 | |
9553 pVerticesD3D[i].pos.z = v15; | |
9554 | |
9555 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
9556 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
9557 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; | |
9558 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
9559 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
9560 pVerticesD3D[i].specular = 0; | |
9561 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
9562 } | |
9563 | |
9564 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9565 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
9566 else | |
9567 v21 = D3DDP_DONOTLIGHT; | |
9568 | |
9569 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9570 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9571 pVerticesD3D, | |
9572 pDecal->uNumVertices, | |
9573 v21)); | |
9574 } | |
9575 | |
9576 | |
9577 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
9578 { | |
9579 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
9580 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
9581 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9582 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9583 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9584 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
9585 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9586 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
9587 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
9588 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9589 (void *)vertices, 4, 28)); | |
9590 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
9591 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9592 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9593 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9594 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9595 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
9596 } |