Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwingltexture.cpp
Show First 20 Lines • Show All 531 Lines • ▼ Show 20 Line(s) | 531 | { | |||
---|---|---|---|---|---|
532 | Q_D(GLTexture); | 532 | Q_D(GLTexture); | ||
533 | Q_ASSERT(!d->m_foreign); | 533 | Q_ASSERT(!d->m_foreign); | ||
534 | if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && | 534 | if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && | ||
535 | GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065 | 535 | GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065 | ||
536 | glGenFramebuffers(1, &GLTexturePrivate::s_fbo); | 536 | glGenFramebuffers(1, &GLTexturePrivate::s_fbo); | ||
537 | 537 | | |||
538 | if (GLTexturePrivate::s_fbo) { | 538 | if (GLTexturePrivate::s_fbo) { | ||
539 | // Clear the texture | 539 | // Clear the texture | ||
540 | GLuint previousFramebuffer = 0; | ||||
541 | glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, reinterpret_cast<GLint *>(&previousFramebuffer)); | ||||
542 | if (GLTexturePrivate::s_fbo != previousFramebuffer) | ||||
540 | glBindFramebuffer(GL_FRAMEBUFFER, GLTexturePrivate::s_fbo); | 543 | glBindFramebuffer(GL_FRAMEBUFFER, GLTexturePrivate::s_fbo); | ||
541 | glClearColor(0, 0, 0, 0); | 544 | glClearColor(0, 0, 0, 0); | ||
542 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, d->m_texture, 0); | 545 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, d->m_texture, 0); | ||
543 | glClear(GL_COLOR_BUFFER_BIT); | 546 | glClear(GL_COLOR_BUFFER_BIT); | ||
544 | glBindFramebuffer(GL_FRAMEBUFFER, 0); | 547 | if (GLTexturePrivate::s_fbo != previousFramebuffer) | ||
548 | glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); | ||||
545 | } else { | 549 | } else { | ||
546 | if (const int size = width()*height()) { | 550 | if (const int size = width()*height()) { | ||
547 | uint32_t *buffer = new uint32_t[size]; | 551 | uint32_t *buffer = new uint32_t[size]; | ||
548 | memset(buffer, 0, size*sizeof(uint32_t)); | 552 | memset(buffer, 0, size*sizeof(uint32_t)); | ||
549 | bind(); | 553 | bind(); | ||
550 | if (!GLPlatform::instance()->isGLES()) { | 554 | if (!GLPlatform::instance()->isGLES()) { | ||
551 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width(), height(), | 555 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width(), height(), | ||
552 | GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); | 556 | GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); | ||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |