------------------------------------------------------------------------------ Description: Create an offScreen window based on OpenGL framebuffer extension. Return if the creation was successful or not. \pre positive_width: width>0 \pre positive_height: height>0 \post valid_result: (result==0 || result==1)
| 2772 | // \pre positive_height: height>0 |
| 2773 | // \post valid_result: (result==0 || result==1) |
| 2774 | int vtkOpenGLRenderWindow::CreateFramebuffers(int width, int height) |
| 2775 | { |
| 2776 | assert("pre: positive_width" && width > 0); |
| 2777 | assert("pre: positive_height" && height > 0); |
| 2778 | |
| 2779 | #if defined(__APPLE__) |
| 2780 | // make sure requested multisamples is OK with platform |
| 2781 | // APPLE Intel systems seem to have buggy multisampled |
| 2782 | // framebuffer blits etc that cause issues |
| 2783 | if (this->MultiSamples > 0) |
| 2784 | { |
| 2785 | if (this->GetState()->GetVendor().find("Intel") != std::string::npos) |
| 2786 | { |
| 2787 | this->MultiSamples = 0; |
| 2788 | } |
| 2789 | } |
| 2790 | #endif |
| 2791 | |
| 2792 | if (this->LastMultiSamples != this->MultiSamples) |
| 2793 | { |
| 2794 | this->RenderFramebuffer->ReleaseGraphicsResources(this); |
| 2795 | } |
| 2796 | |
| 2797 | if (!this->RenderFramebuffer->GetFBOIndex()) |
| 2798 | { |
| 2799 | // verify that our multisample setting does not exceed the hardware |
| 2800 | if (this->MultiSamples) |
| 2801 | { |
| 2802 | #ifdef GL_MAX_SAMPLES |
| 2803 | int msamples = 0; |
| 2804 | this->GetState()->vtkglGetIntegerv(GL_MAX_SAMPLES, &msamples); |
| 2805 | this->MultiSamples = std::min(this->MultiSamples, msamples); |
| 2806 | if (this->MultiSamples == 1) |
| 2807 | { |
| 2808 | this->MultiSamples = 0; |
| 2809 | } |
| 2810 | #else |
| 2811 | this->MultiSamples = 0; |
| 2812 | #endif |
| 2813 | } |
| 2814 | this->GetState()->PushFramebufferBindings(); |
| 2815 | this->RenderFramebuffer->PopulateFramebuffer(width, height, |
| 2816 | #ifdef GL_TEXTURE_2D_MULTISAMPLE |
| 2817 | true, // textures |
| 2818 | #else |
| 2819 | this->MultiSamples ? false : true, // textures |
| 2820 | #endif |
| 2821 | 1, VTK_UNSIGNED_CHAR, // 1 color buffer uchar |
| 2822 | true, this->RenderBufferTargetDepthSize, // depth buffer |
| 2823 | this->MultiSamples, this->StencilCapable != 0); |
| 2824 | this->LastMultiSamples = this->MultiSamples; |
| 2825 | this->GetState()->PopFramebufferBindings(); |
| 2826 | } |
| 2827 | else |
| 2828 | { |
| 2829 | this->RenderFramebuffer->Resize(width, height); |
| 2830 | } |
| 2831 |
no test coverage detected