Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Nov 20, 2024
1 parent 5a0f5ed commit 440da6d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DImguiObserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace
{

ImGuiKey GetImGuiKeyFromKeySym(std::string_view keySym)
{
if (keySym == "Tab") return ImGuiKey_Tab;
Expand Down Expand Up @@ -126,6 +125,7 @@ namespace
}
}

//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkF3DImguiObserver);

//----------------------------------------------------------------------------
Expand Down
67 changes: 35 additions & 32 deletions vtkext/private/module/vtkF3DImguiRender.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ struct vtkF3DImguiRender::Internals
}
}

void Release(vtkOpenGLRenderWindow* renWin)
{
if (ImGui::GetCurrentContext() != nullptr)
{
ImGuiIO& io = ImGui::GetIO();

if (this->FontTexture)
{
io.Fonts->SetTexID(0);
this->FontTexture->ReleaseGraphicsResources(renWin);
this->FontTexture = nullptr;
}

if (this->VertexBuffer)
{
this->VertexBuffer = nullptr;
}

if (this->IndexBuffer)
{
this->IndexBuffer = nullptr;
}

if (this->Program)
{
this->Program->ReleaseGraphicsResources(renWin);
this->Program = nullptr;
}

io.BackendPlatformName = io.BackendRendererName = nullptr;
ImGui::DestroyContext();
}
}

void RenderDrawData(vtkOpenGLRenderWindow* renWin, ImDrawData* drawData)
{
// Avoid rendering when minimized, scale coordinates for retina displays
Expand Down Expand Up @@ -261,38 +295,7 @@ void vtkF3DImguiRender::Initialize(vtkOpenGLRenderWindow* renWin)

void vtkF3DImguiRender::ReleaseGraphicsResources(vtkWindow* w)
{
if (ImGui::GetCurrentContext() != nullptr)
{
ImGuiIO& io = ImGui::GetIO();

vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(w);

if (this->Pimpl->FontTexture)
{
io.Fonts->SetTexID(0);
this->Pimpl->FontTexture->ReleaseGraphicsResources(renWin);
this->Pimpl->FontTexture = nullptr;
}

if (this->Pimpl->VertexBuffer)
{
this->Pimpl->VertexBuffer = nullptr;
}

if (this->Pimpl->IndexBuffer)
{
this->Pimpl->IndexBuffer = nullptr;
}

if (this->Pimpl->Program)
{
this->Pimpl->Program->ReleaseGraphicsResources(renWin);
this->Pimpl->Program = nullptr;
}

io.BackendPlatformName = io.BackendRendererName = nullptr;
ImGui::DestroyContext();
}
this->Pimpl->Release(vtkOpenGLRenderWindow::SafeDownCast(w));
}

//----------------------------------------------------------------------------
Expand Down

0 comments on commit 440da6d

Please sign in to comment.