mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-06-11 04:37:59 -04:00
Fix text rendering in orthographic mode. (#27)
This commit is contained in:
+1
-1
Submodule lib/rt64 updated: 2fb9bd809b...ad1cf390c4
@@ -116,9 +116,15 @@ float identity_matrix[4][4] = {
|
||||
RECOMP_PATCH void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx) {
|
||||
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
|
||||
|
||||
// @recomp Use a high precision version of the projection matrix instead of the fixed precision one. This fixes accuracy issues when rendering text using the orthographic projection.
|
||||
guOrthoF(*mtx, -(2 * (f32)gFramebufferWidth), (2 * (f32)gFramebufferWidth), -(2 * (f32)gFramebufferHeight), (2 * (f32)gFramebufferHeight), 1.0f, 20.0f, 1.0f);
|
||||
gEXMatrixFloat((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
#if 0
|
||||
guOrtho(*mtx, -(2*(f32)gFramebufferWidth), (2*(f32)gFramebufferWidth), -(2*(f32)gFramebufferHeight), (2*(f32)gFramebufferHeight), 1.0f, 20.0f, 1.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
#endif
|
||||
|
||||
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
||||
@@ -317,7 +317,8 @@ RECOMP_PATCH void _printbuffer_draw_letter(char letter, f32 *xPtr, f32 *yPtr, f3
|
||||
}//L802F677C
|
||||
|
||||
// @recomp Force orthographic projection rectangles to be used for all letters as it allows them to be interpolated.
|
||||
if (TRUE) { //if (D_80380AF4 != 0) {
|
||||
//if (D_80380AF4 != 0) {
|
||||
if (TRUE) {
|
||||
f32 temp_f24;
|
||||
f32 spD0;
|
||||
f32 ix;
|
||||
@@ -328,7 +329,10 @@ RECOMP_PATCH void _printbuffer_draw_letter(char letter, f32 *xPtr, f32 *yPtr, f3
|
||||
temp_f24 = (sp214->x - 1.0);
|
||||
spD0 = sp214->y - 1.0;
|
||||
temp_f26 = (f64)sp200 - (f32)gFramebufferWidth * 0.5;
|
||||
spC0 = (f64)f28 - (f32)gFramebufferHeight * 0.5 - 0.5f;
|
||||
|
||||
// @recomp Remove the incorrect half pixel offset that was applied.
|
||||
//spC0 = (f64)f28 - (f32)gFramebufferHeight * 0.5 - 0.5f;
|
||||
spC0 = (f64)f28 - (f32)gFramebufferHeight * 0.5;
|
||||
|
||||
// @recomp Assign a unique matrix and group to each letter drawn if an ID is currently assigned.
|
||||
if (cur_drawn_text_transform_id != 0) {
|
||||
@@ -343,18 +347,29 @@ RECOMP_PATCH void _printbuffer_draw_letter(char letter, f32 *xPtr, f32 *yPtr, f3
|
||||
|
||||
cur_drawn_text_transform_id++;
|
||||
}
|
||||
|
||||
|
||||
gSPVertex((*gfx)++, *vtx, 4, 0);
|
||||
for (iy = 0.0f; iy < 2.0; iy += 1.0) {
|
||||
for (ix = 0.0f; ix < 2.0; ix += 1.0) {
|
||||
s32 s = (ix * temp_f24 * 64.0f);
|
||||
(*vtx)->v.ob[0] = (s16)(s32)((f64)(temp_f26 + (temp_f24 * arg3 * ix)) * 4.0);
|
||||
// @recomp Add one pixel to the right of the rectangle.
|
||||
//(*vtx)->v.ob[0] = (s16)(s32)((f64)(temp_f26 + (temp_f24 * arg3 * ix)) * 4.0);
|
||||
s32 x = (s32)((f64)(temp_f26 + (temp_f24 * arg3 * ix)) * 4.0) + (ix * 4);
|
||||
(*vtx)->v.ob[0] = (s16)(x);
|
||||
|
||||
{
|
||||
s32 t = (iy * spD0 * 64.0f);
|
||||
(*vtx)->v.ob[1] = (s16)(s32)((f64)(spC0 + (spD0 * arg3 * iy)) * -4.0);
|
||||
// @recomp Add one pixel to the bottom of the rectangle.
|
||||
//(*vtx)->v.ob[1] = (s16)(s32)((f64)(spC0 + (spD0 * arg3 * iy)) * -4.0);
|
||||
s32 y = (s32)((f64)(spC0 + (spD0 * arg3 * iy)) * -4.0) - iy * 4;
|
||||
(*vtx)->v.ob[1] = (s16)(y);
|
||||
(*vtx)->v.ob[2] = -0x14;
|
||||
(*vtx)->v.tc[0] = s;
|
||||
(*vtx)->v.tc[1] = t;
|
||||
|
||||
// @recomp Add one pixel to the texture coordinates.
|
||||
//(*vtx)->v.tc[0] = s;
|
||||
//(*vtx)->v.tc[1] = t;
|
||||
(*vtx)->v.tc[0] = s + ix * 64;
|
||||
(*vtx)->v.tc[1] = t + iy * 64;
|
||||
}
|
||||
(*vtx)->v.cn[3] = (iy != 0.0f) ? print_sCurrentPtr->unk6 : print_sCurrentPtr->unk4;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user