diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp new file mode 100644 index 000000000..f1cc97d0d --- /dev/null +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -0,0 +1,132 @@ +#include +#include +#include +#include + +InputValue::InputValue(ShaderGraph& graph) : +ShaderNode(graph), +m_currentInputIndex(0) +{ + m_layout = new QVBoxLayout; + + m_inputSelection = new QComboBox; + m_inputSelection->setStyleSheet("background-color: rgba(255,255,255,255)"); + connect(m_inputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index < 0) + return; + + m_currentInputIndex = static_cast(index); + UpdatePreview(); + }); + + m_layout->addWidget(m_inputSelection); + + m_previewLabel = new QLabel; + + m_layout->addWidget(m_previewLabel); + + m_widget = new QWidget; + m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); + m_widget->setLayout(m_layout); + + m_onInputListUpdateSlot.Connect(GetGraph().OnInputListUpdate, [&](ShaderGraph*) { UpdateInputList(); }); + m_onInputUpdateSlot.Connect(GetGraph().OnInputUpdate, [&](ShaderGraph*, std::size_t inputIndex) + { + if (m_currentInputIndex == inputIndex) + UpdatePreview(); + }); + + UpdateInputList(); + UpdatePreview(); +} + +QWidget* InputValue::embeddedWidget() +{ + return m_widget; +} + +unsigned int InputValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 0; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +void InputValue::UpdatePreview() +{ + if (m_inputSelection->count() == 0) + return; + + Q_EMIT dataUpdated(0); +} + +void InputValue::UpdateInputList() +{ + QString currentInput = m_inputSelection->currentText(); + m_inputSelection->clear(); + + for (const auto& inputEntry : GetGraph().GetInputs()) + m_inputSelection->addItem(QString::fromStdString(inputEntry.name)); + + m_inputSelection->setCurrentText(currentInput); +} + +Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 0); + + const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + + Nz::ShaderAst::ExpressionType expression = [&] + { + switch (inputEntry.type) + { + case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InputType::Float2: return Nz::ShaderAst::ExpressionType::Float2; + case InputType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InputType::Float4: return Nz::ShaderAst::ExpressionType::Float4; + } + + assert(false); + throw std::runtime_error("Unhandled input type"); + }(); + + return Nz::ShaderBuilder::Input(inputEntry.name, expression); +} + +auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + switch (inputEntry.type) + { + //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + //case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InputType::Float2: return Vec2Data::Type(); + //case InputType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InputType::Float4: return Vec4Data::Type(); + } + + assert(false); + throw std::runtime_error("Unhandled input type"); +} + +std::shared_ptr InputValue::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + + auto vecData = std::make_shared(); + vecData->preview = QImage(); + + return vecData; +} diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp new file mode 100644 index 000000000..63e896adf --- /dev/null +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -0,0 +1,47 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_INPUTVALUE_HPP +#define NAZARA_SHADERNODES_INPUTVALUE_HPP + +#include +#include +#include +#include +#include +#include + +class InputValue : public ShaderNode +{ + public: + InputValue(ShaderGraph& graph); + ~InputValue() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + + QString caption() const override { return "Input"; } + QString name() const override { return "Input"; } + + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + protected: + void UpdatePreview(); + void UpdateInputList(); + + NazaraSlot(ShaderGraph, OnInputListUpdate, m_onInputListUpdateSlot); + NazaraSlot(ShaderGraph, OnInputUpdate, m_onInputUpdateSlot); + + std::size_t m_currentInputIndex; + QComboBox* m_inputSelection; + QLabel* m_previewLabel; + QWidget* m_widget; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/InputValue.inl b/src/ShaderNode/DataModels/InputValue.inl new file mode 100644 index 000000000..ff350c7c4 --- /dev/null +++ b/src/ShaderNode/DataModels/InputValue.inl @@ -0,0 +1,2 @@ +#include +#include diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 180989226..925094b6b 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -94,7 +94,20 @@ Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::Express { assert(count == 1); - auto sampler = Nz::ShaderBuilder::Uniform("Texture0", Nz::ShaderAst::ExpressionType::Sampler2D); + const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); + + Nz::ShaderAst::ExpressionType expression = [&] + { + switch (textureEntry.type) + { + case TextureType::Sampler2D: return Nz::ShaderAst::ExpressionType::Sampler2D; + } + + assert(false); + throw std::runtime_error("Unhandled texture type"); + }(); + + auto sampler = Nz::ShaderBuilder::Uniform(textureEntry.name, expression); return Nz::ShaderBuilder::Sample2D(sampler, expressions[0]); } diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp new file mode 100644 index 000000000..f280ce793 --- /dev/null +++ b/src/ShaderNode/Enums.cpp @@ -0,0 +1,42 @@ +#include +#include + +const char* EnumToString(InputRole role) +{ + switch (role) + { + case InputRole::None: return "None"; + case InputRole::Normal: return "Normal"; + case InputRole::Position: return "Position"; + case InputRole::TexCoord: return "TexCoord"; + } + + assert(false); + return ""; +} + +const char* EnumToString(InputType input) +{ + switch (input) + { + case InputType::Bool: return "Bool"; + case InputType::Float1: return "Float"; + case InputType::Float2: return "Float2"; + case InputType::Float3: return "Float3"; + case InputType::Float4: return "Float4"; + } + + assert(false); + return ""; +} + +const char* EnumToString(TextureType textureType) +{ + switch (textureType) + { + case TextureType::Sampler2D: return "Sampler2D"; + } + + assert(false); + return ""; +} diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp new file mode 100644 index 000000000..6a7a34336 --- /dev/null +++ b/src/ShaderNode/Enums.hpp @@ -0,0 +1,48 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_ENUMS_HPP +#define NAZARA_SHADERNODES_ENUMS_HPP + +#include + +enum class InputRole +{ + None, + Normal, + Position, + TexCoord, + + Max = TexCoord +}; + +constexpr std::size_t InputRoleCount = static_cast(InputRole::Max) + 1; + +enum class InputType +{ + Bool, + Float1, + Float2, + Float3, + Float4, + + Max = Float4 +}; + +constexpr std::size_t InputTypeCount = static_cast(InputType::Max) + 1; + +enum class TextureType +{ + Sampler2D, + + Max = Sampler2D +}; + +constexpr std::size_t TextureTypeCount = static_cast(TextureType::Max) + 1; + +const char* EnumToString(InputRole role); +const char* EnumToString(InputType input); +const char* EnumToString(TextureType textureType); + +#include + +#endif diff --git a/src/ShaderNode/Enums.inl b/src/ShaderNode/Enums.inl new file mode 100644 index 000000000..a23a54efb --- /dev/null +++ b/src/ShaderNode/Enums.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index ee02e6c11..0b95e137f 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,21 @@ m_flowScene(BuildRegistry()) m_flowScene.createConnection(node2, 0, node1, 0); } -std::size_t ShaderGraph::AddTexture(std::string name, Nz::ShaderAst::ExpressionType type) +std::size_t ShaderGraph::AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex) +{ + std::size_t index = m_inputs.size(); + auto& inputEntry = m_inputs.emplace_back(); + inputEntry.name = std::move(name); + inputEntry.role = role; + inputEntry.roleIndex = roleIndex; + inputEntry.type = type; + + OnInputListUpdate(this); + + return index; +} + +std::size_t ShaderGraph::AddTexture(std::string name, TextureType type) { std::size_t index = m_textures.size(); auto& textureEntry = m_textures.emplace_back(); @@ -85,6 +100,18 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() return std::make_shared(std::move(statements)); } +void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InputType type, InputRole role, std::size_t roleIndex) +{ + assert(inputIndex < m_inputs.size()); + auto& inputEntry = m_inputs[inputIndex]; + inputEntry.name = std::move(name); + inputEntry.role = role; + inputEntry.roleIndex = roleIndex; + inputEntry.type = type; + + OnInputUpdate(this, inputIndex); +} + void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) { assert(textureIndex < m_textures.size()); @@ -98,7 +125,8 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); - RegisterShaderNode(*this, registry, "Output"); + RegisterShaderNode(*this, registry, "Outputs"); + RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index cac252802..132c9c25b 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -6,35 +6,50 @@ #include #include #include -#include +#include #include #include class ShaderGraph { public: + struct InputEntry; struct TextureEntry; ShaderGraph(); ~ShaderGraph() = default; - std::size_t AddTexture(std::string name, Nz::ShaderAst::ExpressionType type); + std::size_t AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex); + std::size_t AddTexture(std::string name, TextureType type); + inline const InputEntry& GetInput(std::size_t inputIndex) const; + inline const std::vector& GetInputs() const; inline QtNodes::FlowScene& GetScene(); inline const TextureEntry& GetTexture(std::size_t textureIndex) const; - inline const std::vector& GetTextures(); + inline const std::vector& GetTextures() const; Nz::ShaderAst::StatementPtr ToAst(); + void UpdateInput(std::size_t inputIndex, std::string name, InputType type, InputRole role, std::size_t roleIndex); void UpdateTexturePreview(std::size_t texture, QImage preview); + struct InputEntry + { + std::size_t roleIndex; + std::string name; + InputRole role; + InputType type; + }; + struct TextureEntry { std::string name; - Nz::ShaderAst::ExpressionType type; + TextureType type; QImage preview; }; + NazaraSignal(OnInputListUpdate, ShaderGraph*); + NazaraSignal(OnInputUpdate, ShaderGraph*, std::size_t /*inputIndex*/); NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); @@ -42,6 +57,7 @@ class ShaderGraph std::shared_ptr BuildRegistry(); QtNodes::FlowScene m_flowScene; + std::vector m_inputs; std::vector m_textures; }; diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 1f0b463e9..bb39d44f3 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -1,5 +1,16 @@ #include +inline auto ShaderGraph::GetInput(std::size_t inputIndex) const -> const InputEntry& +{ + assert(inputIndex < m_inputs.size()); + return m_inputs[inputIndex]; +} + +inline auto ShaderGraph::GetInputs() const -> const std::vector& +{ + return m_inputs; +} + inline QtNodes::FlowScene& ShaderGraph::GetScene() { return m_flowScene; @@ -11,7 +22,7 @@ inline auto ShaderGraph::GetTexture(std::size_t textureIndex) const -> const Tex return m_textures[textureIndex]; } -inline auto ShaderGraph::GetTextures() -> const std::vector& +inline auto ShaderGraph::GetTextures() const -> const std::vector& { return m_textures; } diff --git a/src/ShaderNode/Widgets/InputEditDialog.cpp b/src/ShaderNode/Widgets/InputEditDialog.cpp new file mode 100644 index 000000000..d9642966c --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditDialog.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +InputEditDialog::InputEditDialog(QWidget* parent) : +QDialog(parent) +{ + setWindowTitle(tr("Input edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_inputName = new QLineEdit; + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < InputTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + m_roleList = new QComboBox; + for (std::size_t i = 0; i < InputRoleCount; ++i) + m_roleList->addItem(EnumToString(static_cast(i))); + + m_roleIndex = new QSpinBox; + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_inputName); + formLayout->addRow(tr("Type"), m_typeList); + formLayout->addRow(tr("Role"), m_roleList); + formLayout->addRow(tr("Role index"), m_roleIndex); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &InputEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +InputEditDialog::InputEditDialog(const InputInfo& input, QWidget* parent) : +InputEditDialog(parent) +{ + m_inputName->setText(QString::fromStdString(input.name)); + m_roleIndex->setValue(int(input.roleIndex)); + m_roleList->setCurrentText(EnumToString(input.role)); + m_typeList->setCurrentText(EnumToString(input.type)); +} + +InputInfo InputEditDialog::GetInputInfo() const +{ + InputInfo inputInfo; + inputInfo.name = m_inputName->text().toStdString(); + inputInfo.role = static_cast(m_roleList->currentIndex()); + inputInfo.roleIndex = static_cast(m_roleIndex->value()); + inputInfo.type = static_cast(m_typeList->currentIndex()); + + return inputInfo; +} + +void InputEditDialog::OnAccept() +{ + if (m_inputName->text().isEmpty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Input name must be set"), QMessageBox::Ok); + return; + } + + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid type"), tr("You must select a type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/InputEditDialog.hpp b/src/ShaderNode/Widgets/InputEditDialog.hpp new file mode 100644 index 000000000..829697049 --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditDialog.hpp @@ -0,0 +1,41 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_INPUTEDITDIALOG_HPP +#define NAZARA_SHADERNODES_INPUTEDITDIALOG_HPP + +#include +#include + +class QComboBox; +class QLineEdit; +class QSpinBox; + +struct InputInfo +{ + std::size_t roleIndex; + std::string name; + InputRole role; + InputType type; +}; + +class InputEditDialog : public QDialog +{ + public: + InputEditDialog(QWidget* parent = nullptr); + InputEditDialog(const InputInfo& input, QWidget* parent = nullptr); + ~InputEditDialog() = default; + + InputInfo GetInputInfo() const; + + private: + void OnAccept(); + + QComboBox* m_roleList; + QComboBox* m_typeList; + QLineEdit* m_inputName; + QSpinBox* m_roleIndex; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/InputEditDialog.inl b/src/ShaderNode/Widgets/InputEditDialog.inl new file mode 100644 index 000000000..a480716aa --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditDialog.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/InputEditor.cpp b/src/ShaderNode/Widgets/InputEditor.cpp new file mode 100644 index 000000000..86a28a2eb --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditor.cpp @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +InputEditor::InputEditor(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + m_inputList = new QListWidget(this); + connect(m_inputList, &QListWidget::currentRowChanged, this, &InputEditor::OnInputSelectionUpdate); + connect(m_inputList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditInput(m_inputList->row(item)); + }); + + QPushButton* addInputButton = new QPushButton(tr("Add input...")); + connect(addInputButton, &QPushButton::released, this, &InputEditor::OnAddInput); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_inputList); + m_layout->addWidget(addInputButton); + + setLayout(m_layout); + + m_onInputListUpdateSlot.Connect(m_shaderGraph.OnInputListUpdate, this, &InputEditor::OnInputListUpdate); + m_onInputUpdateSlot.Connect(m_shaderGraph.OnInputUpdate, this, &InputEditor::OnInputUpdate); + + RefreshInputs(); +} + +void InputEditor::OnAddInput() +{ + InputEditDialog* dialog = new InputEditDialog(this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + InputInfo inputInfo = dialog->GetInputInfo(); + m_shaderGraph.AddInput(std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex); + }); + + dialog->open(); +} + +void InputEditor::OnEditInput(int inputIndex) +{ + const auto& input = m_shaderGraph.GetInput(inputIndex); + + InputInfo info; + info.name = input.name; + info.type = input.type; + info.role = input.role; + info.roleIndex = input.roleIndex; + + InputEditDialog* dialog = new InputEditDialog(std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] + { + InputInfo inputInfo = dialog->GetInputInfo(); + m_shaderGraph.UpdateInput(inputIndex, std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex); + }); + + dialog->open(); +} + +void InputEditor::OnInputSelectionUpdate(int inputIndex) +{ + if (inputIndex >= 0) + { + m_currentInputIndex = inputIndex; + } + else + m_currentInputIndex.reset(); +} + +void InputEditor::OnInputListUpdate(ShaderGraph* /*graph*/) +{ + RefreshInputs(); +} + +void InputEditor::OnInputUpdate(ShaderGraph* /*graph*/, std::size_t inputIndex) +{ + const auto& inputEntry = m_shaderGraph.GetInput(inputIndex); + m_inputList->item(int(inputIndex))->setText(QString::fromStdString(inputEntry.name)); +} + +void InputEditor::RefreshInputs() +{ + m_inputList->clear(); + m_inputList->setCurrentRow(-1); + + for (const auto& inputEntry : m_shaderGraph.GetInputs()) + m_inputList->addItem(QString::fromStdString(inputEntry.name)); +} diff --git a/src/ShaderNode/Widgets/InputEditor.hpp b/src/ShaderNode/Widgets/InputEditor.hpp new file mode 100644 index 000000000..236f9069f --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditor.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_INPUTEDITOR_HPP +#define NAZARA_SHADERNODES_INPUTEDITOR_HPP + +#include +#include +#include + +class QLabel; +class QListWidget; +class QVBoxLayout; + +class InputEditor : public QWidget +{ + public: + InputEditor(ShaderGraph& graph); + ~InputEditor() = default; + + private: + void OnAddInput(); + void OnEditInput(int inputIndex); + void OnInputSelectionUpdate(int inputIndex); + void OnInputListUpdate(ShaderGraph* graph); + void OnInputUpdate(ShaderGraph* graph, std::size_t inputIndex); + void RefreshInputs(); + + NazaraSlot(ShaderGraph, OnInputListUpdate, m_onInputListUpdateSlot); + NazaraSlot(ShaderGraph, OnInputUpdate, m_onInputUpdateSlot); + + std::optional m_currentInputIndex; + ShaderGraph& m_shaderGraph; + QListWidget* m_inputList; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/InputEditor.inl b/src/ShaderNode/Widgets/InputEditor.inl new file mode 100644 index 000000000..a480716aa --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditor.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index d4a661790..150770541 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,8 +1,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -17,6 +19,13 @@ m_shaderGraph(graph) QtNodes::FlowView* flowView = new QtNodes::FlowView(scene); setCentralWidget(flowView); + QDockWidget* inputDock = new QDockWidget(tr("&Inputs")); + + InputEditor* inputEditor = new InputEditor(m_shaderGraph); + inputDock->setWidget(inputEditor); + + addDockWidget(Qt::LeftDockWidgetArea, inputDock); + QDockWidget* textureDock = new QDockWidget(tr("&Textures")); TextureEditor* textureEditor = new TextureEditor(m_shaderGraph); diff --git a/src/ShaderNode/Widgets/TextureEditor.cpp b/src/ShaderNode/Widgets/TextureEditor.cpp index 594262c1a..44a68fec9 100644 --- a/src/ShaderNode/Widgets/TextureEditor.cpp +++ b/src/ShaderNode/Widgets/TextureEditor.cpp @@ -9,7 +9,7 @@ TextureEditor::TextureEditor(ShaderGraph& graph) : m_shaderGraph(graph) { - m_textureList = new QListWidget(this); + m_textureList = new QListWidget; connect(m_textureList, &QListWidget::currentRowChanged, this, &TextureEditor::OnTextureSelectionUpdate); m_pixmapLabel = new QLabel; diff --git a/src/ShaderNode/Widgets/TextureEditor.hpp b/src/ShaderNode/Widgets/TextureEditor.hpp index fcdbf3f7c..456b9b1d5 100644 --- a/src/ShaderNode/Widgets/TextureEditor.hpp +++ b/src/ShaderNode/Widgets/TextureEditor.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_TEXTUREEDITOR_HPP #include -#include +#include #include class QLabel; diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp index 648cbbbbc..a9554c8bd 100644 --- a/src/ShaderNode/main.cpp +++ b/src/ShaderNode/main.cpp @@ -8,8 +8,8 @@ int main(int argc, char* argv[]) QApplication app(argc, argv); ShaderGraph shaderGraph; - shaderGraph.AddTexture("Potato", Nz::ShaderAst::ExpressionType::Sampler2D); - shaderGraph.AddTexture("Blackbird", Nz::ShaderAst::ExpressionType::Sampler2D); + shaderGraph.AddInput("UV", InputType::Float2, InputRole::TexCoord, 0); + shaderGraph.AddTexture("Potato", TextureType::Sampler2D); MainWindow mainWindow(shaderGraph); mainWindow.resize(1280, 720);