------------------------------------------------------------------------------ Description: Copy a sub-part of a logical buffer of the framebuffer (color or depth) to the texture object. src is the framebuffer, dst is the texture. (srcXmin,srcYmin) is the location of the lower left corner of the rectangle in the framebuffer. (dstXmin,dstYmin) is the location of the lower left corner of the rectang
| 2136 | // glReadBuffer(). |
| 2137 | // \pre is2D: GetNumberOfDimensions()==2 |
| 2138 | void vtkTextureObject::CopyFromFrameBuffer( |
| 2139 | int srcXmin, int srcYmin, int vtkNotUsed(dstXmin), int vtkNotUsed(dstYmin), int width, int height) |
| 2140 | { |
| 2141 | assert("pre: is2D" && this->GetNumberOfDimensions() == 2); |
| 2142 | |
| 2143 | // make assumption on the need to resolve |
| 2144 | // based on MultiSample setting |
| 2145 | if (this->Context->GetMultiSamples()) |
| 2146 | { |
| 2147 | vtkNew<vtkOpenGLFramebufferObject> resolvedFBO; |
| 2148 | resolvedFBO->SetContext(this->Context); |
| 2149 | this->Context->GetState()->PushFramebufferBindings(); |
| 2150 | resolvedFBO->PopulateFramebuffer(width, height, |
| 2151 | /* useTextures = */ true, |
| 2152 | /* numberOfColorAttachments = */ 1, |
| 2153 | /* colorDataType = */ VTK_UNSIGNED_CHAR, |
| 2154 | /* wantDepthAttachment = */ true, |
| 2155 | /* depthBitplanes = */ 24, |
| 2156 | /* multisamples = */ 0); |
| 2157 | |
| 2158 | // PopulateFramebuffer changes active read/write buffer bindings, |
| 2159 | // hence we restore the read buffer bindings to read from the original |
| 2160 | // frame buffer. |
| 2161 | this->Context->GetState()->PopReadFramebufferBinding(); |
| 2162 | |
| 2163 | vtkOpenGLState::ScopedglViewport vsaver(this->Context->GetState()); |
| 2164 | this->Context->GetState()->vtkglViewport(0, 0, width, height); |
| 2165 | vtkOpenGLState::ScopedglScissor ssaver(this->Context->GetState()); |
| 2166 | this->Context->GetState()->vtkglScissor(0, 0, width, height); |
| 2167 | |
| 2168 | // Now blit to resolve the MSAA and get an anti-aliased rendering in |
| 2169 | // resolvedFBO. |
| 2170 | this->Context->GetState()->vtkglBlitFramebuffer(srcXmin, srcYmin, srcXmin + width, |
| 2171 | srcYmin + height, 0, 0, width, height, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 2172 | |
| 2173 | // Now make the resolvedFBO the read buffer and read from it. |
| 2174 | this->Context->GetState()->PushReadFramebufferBinding(); |
| 2175 | resolvedFBO->Bind(GL_READ_FRAMEBUFFER); |
| 2176 | resolvedFBO->ActivateReadBuffer(0); |
| 2177 | |
| 2178 | this->Activate(); |
| 2179 | |
| 2180 | glCopyTexImage2D(this->Target, 0, this->InternalFormat, 0, 0, width, height, 0); |
| 2181 | |
| 2182 | // restore bindings and release the resolvedFBO. |
| 2183 | this->Context->GetState()->PopFramebufferBindings(); |
| 2184 | } |
| 2185 | else |
| 2186 | { |
| 2187 | this->Activate(); |
| 2188 | glCopyTexImage2D(this->Target, 0, this->InternalFormat, srcXmin, srcYmin, width, height, 0); |
| 2189 | } |
| 2190 | |
| 2191 | vtkOpenGLCheckErrorMacro("failed at glCopyTexImage2D " << this->InternalFormat); |
| 2192 | } |
| 2193 | |
| 2194 | //------------------------------------------------------------------------------ |
| 2195 | int vtkTextureObject::GetMaximumTextureSize(vtkOpenGLRenderWindow* context) |
no test coverage detected