| 81 | } |
| 82 | |
| 83 | void GFXGLWindowTarget::resolveTo(GFXTextureObject* obj) |
| 84 | { |
| 85 | AssertFatal(dynamic_cast<GFXGLTextureObject*>(obj), "GFXGLTextureTarget::resolveTo - Incorrect type of texture, expected a GFXGLTextureObject"); |
| 86 | GFXGLTextureObject* glTexture = static_cast<GFXGLTextureObject*>(obj); |
| 87 | |
| 88 | if( GFXGL->mCapabilities.copyImage ) |
| 89 | { |
| 90 | if(mBackBufferColorTex.getWidth() == glTexture->getWidth() |
| 91 | && mBackBufferColorTex.getHeight() == glTexture->getHeight() |
| 92 | && mBackBufferColorTex.getFormat() == glTexture->getFormat()) |
| 93 | { |
| 94 | glCopyImageSubData( |
| 95 | static_cast<GFXGLTextureObject*>(mBackBufferColorTex.getPointer())->getHandle(), GL_TEXTURE_2D, 0, 0, 0, 0, |
| 96 | glTexture->getHandle(), GL_TEXTURE_2D, 0, 0, 0, 0, |
| 97 | getSize().x, getSize().y, 1); |
| 98 | return; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | PRESERVE_FRAMEBUFFER(); |
| 103 | |
| 104 | if(!mCopyFBO) |
| 105 | { |
| 106 | glGenFramebuffers(1, &mCopyFBO); |
| 107 | } |
| 108 | |
| 109 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mCopyFBO); |
| 110 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexture->getHandle(), 0); |
| 111 | |
| 112 | glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackBufferFBO); |
| 113 | |
| 114 | glBlitFramebuffer(0, 0, getSize().x, getSize().y, |
| 115 | 0, 0, glTexture->getWidth(), glTexture->getHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 116 | } |
| 117 | |
| 118 | inline void GFXGLWindowTarget::_setupAttachments() |
| 119 | { |