mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-14 05:41:02 +00:00
Draw the final screen texture in the centre with black bars
Only applies when the monitor aspect ratio is different to the game's aspect ratio.
This commit is contained in:
parent
527df5c248
commit
31d1ef8db0
1 changed files with 23 additions and 5 deletions
|
@ -2601,6 +2601,9 @@ EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
|
||||||
EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||||
{
|
{
|
||||||
float xfix, yfix;
|
float xfix, yfix;
|
||||||
|
float origaspect, newaspect;
|
||||||
|
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
|
||||||
|
FRGBAFloat clearColour;
|
||||||
INT32 texsize = 2048;
|
INT32 texsize = 2048;
|
||||||
|
|
||||||
if(screen_width <= 1024)
|
if(screen_width <= 1024)
|
||||||
|
@ -2611,28 +2614,43 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||||
xfix = 1/((float)(texsize)/((float)((screen_width))));
|
xfix = 1/((float)(texsize)/((float)((screen_width))));
|
||||||
yfix = 1/((float)(texsize)/((float)((screen_height))));
|
yfix = 1/((float)(texsize)/((float)((screen_height))));
|
||||||
|
|
||||||
//pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
origaspect = (float)screen_width / screen_height;
|
||||||
|
newaspect = (float)width / height;
|
||||||
|
if (origaspect < newaspect)
|
||||||
|
{
|
||||||
|
xoff = origaspect / newaspect;
|
||||||
|
yoff = 1;
|
||||||
|
}
|
||||||
|
else if (origaspect > newaspect)
|
||||||
|
{
|
||||||
|
xoff = 1;
|
||||||
|
yoff = newaspect / origaspect;
|
||||||
|
}
|
||||||
|
|
||||||
pglViewport(0, 0, width, height);
|
pglViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
clearColour.red = clearColour.green = clearColour.blue = 0;
|
||||||
|
clearColour.alpha = 1;
|
||||||
|
ClearBuffer(true, false, &clearColour);
|
||||||
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
||||||
pglBegin(GL_QUADS);
|
pglBegin(GL_QUADS);
|
||||||
|
|
||||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
// Bottom left
|
// Bottom left
|
||||||
pglTexCoord2f(0.0f, 0.0f);
|
pglTexCoord2f(0.0f, 0.0f);
|
||||||
pglVertex3f(-1, -1, 1.0f);
|
pglVertex3f(-xoff, -yoff, 1.0f);
|
||||||
|
|
||||||
// Top left
|
// Top left
|
||||||
pglTexCoord2f(0.0f, yfix);
|
pglTexCoord2f(0.0f, yfix);
|
||||||
pglVertex3f(-1, 1, 1.0f);
|
pglVertex3f(-xoff, yoff, 1.0f);
|
||||||
|
|
||||||
// Top right
|
// Top right
|
||||||
pglTexCoord2f(xfix, yfix);
|
pglTexCoord2f(xfix, yfix);
|
||||||
pglVertex3f(1, 1, 1.0f);
|
pglVertex3f(xoff, yoff, 1.0f);
|
||||||
|
|
||||||
// Bottom right
|
// Bottom right
|
||||||
pglTexCoord2f(xfix, 0.0f);
|
pglTexCoord2f(xfix, 0.0f);
|
||||||
pglVertex3f(1, -1, 1.0f);
|
pglVertex3f(xoff, -yoff, 1.0f);
|
||||||
|
|
||||||
pglEnd();
|
pglEnd();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue