Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Widescreen related funcs to lus #723

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/public/bridge/windowbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,41 @@ int32_t WindowGetPosY(void) {
bool WindowIsFullscreen(void) {
return Ship::Context::GetInstance()->GetWindow()->IsFullscreen();
}

/**
* Widescreen functions
*
*/

float ScreenGetAspectRatio() {
return gfx_current_dimensions.aspect_ratio;
}

// AdjustXFromLeftEdge
float LeftEdgeAlign(float v) {
return (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * OTRGetAspectRatio() + (v));
MegaMech marked this conversation as resolved.
Show resolved Hide resolved
}

int16_t LeftEdgeRectAlign(float v) {
return ((int) floorf(OTRGetDimensionFromLeftEdge(v)));
}

float RightEdgeAlign(float v) {
return (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * OTRGetAspectRatio() - (SCREEN_WIDTH - v));
}

int16_t RightEdgeRectAlign(float v) {
return ((int) ceilf(OTRGetDimensionFromRightEdge(v)));
}

// Gets the width of the current render target area
uint32_t WindowGetGameRenderWidth() {
return gfx_current_dimensions.width;
}

// Gets the height of the current render target area
uint32_t WindowGetGameRenderHeight() {
return gfx_current_dimensions.height;
}

}
10 changes: 9 additions & 1 deletion src/public/bridge/windowbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ int32_t WindowGetPosX(void);
int32_t WindowGetPosY(void);
bool WindowIsFullscreen(void);

float ScreenGetAspectRatio(void);
float LeftEdgeAlign(float v);
int16_t LeftEdgeRectAlign(float v);
float RightEdgeAlign(float v);
int16_t RightEdgeRectAlign(float v);
uint32_t WindowGetGameRenderWidth();
uint32_t WindowGetGameRenderHeight();
MegaMech marked this conversation as resolved.
Show resolved Hide resolved

#ifdef __cplusplus
};
#endif

#endif
#endif
Loading