qt_hardwarerenderer: Use setData on Qt 5.14 and later

This commit is contained in:
Cacodemon345
2022-09-03 13:13:07 +06:00
committed by GitHub
parent fa9ac2409d
commit d47bd06f25

View File

@@ -199,10 +199,14 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) {
return;
}
m_context->makeCurrent(this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)), &m_transferOptions);
#else
m_texture->bind();
glPixelStorei(GL_UNPACK_ROW_LENGTH, 2048);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)));
m_texture->release();
#endif
buf_usage[buf_idx].clear();
source.setRect(x, y, w, h);
if (origSource != source) onResize(this->width(), this->height());