aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-21 17:09:38 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-21 17:09:38 +0000
commit4cbefb8f24d2ccb0238a5e442701811d20b476a0 (patch)
treeb57f841cdf97f3f28f5e8370caab4f1eba18d42e /Game
parentc7f30437ac8404b36521c18b03eec84839cafe5d (diff)
downloadusdx-4cbefb8f24d2ccb0238a5e442701811d20b476a0.tar.gz
usdx-4cbefb8f24d2ccb0238a5e442701811d20b476a0.tar.xz
usdx-4cbefb8f24d2ccb0238a5e442701811d20b476a0.zip
Video Aspect-Ratio fix (e.g. for 16:9 displays)
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1113 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UVideo.pas34
1 files changed, 23 insertions, 11 deletions
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas
index d29b713b..b03f29bf 100644
--- a/Game/Code/Classes/UVideo.pas
+++ b/Game/Code/Classes/UVideo.pas
@@ -87,8 +87,7 @@ type
fVideoTex: GLuint;
TexWidth, TexHeight: Cardinal;
- ScaledVideoWidth, ScaledVideoHeight: Real;
-
+
VideoAspect: Real;
VideoTimeBase, VideoTime: Extended;
fLoopTime: Extended;
@@ -135,6 +134,7 @@ begin
AVERROR_NOFMT: Result := 'AVERROR_NOFMT';
AVERROR_NOTSUPP: Result := 'AVERROR_NOTSUPP';
AVERROR_NOENT: Result := 'AVERROR_NOENT';
+ AVERROR_PATCHWELCOME: Result := 'AVERROR_PATCHWELCOME';
else Result := 'AVERROR_#'+inttostr(Errnum);
end;
end;
@@ -469,9 +469,9 @@ var
TexVideoRightPos, TexVideoLowerPos: Single;
ScreenLeftPos, ScreenRightPos: Single;
ScreenUpperPos, ScreenLowerPos: Single;
-const
- ScreenMidPosX = 400.0;
- ScreenMidPosY = 300.0;
+ ScaledVideoWidth, ScaledVideoHeight: Single;
+ ScreenMidPosX, ScreenMidPosY: Single;
+ ScreenAspect, RenderAspect: Single;
begin
// have a nice black background to draw on (even if there were errors opening the vid)
if (Screen = 1) then
@@ -488,17 +488,32 @@ begin
Log.BenchmarkStart(15);
{$ENDIF}
- TexVideoRightPos := VideoCodecContext^.width / TexWidth;
- TexVideoLowerPos := VideoCodecContext^.height / TexHeight;
+ ScreenAspect := ScreenW / ScreenH;
+ RenderAspect := RenderW / RenderH;
+ ScaledVideoWidth := RenderW;
+ ScaledVideoHeight := ScaledVideoWidth/VideoAspect * ScreenAspect/RenderAspect;
+
+ // Note: Scaling the width does not look good because the video might contain
+ // black borders at the top already
+ //ScaledVideoHeight := RenderH;
+ //ScaledVideoWidth := ScaledVideoHeight*VideoAspect * RenderAspect/ScreenAspect;
+
+ // center the video
+ ScreenMidPosX := RenderW/2;
+ ScreenMidPosY := RenderH/2;
ScreenLeftPos := ScreenMidPosX - ScaledVideoWidth/2;
ScreenRightPos := ScreenMidPosX + ScaledVideoWidth/2;
ScreenUpperPos := ScreenMidPosY - ScaledVideoHeight/2;
ScreenLowerPos := ScreenMidPosY + ScaledVideoHeight/2;
+ // the video-texture contains empty borders because its width and height must be
+ // a power of 2. So we have to determine the texture coords of the video.
+ TexVideoRightPos := VideoCodecContext^.width / TexWidth;
+ TexVideoLowerPos := VideoCodecContext^.height / TexHeight;
// we could use blending for brightness control, but do we need this?
glDisable(GL_BLEND);
- // TODO: disable other stuff like lightning, etc.
+ // TODO: disable other stuff like lightning, etc.
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fVideoTex);
@@ -721,9 +736,6 @@ begin
VideoAspect := VideoAspect * VideoCodecContext^.width /
VideoCodecContext^.height;
- ScaledVideoWidth := 800.0;
- ScaledVideoHeight := 800.0 / VideoAspect;
-
VideoTimeBase := 1/av_q2d(VideoStream^.r_frame_rate);
// hack to get reasonable timebase (for divx and others)