Batch #2457 by ragnarok-clanker: 0 byte-identical, 48 confirmed by peer review. - fn_00152 TextureCache::TextureCache: logic confirmed by peer review - fn_01952 DrawAlphaRectangle: logic confirmed by peer review - fn_01953 DrawBlendedRectangle: logic confirmed by peer review - fn_01954 DrawTexturedRectangle: logic confirmed by peer review - fn_01955 DrawTextureRegion: logic confirmed by peer review - fn_02237 CRendererDX9::SaveLogo: logic confirmed by peer review - fn_02353 CRenderSystemDX9::CRenderSystemDX9: logic confirmed by peer review - fn_02447 TextureCache::~TextureCache: logic confirmed by peer review (already on main) - fn_02449 TextureCache::Upload: logic confirmed by peer review - fn_02451 TextureCache::Clear: logic confirmed by peer review (already on main) - fn_02452 TextureCache::Remove: logic confirmed by peer review (already on main) - fn_02453 TextureCache::Default: logic confirmed by peer review - fn_02454 TextureCache::Load: logic confirmed by peer review (already on main) - fn_02455 TextureCache::Create: logic confirmed by peer review - fn_02456 TextureCache::Reload: logic confirmed by peer review - fn_02457 TextureCache::ClearUnused: logic confirmed by peer review - fn_07897 EZeffectClip::Texture: logic confirmed by peer review - fn_07898 EZeffectClip::Texture: logic confirmed by peer review - fn_07958 C3dAnimModelRes::Load: logic confirmed by peer review - fn_07996 ModelNode::~ModelNode: logic confirmed by peer review - fn_08010 C3dGrannyModelRes::CreateTexture: logic confirmed by peer review - fn_08020 C3dModelResV2::ReadVersion1: logic confirmed by peer review - fn_08021 C3dModelResV2::ReadVersion2: logic confirmed by peer review - fn_08022 C3dModelResV2::ReadVersion3: logic confirmed by peer review - fn_09166 BinkMovies::Update: logic confirmed by peer review - fn_10122 UIRPData::DrawNamed: logic confirmed by peer review - fn_12091 UIWhisperWnd::Slot43: logic confirmed by peer review - fn_17556 GroundGeometry::Build: logic confirmed by peer review - fn_17565 GroundGeometry::BuildLightmaps: logic confirmed by peer review - fn_17581 GroundWaterState::Update: logic confirmed by peer review - fn_17587 GroundGeometry::DrawGrid: logic confirmed by peer review - fn_17599 GroundWaterState::Import: logic confirmed by peer review - fn_17842 ModeFade::Draw: logic confirmed by peer review - fn_17847 FadeOutMode: logic confirmed by peer review - fn_20019 CRagEffect::Blessing: logic confirmed by peer review - fn_20023 CRagEffect::Bottom: logic confirmed by peer review - fn_20024 CRagEffect::BowlingBash: logic confirmed by peer review - fn_20025 CRagEffect::CartRevolution: logic confirmed by peer review - fn_20042 CRagEffect::Entry: logic confirmed by peer review - fn_20054 CRagEffect::FrostDiver: logic confirmed by peer review - fn_20058 CRagEffect::GrimTooth: logic confirmed by peer review - fn_20066 CRagEffect::Hit4: logic confirmed by peer review - fn_20088 UpdatePartyEffect: logic confirmed by peer review - fn_20105 CRagEffect::SonicBlowHit: logic confirmed by peer review - fn_20109 CRagEffect::SprayPond: logic confirmed by peer review - fn_20124 CRagEffect::Yufitel: logic confirmed by peer review - fn_20132 CRagEffect::AirTexture: logic confirmed by peer review - fn_20133 CRagEffect::AttackEnergy2: logic confirmed by peer review Reviewed-by: ragnarok-clanker
163 lines
5.7 KiB
C++
163 lines
5.7 KiB
C++
#include "Render/DX9/DeviceOwnerDX9.h"
|
|
#include "Render/DX9/RendererDX9.h"
|
|
#include "Render/DX9/RendererFrameDX9.h"
|
|
#include "Render/Textures/TextureCache.h"
|
|
#include "Resource/Bitmap/BitmapResource.h"
|
|
#include "Resource/TextureNames.h"
|
|
|
|
#include <memory>
|
|
|
|
// OFFSET: 0x00564EB0
|
|
// FUNCTION: fn_02209
|
|
CRendererDX9::CRendererDX9(DeviceOwnerDX9& owner, RendererDX9Context& context)
|
|
: CRenderer(context.system), device(&owner), nativeDevice(owner.device), clearColor(0), lastTick(0), frames(0), fps(0.0f), m_context(&context),
|
|
m_textureContext(owner.TextureContext(context.d3dx, this->primitives, this->queues, false, context.fog.start, context.fog.end)) {
|
|
}
|
|
|
|
// OFFSET: 0x00564FE0
|
|
// OFFSET: 0x00565070
|
|
// FUNCTION: fn_02210
|
|
CRendererDX9::~CRendererDX9() = default;
|
|
|
|
TextureDX9Context& CRendererDX9::TextureContext() {
|
|
this->m_textureContext.dynamicTextures = this->device->dynamicTextures;
|
|
this->m_textureContext.depthAlpha = this->fog.supported != 0;
|
|
this->m_textureContext.depthStart = this->m_context->fog.start;
|
|
this->m_textureContext.depthEnd = this->m_context->fog.end;
|
|
|
|
return this->m_textureContext;
|
|
}
|
|
|
|
RendererDX9Operations CRendererDX9::Operations(TextureDX9Context& context) {
|
|
context.device = this->nativeDevice;
|
|
return {context, this->device->state};
|
|
}
|
|
|
|
void CRendererDX9::SetCamera(const float* eye, const float* target, const float* up) {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).SetCamera(eye, target, up);
|
|
}
|
|
|
|
void CRendererDX9::SetLighting(const float* direction, const float* diffuse, const float* ambient) {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).SetLighting(direction, diffuse, ambient);
|
|
}
|
|
|
|
// OFFSET: 0x00568360
|
|
// FUNCTION: fn_02238
|
|
void CRendererDX9::SetClearColor(unsigned color) {
|
|
this->clearColor = color;
|
|
}
|
|
|
|
void CRendererDX9::SetFog(int enabled) {
|
|
this->fog.Set(enabled, this->device->caps, this->m_context->fog);
|
|
}
|
|
|
|
void CRendererDX9::ClearDepth(int clearColor) {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).ClearDepth(clearColor);
|
|
}
|
|
|
|
void CRendererDX9::ClearWorld() {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).ClearWorld(this->clearColor, this->fog.enabled, this->m_context->worldFlag, this->m_context->overlayColor);
|
|
}
|
|
|
|
bool CRendererDX9::Draw() {
|
|
auto& context = this->TextureContext();
|
|
auto operations = this->Operations(context);
|
|
RendererFrameDX9 frame{*this->device, operations, this->commands, this->primitives,
|
|
this->lightmapped, this->vertices, this->queues, this->m_context->retirement};
|
|
|
|
return frame.Draw(
|
|
&this->m_context->system, this->m_context->options, this->m_context->multitexture, this->twoPass, this->fog, this->viewport.aspect, this->m_context->fog
|
|
);
|
|
}
|
|
|
|
HRESULT CRendererDX9::Present(int option) {
|
|
RendererPresentation presentation{this->frame, this->lastTick, this->frames, this->fps, this->m_context->diagnostic};
|
|
return presentation.Present(*this->device, option);
|
|
}
|
|
|
|
// OFFSET: 0x00567E70
|
|
// FUNCTION: fn_02231
|
|
float CRendererDX9::FPS() const {
|
|
return this->fps;
|
|
}
|
|
|
|
bool CRendererDX9::CaptureBackBuffer() {
|
|
return this->device->CaptureBackBuffer();
|
|
}
|
|
|
|
bool CRendererDX9::RestoreBackBuffer() {
|
|
return this->device->RestoreBackBuffer();
|
|
}
|
|
|
|
// OFFSET: 0x00565860
|
|
// FUNCTION: fn_02220
|
|
void CRendererDX9::DrawAuxiliaryPrimitive(LightmappedPrimitive* primitive) {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).DrawLightmappedPrimitive(primitive);
|
|
}
|
|
|
|
void CRendererDX9::DrawLightmappedPrimitive(LightmappedPrimitive* primitive) {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).DrawLightmappedPrimitive(primitive);
|
|
}
|
|
|
|
void CRendererDX9::DrawPrimitive(RenderCommand* primitive) {
|
|
auto& context = this->TextureContext();
|
|
this->Operations(context).DrawPrimitive(primitive);
|
|
}
|
|
|
|
bool CRendererDX9::RenderToTexture(int width, int height, const std::list<RenderPrimitive*>& primitives, CTexture*& texture) {
|
|
auto& context = this->TextureContext();
|
|
return this->Operations(context).RenderToTexture(width, height, primitives, texture);
|
|
}
|
|
|
|
bool CRendererDX9::SaveBitmapResource(const char* filename, int format, CBitmapRes* bitmap) {
|
|
std::unique_ptr<CTexture> overlay;
|
|
|
|
if (bitmap) {
|
|
const auto& image = bitmap->image;
|
|
overlay.reset(g_texMgr.Upload(image.width, image.height, image.pixels, image.alpha != 0, 0, false, false, false));
|
|
}
|
|
|
|
auto& context = this->TextureContext();
|
|
return this->Operations(context).SaveScreenshot(*this->device, &this->m_context->system, filename, format, overlay.get(), nullptr);
|
|
}
|
|
|
|
// OFFSET: 0x00567FC0
|
|
// FUNCTION: fn_02234
|
|
bool CRendererDX9::SaveBitmap(const char* filename, CBitmapRes* overlay) {
|
|
return this->SaveBitmapResource(filename, 0, overlay);
|
|
}
|
|
|
|
// OFFSET: 0x00568030
|
|
// FUNCTION: fn_02235
|
|
bool CRendererDX9::SaveJpeg(const char* filename, CBitmapRes* overlay) {
|
|
return this->SaveBitmapResource(filename, 1, overlay);
|
|
}
|
|
|
|
// OFFSET: 0x00568EC0
|
|
// FUNCTION: fn_02242
|
|
void CRendererDX9::CleanupTextures() {
|
|
}
|
|
|
|
// OFFSET: 0x005682D0
|
|
// FUNCTION: fn_02237
|
|
bool CRendererDX9::SaveLogo(std::string filename) {
|
|
const char* name = Resolve("scr_logo.bmp");
|
|
CTexture* overlay = g_texMgr.Load(name, 0, false, true, false);
|
|
auto& context = this->TextureContext();
|
|
|
|
return this->Operations(context).SaveScreenshot(*this->device, &this->m_context->system, filename.c_str(), 1, overlay, nullptr);
|
|
}
|
|
|
|
void CRendererDX9::Submit(RenderCommand* command, std::uint16_t flags) {
|
|
this->queues.Submit(command, flags, this->fog.supported != 0, this->m_context->fog.start, this->m_context->fog.end);
|
|
}
|
|
|
|
void CRendererDX9::Submit(LightmappedPrimitive* command, int queue) {
|
|
this->queues.lightmapped.Submit(command, queue, this->fog.supported != 0, this->m_context->fog.start, this->m_context->fog.end);
|
|
}
|