Decompile 4 functions in Source/Render/DX7/RendererDX7Operations.cpp, Source/Render/DX7/RendererFogDX7.cpp, ...
Batch #10458 by secret: 0 byte-identical, 4 confirmed by peer review. - fn_45495 CRendererDX7::FlushRenderList: logic confirmed by peer review - fn_45496 CRendererDX7::DrawTopmostQueue: logic confirmed by peer review - fn_45497 CRendererDX7::DrawBlendedQueue: logic confirmed by peer review - fn_02080 CRendererDX7::ApplyFog: logic confirmed by peer review Peer-reviewed-by: Yommy, KWDev, seumadruga Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
4852c57d98
commit
63cdd77f7f
5 changed files with 329 additions and 24 deletions
|
|
@ -115,5 +115,6 @@ static_assert(offsetof(DeviceOwnerDX7, alpha) == 0x01FC);
|
|||
#endif
|
||||
|
||||
extern DeviceOwnerDX7* g_deviceOwnerDX7;
|
||||
extern D3DDEVICEDESC7 g_emptyCapabilitiesDX7;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
#include "Render/DX7/RenderSystemDX7.h"
|
||||
#include "Contents/Configuration/ServiceOptions.h"
|
||||
#include "Render/BlendColor.h"
|
||||
#include "Render/DX7/DeviceOwnerDX7.h"
|
||||
#include "Render/DX7/QueuedDrawingDX7.h"
|
||||
#include "Render/Primitives/LightmappedPrimitive.h"
|
||||
#include "Render/Primitives/RenderPrimitive.h"
|
||||
#include "Render/RendererDX7.h"
|
||||
#include "Render/TextureQuad.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <cstdint>
|
||||
|
||||
// OFFSET: 0x0055EC10
|
||||
// FUNCTION: fn_02114
|
||||
|
|
@ -101,3 +106,288 @@ std::uint16_t DeviceOwnerDX7Handle::PackColor(int red, int green, int blue) cons
|
|||
(static_cast<std::uint16_t>(red >> owner->red.expansion) << owner->red.shift)
|
||||
);
|
||||
}
|
||||
|
||||
// OFFSET: 0x0055C110
|
||||
// FUNCTION: fn_45496
|
||||
void CRendererDX7::DrawTopmostQueue() {
|
||||
std::sort(this->queues.queue_021C.begin(), this->queues.queue_021C.end(), [](const DepthPrimitive& left, const DepthPrimitive& right) {
|
||||
if (left.depth < right.depth) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (right.depth < left.depth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return left.depth == right.depth && reinterpret_cast<std::uintptr_t>(left.primitive) < reinterpret_cast<std::uintptr_t>(right.primitive);
|
||||
});
|
||||
|
||||
for (auto it = this->queues.queue_021C.begin(); it != this->queues.queue_021C.end(); ++it) {
|
||||
RenderCommand* command = it->primitive;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x0055C1B0
|
||||
// FUNCTION: fn_45497
|
||||
void CRendererDX7::DrawBlendedQueue() {
|
||||
for (auto it = this->queues.queue_0210.begin(); it != this->queues.queue_0210.end(); ++it) {
|
||||
if (RenderCommand* command = *it) {
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
this->SetTextureMode(command->unknown_0020);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, command->unknown_0018);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, command->unknown_001C);
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
}
|
||||
|
||||
this->SetTextureMode(0);
|
||||
}
|
||||
|
||||
// OFFSET: 0x0055C270
|
||||
// FUNCTION: fn_45495
|
||||
void CRendererDX7::FlushRenderList() {
|
||||
const auto byDepth = [](const DepthPrimitive& left, const DepthPrimitive& right) {
|
||||
if (left.depth < right.depth) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (right.depth < left.depth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return left.depth == right.depth && reinterpret_cast<std::uintptr_t>(left.primitive) < reinterpret_cast<std::uintptr_t>(right.primitive);
|
||||
};
|
||||
|
||||
this->device->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
|
||||
this->ApplyFog();
|
||||
this->device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
this->device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
this->device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
this->device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGENABLE, this->fog.enabled);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 207);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE);
|
||||
this->DrawOpaqueQueues();
|
||||
this->device->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xFFFFFFFF);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW);
|
||||
|
||||
if (g_serviceOptions.Get(119)) {
|
||||
if (g_multitexture) {
|
||||
this->device->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
|
||||
this->device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATEALPHA_ADDCOLOR);
|
||||
std::sort(
|
||||
this->queues.lightmapped.first.begin(), this->queues.lightmapped.first.end(),
|
||||
[](const LightmappedPrimitive* left, const LightmappedPrimitive* right) {
|
||||
const auto first = reinterpret_cast<std::uintptr_t>(left->texture);
|
||||
const auto second = reinterpret_cast<std::uintptr_t>(right->texture);
|
||||
|
||||
if (first != second) {
|
||||
return first < second;
|
||||
}
|
||||
|
||||
return reinterpret_cast<std::uintptr_t>(left->lightmap) < reinterpret_cast<std::uintptr_t>(right->lightmap);
|
||||
}
|
||||
);
|
||||
|
||||
for (auto it = this->queues.lightmapped.first.begin(); it != this->queues.lightmapped.first.end(); ++it) {
|
||||
LightmappedPrimitive* command = *it;
|
||||
|
||||
if (command->vertexCount > 0) {
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
this->BindLightmap(static_cast<CTextureDX7*>(command->lightmap));
|
||||
command->DrawLightmapped(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
}
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);
|
||||
this->device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
} else {
|
||||
this->DrawGroundBaseQueue();
|
||||
this->device->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
|
||||
this->device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
this->device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 1);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA);
|
||||
std::sort(this->queues.queue_0174.begin(), this->queues.queue_0174.end(), [](const RenderCommand* left, const RenderCommand* right) {
|
||||
return reinterpret_cast<std::uintptr_t>(left->texture) < reinterpret_cast<std::uintptr_t>(right->texture);
|
||||
});
|
||||
|
||||
for (auto it = this->queues.queue_0174.begin(); it != this->queues.queue_0174.end(); ++it) {
|
||||
RenderCommand* command = *it;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);
|
||||
this->device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
this->device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 207);
|
||||
}
|
||||
} else {
|
||||
this->DrawGroundBaseQueue();
|
||||
}
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_AMBIENT, 0);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 1);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
||||
this->DrawAuxiliaryQueue();
|
||||
|
||||
DWORD fogEnable = 0;
|
||||
DWORD zWrite = 0;
|
||||
this->device->GetRenderState(D3DRENDERSTATE_FOGENABLE, &fogEnable);
|
||||
this->device->GetRenderState(D3DRENDERSTATE_ZWRITEENABLE, &zWrite);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
|
||||
this->DrawBlendedQueue();
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGENABLE, fogEnable);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, zWrite);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||
this->DrawTopmostQueue();
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
|
||||
|
||||
DWORD depthWrite = 0;
|
||||
DWORD alphaTest = 0;
|
||||
DWORD alphaReference = 0;
|
||||
DWORD alphaFunction = 0;
|
||||
this->device->GetRenderState(D3DRENDERSTATE_ZWRITEENABLE, &depthWrite);
|
||||
this->device->GetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, &alphaTest);
|
||||
this->device->GetRenderState(D3DRENDERSTATE_ALPHAREF, &alphaReference);
|
||||
this->device->GetRenderState(D3DRENDERSTATE_ALPHAFUNC, &alphaFunction);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 159);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, D3DCMP_GREATEREQUAL);
|
||||
this->DrawDepthSortedQueue();
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 159);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, D3DCMP_LESS);
|
||||
this->DrawDepthSortedQueue();
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, depthWrite);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, alphaTest);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, alphaReference);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, alphaFunction);
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
|
||||
std::sort(this->queues.queue_01C8.begin(), this->queues.queue_01C8.end(), byDepth);
|
||||
|
||||
for (auto it = this->queues.queue_01C8.begin(); it != this->queues.queue_01C8.end(); ++it) {
|
||||
RenderCommand* command = it->primitive;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
this->DrawAlphaQueues();
|
||||
|
||||
DWORD reference = 0;
|
||||
this->device->GetRenderState(D3DRENDERSTATE_ALPHAREF, &reference);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, 207);
|
||||
std::sort(this->queues.queue_0228.begin(), this->queues.queue_0228.end(), byDepth);
|
||||
|
||||
for (auto it = this->queues.queue_0228.begin(); it != this->queues.queue_0228.end(); ++it) {
|
||||
RenderCommand* command = it->primitive;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ALPHAREF, reference);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
|
||||
std::sort(this->queues.queue_01D4.begin(), this->queues.queue_01D4.end(), byDepth);
|
||||
|
||||
for (auto it = this->queues.queue_01D4.begin(); it != this->queues.queue_01D4.end(); ++it) {
|
||||
RenderCommand* command = it->primitive;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
|
||||
this->device->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
||||
|
||||
for (auto it = this->queues.queue_01EC.begin(); it != this->queues.queue_01EC.end(); ++it) {
|
||||
if (RenderCommand* command = *it) {
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
this->SetTextureMode(command->unknown_0020);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, command->unknown_0018);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, command->unknown_001C);
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
}
|
||||
|
||||
this->SetTextureMode(0);
|
||||
this->device->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
|
||||
std::sort(this->queues.queue_01E0.begin(), this->queues.queue_01E0.end(), byDepth);
|
||||
|
||||
for (auto it = this->queues.queue_01E0.begin(); it != this->queues.queue_01E0.end(); ++it) {
|
||||
RenderCommand* command = it->primitive;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
|
||||
for (auto it = this->queues.queue_0198.begin(); it != this->queues.queue_0198.end(); ++it) {
|
||||
RenderCommand* command = it->primitive;
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
|
||||
for (auto it = this->queues.queue_0234.begin(); it != this->queues.queue_0234.end(); ++it) {
|
||||
if (RenderCommand* command = it->primitive) {
|
||||
this->BindTexture(static_cast<CTextureDX7*>(command->texture));
|
||||
this->SetTextureMode(command->unknown_0020);
|
||||
|
||||
if (it->depth >= 0.99f) {
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
} else {
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, command->unknown_0018);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, command->unknown_001C);
|
||||
}
|
||||
|
||||
command->Draw(reinterpret_cast<int>(this->device));
|
||||
}
|
||||
}
|
||||
|
||||
this->SetTextureMode(0);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
this->device->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_NONE);
|
||||
}
|
||||
|
||||
// OFFSET: 0x0055ADA0
|
||||
bool CRendererDX7::Draw() {
|
||||
this->screenWidth = g_deviceOwnerDX7 ? g_deviceOwnerDX7->width : 0;
|
||||
this->screenHeight = g_deviceOwnerDX7 ? g_deviceOwnerDX7->height : 0;
|
||||
|
||||
if (SUCCEEDED(this->device->BeginScene())) {
|
||||
this->FlushRenderList();
|
||||
this->ClearFrame();
|
||||
this->device->EndScene();
|
||||
return true;
|
||||
} else {
|
||||
this->ClearFrame();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#include "Client/Application/ErrorDialog.h"
|
||||
#include "Render/TextureQuad.h"
|
||||
#include "Render/DX7/RendererFogDX7.h"
|
||||
#include "Render/DX7/DeviceOwnerDX7.h"
|
||||
#include "Render/DeviceContext/DCSurface.h"
|
||||
#include "Render/RendererDX7.h"
|
||||
|
||||
#include <bit>
|
||||
#include <cmath>
|
||||
|
|
@ -76,51 +79,54 @@ void RendererFogDX7::Set(int value, IDirect3DDevice7* device, const D3DDEVICEDES
|
|||
|
||||
// OFFSET: 0x0055A500
|
||||
// FUNCTION: fn_02080
|
||||
void RendererFogDX7::Apply(
|
||||
IDirect3DDevice7* device, const D3DDEVICEDESC7& caps, float aspect, CRenderSystemBase* renderSystem
|
||||
) {
|
||||
if (!this->dirty) {
|
||||
void CRendererDX7::ApplyFog() {
|
||||
if (!this->fog.dirty) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->enabled) {
|
||||
if (this->fog.enabled) {
|
||||
D3DDEVICEDESC7 empty = g_emptyCapabilitiesDX7;
|
||||
const D3DDEVICEDESC7 caps = g_deviceOwnerDX7 ? g_deviceOwnerDX7->caps : empty;
|
||||
const float start = g_depthStart * 1490.0f + 10.0f;
|
||||
const float end = g_depthEnd * 1490.0f + 10.0f;
|
||||
const bool vertexFog = (caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0;
|
||||
D3DMATRIX identity{};
|
||||
identity._11 = identity._22 = identity._33 = identity._44 = 1;
|
||||
D3DMATRIX projection;
|
||||
PerspectiveMatrixDX7(projection, 0.26179934f, aspect, 10.0f, 1500.0f);
|
||||
device->SetTransform(D3DTRANSFORMSTATE_WORLD, &identity);
|
||||
device->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &projection);
|
||||
device->SetTransform(D3DTRANSFORMSTATE_VIEW, &identity);
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGCOLOR, g_worldOverlayColor);
|
||||
PerspectiveMatrixDX7(projection, 0.26179934f, this->viewport.aspect, 10.0f, 1500.0f);
|
||||
this->device->SetTransform(D3DTRANSFORMSTATE_WORLD, &identity);
|
||||
this->device->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &projection);
|
||||
this->device->SetTransform(D3DTRANSFORMSTATE_VIEW, &identity);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGCOLOR, g_worldOverlayColor);
|
||||
|
||||
if (g_fogVertexMode == D3DFOG_LINEAR) {
|
||||
if (vertexFog) {
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGSTART, std::bit_cast<unsigned>(start));
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGEND, std::bit_cast<unsigned>(end));
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGDENSITY, std::bit_cast<unsigned>(g_fogDensity));
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE);
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE, g_fogVertexMode);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGSTART, std::bit_cast<unsigned>(start));
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGEND, std::bit_cast<unsigned>(end));
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGDENSITY, std::bit_cast<unsigned>(g_fogDensity));
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE, g_fogVertexMode);
|
||||
} else {
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
|
||||
}
|
||||
} else {
|
||||
if (vertexFog) {
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE);
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE, g_fogVertexMode);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE, g_fogVertexMode);
|
||||
} else {
|
||||
ShowErrorDialog(renderSystem, "Your graphic accelerator does not support fog effect.", 0);
|
||||
ShowErrorDialog(GetRenderSystemHolder()->system, "Your graphic accelerator does not support fog effect.", 0);
|
||||
}
|
||||
|
||||
device->SetRenderState(D3DRENDERSTATE_FOGDENSITY, std::bit_cast<unsigned>(g_fogDensity));
|
||||
this->device->SetRenderState(D3DRENDERSTATE_FOGDENSITY, std::bit_cast<unsigned>(g_fogDensity));
|
||||
}
|
||||
|
||||
if (vertexFog && g_fogRange) {
|
||||
device->SetRenderState(D3DRENDERSTATE_RANGEFOGENABLE, 1);
|
||||
this->device->SetRenderState(D3DRENDERSTATE_RANGEFOGENABLE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this->dirty = 0;
|
||||
this->fog.dirty = 0;
|
||||
}
|
||||
|
||||
// GLOBAL: gl_24699
|
||||
D3DDEVICEDESC7 g_emptyCapabilitiesDX7;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ struct RendererFogDX7 {
|
|||
/* 0158 */ int supported;
|
||||
|
||||
void Set(int value, IDirect3DDevice7* device, const D3DDEVICEDESC7& caps);
|
||||
void Apply(IDirect3DDevice7* device, const D3DDEVICEDESC7& caps, float aspect, CRenderSystemBase* renderSystem);
|
||||
};
|
||||
|
||||
static_assert(sizeof(RendererFogDX7) == 12);
|
||||
|
|
|
|||
|
|
@ -22,10 +22,13 @@ public:
|
|||
/* 026C */ CTextureDX7* boundLightmap;
|
||||
/* 0270 */ unsigned clearColor;
|
||||
/* 0274 */ IDirect3DDevice7* device;
|
||||
/* 0278 */ unsigned char unknown_0278[0xC];
|
||||
/* 0278 */ unsigned char unknown_0278[4];
|
||||
/* 027C */ unsigned screenWidth;
|
||||
/* 0280 */ unsigned screenHeight;
|
||||
|
||||
void SetCamera(const float* eye, const float* target, const float* up) override;
|
||||
void SetClearColor(unsigned color) override;
|
||||
bool Draw() override;
|
||||
|
||||
void SetTextureFormat(unsigned format);
|
||||
void SetLighting(const float* direction, const float* diffuse, const float* ambient);
|
||||
|
|
@ -47,6 +50,10 @@ public:
|
|||
void DrawOpaqueQueues();
|
||||
void DrawGroundBaseQueue();
|
||||
void DrawAuxiliaryQueue();
|
||||
void ApplyFog();
|
||||
void DrawTopmostQueue();
|
||||
void DrawBlendedQueue();
|
||||
void FlushRenderList();
|
||||
// INLINED
|
||||
void BindTexture(CTextureDX7* texture);
|
||||
// INLINED
|
||||
|
|
@ -59,6 +66,8 @@ static_assert(offsetof(CRendererDX7, clearColor) == 0x0270);
|
|||
static_assert(offsetof(CRendererDX7, boundTexture) == 0x0268);
|
||||
static_assert(offsetof(CRendererDX7, boundLightmap) == 0x026C);
|
||||
static_assert(offsetof(CRendererDX7, device) == 0x0274);
|
||||
static_assert(offsetof(CRendererDX7, screenWidth) == 0x027C);
|
||||
static_assert(offsetof(CRendererDX7, screenHeight) == 0x0280);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue