The C# analog of CreatureMode::Render: draws one re-dressed player clone into a private FBO (RGBA8 + depth24-stencil8) with the fixed DollCamera + one distant light (retail 0.3,1.9,0.65 @ 2.0), sealed in a GLStateScope so it can't disturb world/UI GL state. frustum:null ⇒ the doll's synthetic landblock is always visible ⇒ walked from entry.Entities and drawn from its current MeshRefs (static pose; idle animation is a later slice). Manages the FBO directly via GL (ManagedGLFramebuffer is unused/bitrotted WB infra). UiViewport blit flips V (FBO bottom-left origin vs UI top-left) so the doll isn't upside-down. Not yet wired — GameWindow hook is next. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
1.3 KiB
C#
27 lines
1.3 KiB
C#
using System.Numerics;
|
|
|
|
namespace AcDream.App.UI;
|
|
|
|
/// <summary>Leaf widget for dat Type 0xD (UIElement_Viewport). Blits the texture produced by its
|
|
/// IUiViewportRenderer (run in the pre-UI hook) as a single sprite at its own rect. The 3-D render
|
|
/// does NOT happen here (OnDraw only has a 2-D context).</summary>
|
|
public sealed class UiViewport : UiElement
|
|
{
|
|
public override bool ConsumesDatChildren => true;
|
|
|
|
/// <summary>Renderer that produces the off-screen texture. Set by GameWindow wiring (later task).</summary>
|
|
public IUiViewportRenderer? Renderer { get; set; }
|
|
|
|
/// <summary>Last GL color-texture handle produced by the pre-UI hook. 0 = nothing to blit.</summary>
|
|
public uint TextureHandle { get; set; }
|
|
|
|
protected override void OnDraw(UiRenderContext ctx)
|
|
{
|
|
if (!Visible || TextureHandle == 0) return;
|
|
// Local origin is already at this widget's Left/Top (PushTransform applied by DrawSelfAndChildren).
|
|
// V is FLIPPED (v0=1, v1=0): TextureHandle is an off-screen FBO color texture, whose origin is
|
|
// bottom-left (GL), while the UI sprite convention is top-left. Without the flip the doll renders
|
|
// upside-down. (If the doll appears upside-down at the visual gate, this is the line to revisit.)
|
|
ctx.DrawSprite(TextureHandle, 0f, 0f, Width, Height, 0f, 1f, 1f, 0f, Vector4.One);
|
|
}
|
|
}
|