MCPcopy Create free account
hub / github.com/Kitware/VTK / Load

Method Load

Rendering/OpenGL2/vtkEquirectangularToCubeMapTexture.cxx:56–161  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

54
55//------------------------------------------------------------------------------
56void vtkEquirectangularToCubeMapTexture::Load(vtkRenderer* ren)
57{
58 vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(ren->GetRenderWindow());
59 if (!renWin)
60 {
61 vtkErrorMacro("No render window.");
62 }
63
64 if (!this->InputTexture)
65 {
66 vtkErrorMacro("No input texture specified.");
67 }
68
69 this->InputTexture->Render(ren);
70
71 if (this->GetMTime() > this->LoadTime.GetMTime() ||
72 this->InputTexture->GetMTime() > this->LoadTime.GetMTime())
73 {
74 if (this->TextureObject == nullptr)
75 {
76 this->TextureObject = vtkTextureObject::New();
77 }
78 this->TextureObject->SetContext(renWin);
79 this->TextureObject->SetFormat(
80 this->InputTexture->GetTextureObject()->GetFormat(VTK_FLOAT, 3, true));
81 this->TextureObject->SetInternalFormat(
82 this->InputTexture->GetTextureObject()->GetInternalFormat(VTK_FLOAT, 3, true));
83 this->TextureObject->SetDataType(
84 this->InputTexture->GetTextureObject()->GetDataType(VTK_FLOAT));
85 this->TextureObject->SetWrapS(vtkTextureObject::ClampToEdge);
86 this->TextureObject->SetWrapT(vtkTextureObject::ClampToEdge);
87 this->TextureObject->SetWrapR(vtkTextureObject::ClampToEdge);
88 this->TextureObject->SetMinificationFilter(vtkTextureObject::Linear);
89 this->TextureObject->SetMagnificationFilter(vtkTextureObject::Linear);
90 this->TextureObject->CreateCubeFromRaw(
91 this->CubeMapSize, this->CubeMapSize, 3, VTK_FLOAT, nullptr);
92
93 this->RenderWindow = renWin;
94
95 vtkOpenGLState* state = renWin->GetState();
96 vtkOpenGLState::ScopedglViewport svp(state);
97 vtkOpenGLState::ScopedglEnableDisable sdepth(state, GL_DEPTH_TEST);
98 vtkOpenGLState::ScopedglEnableDisable sblend(state, GL_BLEND);
99 vtkOpenGLState::ScopedglEnableDisable sscissor(state, GL_SCISSOR_TEST);
100
101 this->TextureObject->Activate();
102
103 vtkNew<vtkOpenGLFramebufferObject> fbo;
104 fbo->SetContext(renWin);
105 state->PushFramebufferBindings();
106 fbo->Bind();
107
108 for (int i = 0; i < 6; i++)
109 {
110 fbo->AddColorAttachment(i, this->TextureObject, 0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
111 }
112 fbo->ActivateDrawBuffers(6);
113 fbo->Start(this->CubeMapSize, this->CubeMapSize);

Callers

nothing calls this directly

Calls 15

SetInternalFormatMethod · 0.80
GetInternalFormatMethod · 0.80
CreateCubeFromRawMethod · 0.80
AddColorAttachmentMethod · 0.80
RenderMethod · 0.65
NewFunction · 0.50
GetRenderWindowMethod · 0.45
GetMTimeMethod · 0.45
SetContextMethod · 0.45
SetFormatMethod · 0.45
GetFormatMethod · 0.45
SetDataTypeMethod · 0.45

Tested by

no test coverage detected