- Fix mouse position being wrong when vid_scalemode is active
This commit is contained in:
parent
3540440bf6
commit
7d21fe6d75
4 changed files with 59 additions and 17 deletions
|
|
@ -714,6 +714,29 @@ void OpenGLSWFrameBuffer::DrawTriangleList(int minIndex, int numVertices, int st
|
|||
glDrawRangeElements(GL_TRIANGLES, minIndex, minIndex + numVertices - 1, primitiveCount * 3, GL_UNSIGNED_SHORT, (const void*)(startIndex * sizeof(uint16_t)));
|
||||
}
|
||||
|
||||
void OpenGLSWFrameBuffer::GetLetterboxFrame(int &letterboxX, int &letterboxY, int &letterboxWidth, int &letterboxHeight)
|
||||
{
|
||||
int clientWidth = GetClientWidth();
|
||||
int clientHeight = GetClientHeight();
|
||||
|
||||
float scaleX, scaleY;
|
||||
if (ViewportIsScaled43())
|
||||
{
|
||||
scaleX = MIN(clientWidth / (float)Width, clientHeight / (Height * 1.2f));
|
||||
scaleY = scaleX * 1.2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scaleX = MIN(clientWidth / (float)Width, clientHeight / (float)Height);
|
||||
scaleY = scaleX;
|
||||
}
|
||||
|
||||
letterboxWidth = (int)round(Width * scaleX);
|
||||
letterboxHeight = (int)round(Height * scaleY);
|
||||
letterboxX = (clientWidth - letterboxWidth) / 2;
|
||||
letterboxY = (clientHeight - letterboxHeight) / 2;
|
||||
}
|
||||
|
||||
void OpenGLSWFrameBuffer::Present()
|
||||
{
|
||||
int clientWidth = GetClientWidth();
|
||||
|
|
@ -723,23 +746,8 @@ void OpenGLSWFrameBuffer::Present()
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, clientWidth, clientHeight);
|
||||
|
||||
float scaleX, scaleY;
|
||||
if (ViewportIsScaled43())
|
||||
{
|
||||
scaleX = MIN(clientWidth / (float)Width, clientHeight / (Height * 1.2f));
|
||||
scaleY = scaleX * 1.2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scaleX = MIN(clientWidth / (float)Width, clientHeight / (float)Height);
|
||||
scaleY = scaleX;
|
||||
}
|
||||
|
||||
int letterboxWidth = (int)round(Width * scaleX);
|
||||
int letterboxHeight = (int)round(Height * scaleY);
|
||||
int letterboxX = (clientWidth - letterboxWidth) / 2;
|
||||
int letterboxY = (clientHeight - letterboxHeight) / 2;
|
||||
|
||||
int letterboxX, letterboxY, letterboxWidth, letterboxHeight;
|
||||
GetLetterboxFrame(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
||||
DrawLetterbox(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
||||
glViewport(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
||||
|
||||
|
|
@ -3830,3 +3838,16 @@ void OpenGLSWFrameBuffer::SetPaletteTexture(HWTexture *texture, int count, uint3
|
|||
SetConstant(PSCONST_PaletteMod, 255 * fcount, 0.5f * fcount, 0, 0);
|
||||
SetTexture(1, texture);
|
||||
}
|
||||
|
||||
void OpenGLSWFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y)
|
||||
{
|
||||
int letterboxX, letterboxY, letterboxWidth, letterboxHeight;
|
||||
GetLetterboxFrame(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
||||
|
||||
// Subtract the LB video mode letterboxing
|
||||
if (IsFullscreen())
|
||||
y -= (GetTrueHeight() - VideoHeight) / 2;
|
||||
|
||||
x = int16_t((x - letterboxX) * Width / letterboxWidth);
|
||||
y = int16_t((y - letterboxY) * Height / letterboxHeight);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue