From 4fe107c991da7e63158c8d49f146103f3ed33db5 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 25 Sep 2018 01:56:15 +0200 Subject: [PATCH] adjust alignment in case width is not divisible 4 - fixes resolutions such as 1366*768 --- src/render.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/render.c b/src/render.c index 5e94d0a..28aec7a 100644 --- a/src/render.c +++ b/src/render.c @@ -49,6 +49,7 @@ static GLuint FrameBufferId; static GLuint FrameBufferTexId; static GLuint ScaleVBOs[3], ScaleVAO; static BOOL UseOpenGL; +static BOOL AdjustAlignment; static HGLRC CreateContext(HDC hdc); static void SetMaxFPS(int baseMaxFPS); @@ -199,6 +200,8 @@ static void CreateTextures(int width, int height) SurfaceTex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SurfaceTexWidth * SurfaceTexHeight * sizeof(int)); + AdjustAlignment = (width % 4) != 0; + ScaleW = (float)width / SurfaceTexWidth; ScaleH = (float)height / SurfaceTexHeight; @@ -644,6 +647,9 @@ static void Render() glBindTexture(GL_TEXTURE_2D, SurfaceTexIds[texIndex]); + if (AdjustAlignment) + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexSubImage2D( GL_TEXTURE_2D, 0, @@ -654,6 +660,9 @@ static void Render() SurfaceFormat, GL_UNSIGNED_BYTE, ddraw->primary->surface); + + if (AdjustAlignment) + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } } else