port: GrpScreen verbatim 40250 (2d draws via UIRender, D3D8 shim device-lost/Present/ID3DXMesh)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 14:40:57 +09:00
co-authored by Claude Opus 5.5
parent d73f5ea4bd
commit b5d413afa6
7 changed files with 1125 additions and 323 deletions
+29
View File
@@ -20,7 +20,9 @@
#include "../../src/platform/ScriptLib/PythonHost.h"
#include "../../src/platform/UserInterface/UserInterface.h"
#include "../../src/platform/EterLib/UIRenderCommands.h"
#include "../../src/platform/EterLib/RenderCommands3D.h"
#include "EterLib/GrpScreen.h"
#include "EterLib/StateManager.h"
#include "EterPythonLib/PythonGraphic.h"
#include <dinput.h> // DIK_ESCAPE
@@ -289,6 +291,33 @@ int main(int argc, char** argv)
frames(1);
CHECK(py("assert not _stream.popupWindow.IsShow() and _popup_closed == [1]"));
// CScreen's 3D primitives (40250 GrpScreen.cpp, verbatim) go through the device's dynamic PDT stream:
// under a perspective projection RenderLine3d is one line-list draw, RenderBar3d a two-triangle strip,
// both in the current diffuse colour. The device is lost-free (TestCooperativeLevel is D3D_OK).
{
CScreen screen;
CHECK(!screen.IsLostDevice() && screen.RestoreDevice());
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovRH(&proj, D3DX_PI * 0.25f, 4.0f / 3.0f, 10.0f, 1000.0f);
CHECK(screen.Begin()); // CStateManager hands transforms to the device only inside the scene
STATEMANAGER.SaveTransform(D3DTS_PROJECTION, &proj);
Render3DBeginFrame();
screen.SetDiffuseColor(0.0f, 1.0f, 0.0f);
screen.RenderLine3d(0, 0, -100, 10, 0, -100);
screen.RenderBar3d(0, 0, -100, 10, 10, -100);
STATEMANAGER.RestoreTransform(D3DTS_PROJECTION);
screen.End();
const auto& draws = Render3DDraws();
CHECK(draws.size() == 2);
if (draws.size() == 2)
{
CHECK(draws[0].lines && draws[0].positions.size() == 6 && near(draws[0].positions[3], 10));
CHECK(!draws[1].lines && draws[1].positions.size() == 12);
CHECK(!draws[0].diffuse.empty() && draws[0].diffuse[0] == 0xFF00FF00u);
}
Render3DBeginFrame();
}
// ExpandedImageBox (CGraphicExpandedImageInstance::OnRender): scale + rendering rect, then rotation.
CHECK(py("import ui\n"
"_ex = ui.ExpandedImageBox()\n"