feat(ww3d2): add IRenderBackend Interface#2613
feat(ww3d2): add IRenderBackend Interface#2613bobtista wants to merge 4 commits intoTheSuperHackers:mainfrom
Conversation
5e014bf to
e648a3e
Compare
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h | New abstract interface; clean forward-declaration strategy, documented C++98 constraints, #pragma once, GPL header, and nullptr-based destructor all correct. |
| Core/Libraries/Source/WWVegas/WW3D2/DX8Backend.h | Concrete adapter declaration; correctly inherits IRenderBackend, uses #pragma once, and mirrors the interface with virtual for C++98 compatibility. |
| Core/Libraries/Source/WWVegas/WW3D2/DX8Backend.cpp | Pure one-line trampolines to DX8Wrapper statics; Set_Viewport correctly converts RenderBackendViewport fields (types match D3DVIEWPORT8 exactly), shader handle casts to DWORD are safe on Windows. |
| Core/Libraries/Source/WWVegas/WW3D2/RenderBackend.h | Minimal accessor header; extern IRenderBackend * g_renderBackend declaration and two lifecycle function prototypes are correct, #pragma once and GPL header present. |
| Core/Libraries/Source/WWVegas/WW3D2/RenderBackend.cpp | Lifecycle management is correct; double-init guard and null-check on shutdown are both sound, nullptr used throughout. |
| Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Adds Init_Render_Backend() at end of Do_Onetime_Device_Dependent_Inits and Shutdown_Render_Backend() at top of Do_Onetime_Device_Dependent_Shutdowns; ordering is correct to ensure backend is torn down before D3D device release. |
| Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt | Adds all five new source/header files to WW3D2_SRC in alphabetically consistent positions. |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class IRenderBackend {
<<abstract>>
+Is_Device_Lost() bool
+Has_Stencil() bool
+Get_Back_Buffer_Format() WW3DFormat
+Begin_Scene() void
+End_Scene(flip_frame) void
+Clear(...) void
+Set_Viewport(viewport) void
+Set_Shader(shader) void
+Set_Texture(stage, texture) void
+Set_Transform(kind, m) void
+Set_Light(index, light) void
+Draw_Triangles(...) void
+Set_Vertex_Shader(vs) void
+Create_Render_Target(...) TextureClass*
+~IRenderBackend() void
}
class DX8Backend {
+DX8Backend()
+~DX8Backend()
... all IRenderBackend methods
}
class DX8Wrapper {
<<static facade>>
+Do_Onetime_Device_Dependent_Inits()$
+Do_Onetime_Device_Dependent_Shutdowns()$
}
class RenderBackend {
<<global owner>>
+g_renderBackend IRenderBackend*
+Init_Render_Backend() void
+Shutdown_Render_Backend() void
}
IRenderBackend <|-- DX8Backend : implements
DX8Backend --> DX8Wrapper : forwards all calls
RenderBackend --> DX8Backend : constructs / owns
DX8Wrapper --> RenderBackend : Init/Shutdown calls
Reviews (3): Last reviewed commit: "fix(ww3d2): Update copyright headers to ..." | Re-trigger Greptile
Summary
First PR in a planned multi-step refactor introducing an
IRenderBackendinterface in WW3D2. This PR adds only the scaffolding — interface, adapter, lifecycle wiring, and one isolated proof-of-concept call site. zero behavior change. The DX8 path remains the only renderer;g_renderBackendis constructed as aDX8Backendthat forwards every method to the existingDX8Wrapperstatic facade.What this PR adds
IRenderBackend.h— abstract interface covering the W3D-facing subset ofDX8Wrapper's public API. Only high-level methods (those takingShaderClass/TextureBaseClass/Matrix4x4/etc.) are virtualized. D3D8-typed low-level methods stay onDX8WrapperasDX8Backend-specific escape hatches — see the doc for the rationale.DX8Backend.{h,cpp}— concrete adapter that forwards every virtual method to the existingDX8Wrapper::static functions. Pure forwarding, no new rendering logic.RenderBackend.{h,cpp}— exposes the globalIRenderBackend* g_renderBackend.Init_Render_Backend()constructsnew DX8Backend()fromDX8Wrapper::Do_Onetime_Device_Dependent_Inits();Shutdown_Render_Backend()tears it down fromDX8Wrapper::Do_Onetime_Device_Dependent_Shutdowns().Test plan