Skip to content

Commit

Permalink
Merge pull request #72 from whitedragon0000/PLUS
Browse files Browse the repository at this point in the history
fixed video aspect support for PS3 and Android port
  • Loading branch information
whitedragon0000 authored Oct 11, 2018
2 parents fcad7c8 + 0137b6c commit ad7d462
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions engine/android/jni/openbor/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ void blit()
float aspectRatio = (float)textureWidth / (float)textureHeight;
float newWidth = nativeHeight * aspectRatio;

if (newWidth > nativeWidth) {
float newHeight;

newWidth = nativeWidth;
newHeight = newWidth / aspectRatio;
scaledWidth = (unsigned)newWidth;
scaledHeight = (unsigned)newHeight;
}

//SDL_Log("aspect: from %d/%d con %f, orig: %d/%d -> %d",textureWidth,textureHeight,aspectRatio,nativeWidth,nativeHeight,(int)newWidth);
SDL_Rect d_rect = {(int)(nativeWidth/2.0f - newWidth/2.0f), 0, (int)newWidth, nativeHeight};
SDL_RenderCopy(renderer, texture, NULL, &d_rect);
Expand Down
14 changes: 12 additions & 2 deletions engine/ps3/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void video_fullscreen_flip()

void blit()
{
unsigned resMargin = 50;
//SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
SDL_RenderClear(renderer);

Expand All @@ -203,7 +204,7 @@ void blit()
{
//SDL_RenderSetLogicalSize(renderer, 0, 0);
//SDL_RenderCopy(renderer, texture, NULL, NULL);
unsigned scaledWidth = nativeWidth - 50;
unsigned scaledWidth = nativeWidth - resMargin;
unsigned scaledHeight = (scaledWidth * nativeHeight) / nativeWidth;

SDL_Rect d_rect = {(int)(nativeWidth/2.0f - scaledWidth/2.0f), (int)(nativeHeight/2.0f - scaledHeight/2.0f), scaledWidth, scaledHeight};
Expand All @@ -214,9 +215,18 @@ void blit()
//SDL_RenderSetLogicalSize(renderer, textureWidth, textureHeight);
float aspectRatio = (float)textureWidth / (float)textureHeight;
float newWidth = nativeHeight * aspectRatio;
unsigned scaledWidth = newWidth - 50;
unsigned scaledWidth = newWidth - resMargin;
unsigned scaledHeight = (scaledWidth * nativeHeight) / newWidth;

if (newWidth > nativeWidth) {
float newHeight;

newWidth = nativeWidth - resMargin;
newHeight = newWidth / aspectRatio;
scaledWidth = (unsigned)newWidth;
scaledHeight = (unsigned)newHeight;
}

//SDL_Log("aspect: from %d/%d con %f, orig: %d/%d -> %d",textureWidth,textureHeight,aspectRatio,nativeWidth,nativeHeight,(int)newWidth);
//SDL_Rect d_rect = {(int)(nativeWidth/2.0f - newWidth/2.0f), 0, (int)newWidth, nativeHeight};
SDL_Rect d_rect = {(int)(nativeWidth/2.0f - scaledWidth/2.0f), (int)(nativeHeight/2.0f - scaledHeight/2.0f), scaledWidth, scaledHeight};
Expand Down

0 comments on commit ad7d462

Please sign in to comment.