aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes
diff options
context:
space:
mode:
authorbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-05-23 13:06:11 +0000
committerbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-05-23 13:06:11 +0000
commit959bbdce321e92c47107af89f979c3b280f00577 (patch)
tree1844d33b0679d6fc3f804fecad1d06e10bd14e69 /Game/Code/Classes
parent839110b8abea8b835e1865c55b2f5ac3b6e17dc2 (diff)
downloadusdx-959bbdce321e92c47107af89f979c3b280f00577.tar.gz
usdx-959bbdce321e92c47107af89f979c3b280f00577.tar.xz
usdx-959bbdce321e92c47107af89f979c3b280f00577.zip
fixed aspect in video preview; added video zoom animation in song screen
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2406 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r--Game/Code/Classes/UVideo.pas129
1 files changed, 77 insertions, 52 deletions
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas
index 7957c8a8..c50006e8 100644
--- a/Game/Code/Classes/UVideo.pas
+++ b/Game/Code/Classes/UVideo.pas
@@ -37,17 +37,17 @@ uses SDL,
UIni;
type
+ TAspectCorrection = (acoStretch, acoCrop, acoLetterBox); //from 1.1
+
TRectCoords = record //from 1.1
Left, Right: double;
Upper, Lower: double;
windowed: boolean;
Reflection: boolean;
ReflactionSpacing: real;
+ TargetAspect: TAspectCorrection;
+ ZoomFaktor: real;
end;
-
- TAspectCorrection = (acoStretch, acoCrop, acoLetterBox); //from 1.1
-
-
procedure Init;
procedure acOpenFile(FileName: pAnsiChar);
@@ -647,63 +647,87 @@ end;
procedure GetVideoRect(var ScreenRect, TexRect: TRectCoords; Window: TRectCoords);
var
- ScreenAspect: double; // aspect of screen resolution
- ScaledVideoWidth, ScaledVideoHeight: double;
- rW, rH: double;
-begin
- // Three aspects to take into account:
- // 1. Screen/display resolution (e.g. 1920x1080 -> 16:9)
- // 2. Render aspect (fixed to 800x600 -> 4:3)
- // 3. Movie aspect (video frame aspect stored in fAspect)
- if (Window.windowed) then
- begin
- rW := Window.Right-Window.Left;
- rH := Window.Lower-Window.Upper;
- ScreenAspect := rW/rH;
- end else
- begin
- rW := RenderW;
- rH := RenderH;
- ScreenAspect := (ScreenW/Screens) / ScreenH;
- end;
+ RectS, RectT: TRectCoords;
- case fAspectCorrection of
- acoStretch: begin
- ScaledVideoWidth := rW;
- ScaledVideoHeight := rH;
+
+ procedure GetCoords(var SRect: TRectCoords; Win: TRectCoords; Aspect: TAspectCorrection);
+ var
+ ScreenAspect: double; // aspect of screen resolution
+ ScaledVideoWidth: double;
+ ScaledVideoHeight: double;
+ rW, rH: double;
+
+ begin
+ // Three aspects to take into account:
+ // 1. Screen/display resolution (e.g. 1920x1080 -> 16:9)
+ // 2. Render aspect (fixed to 800x600 -> 4:3)
+ // 3. Movie aspect (video frame aspect stored in fAspect)
+ if (Win.windowed) then
+ begin
+ rW := (Win.Right-Win.Left);
+ rH := (Win.Lower-Win.Upper);
+ ScreenAspect := rW*((ScreenW/Screens)/RenderW)/(rH*(ScreenH/RenderH));
+ end else
+ begin
+ rW := RenderW;
+ rH := RenderH;
+ ScreenAspect := (ScreenW/Screens) / ScreenH;
end;
- acoCrop: begin
- if (ScreenAspect >= fAspect) then
- begin
+
+ case Aspect of
+ acoStretch: begin
ScaledVideoWidth := rW;
- ScaledVideoHeight := rH * ScreenAspect/fAspect;
- end
- else
- begin
ScaledVideoHeight := rH;
- ScaledVideoWidth := rW * fAspect/ScreenAspect;
end;
- end;
- acoLetterBox: begin
- if (ScreenAspect <= fAspect) then
- begin
- ScaledVideoWidth := rW;
- ScaledVideoHeight := rH * ScreenAspect/fAspect;
+
+ acoCrop: begin
+ if (ScreenAspect >= fAspect) then
+ begin
+ ScaledVideoWidth := rW;
+ ScaledVideoHeight := rH * ScreenAspect/fAspect;
+ end
+ else
+ begin
+ ScaledVideoHeight := rH;
+ ScaledVideoWidth := rW * fAspect/ScreenAspect;
+ end;
+ end;
+
+ acoLetterBox: begin
+ if (ScreenAspect <= fAspect) then
+ begin
+ ScaledVideoWidth := rW;
+ ScaledVideoHeight := rH * ScreenAspect/fAspect;
+ end
+ else
+ begin
+ ScaledVideoHeight := rH;
+ ScaledVideoWidth := rW * fAspect/ScreenAspect;
+ end;
end
else
- begin
- ScaledVideoHeight := rH;
- ScaledVideoWidth := rW * fAspect/ScreenAspect;
- end;
- end
- else
- raise Exception.Create('Unhandled aspect correction!');
+ raise Exception.Create('Unhandled aspect correction!');
+ end;
+
+ SRect.Left := (rW - ScaledVideoWidth) / 2 + Win.Left;
+ SRect.Right := SRect.Left + ScaledVideoWidth;
+ SRect.Upper := (rH - ScaledVideoHeight) / 2 + Win.Upper;
+ SRect.Lower := SRect.Upper + ScaledVideoHeight;
+ end;
+begin
+ if (Window.TargetAspect = fAspectCorrection) then
+ GetCoords(ScreenRect, Window, fAspectCorrection)
+ else
+ begin
+ GetCoords(RectS, Window, fAspectCorrection);
+ GetCoords(RectT, Window, Window.TargetAspect);
+
+ ScreenRect.Left := RectS.Left + (RectT.Left-RectS.Left)*Window.ZoomFaktor;
+ ScreenRect.Right := RectS.Right + (RectT.Right-RectS.Right)*Window.ZoomFaktor;
+ ScreenRect.Upper := RectS.Upper + (RectT.Upper-RectS.Upper)*Window.ZoomFaktor;
+ ScreenRect.Lower := RectS.Lower + (RectT.Lower-RectS.Lower)*Window.ZoomFaktor;
end;
- ScreenRect.Left := (rW - ScaledVideoWidth) / 2 + Window.Left;
- ScreenRect.Right := ScreenRect.Left + ScaledVideoWidth;
- ScreenRect.Upper := (rH - ScaledVideoHeight) / 2 + Window.Upper;
- ScreenRect.Lower := ScreenRect.Upper + ScaledVideoHeight;
// texture contains right/lower (power-of-2) padding.
// Determine the texture coords of the video frame.
@@ -726,6 +750,7 @@ begin
Window.Lower := RenderH;
Window.windowed := false;
Window.Reflection := false;
+ Window.TargetAspect := fAspectCorrection;
acDrawGLi(Screen, Window, 1);
end;