rodecomp/Source/Render/RendererDX7Operations.cpp
2026-10-24 00:35:19 +00:00

85 lines
2.5 KiB
C++

#include "Render/BlendColor.h"
#include "Render/DeviceOwnerDX7.h"
#include "Render/LightmappedPrimitive.h"
#include "Render/RenderPrimitive.h"
#include "Render/RendererDX7Operations.h"
#include <bit>
// OFFSET: 0x0055EC10
// FUNCTION: fn_02114
void RendererDX7Operations::SetLighting(const float* direction, const float* diffuse, const float* ambient) {
D3DLIGHT7 light{};
light.dltType = D3DLIGHT_DIRECTIONAL;
light.dvDirection.x = -direction[0];
light.dvDirection.y = -direction[1];
light.dvDirection.z = -direction[2];
light.dcvDiffuse.r = diffuse[0];
light.dcvDiffuse.g = diffuse[1];
light.dcvDiffuse.b = diffuse[2];
light.dcvDiffuse.a = 255.0f;
light.dcvAmbient.r = ambient[0];
light.dcvAmbient.g = ambient[1];
light.dcvAmbient.b = ambient[2];
light.dcvAmbient.a = 255.0f;
this->device->SetLight(0, &light);
this->device->LightEnable(0, TRUE);
}
// OFFSET: 0x0055A210
// FUNCTION: fn_02077
void RendererDX7Operations::ClearDepth(int clearColor) {
if (clearColor) {
this->owner.Clear(0xFF000000);
} else {
this->owner.ClearDepth();
}
}
// OFFSET: 0x0055A240
// FUNCTION: fn_02078
void RendererDX7Operations::ClearWorld(unsigned color, int mode, unsigned char worldFlag, unsigned overlay) {
if (mode != 0 && worldFlag == 1) {
color = BlendColor(color, overlay);
}
this->owner.Clear(color);
}
// OFFSET: 0x0055ACB0
// FUNCTION: fn_02082
void RendererDX7Operations::DrawPrimitive(RenderCommand* primitive) {
if (std::bit_cast<int>(primitive->vertexCount) <= 0) {
return;
}
const auto type = static_cast<D3DPRIMITIVETYPE>(primitive->primitiveType);
if (primitive->indexCount) {
this->device->DrawIndexedPrimitive(
type, 452, primitive->vertices, primitive->vertexCount, primitive->indices, primitive->indexCount, 0
);
} else {
this->device->DrawPrimitive(type, 452, primitive->vertices, primitive->vertexCount, 0);
}
}
// OFFSET: 0x0055AD00
// FUNCTION: fn_02083
// OFFSET: 0x0055AD50
// FUNCTION: fn_02084
void RendererDX7Operations::DrawLightmappedPrimitive(LightmappedPrimitive* primitive) {
if (std::bit_cast<int>(primitive->vertexCount) <= 0) {
return;
}
const auto type = static_cast<D3DPRIMITIVETYPE>(primitive->primitiveType);
if (primitive->indexCount) {
this->device->DrawIndexedPrimitive(
type, 708, primitive->vertices, primitive->vertexCount, primitive->indices, primitive->indexCount, 0
);
} else {
this->device->DrawPrimitive(type, 708, primitive->vertices, primitive->vertexCount, 0);
}
}