Skip to content

Commit

Permalink
Added movie sizing/aspect ratio correction
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Nov 14, 2023
1 parent 4670d0f commit e4d0c87
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions source_files/edge/i_movie.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,18 @@ void E_PlayMovie(const std::string &name)

int movie_width = plm_get_width(decoder);
int movie_height = plm_get_height(decoder);
//float movie_ratio = movie_width / movie_height;
float movie_ratio = (float)movie_width / movie_height;
// Size frame to display with correct ratio
// Should only need to be set once unless at some point
// we allow menu access/console while a movie is playing
int frame_height = SCREENHEIGHT;
int frame_width = I_ROUND((float)SCREENHEIGHT * movie_ratio);
if (frame_width > SCREENWIDTH)
{
frame_width = SCREENWIDTH;
frame_height = I_ROUND((float)SCREENWIDTH / movie_ratio);
}

int num_pixels = movie_width * movie_height * 3;
rgb_data = new uint8_t[num_pixels];
memset(rgb_data, 0, num_pixels);
Expand Down Expand Up @@ -179,10 +190,6 @@ void E_PlayMovie(const std::string &name)
{
I_StartFrame();

// TODO: Fit this to screen dimensions while preserving aspect ratio
int frame_width = SCREENWIDTH;
int frame_height = SCREENHEIGHT;

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, canvas);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
Expand Down Expand Up @@ -260,10 +267,6 @@ void E_PlayMovie(const std::string &name)
fadeout = current_time - last_time;
I_StartFrame();

// TODO: Fit this to screen dimensions while preserving aspect ratio
int frame_width = SCREENWIDTH;
int frame_height = SCREENHEIGHT;

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, canvas);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
Expand Down

0 comments on commit e4d0c87

Please sign in to comment.