diff --git a/src/duckstation-qt/opengldisplaywidget.cpp b/src/duckstation-qt/opengldisplaywidget.cpp index c27965906..c0131ab5b 100644 --- a/src/duckstation-qt/opengldisplaywidget.cpp +++ b/src/duckstation-qt/opengldisplaywidget.cpp @@ -153,14 +153,21 @@ void OpenGLDisplayWidget::UpdateTexture(HostDisplayTexture* texture, u32 x, u32 const void* texture_data, u32 texture_data_stride) { OpenGLDisplayWidgetTexture* tex = static_cast(texture); - Assert(texture_data_stride == (width * sizeof(u32))); + Assert((texture_data_stride % sizeof(u32)) == 0); - GLint old_texture_binding = 0; + GLint old_texture_binding = 0, old_alignment = 0, old_row_length = 0; glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_texture_binding); + glGetIntegerv(GL_UNPACK_ALIGNMENT, &old_alignment); + glGetIntegerv(GL_UNPACK_ROW_LENGTH, &old_row_length); glBindTexture(GL_TEXTURE_2D, tex->GetGLID()); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glPixelStorei(GL_UNPACK_ROW_LENGTH, texture_data_stride / sizeof(u32)); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, texture_data); + glPixelStorei(GL_UNPACK_ALIGNMENT, old_alignment); + glPixelStorei(GL_UNPACK_ROW_LENGTH, old_row_length); glBindTexture(GL_TEXTURE_2D, old_texture_binding); }