88#include " Runtime/Graphics/CGX.hpp"
99
1010#include < zeus/Math.hpp>
11+ #include < dolphin/gx.h>
1112
1213namespace metaforce {
1314CGraphics::CProjectionState CGraphics::g_Proj;
@@ -190,12 +191,21 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
190191 const auto oldProj = g_Proj;
191192 const auto oldCull = g_cullMode;
192193 const auto oldLights = g_LightActive;
193- SetOrtho (-g_Viewport.x10_halfWidth , g_Viewport.x10_halfWidth , g_Viewport.x14_halfHeight , -g_Viewport.x14_halfHeight ,
194- -1 . f , - 10 .f );
194+ SetOrtho (-g_Viewport.x8_width / 2 , g_Viewport.x8_width / 2 , g_Viewport.xc_height / 2 , -g_Viewport.xc_height / 2 , - 1 . f ,
195+ -10 .f );
195196 GXLoadPosMtxImm (&zeus::skIdentityMatrix4f, GX_PNMTX0);
196- DisableAllLights ();
197+ GXVtxDescList desc[] = {
198+ {GX_VA_POS, GX_DIRECT},
199+ {GX_VA_CLR0, GX_DIRECT},
200+ {GX_VA_TEX0, GX_DIRECT},
201+ {GX_VA_NULL, GX_NONE},
202+ };
203+ CGX::SetVtxDescv (desc);
204+ SetTevStates (6 );
205+ if (g_LightActive.any ()) {
206+ DisableAllLights ();
207+ }
197208 SetCullMode (ERglCullMode::None);
198- tex.Load (GX_TEXMAP0, EClampMode::Repeat);
199209
200210 // float hPad, vPad;
201211 // if (CGraphics::GetViewportAspect() >= 1.78f) {
@@ -211,23 +221,32 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
211221 float scaledW = static_cast <float >(w) / 640 .f * static_cast <float >(g_Viewport.x8_width );
212222 float scaledH = static_cast <float >(h) / 448 .f * static_cast <float >(g_Viewport.xc_height );
213223
214- float x1 = scaledX - g_Viewport.x10_halfWidth ;
215- float y1 = scaledY - g_Viewport.x14_halfHeight ;
224+ float x1 = scaledX - ( g_Viewport.x8_width / 2 ) ;
225+ float y1 = scaledY - ( g_Viewport.xc_height / 2 ) ;
216226 float x2 = x1 + scaledW;
217227 float y2 = y1 + scaledH;
218- StreamBegin (GX_TRIANGLESTRIP);
219- StreamColor (col);
220- StreamTexcoord (0 .f , 0 .f );
221- StreamVertex (x1, y1, 1 .f );
222- StreamTexcoord (1 .f , 0 .f );
223- StreamVertex (x2, y1, 1 .f );
224- StreamTexcoord (0 .f , 1 .f );
225- StreamVertex (x1, y2, 1 .f );
226- StreamTexcoord (1 .f , 1 .f );
227- StreamVertex (x2, y2, 1 .f );
228- StreamEnd ();
229228
230- SetLightState (g_LightActive);
229+ tex.Load (GX_TEXMAP0, EClampMode::Repeat);
230+ CGX::Begin (GX_TRIANGLESTRIP, GX_VTXFMT0, 4 );
231+ {
232+ GXPosition3f32 (x1, y1, 1 .f );
233+ GXColor4f32 (col.r (), col.g (), col.b (), col.a ());
234+ GXTexCoord2f32 (0 .f , 0 .f );
235+ GXPosition3f32 (x2, y1, 1 .f );
236+ GXColor4f32 (col.r (), col.g (), col.b (), col.a ());
237+ GXTexCoord2f32 (1 .f , 0 .f );
238+ GXPosition3f32 (x1, y2, 1 .f );
239+ GXColor4f32 (col.r (), col.g (), col.b (), col.a ());
240+ GXTexCoord2f32 (0 .f , 1 .f );
241+ GXPosition3f32 (x2, y2, 1 .f );
242+ GXColor4f32 (col.r (), col.g (), col.b (), col.a ());
243+ GXTexCoord2f32 (1 .f , 1 .f );
244+ }
245+ CGX::End ();
246+
247+ if (oldLights.any ()) {
248+ SetLightState (oldLights);
249+ }
231250 g_Proj = oldProj;
232251 FlushProjection ();
233252 SetModelMatrix ({});
0 commit comments