mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
- 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
|
@ -548,3 +548,18 @@ void OpenGLFrameBuffer::GameRestart()
|
||||||
gl_GenerateGlobalBrightmapFromColormap();
|
gl_GenerateGlobalBrightmapFromColormap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OpenGLFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y)
|
||||||
|
{
|
||||||
|
int letterboxX = GLRenderer->mOutputLetterbox.left;
|
||||||
|
int letterboxY = GLRenderer->mOutputLetterbox.top;
|
||||||
|
int letterboxWidth = GLRenderer->mOutputLetterbox.width;
|
||||||
|
int letterboxHeight = GLRenderer->mOutputLetterbox.height;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
|
|
||||||
void SetVSync(bool vsync);
|
void SetVSync(bool vsync);
|
||||||
|
|
||||||
|
void ScaleCoordsFromWindow(int16_t &x, int16_t &y) override;
|
||||||
|
|
||||||
bool HWGammaActive = false; // Are we using hardware or software gamma?
|
bool HWGammaActive = false; // Are we using hardware or software gamma?
|
||||||
std::shared_ptr<FGLDebug> mDebug; // Debug API
|
std::shared_ptr<FGLDebug> mDebug; // Debug API
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -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)));
|
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()
|
void OpenGLSWFrameBuffer::Present()
|
||||||
{
|
{
|
||||||
int clientWidth = GetClientWidth();
|
int clientWidth = GetClientWidth();
|
||||||
|
@ -723,23 +746,8 @@ void OpenGLSWFrameBuffer::Present()
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(0, 0, clientWidth, clientHeight);
|
glViewport(0, 0, clientWidth, clientHeight);
|
||||||
|
|
||||||
float scaleX, scaleY;
|
int letterboxX, letterboxY, letterboxWidth, letterboxHeight;
|
||||||
if (ViewportIsScaled43())
|
GetLetterboxFrame(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
DrawLetterbox(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
DrawLetterbox(letterboxX, letterboxY, letterboxWidth, letterboxHeight);
|
||||||
glViewport(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);
|
SetConstant(PSCONST_PaletteMod, 255 * fcount, 0.5f * fcount, 0, 0);
|
||||||
SetTexture(1, texture);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ public:
|
||||||
int GetTrueHeight() override { return TrueHeight; }
|
int GetTrueHeight() override { return TrueHeight; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void ScaleCoordsFromWindow(int16_t &x, int16_t &y) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FBVERTEX
|
struct FBVERTEX
|
||||||
{
|
{
|
||||||
|
@ -195,6 +197,8 @@ private:
|
||||||
void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount);
|
void DrawTriangleList(int minIndex, int numVertices, int startIndex, int primitiveCount);
|
||||||
void Present();
|
void Present();
|
||||||
|
|
||||||
|
void GetLetterboxFrame(int &x, int &y, int &width, int &height);
|
||||||
|
|
||||||
static void BgraToRgba(uint32_t *dest, const uint32_t *src, int width, int height, int srcpitch);
|
static void BgraToRgba(uint32_t *dest, const uint32_t *src, int width, int height, int srcpitch);
|
||||||
|
|
||||||
void BindFBBuffer();
|
void BindFBBuffer();
|
||||||
|
|
Loading…
Reference in a new issue