mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Enable dynamic change of image processing Shader on source.
This commit is contained in:
@@ -91,6 +91,9 @@ void ImGuiVisitor::visit(Group &n)
|
||||
|
||||
// ImGui::TreePop();
|
||||
// }
|
||||
|
||||
// spacing
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetTextLineHeight() / 2.f);
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Switch &n)
|
||||
@@ -182,12 +185,12 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
{
|
||||
ImGui::PushID(n.id());
|
||||
|
||||
// if (ImGuiToolkit::ButtonIcon(6, 2)) {
|
||||
// ImageProcessingShader defaultvalues;
|
||||
// n = defaultvalues;
|
||||
// }
|
||||
// ImGui::SameLine(0, 10);
|
||||
// ImGui::Text("Filters");
|
||||
if (ImGuiToolkit::ButtonIcon(6, 2)) {
|
||||
ImageProcessingShader defaultvalues;
|
||||
n = defaultvalues;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::Text("Filters");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(6, 4)) n.gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
ImGui::SameLine(0, 10);
|
||||
@@ -258,6 +261,8 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, n.chromadelta < 0.001 ? "None" : "Tolerance %.2f");
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetTextLineHeight() / 2.f);
|
||||
}
|
||||
|
||||
|
||||
@@ -271,15 +276,19 @@ void ImGuiVisitor::visit (Source& s)
|
||||
ImVec2 imagesize ( preview_width, preview_width / s.frame()->aspectRatio());
|
||||
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), imagesize);
|
||||
|
||||
ImVec2 pos = ImGui::GetCursorPos(); // remember where we were...
|
||||
|
||||
// toggle enable/disable image processing
|
||||
bool on = s.imageProcessingEnabled();
|
||||
if (ImGuiToolkit::ButtonIconToggle(11, 4, 10, 4, &on)) {
|
||||
ImGui::SetCursorPos( ImVec2(preview_width + 15, pos.y -ImGui::GetFrameHeight() ) );
|
||||
const char *tooltip[2] = {"GPU Image processing\nCurrently disabled", "GPU Image processing\nCurrently enabled"};
|
||||
if (ImGuiToolkit::IconToggle(12, 11, 14, 1, &on, tooltip))
|
||||
s.setImageProcessingEnabled(on);
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::Text("Filters");
|
||||
|
||||
ImGui::SetCursorPos(pos); // ...come back
|
||||
|
||||
// image processing pannel
|
||||
if (on)
|
||||
if (s.imageProcessingEnabled())
|
||||
s.processingShader()->accept(*this);
|
||||
|
||||
// geometry direct control
|
||||
|
||||
14
Source.h
14
Source.h
@@ -65,8 +65,11 @@ public:
|
||||
// a Source has a shader used to render in fbo
|
||||
inline Shader *renderingShader() const { return renderingshader_; }
|
||||
|
||||
// the rendering shader is either a simple or an image processing shader
|
||||
// the rendering shader always have an image processing shader
|
||||
inline ImageProcessingShader *processingShader () const { return processingshader_; }
|
||||
|
||||
// the image processing shader can be enabled or disabled
|
||||
// (NB: when disabled, a simple ImageShader is applied)
|
||||
void setImageProcessingEnabled (bool on);
|
||||
bool imageProcessingEnabled();
|
||||
|
||||
@@ -141,10 +144,13 @@ protected:
|
||||
// It is associated to the rendershader for mixing effects
|
||||
FrameBufferSurface *rendersurface_;
|
||||
|
||||
// render and image processing shaders
|
||||
virtual void replaceRenderingShader() = 0;
|
||||
Shader *renderingshader_;
|
||||
// image processing shaders
|
||||
ImageProcessingShader *processingshader_;
|
||||
// pointer to the currently attached shader
|
||||
// (will be processingshader_ if image processing is enabled)
|
||||
Shader *renderingshader_;
|
||||
// every sub class will attach the shader to a different node / hierarchy
|
||||
virtual void replaceRenderingShader() = 0;
|
||||
|
||||
// blendingshader provides mixing controls
|
||||
ImageShader *blendingshader_;
|
||||
|
||||
Reference in New Issue
Block a user