From 3e71f83d610ea3c4ba23c39f2727f8dc10b5dc88 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 26 Jun 2025 13:58:07 +0800 Subject: [PATCH] [Fix] (MG_State/Texture): implement GL_UNPACK_SKIP_ROWS and GL_UNPACK_SKIP_PIXELS, fixing non-unicode fonts --- MG/MG_GL/Implementations/GL/Texture/GL_Texture.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MG/MG_GL/Implementations/GL/Texture/GL_Texture.cpp b/MG/MG_GL/Implementations/GL/Texture/GL_Texture.cpp index 9ceb27e5..8852700f 100644 --- a/MG/MG_GL/Implementations/GL/Texture/GL_Texture.cpp +++ b/MG/MG_GL/Implementations/GL/Texture/GL_Texture.cpp @@ -624,11 +624,16 @@ namespace MG_GL::GL { return; } - auto rowLength = TextureState::GetUnpackParam_(GL_UNPACK_ROW_LENGTH); + auto rowLength = MG_State::QueryPixelStoreInt(GL_UNPACK_ROW_LENGTH); + rowLength = ((rowLength > 0) ? rowLength : width); + auto skipRows = MG_State::QueryPixelStoreInt(GL_UNPACK_SKIP_ROWS); + auto skipPixels = MG_State::QueryPixelStoreInt(GL_UNPACK_SKIP_PIXELS); + auto bpp = GetBytesPerPixel(format, type); + char* pixelStart = (char*)pixels + bpp * (rowLength * skipRows + skipPixels); Diligent::TextureSubResData SubResData; - SubResData.pData = pixels; - SubResData.Stride = ((rowLength > 0) ? rowLength : width) * GetBytesPerPixel(format, type); + SubResData.Stride = rowLength * bpp; + SubResData.pData = pixelStart; Diligent::Box UpdateBox; UpdateBox.MinX = xoffset;