Skip to content

Commit 575843d

Browse files
committed
More video playback adjustments
1 parent 80ea420 commit 575843d

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

RSDKv3/Drawing.cpp

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ GfxTexture* videoBuffer = 0;
8989
#endif
9090
DrawVertex* screenRect;
9191
DrawVertex* retroScreenRect;
92-
DrawVertex3D *screenVerts;
92+
DrawVertex *screenVerts;
9393

9494
#if !RETRO_USE_ORIGINAL_CODE
9595
// enable integer scaling, which is a modification of enhanced scaling
@@ -295,7 +295,7 @@ int InitRenderDevice()
295295
polyList3D = (DrawVertex3D*)Gfx_LinearAlloc(VERTEX3D_COUNT * sizeof(DrawVertex3D));
296296
screenRect = (DrawVertex*)Gfx_LinearAlloc(4 * sizeof(DrawVertex));
297297
retroScreenRect = (DrawVertex*)Gfx_LinearAlloc(4 * sizeof(DrawVertex));
298-
screenVerts = (DrawVertex3D*)Gfx_LinearAlloc(4 * sizeof(DrawVertex3D));
298+
screenVerts = (DrawVertex*)Gfx_LinearAlloc(4 * sizeof(DrawVertex));
299299

300300
Engine.screenRefreshRate = 60;
301301
Engine.startFullScreen = false;
@@ -776,7 +776,12 @@ void RenderFromRetroBuffer()
776776
#if RETRO_USING_OPENGL
777777
Gfx_MatrixMode(MTX_MODE_PROJECTION);
778778
Gfx_LoadIdentity();
779-
Gfx_OrthoTilt(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
779+
780+
float right = (float)viewWidth / ceilPowerOfTwo(viewWidth);
781+
float top = 1.0 - ((float)viewHeight / ceilPowerOfTwo(viewHeight));
782+
783+
Gfx_OrthoTilt(0, right, top, 1.0, -1.0, 1.0);
784+
780785
Gfx_TextureBind(retroBuffer);
781786

782787
Gfx_RenderTargetBind(nullptr, STEREO_EYE_LEFT);
@@ -808,7 +813,6 @@ void FlipScreenVideo()
808813
{
809814
#if RETRO_USING_OPENGL
810815
for (int i = 0; i < 4; ++i) {
811-
screenVerts[i].z = 0.0f;
812816
screenVerts[i].u = retroScreenRect[i].u;
813817
screenVerts[i].v = retroScreenRect[i].v;
814818
screenVerts[i].colour.r = 0xFF;
@@ -817,36 +821,37 @@ void FlipScreenVideo()
817821
screenVerts[i].colour.a = 0xFF;
818822
}
819823

820-
float best = minVal(viewWidth / (float)videoWidth, viewHeight / (float)videoHeight);
824+
Gfx_MatrixMode(MTX_MODE_PROJECTION);
825+
Gfx_LoadIdentity();
826+
Gfx_OrthoTilt(0.0, videoWidth, videoHeight, 0.0, -1.0, 1.0);
821827

822-
float w = videoWidth * best;
823-
float h = videoHeight * best;
828+
#if RETRO_PLATFORM == RETRO_3DS
829+
screenVerts[0].x = 0;
830+
screenVerts[0].y = ceilPowerOfTwo(videoHeight);
824831

825-
float x = normalize((viewWidth - w) / 2, 0, viewWidth) * 2 - 1.0f;
826-
float y = -(normalize((viewHeight - h) / 2, 0, viewHeight) * 2 - 1.0f);
832+
screenVerts[1].x = ceilPowerOfTwo(videoWidth);
833+
screenVerts[1].y = ceilPowerOfTwo(videoHeight);
827834

828-
w = normalize(w, 0, viewWidth) * 2;
829-
h = -(normalize(h, 0, viewHeight) * 2);
835+
screenVerts[2].x = 0;
836+
screenVerts[2].y = 0;
830837

831-
screenVerts[0].x = x;
832-
screenVerts[0].y = y;
838+
screenVerts[3].x = ceilPowerOfTwo(videoWidth);
839+
screenVerts[3].y = 0;
833840

834-
screenVerts[1].x = w + x;
835-
screenVerts[1].y = y;
841+
BindVideoTex3DS();
842+
#else
843+
screenVerts[0].x = 0;
844+
screenVerts[0].y = 0;
836845

837-
screenVerts[2].x = x;
838-
screenVerts[2].y = h + y;
846+
screenVerts[1].x = videoWidth;
847+
screenVerts[1].y = 0;
839848

840-
screenVerts[3].x = w + x;
841-
screenVerts[3].y = h + y;
849+
screenVerts[2].x = 0;
850+
screenVerts[2].y = videoHeight;
842851

843-
Gfx_MatrixMode(MTX_MODE_PROJECTION);
844-
Gfx_LoadIdentity();
845-
Gfx_OrthoTilt(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
852+
screenVerts[3].x = videoWidth;
853+
screenVerts[3].y = videoHeight;
846854

847-
#if RETRO_PLATFORM == RETRO_3DS
848-
BindVideoTex3DS();
849-
#else
850855
Gfx_TextureBind(videoBuffer);
851856
#endif
852857

@@ -867,7 +872,7 @@ void FlipScreenVideo()
867872
}
868873
#endif
869874
Gfx_SetViewportTilt(viewOffsetX, 0, viewWidth, viewHeight);
870-
Gfx_SetVertexBufs(sizeof(DrawVertex3D), screenVerts);
875+
Gfx_SetVertexBufs(sizeof(DrawVertex), screenVerts);
871876
Gfx_SetBlend(false);
872877
Gfx_DrawElements(6, gfxPolyListIndex);
873878
#endif
@@ -1222,7 +1227,7 @@ void SetScreenDimensions(int width, int height, int winWidth, int winHeight)
12221227

12231228
// HW_TEXTURE_SIZE == 1.0 due to the scaling we did on the Texture Matrix earlier
12241229

1225-
retroScreenRect[0].x = -1;
1230+
retroScreenRect[0].x = 0;
12261231
retroScreenRect[0].y = 1;
12271232
retroScreenRect[0].u = 0;
12281233
retroScreenRect[0].v = 0;
@@ -1240,8 +1245,8 @@ void SetScreenDimensions(int width, int height, int winWidth, int winHeight)
12401245
retroScreenRect[1].colour.b = 0xFF;
12411246
retroScreenRect[1].colour.a = 0xFF;
12421247

1243-
retroScreenRect[2].x = -1;
1244-
retroScreenRect[2].y = -1;
1248+
retroScreenRect[2].x = 0;
1249+
retroScreenRect[2].y = 0;
12451250
retroScreenRect[2].u = 0;
12461251
retroScreenRect[2].v = HW_TEXTURE_SIZE;
12471252
retroScreenRect[2].colour.r = 0xFF;
@@ -1250,7 +1255,7 @@ void SetScreenDimensions(int width, int height, int winWidth, int winHeight)
12501255
retroScreenRect[2].colour.a = 0xFF;
12511256

12521257
retroScreenRect[3].x = 1;
1253-
retroScreenRect[3].y = -1;
1258+
retroScreenRect[3].y = 0;
12541259
retroScreenRect[3].u = HW_TEXTURE_SIZE;
12551260
retroScreenRect[3].v = HW_TEXTURE_SIZE;
12561261
retroScreenRect[3].colour.r = 0xFF;

RSDKv3/platform/3DS/Video3DS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void changeFile(const char* filepath) {
101101
vinfo = THEORA_vidinfo(&vidCtx);
102102
ainfo = THEORA_audinfo(&vidCtx);
103103

104-
videoWidth = -vinfo->width;
104+
videoWidth = vinfo->width;
105105
videoHeight = vinfo->height;
106106

107107
audioInit(ainfo);

0 commit comments

Comments
 (0)