summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-04-01 10:26:26 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-04-01 10:26:26 +0200
commita269a82011855c220f5fa726234c2fffe9d70443 (patch)
tree17a77b10fd76b7a70072f936d12ed39ec779eddb /examples
parente5b17da8674447acaf0c30cd003fed18875d379e (diff)
Use QSGPlainTexture::setImage() instead of generating our own texture.
Takes care of swizzling based on whether we're on GL ES or not.
Diffstat (limited to 'examples')
-rw-r--r--examples/qml-compositor/main.cpp20
1 files changed, 2 insertions, 18 deletions
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);