Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwingltexture.cpp
Show First 20 Lines • Show All 508 Lines • ▼ Show 20 Line(s) | |||||
509 | { | 509 | { | ||
510 | Q_D(GLTexture); | 510 | Q_D(GLTexture); | ||
511 | if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && | 511 | if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && | ||
512 | GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065 | 512 | GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065 | ||
513 | glGenFramebuffers(1, &GLTexturePrivate::s_fbo); | 513 | glGenFramebuffers(1, &GLTexturePrivate::s_fbo); | ||
514 | 514 | | |||
515 | if (GLTexturePrivate::s_fbo) { | 515 | if (GLTexturePrivate::s_fbo) { | ||
516 | // Clear the texture | 516 | // Clear the texture | ||
517 | GLuint previousFramebuffer = 0; | ||||
518 | glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, reinterpret_cast<GLint *>(&previousFramebuffer)); | ||||
519 | if (GLTexturePrivate::s_fbo != previousFramebuffer) | ||||
517 | glBindFramebuffer(GL_FRAMEBUFFER, GLTexturePrivate::s_fbo); | 520 | glBindFramebuffer(GL_FRAMEBUFFER, GLTexturePrivate::s_fbo); | ||
518 | glClearColor(0, 0, 0, 0); | 521 | glClearColor(0, 0, 0, 0); | ||
519 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, d->m_texture, 0); | 522 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, d->m_texture, 0); | ||
520 | glClear(GL_COLOR_BUFFER_BIT); | 523 | glClear(GL_COLOR_BUFFER_BIT); | ||
521 | glBindFramebuffer(GL_FRAMEBUFFER, 0); | 524 | if (GLTexturePrivate::s_fbo != previousFramebuffer) | ||
525 | glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); | ||||
522 | } else { | 526 | } else { | ||
523 | if (const int size = width()*height()) { | 527 | if (const int size = width()*height()) { | ||
524 | uint32_t *buffer = new uint32_t[size]; | 528 | uint32_t *buffer = new uint32_t[size]; | ||
525 | memset(buffer, 0, size*sizeof(uint32_t)); | 529 | memset(buffer, 0, size*sizeof(uint32_t)); | ||
526 | bind(); | 530 | bind(); | ||
527 | if (!GLPlatform::instance()->isGLES()) { | 531 | if (!GLPlatform::instance()->isGLES()) { | ||
528 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width(), height(), | 532 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width(), height(), | ||
529 | GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); | 533 | GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); | ||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |