From 80b428ad14d96aac0cccc7b99c18c2c9266374f8 Mon Sep 17 00:00:00 2001 From: Maddie Slockbower Date: Fri, 19 Jul 2024 14:43:18 -0400 Subject: [PATCH] Added License Brief to Source Files --- CMakeLists.txt | 6 +- Include/Core/Console.h | 14 ++- Include/Core/Engine.h | 14 ++- Include/Core/Renderer.h | 14 ++- Include/Core/Window.h | 13 ++- Include/Editor/ConsoleWindow.h | 13 ++- Include/Editor/EditorSystem.h | 13 ++- Include/Editor/EditorWindow.h | 13 ++- Include/Editor/Profiler.h | 13 ++- Include/Graph/Nodes/Math.h | 13 ++- Include/Graph/ShaderGraph.h | 17 +++- Include/OpenGL/BufferObject.h | 164 ++++++++++++++++++++++++++++++++ Include/OpenGL/Enum.h | 88 +++++++++++++++++ Include/OpenGL/Type.h | 30 ++++++ Include/Utility/DirectedGraph.h | 13 ++- Include/Utility/Optional.h | 13 ++- Include/Utility/Startup.h | 13 ++- Include/Utility/Timer.h | 13 ++- Include/Utility/UniqueID.h | 13 ++- Source/Core/Console.cpp | 13 ++- Source/Core/Engine.cpp | 13 ++- Source/Core/EventSystem.cpp | 13 ++- Source/Core/Renderer.cpp | 14 ++- Source/Core/Window.cpp | 13 ++- Source/Editor/ConsoleWindow.cpp | 13 ++- Source/Editor/EditorSystem.cpp | 17 +++- Source/Editor/EditorWindow.cpp | 13 ++- Source/Editor/Profiler.cpp | 13 ++- Source/Entry.cpp | 14 ++- Source/Graph/Nodes/Math.cpp | 13 ++- Source/Graph/ShaderGraph.cpp | 84 +++++++++------- 31 files changed, 651 insertions(+), 72 deletions(-) create mode 100644 Include/OpenGL/BufferObject.h create mode 100644 Include/OpenGL/Enum.h create mode 100644 Include/OpenGL/Type.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 66702e4..174cf9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,6 @@ endif() include_directories(Include) include_directories(External) -add_subdirectory(External/imnodes-master) - add_executable(OpenShaderDesigner Source/Entry.cpp @@ -67,8 +65,7 @@ add_executable(OpenShaderDesigner External/imgui-docking/backends/imgui_impl_opengl3.cpp External/imgui-docking/misc/cpp/imgui_stdlib.cpp External/imgui-docking/misc/freetype/imgui_freetype.cpp - Include/Utility/DirectedGraph.h - Include/Utility/Optional.h + Include/OpenGL/BufferObject.h ) @@ -77,5 +74,4 @@ target_link_libraries(OpenShaderDesigner PRIVATE GLEW::GLEW OpenGL::GL ${SDL2_LIBRARIES} - imnodes ) \ No newline at end of file diff --git a/Include/Core/Console.h b/Include/Core/Console.h index 41615a3..9cf0ac1 100644 --- a/Include/Core/Console.h +++ b/Include/Core/Console.h @@ -1,6 +1,18 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + #ifndef CONSOLE_H #define CONSOLE_H diff --git a/Include/Core/Engine.h b/Include/Core/Engine.h index 003cd77..6dc8cf9 100644 --- a/Include/Core/Engine.h +++ b/Include/Core/Engine.h @@ -1,6 +1,18 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + #ifndef ENGINE_H #define ENGINE_H diff --git a/Include/Core/Renderer.h b/Include/Core/Renderer.h index 6c68aee..627fdd1 100644 --- a/Include/Core/Renderer.h +++ b/Include/Core/Renderer.h @@ -1,6 +1,18 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/1/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + #ifndef RENDERER_H #define RENDERER_H diff --git a/Include/Core/Window.h b/Include/Core/Window.h index 4245a59..d1c9264 100644 --- a/Include/Core/Window.h +++ b/Include/Core/Window.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef WINDOW_H #define WINDOW_H diff --git a/Include/Editor/ConsoleWindow.h b/Include/Editor/ConsoleWindow.h index 7583f78..b639016 100644 --- a/Include/Editor/ConsoleWindow.h +++ b/Include/Editor/ConsoleWindow.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/21/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef CONSOLEWINDOW_H #define CONSOLEWINDOW_H diff --git a/Include/Editor/EditorSystem.h b/Include/Editor/EditorSystem.h index 42139cc..be07d1d 100644 --- a/Include/Editor/EditorSystem.h +++ b/Include/Editor/EditorSystem.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef EDITORSYSTEM_H #define EDITORSYSTEM_H diff --git a/Include/Editor/EditorWindow.h b/Include/Editor/EditorWindow.h index 2e6a669..ba6dd29 100644 --- a/Include/Editor/EditorWindow.h +++ b/Include/Editor/EditorWindow.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef EDITORWINDOW_H #define EDITORWINDOW_H diff --git a/Include/Editor/Profiler.h b/Include/Editor/Profiler.h index 81303e8..834f5e8 100644 --- a/Include/Editor/Profiler.h +++ b/Include/Editor/Profiler.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/1/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef PROFILER_H #define PROFILER_H diff --git a/Include/Graph/Nodes/Math.h b/Include/Graph/Nodes/Math.h index b4eb938..85f84da 100644 --- a/Include/Graph/Nodes/Math.h +++ b/Include/Graph/Nodes/Math.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/11/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef MATH_H #define MATH_H diff --git a/Include/Graph/ShaderGraph.h b/Include/Graph/ShaderGraph.h index 2388a0d..bb90147 100644 --- a/Include/Graph/ShaderGraph.h +++ b/Include/Graph/ShaderGraph.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/1/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef SHADERGRAPH_H #define SHADERGRAPH_H @@ -183,8 +194,9 @@ namespace OpenShaderDesigner static void Register(const std::filesystem::path& path, ConstructorPtr constructor); + + private: - std::unordered_set Selected; std::vector Nodes; std::unordered_set Erased; ConnectionMap Connections; @@ -250,6 +262,7 @@ namespace OpenShaderDesigner std::unordered_set DragSelect; bool LocksDragged, NodeHovered; Optional NewConnection; + std::unordered_set Selected; } Mouse; struct diff --git a/Include/OpenGL/BufferObject.h b/Include/OpenGL/BufferObject.h new file mode 100644 index 0000000..2787d40 --- /dev/null +++ b/Include/OpenGL/BufferObject.h @@ -0,0 +1,164 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + +#ifndef BUFFEROBJECT_H +#define BUFFEROBJECT_H + +#ifndef NULL +#define NULL 0 +#endif + +#include + +#include "Enum.h" +#include "Type.h" + +namespace GLW +{ +// Definition ========================================================================================================== + + template + class BufferObject + { + public: + static constexpr BufferType Type = T; + static constexpr BufferUsage Usage = U; + static constexpr BufferStorage Storage = S; + + /** + * \brief BufferObject constructor + * \param size Size in bytes of the Buffer + * \param data Data to be used as the initial contents of the Buffer + */ + BufferObject(SizeT size, void* data = nullptr); + + /** + * \brief Move Constructor + */ + BufferObject(BufferObject&& other); + + /** + * \brief Copy Constructor + */ + BufferObject(const BufferObject& other); + + /** + * \brief Destructor + */ + ~BufferObject(); + + /** + * \brief Validity test + */ + [[nodiscard]] operator bool() const { return Handle != 0; } + + /** + * \brief Copy Assignment + */ + BufferObject& operator=(const BufferObject& other); + + /** + * \brief Move Assignment + */ + BufferObject& operator=(BufferObject&& other) noexcept; + + [[nodiscard]] SizeT Size() const { return Size; } + void Resize(SizeT size); + + private: + HandleT Handle; + SizeT Size; + void* Mapping; + }; + +// Constructors ======================================================================================================== + + template + BufferObject::BufferObject(SizeT size, void* data) + : Handle(NULL) + , Size(size) + , Mapping(nullptr) + { + glGenBuffers(1, &Handle); + + if(!*this) return; + + glBindBuffer(Type, Handle); + glBufferStorage(Type, Size, data, Usage); + glBindBuffer(Type, 0); + } + + template + BufferObject::BufferObject(BufferObject&& other) + : Handle(other.Handle) + , Size(other.Size) + , Mapping(other.Size) + { + other.Handle = NULL; + other.Size = 0; + other.Mapping = nullptr; + } + + template + BufferObject::BufferObject(const BufferObject& other) + : BufferObject(other.Size) + { + if(Handle == NULL) return; + if(other.Handle == NULL) return; + + glCopyNamedBufferSubData(other.Handle, Handle, 0, 0, Size); + } + + template + BufferObject::~BufferObject() + { + glDeleteBuffers(1, &Handle); + } + +// Assignment Operators ================================================================================================ + + template + BufferObject& BufferObject::operator=(const BufferObject& other) + { + BufferObject temp(other); + return (*this = std::move(temp)); // NOLINT(*-unconventional-assign-operator) + } + + template + BufferObject& BufferObject::operator=(BufferObject&& other) noexcept + { + glDeleteBuffers(1, &Handle); + + Handle = other.Handle; + Size = other.Size; + Mapping = other.Mapping; + + other.Handle = NULL; + other.Size = 0; + other.Mapping = nullptr; + + return *this; + } + + template + void BufferObject::Resize(SizeT size) + { + BufferObject temp(size); + glCopyNamedBufferSubData(Handle, temp.Handle, 0, 0, Size); + *this = std::move(temp); + } +} + +#endif //BUFFEROBJECT_H diff --git a/Include/OpenGL/Enum.h b/Include/OpenGL/Enum.h new file mode 100644 index 0000000..e0576da --- /dev/null +++ b/Include/OpenGL/Enum.h @@ -0,0 +1,88 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + +#ifndef ENUM_H +#define ENUM_H + +#include + +namespace GLW +{ + enum Primitive : GLenum + { + TRIANGLES = GL_TRIANGLES + , LINES = GL_LINES + , POINTS = GL_POINTS + }; + + enum BufferType : GLenum + { + AtomicCounter = GL_ATOMIC_COUNTER_BUFFER + , ElementArray = GL_ELEMENT_ARRAY_BUFFER + , IndirectCompute = GL_DISPATCH_INDIRECT_BUFFER + , IndirectDraw = GL_DRAW_INDIRECT_BUFFER + , PixelPack = GL_PIXEL_PACK_BUFFER + , PixelUnpack = GL_PIXEL_UNPACK_BUFFER + , ShaderStorage = GL_SHADER_STORAGE_BUFFER + , TransformFeedback = GL_TRANSFORM_FEEDBACK + , Uniform = GL_UNIFORM_BUFFER + , VertexArray = GL_ARRAY_BUFFER + }; + + enum BufferUsage : GLenum + { + /** + * \brief Buffer cannot be read or modified by the CPU after creation + */ + STATIC = GL_NONE + + /** + * \brief Buffer can be mapped for Read, Write, or Both + */ + , READ = GL_MAP_READ_BIT + , WRITE = GL_MAP_WRITE_BIT + , READ_WRITE = READ | WRITE + + /** + * \brief Buffer can be written to using glBufferSubData + */ + , DYNAMIC = GL_DYNAMIC_STORAGE_BIT + + /** + * \brief Buffer may be used while mapped + */ + , PERSISTENT = GL_MAP_PERSISTENT_BIT + + /** + * \brief Allows buffer to remain coherent without an explicit barrier + */ + , COHERENT = GL_MAP_PERSISTENT_BIT | PERSISTENT + }; + + enum BufferStorage : GLenum + { + /** + * \brief Buffer memory will come from the GPU + */ + GPU = GL_NONE + + /** + * \brief Buffer memory will come from the CPU + */ + , CPU = GL_CLIENT_STORAGE_BIT + }; +} + +#endif //ENUM_H diff --git a/Include/OpenGL/Type.h b/Include/OpenGL/Type.h new file mode 100644 index 0000000..957b169 --- /dev/null +++ b/Include/OpenGL/Type.h @@ -0,0 +1,30 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + +#ifndef TYPE_H +#define TYPE_H + +#include + +namespace GLW +{ + using OffsetT = GLintptr; + using SizeT = GLsizeiptr; + using IndexT = GLuint; + using FlagT = GLbitfield; + using HandleT = GLuint; +} + +#endif //TYPE_H diff --git a/Include/Utility/DirectedGraph.h b/Include/Utility/DirectedGraph.h index 07f047e..a81c9c6 100644 --- a/Include/Utility/DirectedGraph.h +++ b/Include/Utility/DirectedGraph.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/11/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef DIRECTEDGRAPH_H #define DIRECTEDGRAPH_H diff --git a/Include/Utility/Optional.h b/Include/Utility/Optional.h index 4cc7fc4..efd3941 100644 --- a/Include/Utility/Optional.h +++ b/Include/Utility/Optional.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/12/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef OPTIONAL_H #define OPTIONAL_H diff --git a/Include/Utility/Startup.h b/Include/Utility/Startup.h index f5217d4..d1bdda2 100644 --- a/Include/Utility/Startup.h +++ b/Include/Utility/Startup.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/21/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef STARTUP_H #define STARTUP_H diff --git a/Include/Utility/Timer.h b/Include/Utility/Timer.h index df5acdc..429f121 100644 --- a/Include/Utility/Timer.h +++ b/Include/Utility/Timer.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef TIMER_H #define TIMER_H diff --git a/Include/Utility/UniqueID.h b/Include/Utility/UniqueID.h index d2bd0fa..b2f933a 100644 --- a/Include/Utility/UniqueID.h +++ b/Include/Utility/UniqueID.h @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #ifndef ENGINE_UNIQUEID_H #define ENGINE_UNIQUEID_H diff --git a/Source/Core/Console.cpp b/Source/Core/Console.cpp index 5c2f160..c4418c0 100644 --- a/Source/Core/Console.cpp +++ b/Source/Core/Console.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include #include diff --git a/Source/Core/Engine.cpp b/Source/Core/Engine.cpp index 209771e..5fa8ee8 100644 --- a/Source/Core/Engine.cpp +++ b/Source/Core/Engine.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include #include diff --git a/Source/Core/EventSystem.cpp b/Source/Core/EventSystem.cpp index 12b908e..f4da3e9 100644 --- a/Source/Core/EventSystem.cpp +++ b/Source/Core/EventSystem.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include #include diff --git a/Source/Core/Renderer.cpp b/Source/Core/Renderer.cpp index 378a502..9aede7c 100644 --- a/Source/Core/Renderer.cpp +++ b/Source/Core/Renderer.cpp @@ -1,5 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/1/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + #include diff --git a/Source/Core/Window.cpp b/Source/Core/Window.cpp index 97e8035..2313035 100644 --- a/Source/Core/Window.cpp +++ b/Source/Core/Window.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include #include diff --git a/Source/Editor/ConsoleWindow.cpp b/Source/Editor/ConsoleWindow.cpp index a5e89af..bff4082 100644 --- a/Source/Editor/ConsoleWindow.cpp +++ b/Source/Editor/ConsoleWindow.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/21/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include #include diff --git a/Source/Editor/EditorSystem.cpp b/Source/Editor/EditorSystem.cpp index 7633502..6b68e20 100644 --- a/Source/Editor/EditorSystem.cpp +++ b/Source/Editor/EditorSystem.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include #include @@ -10,8 +21,6 @@ #include #include -#include - using namespace OpenShaderDesigner; void EditorSystem::Initialize() @@ -21,7 +30,6 @@ void EditorSystem::Initialize() Console::Log(Console::Severity::ALERT, "Initializing Dear ImGUI"); IMGUI_CHECKVERSION(); ImGui::CreateContext(); - ImNodes::CreateContext(); // https://github.com/ocornut/imgui/issues/707#issuecomment-917151020 @@ -162,7 +170,6 @@ void EditorSystem::Shutdown() // Shutdown ImGui ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(); - ImNodes::DestroyContext(); } void EditorSystem::HandleEvents(SDL_Event* event) diff --git a/Source/Editor/EditorWindow.cpp b/Source/Editor/EditorWindow.cpp index d96ddc0..06ff44d 100644 --- a/Source/Editor/EditorWindow.cpp +++ b/Source/Editor/EditorWindow.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/20/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include diff --git a/Source/Editor/Profiler.cpp b/Source/Editor/Profiler.cpp index 6f913e5..b0572f2 100644 --- a/Source/Editor/Profiler.cpp +++ b/Source/Editor/Profiler.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/1/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include diff --git a/Source/Entry.cpp b/Source/Entry.cpp index e4a2043..f73de61 100644 --- a/Source/Entry.cpp +++ b/Source/Entry.cpp @@ -1,6 +1,18 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 6/18/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + #include #include diff --git a/Source/Graph/Nodes/Math.cpp b/Source/Graph/Nodes/Math.cpp index 8137922..4245f1a 100644 --- a/Source/Graph/Nodes/Math.cpp +++ b/Source/Graph/Nodes/Math.cpp @@ -1,6 +1,17 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/11/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== #include diff --git a/Source/Graph/ShaderGraph.cpp b/Source/Graph/ShaderGraph.cpp index 78a6eb7..0ac05d1 100644 --- a/Source/Graph/ShaderGraph.cpp +++ b/Source/Graph/ShaderGraph.cpp @@ -1,6 +1,18 @@ +// ===================================================================================================================== +// Copyright 2024 Medusa Slockbower +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Created by Maddie on 7/1/2024. +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ===================================================================================================================== + #include #include @@ -195,7 +207,7 @@ void ShaderGraph::DrawWindow() { if(Drag.x == 0 && Drag.y == 0 && !Mouse.NodeHovered && !(Ctrl || Shift)) { - Selected.clear(); + Mouse.Selected.clear(); } Mouse.Locks.clear(); @@ -373,7 +385,7 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) Mouse.FocusedNode = id; Mouse.LocksDragged = false; - for(NodeId selected : Selected) + for(NodeId selected : Mouse.Selected) { Mouse.Locks.emplace(selected, Mouse.Location - Nodes[selected]->Position); } @@ -385,22 +397,22 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) if(ImGui::IsMouseDragging(ImGuiMouseButton_Left) && !Mouse.NewConnection() && Focused) { // Reset When Dragging a New Node - if(Mouse.FocusedNode() && Mouse.FocusedNode == id && !Selected.contains(id)) + if(Mouse.FocusedNode() && Mouse.FocusedNode == id && !Mouse.Selected.contains(id)) { if(!(Ctrl || Shift)) { - Selected.clear(); + Mouse.Selected.clear(); Mouse.Locks.clear(); } - Selected.insert(id); + Mouse.Selected.insert(id); } // Begin selection - if(Mouse.FocusedNode() && Selected.contains(id) && !(Ctrl || Shift)) + if(Mouse.FocusedNode() && Mouse.Selected.contains(id) && !(Ctrl || Shift)) { Mouse.LocksDragged = true; - for(NodeId selected : Selected) + for(NodeId selected : Mouse.Selected) { Mouse.Locks.emplace(selected, Mouse.Location - Nodes[selected]->Position); } @@ -420,7 +432,7 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) // Clear selection for new selection if(Mouse.DragSelect.empty() && !Shift && !Ctrl && !Mouse.FocusedNode()) { - Selected.clear(); + Mouse.Selected.clear(); } // Select nodes @@ -428,16 +440,16 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) { if(!Ctrl) { - if(!Selected.contains(id)) + if(!Mouse.Selected.contains(id)) { - Selected.insert(id); + Mouse.Selected.insert(id); Mouse.DragSelect.insert(id); } } else { - if(Selected.contains(id)) Selected.erase(id); - else Selected.insert(id); + if(Mouse.Selected.contains(id)) Mouse.Selected.erase(id); + else Mouse.Selected.insert(id); Mouse.DragSelect.insert(id); } @@ -450,12 +462,12 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) if(!Ctrl) { - Selected.erase(id); + Mouse.Selected.erase(id); } else { - if(Selected.contains(id)) Selected.erase(id); - else Selected.insert(id); + if(Mouse.Selected.contains(id)) Mouse.Selected.erase(id); + else Mouse.Selected.insert(id); } } } @@ -463,20 +475,20 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) if(ImGui::IsMouseReleased(ImGuiMouseButton_Left) && HeaderHovered) { - if(Selected.contains(id)) + if(Mouse.Selected.contains(id)) { - if(Ctrl) Selected.erase(id); + if(Ctrl) Mouse.Selected.erase(id); else if(!Shift && !Mouse.LocksDragged) { - Selected.clear(); - Selected.insert(id); + Mouse.Selected.clear(); + Mouse.Selected.insert(id); } } else { if(!(Ctrl || Shift)) - Selected.clear(); - Selected.insert(id); + Mouse.Selected.clear(); + Mouse.Selected.insert(id); } } @@ -504,7 +516,7 @@ void ShaderGraph::DrawNode(Node& node, NodeId id) // Border ========================================================================================================== - if(Selected.contains(id)) DrawList.AddRect(NodeRoot, NodeEdge, Style.Nodes.SelectedBorder.Color, Rounding, 0, Style.Nodes.SelectedBorder.Thickness / Camera.Zoom); + if(Mouse.Selected.contains(id)) DrawList.AddRect(NodeRoot, NodeEdge, Style.Nodes.SelectedBorder.Color, Rounding, 0, Style.Nodes.SelectedBorder.Thickness / Camera.Zoom); else DrawList.AddRect(NodeRoot, NodeEdge, Style.Nodes.Border.Color, Rounding, 0, BorderThickness); // Pins ============================================================================================================ @@ -587,8 +599,8 @@ void ShaderGraph::DrawContextMenu() if(ImGui::BeginPopupContextWindow()) { - if(ImGui::MenuItem("Copy", "Ctrl+C", false, !Selected.empty())) Copy(); - if(ImGui::MenuItem("Cut", "Ctrl+X", false, !Selected.empty())) + if(ImGui::MenuItem("Copy", "Ctrl+C", false, !Mouse.Selected.empty())) Copy(); + if(ImGui::MenuItem("Cut", "Ctrl+X", false, !Mouse.Selected.empty())) { Copy(); EraseSelection(); @@ -849,7 +861,7 @@ NodeId ShaderGraph::AddNode(Node* node) if(Erased.empty()) { Nodes.push_back(node); - return Nodes.size() - 1; + return static_cast(Nodes.size() - 1); } NodeId id = *Erased.begin(); @@ -883,21 +895,21 @@ void ShaderGraph::ClearClipboard() void ShaderGraph::Copy() { - if(Selected.empty()) return; + if(Mouse.Selected.empty()) return; // Helper for connections std::unordered_map clipboardTransform; - ImVec2 min = Nodes[*Selected.begin()]->Position; + ImVec2 min = Nodes[*Mouse.Selected.begin()]->Position; // Reset Clipboard ClearClipboard(); - Clipboard.Nodes.reserve(Selected.size()); + Clipboard.Nodes.reserve(Mouse.Selected.size()); // Copy nodes - for(auto id : Selected) + for(auto id : Mouse.Selected) { Node* node = Nodes[id]; - clipboardTransform[id] = Clipboard.Nodes.size(); + clipboardTransform[id] = static_cast(Clipboard.Nodes.size()); Clipboard.Nodes.push_back(node->Copy(*this)); min = ImMin(node->Position, min); } @@ -911,7 +923,7 @@ void ShaderGraph::Copy() // Copy connections for(const Connection& connection : Connections) { - if(!(Selected.contains(connection.first.Node) && Selected.contains(connection.second.Node))) continue; + if(!(Mouse.Selected.contains(connection.first.Node) && Mouse.Selected.contains(connection.second.Node))) continue; Connection copy = { { clipboardTransform[connection.first.Node], connection.first.Pin, connection.first.Input } @@ -928,7 +940,7 @@ void ShaderGraph::Paste(const ImVec2& location) const float GridSize = (Style.FontSize + Style.Grid.Lines.Padding); std::unordered_map clipboardTransform; ImVec2 root = ImFloor(location / GridSize + ImVec2(0.5f, 0.5f)) * GridSize; - Selected.clear(); + Mouse.Selected.clear(); // Paste the nodes NodeId id = 0; @@ -936,7 +948,7 @@ void ShaderGraph::Paste(const ImVec2& location) { NodeId index = clipboardTransform[id++] = AddNode(node->Copy(*this)); Nodes[index]->Position += root; - Selected.insert(index); + Mouse.Selected.insert(index); } // Paste the connections @@ -951,11 +963,11 @@ void ShaderGraph::Paste(const ImVec2& location) void ShaderGraph::EraseSelection() { - for(auto node : Selected) + for(auto node : Mouse.Selected) { RemoveNode(node); } - Selected.clear(); + Mouse.Selected.clear(); } float ShaderGraph::BezierOffset(const ImVec2& out, const ImVec2& in)