From a269a82011855c220f5fa726234c2fffe9d70443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 1 Apr 2011 10:26:26 +0200 Subject: Use QSGPlainTexture::setImage() instead of generating our own texture. Takes care of swizzling based on whether we're on GL ES or not. --- examples/qml-compositor/main.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'examples') diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index 7746be2..519786d 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -102,27 +102,11 @@ void WaylandSurfaceTextureProvider::surfaceDamaged(const QRect &) if (m_surface->type() == WaylandSurface::Texture) { m_texture->setTextureId(m_surface->texture()); m_texture->setHasAlphaChannel(false); + m_texture->setTextureSize(m_surface->geometry().size()); } else { - if (!m_texture->textureId()) { - GLuint textureId; - glGenTextures(1, &textureId); - glBindTexture(GL_TEXTURE_2D, textureId); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - m_texture->setTextureId(textureId); - } - - const QImage image = m_surface->image(); - - glBindTexture(GL_TEXTURE_2D, m_texture->textureId()); - glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, image.width(), image.height(), 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, image.bits()); - - m_texture->setHasAlphaChannel(image.hasAlphaChannel()); + m_texture->setImage(m_surface->image()); } - m_texture->setTextureSize(m_surface->geometry().size()); m_texture->setOwnsTexture(true); m_texture->setHasMipmaps(false); -- cgit v1.2.3