Show videos with correct aspect ratio.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/qt-trunk@10936 4a71c877-e1ca-e34f-864e-861f7616d084
master
Christian Ohm 2010-06-07 15:10:43 +00:00 committed by Git SVN Gateway
parent e4805ee8d7
commit e8deaceca6
1 changed files with 36 additions and 9 deletions

View File

@ -56,6 +56,8 @@
*/
#include <GLee.h>
#include "lib/framework/frame.h"
#include "lib/framework/frameint.h"
#include "sequence.h"
#include "timer.h"
#include "lib/framework/math_ext.h"
@ -164,8 +166,10 @@ static int frames = 0;
static int dropped = 0;
// Screen dimensions
static int ScrnvidXsize = 0;
static int ScrnvidYsize = 0;
static int videoX1 = 0;
static int videoX2 = 0;
static int videoY1 = 0;
static int videoY2 = 0;
static int ScrnvidXpos = 0;
static int ScrnvidYpos = 0;
@ -340,13 +344,13 @@ static void video_write(bool update)
glTranslatef(ScrnvidXpos, ScrnvidYpos, 0.0f);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glVertex2f(videoX1, videoY1);
glTexCoord2f((float) video_width / texture_width, 0);
glVertex2f(ScrnvidXsize, 0); //screenWidth
glVertex2f(videoX2, videoY1); //screenWidth
glTexCoord2f(0, (float) video_height / texture_height);
glVertex2f(0, ScrnvidYsize); //screenHeight
glVertex2f(videoX1, videoY2); //screenHeight
glTexCoord2f((float) video_width / texture_width, (float) video_height / texture_height);
glVertex2f(ScrnvidXsize, ScrnvidYsize); //screenWidth,screenHeight
glVertex2f(videoX2, videoY2); //screenWidth,screenHeight
glEnd();
glPopMatrix();
@ -419,7 +423,7 @@ static void seq_InitOgg(void)
{
debug(LOG_VIDEO, "seq_InitOgg");
ASSERT((ScrnvidXsize && ScrnvidYsize), "Screen dimensions not specified!");
ASSERT((videoX2 && videoY2), "Screen dimensions not specified!");
stateflag = false;
theora_p = 0;
@ -965,8 +969,31 @@ int seq_GetFrameNumber()
// this controls the size of the video to display on screen
void seq_SetDisplaySize(int sizeX, int sizeY, int posX, int posY)
{
ScrnvidXsize = sizeX;
ScrnvidYsize = sizeY;
videoX1 = 0;
videoY1 = 0;
videoX2 = sizeX;
videoY2 = sizeY;
if (sizeX > 640 || sizeY > 480)
{
const float aspect = screenWidth / (float)screenHeight, videoAspect = 4 / (float)3;
if (aspect > videoAspect)
{
int offset = (screenWidth - screenHeight * videoAspect) / 2;
videoX1 += offset;
videoX2 -= offset;
}
else
{
int offset = (screenHeight - screenWidth / videoAspect) / 2;
videoY1 += offset;
videoY2 -= offset;
}
}
ScrnvidXpos = posX;
ScrnvidYpos = posY;
}