mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 18:59:59 +01:00
BugFix ShaderEditor
This commit is contained in:
@@ -76,6 +76,10 @@ std::list< FilteringProgram > FilteringProgram::presets = {
|
|||||||
FilteringProgram("Fisheye", "shaders/filters/fisheye.glsl", "", { })
|
FilteringProgram("Fisheye", "shaders/filters/fisheye.glsl", "", { })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int FilteringProgram::getFilterHeaderNumlines()
|
||||||
|
{
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
std::string FilteringProgram::getFilterCodeInputs()
|
std::string FilteringProgram::getFilterCodeInputs()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public:
|
|||||||
inline void setParameter(const std::string &p, float value) { parameters_[p] = value; }
|
inline void setParameter(const std::string &p, float value) { parameters_[p] = value; }
|
||||||
|
|
||||||
// globals
|
// globals
|
||||||
|
static int getFilterHeaderNumlines();
|
||||||
static std::string getFilterCodeInputs();
|
static std::string getFilterCodeInputs();
|
||||||
static std::string getFilterCodeDefault();
|
static std::string getFilterCodeDefault();
|
||||||
static std::list< FilteringProgram > presets;
|
static std::list< FilteringProgram > presets;
|
||||||
|
|||||||
@@ -1132,7 +1132,7 @@ void UserInterface::showSourceEditor(Source *s)
|
|||||||
}
|
}
|
||||||
CloneSource *cs = dynamic_cast<CloneSource *>(s);
|
CloneSource *cs = dynamic_cast<CloneSource *>(s);
|
||||||
if (cs != nullptr) {
|
if (cs != nullptr) {
|
||||||
shadercontrol.refresh( cs );
|
shadercontrol.setVisible( cs );
|
||||||
}
|
}
|
||||||
if (s->playable()) {
|
if (s->playable()) {
|
||||||
sourcecontrol.setVisible(true);
|
sourcecontrol.setVisible(true);
|
||||||
@@ -5390,14 +5390,16 @@ bool ShaderEditor::Visible() const
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderEditor::refresh(CloneSource *cs)
|
void ShaderEditor::setVisible(CloneSource *cs)
|
||||||
{
|
{
|
||||||
if ( cs != nullptr && current_ != nullptr && cs == current_ ) {
|
if ( cs != nullptr ) {
|
||||||
filters_.erase(current_);
|
FrameBufferFilter *f = cs->filter();
|
||||||
current_ = nullptr;
|
// if the filter is an Image Filter
|
||||||
}
|
if (f && f->type() == FrameBufferFilter::FILTER_IMAGE )
|
||||||
|
setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShaderEditor::Render()
|
void ShaderEditor::Render()
|
||||||
{
|
{
|
||||||
@@ -5433,7 +5435,7 @@ void ShaderEditor::Render()
|
|||||||
{
|
{
|
||||||
for (auto p = FilteringProgram::presets.begin(); p != FilteringProgram::presets.end(); ++p){
|
for (auto p = FilteringProgram::presets.begin(); p != FilteringProgram::presets.end(); ++p){
|
||||||
|
|
||||||
if (ImGui::MenuItem( p->name().c_str() )) {
|
if (current_ != nullptr && ImGui::MenuItem( p->name().c_str() )) {
|
||||||
ImageFilter *i = dynamic_cast<ImageFilter *>( current_->filter() );
|
ImageFilter *i = dynamic_cast<ImageFilter *>( current_->filter() );
|
||||||
// if we can access the code of inside the image filter
|
// if we can access the code of inside the image filter
|
||||||
if (i) {
|
if (i) {
|
||||||
@@ -5550,9 +5552,9 @@ void ShaderEditor::Render()
|
|||||||
// get message returned from compilation
|
// get message returned from compilation
|
||||||
std::string s = compilation_return_.get();
|
std::string s = compilation_return_.get();
|
||||||
|
|
||||||
// find reported line numbers "0(nn)" and replace with "line N"
|
// find reported line numbers "0:nn" and replace with "line N"
|
||||||
status_ = "";
|
status_ = "";
|
||||||
std::regex e("0\\([[:digit:]]+\\)");
|
std::regex e("0\\:[[:digit:]]+");
|
||||||
std::smatch m;
|
std::smatch m;
|
||||||
while (std::regex_search(s, m, e)) {
|
while (std::regex_search(s, m, e)) {
|
||||||
status_ += m.prefix().str();
|
status_ += m.prefix().str();
|
||||||
@@ -5560,7 +5562,8 @@ void ShaderEditor::Render()
|
|||||||
std::string num = m.str().substr(2, m.length()-2);
|
std::string num = m.str().substr(2, m.length()-2);
|
||||||
if ( BaseToolkit::is_a_number(num, &l)){
|
if ( BaseToolkit::is_a_number(num, &l)){
|
||||||
status_ += "line ";
|
status_ += "line ";
|
||||||
status_ += std::to_string(l-15);
|
status_ += std::to_string(l - FilteringProgram::getFilterHeaderNumlines());
|
||||||
|
status_ += " ";
|
||||||
}
|
}
|
||||||
s = m.suffix().str();
|
s = m.suffix().str();
|
||||||
}
|
}
|
||||||
@@ -5588,7 +5591,9 @@ void ShaderEditor::Render()
|
|||||||
ImageFilter *i = dynamic_cast<ImageFilter *>(f);
|
ImageFilter *i = dynamic_cast<ImageFilter *>(f);
|
||||||
// if we can access the code of the filter
|
// if we can access the code of the filter
|
||||||
if (i) {
|
if (i) {
|
||||||
// set code for this clone
|
// if the current clone was not already registered
|
||||||
|
if ( filters_.find(c) == filters_.end() )
|
||||||
|
// remember code for this clone
|
||||||
filters_[c] = i->program();
|
filters_[c] = i->program();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ public:
|
|||||||
void Render();
|
void Render();
|
||||||
void setVisible(bool on);
|
void setVisible(bool on);
|
||||||
|
|
||||||
void refresh(CloneSource *cs);
|
void setVisible(CloneSource *cs);
|
||||||
|
|
||||||
// from WorkspaceWindow
|
// from WorkspaceWindow
|
||||||
bool Visible() const override;
|
bool Visible() const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user