1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

adjust alignment in case width is not divisible 4 - fixes resolutions such as 1366*768

This commit is contained in:
FunkyFr3sh 2018-09-25 01:56:15 +02:00
parent 5bbf63a025
commit 4fe107c991

View File

@ -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