diff --git a/.gitignore b/.gitignore index ff996e7f..de8ad28d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps +*.make # Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. @@ -864,4 +865,4 @@ Nuake/dependencies/glad/glad.vcxproj.filters *.csproj *.filters cloc.exe -Nuake/src/Modules/Modules.cpp \ No newline at end of file +Nuake/src/Modules/Modules.cpp diff --git a/Editor/Source/Editor/ComponentsPanel/ComponentPanel.h b/Editor/Source/Editor/ComponentsPanel/ComponentPanel.h index 8c7ae4e7..9e89c941 100644 --- a/Editor/Source/Editor/ComponentsPanel/ComponentPanel.h +++ b/Editor/Source/Editor/ComponentsPanel/ComponentPanel.h @@ -16,7 +16,7 @@ #define CompononentPropertyName(name) \ ImGui::AlignTextToFramePadding(); \ -ImGui::Text(##name); +ImGui::Text(name); #define BeginComponentTable(name, component) \ UIFont* boldFont = new UIFont(Fonts::Bold); \ diff --git a/Editor/Source/Editor/ComponentsPanel/MaterialEditor.cpp b/Editor/Source/Editor/ComponentsPanel/MaterialEditor.cpp index 322b0df3..0dc72daf 100644 --- a/Editor/Source/Editor/ComponentsPanel/MaterialEditor.cpp +++ b/Editor/Source/Editor/ComponentsPanel/MaterialEditor.cpp @@ -99,7 +99,7 @@ void MaterialEditor::Draw(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image1"), (ImTextureID)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetAlbedo(TextureManager::Get()->GetTexture(texture)); @@ -133,7 +133,7 @@ void MaterialEditor::Draw(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image3"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetNormal(TextureManager::Get()->GetTexture(texture)); @@ -164,7 +164,7 @@ void MaterialEditor::Draw(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image2"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("Image files (*.png) | *.png | Image files (*.jpg) | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetAO(TextureManager::Get()->GetTexture(texture)); @@ -198,7 +198,7 @@ void MaterialEditor::Draw(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image4"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetMetalness(TextureManager::Get()->GetTexture(texture)); @@ -232,7 +232,7 @@ void MaterialEditor::Draw(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetRoughness(TextureManager::Get()->GetTexture(texture)); @@ -252,4 +252,4 @@ void MaterialEditor::Draw(Ref material) } ImGui::EndChild(); } -} \ No newline at end of file +} diff --git a/Editor/Source/Editor/EditorApplication.cpp b/Editor/Source/Editor/EditorApplication.cpp index 05d3c1b2..f0cd4a70 100644 --- a/Editor/Source/Editor/EditorApplication.cpp +++ b/Editor/Source/Editor/EditorApplication.cpp @@ -87,4 +87,4 @@ void EditorApplication::OnInit() void EditorApplication::OnShutdown() { Nuake::Engine::Close(); -} \ No newline at end of file +} diff --git a/Editor/Source/Editor/Misc/ImGuiTextHelper.cpp b/Editor/Source/Editor/Misc/ImGuiTextHelper.cpp index 9f69b06f..502997af 100644 --- a/Editor/Source/Editor/Misc/ImGuiTextHelper.cpp +++ b/Editor/Source/Editor/Misc/ImGuiTextHelper.cpp @@ -2,6 +2,10 @@ #include +#ifndef _MSC_VER +#define strncpy_s strncpy +#endif + void ImGuiTextSTD(const std::string& label, std::string& value) { char buffer[256]; diff --git a/Editor/Source/Editor/ScriptingContext/Modules/EditorModule.cpp b/Editor/Source/Editor/ScriptingContext/Modules/EditorModule.cpp index d6eb8445..4269a793 100644 --- a/Editor/Source/Editor/ScriptingContext/Modules/EditorModule.cpp +++ b/Editor/Source/Editor/ScriptingContext/Modules/EditorModule.cpp @@ -19,6 +19,6 @@ int GetSelectedEntity() void EditorNetAPI::RegisterMethods() { - RegisterMethod("Editor.SetSelectedEntityIcall", &SelectEntity); - RegisterMethod("Editor.GetSelectedEntityIcall", &GetSelectedEntity); + RegisterMethod("Editor.SetSelectedEntityIcall", (void*)(&SelectEntity)); + RegisterMethod("Editor.GetSelectedEntityIcall", (void*)(&GetSelectedEntity)); } diff --git a/Editor/Source/Editor/Windows/EditorInterface.cpp b/Editor/Source/Editor/Windows/EditorInterface.cpp index 87d4b7a7..1f065af1 100644 --- a/Editor/Source/Editor/Windows/EditorInterface.cpp +++ b/Editor/Source/Editor/Windows/EditorInterface.cpp @@ -2260,7 +2260,7 @@ namespace Nuake { void OpenScene() { // Parse the project and load it. - std::string projectPath = FileDialog::OpenFile(".scene"); + std::string projectPath = FileDialog::OpenFile("Scene file\0*.scene"); if (projectPath.empty() || !FileSystem::FileExists(projectPath, true)) { return; diff --git a/Editor/Source/Editor/Windows/EditorSelectionPanel.cpp b/Editor/Source/Editor/Windows/EditorSelectionPanel.cpp index 0f0346ab..5ef5773e 100644 --- a/Editor/Source/Editor/Windows/EditorSelectionPanel.cpp +++ b/Editor/Source/Editor/Windows/EditorSelectionPanel.cpp @@ -308,7 +308,7 @@ void EditorSelectionPanel::DrawFile(Ref file) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture1"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (!texture.empty()) { sky->SetTextureFace(SkyFaces::Top, FileSystem::AbsoluteToRelative(texture)); @@ -335,7 +335,7 @@ void EditorSelectionPanel::DrawFile(Ref file) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture2"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (!texture.empty()) { sky->SetTextureFace(SkyFaces::Bottom, FileSystem::AbsoluteToRelative(texture)); @@ -362,7 +362,7 @@ void EditorSelectionPanel::DrawFile(Ref file) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture3"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (!texture.empty()) { sky->SetTextureFace(SkyFaces::Left, FileSystem::AbsoluteToRelative(texture)); @@ -389,7 +389,7 @@ void EditorSelectionPanel::DrawFile(Ref file) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture4"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (!texture.empty()) { sky->SetTextureFace(SkyFaces::Right, FileSystem::AbsoluteToRelative(texture)); @@ -416,7 +416,7 @@ void EditorSelectionPanel::DrawFile(Ref file) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture5"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (!texture.empty()) { sky->SetTextureFace(SkyFaces::Front, FileSystem::AbsoluteToRelative(texture)); @@ -443,7 +443,7 @@ void EditorSelectionPanel::DrawFile(Ref file) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture6"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (!texture.empty()) { sky->SetTextureFace(SkyFaces::Back, FileSystem::AbsoluteToRelative(texture)); @@ -1587,7 +1587,7 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image1"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetAlbedo(TextureManager::Get()->GetTexture(texture)); @@ -1621,7 +1621,7 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image3"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetNormal(TextureManager::Get()->GetTexture(texture)); @@ -1652,7 +1652,7 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image2"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("Image files (*.png) | *.png | Image files (*.jpg) | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetAO(TextureManager::Get()->GetTexture(texture)); @@ -1683,7 +1683,7 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image4"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetMetalness(TextureManager::Get()->GetTexture(texture)); @@ -1717,7 +1717,7 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref material) if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { - std::string texture = FileDialog::OpenFile("*.png | *.jpg"); + std::string texture = FileDialog::OpenFile("Image Files\0*.png|*.jpg"); if (texture != "") { material->SetRoughness(TextureManager::Get()->GetTexture(texture)); @@ -2040,10 +2040,10 @@ void EditorSelectionPanel::DrawFieldTypeString(entt::meta_data& field, entt::met std::string controlId = std::string("##") + displayName; ImGui::InputText(controlId.c_str(), &fieldValProxy); - //if (fieldValProxy != fieldVal) - //{ - // Engine::GetProject()->IsDirty = true; - //} + if (fieldValProxy != (const char*)fieldVal.data()) + { + Engine::GetProject()->IsDirty = true; + } } else { diff --git a/Editor/Source/Editor/Windows/MapImporterWindow.cpp b/Editor/Source/Editor/Windows/MapImporterWindow.cpp index 145aaee3..daf2587e 100644 --- a/Editor/Source/Editor/Windows/MapImporterWindow.cpp +++ b/Editor/Source/Editor/Windows/MapImporterWindow.cpp @@ -47,7 +47,7 @@ void MapImporterWindow::Draw() using namespace Nuake; if (ImGui::Button(buttonLbl.c_str())) { - std::string selectedFile = FileDialog::OpenFile("*.map"); + std::string selectedFile = FileDialog::OpenFile("Quake maps\0*.map"); std::string relativePath = FileSystem::AbsoluteToRelative(selectedFile); if (!selectedFile.empty() && FileSystem::FileExists(relativePath)) { diff --git a/Editor/Source/Editor/Windows/PrefabEditor/PrefabEditorWindow.cpp b/Editor/Source/Editor/Windows/PrefabEditor/PrefabEditorWindow.cpp index 4f247880..bc84c7ca 100644 --- a/Editor/Source/Editor/Windows/PrefabEditor/PrefabEditorWindow.cpp +++ b/Editor/Source/Editor/Windows/PrefabEditor/PrefabEditorWindow.cpp @@ -1,7 +1,7 @@ #include "PrefabEditorWindow.h" #include -#include +#include #include #include #include diff --git a/Editor/Source/Editor/Windows/ProjectInterface.cpp b/Editor/Source/Editor/Windows/ProjectInterface.cpp index 14a6bf78..1272cd26 100644 --- a/Editor/Source/Editor/Windows/ProjectInterface.cpp +++ b/Editor/Source/Editor/Windows/ProjectInterface.cpp @@ -54,7 +54,7 @@ namespace Nuake { ImGui::SameLine(); if (ImGui::Button("Browse")) { - std::string path = FileDialog::OpenFile("*.exe"); + std::string path = FileDialog::OpenFile("Windows Executable\0*.exe"); if (path != "") { path += "/../"; diff --git a/Editor/premake5.lua b/Editor/premake5.lua index d5fc6f85..e8dfcae8 100644 --- a/Editor/premake5.lua +++ b/Editor/premake5.lua @@ -1,5 +1,5 @@ project "Editor" - targetname ("Nuake Engine") + targetname "NuakeEngine" kind "ConsoleApp" language "C++" @@ -72,18 +72,66 @@ project "Editor" "msdf-gen", "msdf-atlas-gen", "Freetype", - "vma" + "vma", + "dxcompiler" } + libdirs { "../Nuake/Thirdparty/dxc/lib/x64" } - prebuildcommands { - '{ECHO} "Copying dxcompiler.dll to Working directory..."', - '{COPYFILE} "%{wks.location}Nuake/Thirdparty/dxc/bin/x64/dxcompiler.dll" "%{cfg.debugdir}/"', - '{ECHO} Copying Coral to Working directory...', - '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.dll" "%{cfg.debugdir}/"', - '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.runtimeconfig.json" "%{cfg.debugdir}/"', - '{COPYFILE} "%{wks.location}NuakeNet/Build/%{cfg.buildcfg}/Binaries/NuakeNet.dll" "%{cfg.debugdir}/"', - 'xcopy /E /I /Y "%{wks.location}Data" "%{cfg.debugdir}\\Resources"' - } + filter "system:windows" + defines + { + "NK_WIN" + } + prebuildcommands { + '{ECHO} "Copying dxcompiler.dll to Working directory..."', + '{COPYFILE} "%{wks.location}Nuake/Thirdparty/dxc/bin/x64/dxcompiler.dll" "%{cfg.debugdir}/"', + '{ECHO} Copying Coral to Working directory...', + '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.dll" "%{cfg.debugdir}/"', + '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.runtimeconfig.json" "%{cfg.debugdir}/"', + '{COPYFILE} "%{wks.location}NuakeNet/Build/%{cfg.buildcfg}/Binaries/NuakeNet.dll" "%{cfg.debugdir}/"', + 'xcopy /E /I /Y "%{wks.location}Data" "%{cfg.debugdir}\\Resources"' + } + + filter "system:linux" + defines + { + "NK_LINUX" + } + + links + { + "GL", + "glfw", + "glad", + "X11", + "asound", + "glib-2.0", + "gtk-3", + "gobject-2.0" + } + linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0 gtk+-3.0 glib-2.0 gobject-2.0`" } + + filter "system:bsd" + defines + { + "NK_LINUX", + "NK_BSD" + } + + links + { + "GL", + "glfw", + "glad", + "X11", + "asound", + "glib-2.0", + "gtk-3", + "gobject-2.0", + "pthread", + "execinfo" + } + linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0 gtk+-3.0 glib-2.0 gobject-2.0`" } filter { "system:windows", "action:vs*"} flags diff --git a/Nuake/Source/Nuake/Application/Application.h b/Nuake/Source/Nuake/Application/Application.h index e22f18cd..83170654 100644 --- a/Nuake/Source/Nuake/Application/Application.h +++ b/Nuake/Source/Nuake/Application/Application.h @@ -4,7 +4,7 @@ #include "LayerStack.h" #include -#include +#include #include "Nuake/Window.h" @@ -86,4 +86,4 @@ namespace Nuake { // Implemented by the client Application* CreateApplication(int argc, char** argv); -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/Application/EntryPoint.h b/Nuake/Source/Nuake/Application/EntryPoint.h index 5423d8ca..50987c1e 100644 --- a/Nuake/Source/Nuake/Application/EntryPoint.h +++ b/Nuake/Source/Nuake/Application/EntryPoint.h @@ -18,7 +18,7 @@ namespace Nuake { g_ApplicationRunning = false; } - return 1; + return 0; } } @@ -41,4 +41,4 @@ int main(int argc, char** argv) { return Nuake::Main(argc, argv); } -#endif \ No newline at end of file +#endif diff --git a/Nuake/Source/Nuake/Core/OS.cpp b/Nuake/Source/Nuake/Core/OS.cpp index 84241424..e7444595 100644 --- a/Nuake/Source/Nuake/Core/OS.cpp +++ b/Nuake/Source/Nuake/Core/OS.cpp @@ -140,10 +140,13 @@ namespace Nuake { { path = ""; } -#endif -#ifdef NK_LINUX - path = "~/.config"; +#elif defined(NK_LINUX) + const char* homeDir = getenv("HOME"); + // fallback, should be almost impossible in almost all desktop setups + if (homeDir[0] == '\0') + homeDir = "/root"; + path = std::string(homeDir) + "/.config"; #endif return path; @@ -224,4 +227,4 @@ namespace Nuake { system(command.c_str()); #endif } -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/FileSystem/FileDialog.cpp b/Nuake/Source/Nuake/FileSystem/FileDialog.cpp index 247889d4..8865f938 100644 --- a/Nuake/Source/Nuake/FileSystem/FileDialog.cpp +++ b/Nuake/Source/Nuake/FileSystem/FileDialog.cpp @@ -40,9 +40,7 @@ std::string FileDialog::OpenFile(const std::string_view& filter) filePath = std::string(ofn.lpstrFile); } -#endif - -#ifdef NK_LINUX +#elif defined(NK_LINUX) GtkWidget *dialog; GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; gint res; @@ -58,10 +56,19 @@ std::string FileDialog::OpenFile(const std::string_view& filter) gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); - if (filter) { + if (!filter.empty()) { GtkFileFilter *file_filter = gtk_file_filter_new(); - gtk_file_filter_set_name(file_filter, "Filter Name"); - gtk_file_filter_add_pattern(file_filter, filter); + gtk_file_filter_set_name(file_filter, filter.data()); + + size_t pos = 0; + size_t end = 0; + std::string filterCopy(filter.data() + strlen(filter.data()) + 1); + while ((end = filterCopy.find('|', pos)) != std::string::npos) { + std::string token = filterCopy.substr(pos, end - pos); + gtk_file_filter_add_pattern(file_filter, token.c_str()); + pos = end + 1; + } + gtk_file_filter_add_pattern(file_filter, filterCopy.substr(pos).c_str()); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filter); } @@ -102,8 +109,6 @@ std::string FileDialog::SaveFile(const std::string_view& filter) GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE; gint res; - gtk_init(NULL, NULL); - dialog = gtk_file_chooser_dialog_new("Save File", NULL, action, @@ -114,7 +119,7 @@ std::string FileDialog::SaveFile(const std::string_view& filter) NULL); GtkFileFilter *file_filter = gtk_file_filter_new(); - gtk_file_filter_set_name(file_filter, filter); + gtk_file_filter_set_name(file_filter, filter.data()); gtk_file_filter_add_pattern(file_filter, "*.*"); // You can customize this pattern gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filter); @@ -197,6 +202,30 @@ std::string FileDialog::OpenFolder() // Uninitialize COM library CoUninitialize(); } + +#elif defined(NK_LINUX) + GtkWidget *dialog; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + gint res; + + dialog = gtk_file_chooser_dialog_new("Open Folder", + NULL, + action, + "_Cancel", + GTK_RESPONSE_CANCEL, + "_Open", + GTK_RESPONSE_ACCEPT, + NULL); + + res = gtk_dialog_run(GTK_DIALOG(dialog)); + + if (res == GTK_RESPONSE_ACCEPT) { + char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + folderPath = filename; + g_free(filename); + } + + gtk_widget_destroy(dialog); #endif return folderPath; -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/FileSystem/FileSystem.cpp b/Nuake/Source/Nuake/FileSystem/FileSystem.cpp index 41b01962..a1da7d95 100644 --- a/Nuake/Source/Nuake/FileSystem/FileSystem.cpp +++ b/Nuake/Source/Nuake/FileSystem/FileSystem.cpp @@ -7,16 +7,21 @@ #include "Directory.h" #include "File.h" +#ifndef NK_BSD #include "filewatch/FileWatch.hpp" +#endif #include +#include using namespace Nuake; std::string FileSystem::Root = ""; Ref FileSystem::RootDirectory; +#ifndef NK_BSD Ref> FileSystem::RootFileWatch; +#endif void FileSystem::ForeachFile(OnFileFunc func) { @@ -113,6 +118,7 @@ std::vector> FileSystem::GetAllFiles(const FileType fileType) void FileSystem::SetRootDirectory(const std::string path) { Root = path; +#ifndef NK_BSD RootFileWatch = CreateRef>( path, [&](const std::string& path, const filewatch::Event& event) { @@ -150,6 +156,7 @@ void FileSystem::SetRootDirectory(const std::string path) } } ); +#endif Scan(); } diff --git a/Nuake/Source/Nuake/FileSystem/FileSystem.h b/Nuake/Source/Nuake/FileSystem/FileSystem.h index 38767827..631e09a3 100644 --- a/Nuake/Source/Nuake/FileSystem/FileSystem.h +++ b/Nuake/Source/Nuake/FileSystem/FileSystem.h @@ -4,11 +4,13 @@ #include +#ifndef NK_BSD namespace filewatch { template class FileWatch; } +#endif namespace Nuake { @@ -22,7 +24,9 @@ namespace Nuake public: static std::string Root; static Ref RootDirectory; +#ifndef NK_BSD static Ref> RootFileWatch; +#endif static void SetRootDirectory(const std::string path); diff --git a/Nuake/Source/Nuake/Physics/DynamicWorld.cpp b/Nuake/Source/Nuake/Physics/DynamicWorld.cpp index 5c7e8777..b868dff0 100644 --- a/Nuake/Source/Nuake/Physics/DynamicWorld.cpp +++ b/Nuake/Source/Nuake/Physics/DynamicWorld.cpp @@ -590,7 +590,7 @@ namespace Nuake Vector3(hitPosition.GetX(), hitPosition.GetY(), hitPosition.GetZ()), hitFraction, Vector3(0, 0, 0), - layer, + static_cast(layer), userData }; diff --git a/Nuake/Source/Nuake/Rendering/Vulkan/ShaderCompiler.cpp b/Nuake/Source/Nuake/Rendering/Vulkan/ShaderCompiler.cpp index 6c7794d4..b898c27e 100644 --- a/Nuake/Source/Nuake/Rendering/Vulkan/ShaderCompiler.cpp +++ b/Nuake/Source/Nuake/Rendering/Vulkan/ShaderCompiler.cpp @@ -2,7 +2,11 @@ #include "VulkanShader.h" +#if NK_WIN #include +#else +#define __EMULATE_UUID 1 +#endif #include "dxcapi.h" #include #include diff --git a/Nuake/Source/Nuake/Rendering/Vulkan/VulkanInit.cpp b/Nuake/Source/Nuake/Rendering/Vulkan/VulkanInit.cpp index 6480b8ba..7ccbce38 100644 --- a/Nuake/Source/Nuake/Rendering/Vulkan/VulkanInit.cpp +++ b/Nuake/Source/Nuake/Rendering/Vulkan/VulkanInit.cpp @@ -1,5 +1,5 @@ #include "VulkanInit.h" -#include "VulkanImage\VulkanImage.h" +#include "VulkanImage/VulkanImage.h" using namespace Nuake; @@ -294,4 +294,4 @@ void VulkanUtil::CopyImageToImage(VkCommandBuffer cmd, VkImage source, VkImage d blitInfo.pRegions = &blitRegion; vkCmdBlitImage2(cmd, &blitInfo); -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/Rendering/Vulkan/VulkanSceneRenderer.cpp b/Nuake/Source/Nuake/Rendering/Vulkan/VulkanSceneRenderer.cpp index 400e3cd4..a2c15f2c 100644 --- a/Nuake/Source/Nuake/Rendering/Vulkan/VulkanSceneRenderer.cpp +++ b/Nuake/Source/Nuake/Rendering/Vulkan/VulkanSceneRenderer.cpp @@ -52,19 +52,27 @@ void VkSceneRenderer::Init() void VkSceneRenderer::LoadShaders() { - // TODO: load embedded shaders in the future - VkShaderManager& shaderMgr = VkShaderManager::Get(); - ShaderCompiler& shaderCompiler = ShaderCompiler::Get(); - shaderMgr.AddShader("basic_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/triangle.frag")); - shaderMgr.AddShader("basic_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/triangle.vert")); - shaderMgr.AddShader("shading_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shading.frag")); - shaderMgr.AddShader("shading_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shading.vert")); - shaderMgr.AddShader("shadow_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shadow.frag")); - shaderMgr.AddShader("shadow_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shadow.vert")); - shaderMgr.AddShader("tonemap_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/tonemap.frag")); - shaderMgr.AddShader("tonemap_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/tonemap.vert")); - shaderMgr.AddShader("outline_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/outline.frag")); - shaderMgr.AddShader("outline_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/outline.vert")); + try + { + // TODO: load embedded shaders in the future + VkShaderManager& shaderMgr = VkShaderManager::Get(); + ShaderCompiler& shaderCompiler = ShaderCompiler::Get(); + shaderMgr.AddShader("basic_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/triangle.frag")); + shaderMgr.AddShader("basic_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/triangle.vert")); + shaderMgr.AddShader("shading_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shading.frag")); + shaderMgr.AddShader("shading_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shading.vert")); + shaderMgr.AddShader("shadow_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shadow.frag")); + shaderMgr.AddShader("shadow_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/shadow.vert")); + shaderMgr.AddShader("tonemap_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/tonemap.frag")); + shaderMgr.AddShader("tonemap_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/tonemap.vert")); + shaderMgr.AddShader("outline_frag", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/outline.frag")); + shaderMgr.AddShader("outline_vert", shaderCompiler.CompileShader("Resources/Shaders/Vulkan/outline.vert")); + } + catch (std::exception& e) + { + Logger::Log(e.what(), "scenerenderer", CRITICAL); + assert(false && "Failed to load shaders"); + } } void VkSceneRenderer::PrepareScenes(const std::vector>& scenes, RenderContext inContext) diff --git a/Nuake/Source/Nuake/Resource/FGD/FGDFile.h b/Nuake/Source/Nuake/Resource/FGD/FGDFile.h index b0c2f74d..f3f7e5f1 100644 --- a/Nuake/Source/Nuake/Resource/FGD/FGDFile.h +++ b/Nuake/Source/Nuake/Resource/FGD/FGDFile.h @@ -40,7 +40,7 @@ namespace Nuake { END_SERIALIZE(); } - bool Deserialize(const json& j) + bool Deserialize(const json& j) override { if (j.contains("BrushEntities")) { diff --git a/Nuake/Source/Nuake/Resource/Project.cpp b/Nuake/Source/Nuake/Resource/Project.cpp index 6469b7c4..21cbd0a9 100644 --- a/Nuake/Source/Nuake/Resource/Project.cpp +++ b/Nuake/Source/Nuake/Resource/Project.cpp @@ -116,6 +116,9 @@ Ref Project::Load(std::string& path) void Project::ExportEntitiesToTrenchbroom() { + if (TrenchbroomPath == "") + return; + Ref file = EntityDefinitionsFile; file->BrushEntities.clear(); diff --git a/Nuake/Source/Nuake/Scene/Components/CameraComponent.cpp b/Nuake/Source/Nuake/Scene/Components/CameraComponent.cpp index 0c69ada9..0c398044 100644 --- a/Nuake/Source/Nuake/Scene/Components/CameraComponent.cpp +++ b/Nuake/Source/Nuake/Scene/Components/CameraComponent.cpp @@ -1,4 +1,3 @@ -#pragma once #include "CameraComponent.h" #include "Nuake/Rendering/Camera.h" #include "Nuake/Scene/Entities/ImGuiHelper.h" diff --git a/Nuake/Source/Nuake/Scene/Components/LightComponent.cpp b/Nuake/Source/Nuake/Scene/Components/LightComponent.cpp index 57195565..fa6864f4 100644 --- a/Nuake/Source/Nuake/Scene/Components/LightComponent.cpp +++ b/Nuake/Source/Nuake/Scene/Components/LightComponent.cpp @@ -1,5 +1,4 @@ -#pragma once -//#include +//#include #include "LightComponent.h" #include "Nuake/Rendering/Renderer.h" diff --git a/Nuake/Source/Nuake/Scene/Components/RigidbodyComponent.cpp b/Nuake/Source/Nuake/Scene/Components/RigidbodyComponent.cpp index c006498f..05e53915 100644 --- a/Nuake/Source/Nuake/Scene/Components/RigidbodyComponent.cpp +++ b/Nuake/Source/Nuake/Scene/Components/RigidbodyComponent.cpp @@ -1,4 +1,3 @@ -#pragma once #include "RigidbodyComponent.h" #include "Nuake/Physics/Rigibody.h" diff --git a/Nuake/Source/Nuake/Scene/Entities/Entity.h b/Nuake/Source/Nuake/Scene/Entities/Entity.h index a767714e..7048a091 100644 --- a/Nuake/Source/Nuake/Scene/Entities/Entity.h +++ b/Nuake/Source/Nuake/Scene/Entities/Entity.h @@ -128,7 +128,7 @@ namespace Nuake } json Serialize() override; - bool Deserialize(const json& str); + bool Deserialize(const json& str) override; bool DeserializeComponents(const json& str); void PostDeserialize(); diff --git a/Nuake/Source/Nuake/Scene/Lighting/Environment.cpp b/Nuake/Source/Nuake/Scene/Lighting/Environment.cpp index 5d7545e4..882b0fd0 100644 --- a/Nuake/Source/Nuake/Scene/Lighting/Environment.cpp +++ b/Nuake/Source/Nuake/Scene/Lighting/Environment.cpp @@ -1,4 +1,3 @@ -#pragma once #include "Environment.h" #include "Nuake/Core/Core.h" diff --git a/Nuake/Source/Nuake/Scene/Scene.cpp b/Nuake/Source/Nuake/Scene/Scene.cpp index bdb74ed6..fbce57df 100644 --- a/Nuake/Source/Nuake/Scene/Scene.cpp +++ b/Nuake/Source/Nuake/Scene/Scene.cpp @@ -1,4 +1,3 @@ -#pragma once #include "Scene.h" #include "Entities/Entity.h" diff --git a/Nuake/Source/Nuake/Scene/Systems/WadConverter.cpp b/Nuake/Source/Nuake/Scene/Systems/WadConverter.cpp index e0747401..49fce38a 100644 --- a/Nuake/Source/Nuake/Scene/Systems/WadConverter.cpp +++ b/Nuake/Source/Nuake/Scene/Systems/WadConverter.cpp @@ -475,11 +475,11 @@ namespace Nuake if (!wad_R_fp) { - printf("WAD2_OpenRead: no such file: %s\n", filename); + printf("WAD2_OpenRead: no such file: %s\n", filename.c_str()); return; } - printf("Opened WAD2 file: %s\n", filename); + printf("Opened WAD2 file: %s\n", filename.c_str()); if (fread(&wad_R_header, sizeof(wad_R_header), 1, wad_R_fp) != 1) { @@ -560,4 +560,4 @@ namespace Nuake wad_R_dir = NULL; } -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/Scripting/NetModules/EngineNetAPI.cpp b/Nuake/Source/Nuake/Scripting/NetModules/EngineNetAPI.cpp index e259bfb4..85a67444 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/EngineNetAPI.cpp +++ b/Nuake/Source/Nuake/Scripting/NetModules/EngineNetAPI.cpp @@ -9,7 +9,7 @@ #include #include #include "Coral/Type.hpp" -#include "..\..\Subsystems\EngineSubsystemScriptable.h" +#include "../../Subsystems/EngineSubsystemScriptable.h" namespace Nuake { @@ -141,21 +141,21 @@ namespace Nuake { void EngineNetAPI::RegisterMethods() { - RegisterMethod("Engine.LoadSceneIcall", &LoadScene); + RegisterMethod("Engine.LoadSceneIcall", (void*)(&LoadScene)); RegisterMethod("Engine.LoggerLogIcall", (void*)(&Log)); - RegisterMethod("Engine.GetSubsystemByNameIcall", &GetEngineSubsystemByName); + RegisterMethod("Engine.GetSubsystemByNameIcall", (void*)(&GetEngineSubsystemByName)); // Debug renderer - RegisterMethod("Debug.DrawLineIcall", &DrawLine); - RegisterMethod("Debug.DrawShapeBoxIcall", &DrawShapeBox); - RegisterMethod("Debug.DrawShapeSphereIcall", &DrawShapeSphere); - RegisterMethod("Debug.DrawShapeCapsuleIcall", &DrawShapeCapsule); - RegisterMethod("Debug.DrawShapeCylinderIcall", &DrawShapeCylinder); - - RegisterMethod("Physic.RayCastIcall", &Raycast); - RegisterMethod("Physic.ShapeCastSphereIcall", &ShapeCastSphere); - RegisterMethod("Physic.ShapeCastCapsuleIcall", &ShapeCastCapsule); - RegisterMethod("Physic.ShapeCastBoxIcall", &ShapeCastBox); + RegisterMethod("Debug.DrawLineIcall", (void*)(&DrawLine)); + RegisterMethod("Debug.DrawShapeBoxIcall", (void*)(&DrawShapeBox)); + RegisterMethod("Debug.DrawShapeSphereIcall", (void*)(&DrawShapeSphere)); + RegisterMethod("Debug.DrawShapeCapsuleIcall", (void*)(&DrawShapeCapsule)); + RegisterMethod("Debug.DrawShapeCylinderIcall", (void*)(&DrawShapeCylinder)); + + RegisterMethod("Physic.RayCastIcall", (void*)(&Raycast)); + RegisterMethod("Physic.ShapeCastSphereIcall", (void*)(&ShapeCastSphere)); + RegisterMethod("Physic.ShapeCastCapsuleIcall", (void*)(&ShapeCastCapsule)); + RegisterMethod("Physic.ShapeCastBoxIcall", (void*)(&ShapeCastBox)); } } diff --git a/Nuake/Source/Nuake/Scripting/NetModules/EngineSubsystemNetAPI.cpp b/Nuake/Source/Nuake/Scripting/NetModules/EngineSubsystemNetAPI.cpp index ebfedd72..3ea30172 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/EngineSubsystemNetAPI.cpp +++ b/Nuake/Source/Nuake/Scripting/NetModules/EngineSubsystemNetAPI.cpp @@ -31,7 +31,7 @@ namespace Nuake void EngineSubsystemNetAPI::RegisterMethods() { - RegisterMethod("EngineSubsystem.SetCanTickIcall", &SetCanTick); - RegisterMethod("EngineSubsystem.GetCanTickIcall", &GetCanTick); + RegisterMethod("EngineSubsystem.SetCanTickIcall", (void*)(&SetCanTick)); + RegisterMethod("EngineSubsystem.GetCanTickIcall", (void*)(&GetCanTick)); } } diff --git a/Nuake/Source/Nuake/Scripting/NetModules/InputNetAPI.cpp b/Nuake/Source/Nuake/Scripting/NetModules/InputNetAPI.cpp index ea9bf717..e8b20507 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/InputNetAPI.cpp +++ b/Nuake/Source/Nuake/Scripting/NetModules/InputNetAPI.cpp @@ -63,17 +63,17 @@ namespace Nuake { void InputNetAPI::RegisterMethods() { - RegisterMethod("Input.ShowMouseIcall", &ShowMouse); - RegisterMethod("Input.IsKeyDownIcall", &IsKeyDown); - RegisterMethod("Input.IsKeyPressedIcall", &IsKeyPressed); + RegisterMethod("Input.ShowMouseIcall", (void*)(&ShowMouse)); + RegisterMethod("Input.IsKeyDownIcall", (void*)(&IsKeyDown)); + RegisterMethod("Input.IsKeyPressedIcall", (void*)(&IsKeyPressed)); - RegisterMethod("Input.IsMouseButtonDownIcall", &IsMouseButtonDown); - RegisterMethod("Input.GetMousePositionIcall", &GetMousePosition); + RegisterMethod("Input.IsMouseButtonDownIcall", (void*)(&IsMouseButtonDown)); + RegisterMethod("Input.GetMousePositionIcall", (void*)(&GetMousePosition)); - RegisterMethod("Input.IsControllerConnectedIcall", &IsControllerConnected); - RegisterMethod("Input.GetControllerNameIcall", &GetControllerName); - RegisterMethod("Input.IsControllerButtonPressedIcall", &IsControllerButtonPressed); - RegisterMethod("Input.GetControllerAxisIcall", &GetControllerAxis); + RegisterMethod("Input.IsControllerConnectedIcall", (void*)(&IsControllerConnected)); + RegisterMethod("Input.GetControllerNameIcall", (void*)(&GetControllerName)); + RegisterMethod("Input.IsControllerButtonPressedIcall", (void*)(&IsControllerButtonPressed)); + RegisterMethod("Input.GetControllerAxisIcall", (void*)(&GetControllerAxis)); } diff --git a/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h b/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h index 50ac35ca..1e5f2b25 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h +++ b/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h @@ -24,4 +24,4 @@ namespace Nuake { private: MethodMap m_Methods; }; -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/Scripting/NetModules/SceneNetAPI.cpp b/Nuake/Source/Nuake/Scripting/NetModules/SceneNetAPI.cpp index 0b1e7018..3dc16c63 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/SceneNetAPI.cpp +++ b/Nuake/Source/Nuake/Scripting/NetModules/SceneNetAPI.cpp @@ -637,61 +637,61 @@ namespace Nuake { void Nuake::SceneNetAPI::RegisterMethods() { // Entity - RegisterMethod("Entity.EntityHasComponentIcall", &EntityHasComponent); - RegisterMethod("Entity.EntityAddComponentIcall", &EntityAddComponent); - RegisterMethod("Entity.EntityHasManagedInstanceIcall", &EntityHasManagedInstance); - RegisterMethod("Entity.EntityGetEntityIcall", &EntityGetEntity); - RegisterMethod("Entity.EntityGetNameIcall", &EntityGetName); - RegisterMethod("Entity.EntitySetNameIcall", &EntitySetName); - RegisterMethod("Entity.EntityIsValidIcall", &EntityIsValid); - RegisterMethod("Entity.EntityGetTargetsIcall", &EntityGetTargets); - RegisterMethod("Entity.EntityGetTargetIcall", &EntityGetTarget); + RegisterMethod("Entity.EntityHasComponentIcall", (void*)(&EntityHasComponent)); + RegisterMethod("Entity.EntityAddComponentIcall", (void*)(&EntityAddComponent)); + RegisterMethod("Entity.EntityHasManagedInstanceIcall", (void*)(&EntityHasManagedInstance)); + RegisterMethod("Entity.EntityGetEntityIcall", (void*)(&EntityGetEntity)); + RegisterMethod("Entity.EntityGetNameIcall", (void*)(&EntityGetName)); + RegisterMethod("Entity.EntitySetNameIcall", (void*)(&EntitySetName)); + RegisterMethod("Entity.EntityIsValidIcall", (void*)(&EntityIsValid)); + RegisterMethod("Entity.EntityGetTargetsIcall", (void*)(&EntityGetTargets)); + RegisterMethod("Entity.EntityGetTargetIcall", (void*)(&EntityGetTarget)); // Prefab - RegisterMethod("Prefab.PrefabInstanceIcall", &PrefabInstance); + RegisterMethod("Prefab.PrefabInstanceIcall", (void*)(&PrefabInstance)); // Scene - RegisterMethod("Scene.GetEntityIcall", &GetEntity); - RegisterMethod("Scene.GetEntityScriptFromNameIcall", &GetEntityScriptFromName); - RegisterMethod("Scene.GetEntityScriptFromHandleIcall", &GetEntityScriptFromHandle); - RegisterMethod("Scene.InstancePrefabIcall", &InstancePrefab); + RegisterMethod("Scene.GetEntityIcall", (void*)(&GetEntity)); + RegisterMethod("Scene.GetEntityScriptFromNameIcall", (void*)(&GetEntityScriptFromName)); + RegisterMethod("Scene.GetEntityScriptFromHandleIcall", (void*)(&GetEntityScriptFromHandle)); + RegisterMethod("Scene.InstancePrefabIcall", (void*)(&InstancePrefab)); // Components // Transform - RegisterMethod("TransformComponent.SetPositionIcall", &TransformSetPosition); - RegisterMethod("TransformComponent.GetPositionIcall", &TransformGetPosition); - RegisterMethod("TransformComponent.GetGlobalPositionIcall", &TransformGetGlobalPosition); - RegisterMethod("TransformComponent.RotateIcall", &TransformRotate); - RegisterMethod("TransformComponent.LookAtIcall", &TransformLookAt); + RegisterMethod("TransformComponent.SetPositionIcall", (void*)(&TransformSetPosition)); + RegisterMethod("TransformComponent.GetPositionIcall", (void*)(&TransformGetPosition)); + RegisterMethod("TransformComponent.GetGlobalPositionIcall", (void*)(&TransformGetGlobalPosition)); + RegisterMethod("TransformComponent.RotateIcall", (void*)(&TransformRotate)); + RegisterMethod("TransformComponent.LookAtIcall", (void*)(&TransformLookAt)); // Lights - RegisterMethod("LightComponent.GetLightIntensityIcall", &LightGetIntensity); - RegisterMethod("LightComponent.SetLightIntensityIcall", &LightSetIntensity); - RegisterMethod("LightComponent.SetLightColorIcall", &LightSetColor); + RegisterMethod("LightComponent.GetLightIntensityIcall", (void*)(&LightGetIntensity)); + RegisterMethod("LightComponent.SetLightIntensityIcall", (void*)(&LightSetIntensity)); + RegisterMethod("LightComponent.SetLightColorIcall", (void*)(&LightSetColor)); // Camera - RegisterMethod("CameraComponent.GetDirectionIcall", &CameraGetDirection); - RegisterMethod("CameraComponent.GetCameraFOVIcall", &CameraGetFOV); - RegisterMethod("CameraComponent.SetCameraFOVIcall", &CameraSetFOV); + RegisterMethod("CameraComponent.GetDirectionIcall", (void*)(&CameraGetDirection)); + RegisterMethod("CameraComponent.GetCameraFOVIcall", (void*)(&CameraGetFOV)); + RegisterMethod("CameraComponent.SetCameraFOVIcall", (void*)(&CameraSetFOV)); // Character Controller - RegisterMethod("CharacterControllerComponent.MoveAndSlideIcall", &MoveAndSlide); - RegisterMethod("CharacterControllerComponent.IsOnGroundIcall", &IsOnGround); - RegisterMethod("CharacterControllerComponent.GetGroundVelocityIcall", &GetGroundVelocity); - RegisterMethod("CharacterControllerComponent.GetGroundNormalIcall", &GetGroundNormal); + RegisterMethod("CharacterControllerComponent.MoveAndSlideIcall", (void*)(&MoveAndSlide)); + RegisterMethod("CharacterControllerComponent.IsOnGroundIcall", (void*)(&IsOnGround)); + RegisterMethod("CharacterControllerComponent.GetGroundVelocityIcall", (void*)(&GetGroundVelocity)); + RegisterMethod("CharacterControllerComponent.GetGroundNormalIcall", (void*)(&GetGroundNormal)); // Skinned - RegisterMethod("SkinnedModelComponent.PlayIcall", &Play); + RegisterMethod("SkinnedModelComponent.PlayIcall", (void*)(&Play)); // Navigation Mesh - RegisterMethod("NavMeshVolumeComponent.FindPathIcall", &NavMeshComponentFindPath); + RegisterMethod("NavMeshVolumeComponent.FindPathIcall", (void*)(&NavMeshComponentFindPath)); // Audio Emitter - RegisterMethod("AudioEmitterComponent.GetIsPlayingIcall", &AudioEmitterGetIsPlaying); - RegisterMethod("AudioEmitterComponent.SetIsPlayingIcall", &AudioEmitterSetIsPlaying); + RegisterMethod("AudioEmitterComponent.GetIsPlayingIcall", (void*)(&AudioEmitterGetIsPlaying)); + RegisterMethod("AudioEmitterComponent.SetIsPlayingIcall", (void*)(&AudioEmitterSetIsPlaying)); - RegisterMethod("Environment.SetFocusDistanceIcall", &EnvironmentDepthOfFieldSetFocusDistanceIcall); - RegisterMethod("Environment.GetFocusDistanceIcall", &EnvironmentDepthOfFieldGetFocusDistanceIcall); + RegisterMethod("Environment.SetFocusDistanceIcall", (void*)(&EnvironmentDepthOfFieldSetFocusDistanceIcall)); + RegisterMethod("Environment.GetFocusDistanceIcall", (void*)(&EnvironmentDepthOfFieldGetFocusDistanceIcall)); } } diff --git a/Nuake/Source/Nuake/Scripting/NetModules/UINetAPI.cpp b/Nuake/Source/Nuake/Scripting/NetModules/UINetAPI.cpp index 5905c732..227095f0 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/UINetAPI.cpp +++ b/Nuake/Source/Nuake/Scripting/NetModules/UINetAPI.cpp @@ -168,19 +168,19 @@ void SetTextNodeTextICall(const Coral::String& canvasUUID, const Coral::String& void UINetAPI::RegisterMethods() { - RegisterMethod("Node.FindChildByIDICall", &FindChildByIDIcall); - RegisterMethod("Node.HasNativeInstanceICall", &HasNativeInstanceICall); - RegisterMethod("Node.GetNativeInstanceNodeICall", &GetNativeInstanceNodeICall); + RegisterMethod("Node.FindChildByIDICall", (void*)(&FindChildByIDIcall)); + RegisterMethod("Node.HasNativeInstanceICall", (void*)(&HasNativeInstanceICall)); + RegisterMethod("Node.GetNativeInstanceNodeICall", (void*)(&GetNativeInstanceNodeICall)); // Styling - RegisterMethod("Node.GetVisibilityICall", &GetVisibilityICall); - RegisterMethod("Node.SetVisibilityICall", &SetVisibilityICall); + RegisterMethod("Node.GetVisibilityICall", (void*)(&GetVisibilityICall)); + RegisterMethod("Node.SetVisibilityICall", (void*)(&SetVisibilityICall)); - //RegisterMethod("Node.GetWidthPercentageICall", &GetWidthPercentageICall); - RegisterMethod("Node.SetWidthPercentageICall", &SetWidthPercentageICall); - // RegisterMethod("Node.GetHeightPercentageICall", &GetHeightPercentageICall); - RegisterMethod("Node.SetHeightPercentageICall", &SetHeightPercentageICall); + //RegisterMethod("Node.GetWidthPercentageICall", (void*)(&GetWidthPercentageICall)); + RegisterMethod("Node.SetWidthPercentageICall", (void*)(&SetWidthPercentageICall)); + // RegisterMethod("Node.GetHeightPercentageICall", (void*)(&GetHeightPercentageICall)); + RegisterMethod("Node.SetHeightPercentageICall", (void*)(&SetHeightPercentageICall)); - RegisterMethod("TextNode.GetTextNodeTextICall", &GetTextNodeTextICall); - RegisterMethod("TextNode.SetTextNodeTextICall", &SetTextNodeTextICall); -} \ No newline at end of file + RegisterMethod("TextNode.GetTextNodeTextICall", (void*)(&GetTextNodeTextICall)); + RegisterMethod("TextNode.SetTextNodeTextICall", (void*)(&SetTextNodeTextICall)); +} diff --git a/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp b/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp index a6127271..995265c1 100644 --- a/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp +++ b/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp @@ -51,6 +51,8 @@ namespace Nuake if (status != Coral::CoralInitStatus::Success) { Logger::Log("Failed to initialize Coral: " + std::to_string((int)status)); + delete hostInstance; + return; } // Initialize API modules @@ -81,7 +83,9 @@ namespace Nuake ScriptingEngineNet::~ScriptingEngineNet() { - hostInstance->Shutdown(); + if (isInitialized) + hostInstance->Shutdown(); + delete hostInstance; } std::vector ScriptingEngineNet::ExtractErrors(const std::string& output) @@ -178,6 +182,9 @@ namespace Nuake void ScriptingEngineNet::Initialize() { + if (!isInitialized) + return; + loadContext = hostInstance->CreateAssemblyLoadContext(m_ContextName); nuakeAssembly = ReloadEngineAPI(loadContext); @@ -925,4 +932,4 @@ namespace NuakeShowcase return oss.str(); } -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/UI/DataBinding/DataBindObject.h b/Nuake/Source/Nuake/UI/DataBinding/DataBindObject.h index 215bf1fe..4162afd8 100644 --- a/Nuake/Source/Nuake/UI/DataBinding/DataBindObject.h +++ b/Nuake/Source/Nuake/UI/DataBinding/DataBindObject.h @@ -100,6 +100,8 @@ namespace NuakeUI return dataObject.GetType(); } } + + assert(false); } template @@ -138,6 +140,8 @@ namespace NuakeUI return *data; } } + + assert(false); } template<> @@ -154,6 +158,8 @@ namespace NuakeUI return *data; } } + + assert(false); } template<> @@ -170,6 +176,8 @@ namespace NuakeUI return *data; } } + + assert(false); } template<> @@ -186,6 +194,8 @@ namespace NuakeUI return *data; } } + + assert(false); } }; -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/UI/Font/FontLoader.h b/Nuake/Source/Nuake/UI/Font/FontLoader.h index 266a7bc2..6688f4e7 100644 --- a/Nuake/Source/Nuake/UI/Font/FontLoader.h +++ b/Nuake/Source/Nuake/UI/Font/FontLoader.h @@ -168,4 +168,4 @@ namespace NuakeUI } }; -} \ No newline at end of file +} diff --git a/Nuake/Source/Nuake/UI/Nodes/Node.h b/Nuake/Source/Nuake/UI/Nodes/Node.h index 931428c0..2b381026 100644 --- a/Nuake/Source/Nuake/UI/Nodes/Node.h +++ b/Nuake/Source/Nuake/UI/Nodes/Node.h @@ -11,7 +11,7 @@ #include "Nuake/Resource/UUID.h" #include "Nuake/Scripting/ScriptingEngineNet.h" -#include +#include #include #include @@ -20,33 +20,33 @@ #define SetLength(name) \ -if (ComputedStyle.##name.type == LengthType::Auto) \ +if (ComputedStyle.name.type == LengthType::Auto) \ YGNodeStyleSet##name##Auto(mNode); \ -else if (ComputedStyle.##name.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, ComputedStyle.##name.value); \ -else if (ComputedStyle.##name.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, ComputedStyle.##name.value); \ +else if (ComputedStyle.name.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, ComputedStyle.name.value); \ +else if (ComputedStyle.name.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, ComputedStyle.name.value); \ #define SetLengthBorder(name, border) \ -if (ComputedStyle.##name##border.type == LengthType::Auto) \ +if (ComputedStyle.name##border.type == LengthType::Auto) \ YGNodeStyleSet##name##Auto(mNode, YGEdge##border); \ -else if (ComputedStyle.##name##border.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, YGEdge##border, ComputedStyle.##name##border.value); \ -else if (ComputedStyle.##name##border.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, YGEdge##border, ComputedStyle.##name##border.value); \ +else if (ComputedStyle.name##border.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, YGEdge##border, ComputedStyle.name##border.value); \ +else if (ComputedStyle.name##border.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, YGEdge##border, ComputedStyle.name##border.value); \ #define SetLengthBorderNoAuto(name, border) \ -if (ComputedStyle.##name##border.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, YGEdge##border, ComputedStyle.##name##border.value); \ -else if (ComputedStyle.##name##border.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, YGEdge##border, ComputedStyle.##name##border.value); \ +if (ComputedStyle.name##border.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, YGEdge##border, ComputedStyle.name##border.value); \ +else if (ComputedStyle.name##border.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, YGEdge##border, ComputedStyle.name##border.value); \ #define SetLengthNoAuto(name) \ -if (ComputedStyle.##name.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, ComputedStyle.##name.value); \ -else if (ComputedStyle.##name.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, ComputedStyle.##name.value); \ +if (ComputedStyle.name.type == LengthType::Pixel) YGNodeStyleSet##name(mNode, ComputedStyle.name.value); \ +else if (ComputedStyle.name.type == LengthType::Percentage) YGNodeStyleSet##name##Percent(mNode, ComputedStyle.name.value); \ -#define EnumProp(name) EnumPropEx(name, ##name##Type) +#define EnumProp(name) EnumPropEx(name, name##Type) #define EnumPropEx(name, enums) \ case StyleProperties::name: \ { \ auto type = value.value.Enum; \ -ComputedStyle.##name## = (##enums##)type; \ +ComputedStyle.name = (enums)type; \ } \ break;\ diff --git a/Nuake/Source/Nuake/UI/Parsers/CanvasParser.cpp b/Nuake/Source/Nuake/UI/Parsers/CanvasParser.cpp index 1576890a..a0190e21 100644 --- a/Nuake/Source/Nuake/UI/Parsers/CanvasParser.cpp +++ b/Nuake/Source/Nuake/UI/Parsers/CanvasParser.cpp @@ -94,10 +94,14 @@ void CanvasParser::WriteValueFromString(std::variantstring, "%02x%02x%02x%02x", &r, &g, &b, &a); +#else + int result = sscanf(value->string, "%02x%02x%02x%02x", &r, &g, &b, &a); +#endif propValue.value.Color = Color(r, g, b, a); propValue.type = PropValueType::Color; } diff --git a/Nuake/Source/Nuake/Window.cpp b/Nuake/Source/Nuake/Window.cpp index 54331f1a..26637231 100644 --- a/Nuake/Source/Nuake/Window.cpp +++ b/Nuake/Source/Nuake/Window.cpp @@ -19,6 +19,11 @@ #include #include +// Linux +#ifdef NK_LINUX +#include "gtk/gtk.h" +#endif + using namespace Nuake; Window::Window() : @@ -53,9 +58,15 @@ bool Window::ShouldClose() int Window::Init() { +#ifdef NK_LINUX + gtk_init(NULL, NULL); +#endif + if (!glfwInit()) { - Logger::Log("GLFW initialization failed", "window", CRITICAL); + const char* description; + glfwGetError(&description); + Logger::Log("GLFW initialization failed: " + std::string(description), "window", CRITICAL); return -1; } diff --git a/Nuake/Thirdparty/coral_p5.lua b/Nuake/Thirdparty/coral_p5.lua index 2248d0b5..0acdc7fa 100644 --- a/Nuake/Thirdparty/coral_p5.lua +++ b/Nuake/Thirdparty/coral_p5.lua @@ -1,4 +1,6 @@ group "Thirdparty" include "Coral/Coral.Native" -include "Coral/Coral.Managed" -group "" \ No newline at end of file +if not _OPTIONS["disable-dotnet"] then + include "Coral/Coral.Managed" +end +group "" diff --git a/Nuake/Thirdparty/dxc/inc/WinAdapter.h b/Nuake/Thirdparty/dxc/inc/WinAdapter.h new file mode 100644 index 00000000..b8c66468 --- /dev/null +++ b/Nuake/Thirdparty/dxc/inc/WinAdapter.h @@ -0,0 +1,1039 @@ +//===- WinAdapter.h - Windows Adapter for non-Windows platforms -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines Windows-specific types, macros, and SAL annotations used +// in the codebase for non-Windows platforms. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_WIN_ADAPTER_H +#define LLVM_SUPPORT_WIN_ADAPTER_H + +#ifndef _WIN32 + +#ifdef __cplusplus +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // __cplusplus + +#define COM_NO_WINDOWS_H // needed to inform d3d headers that this isn't windows + +//===----------------------------------------------------------------------===// +// +// Begin: Macro Definitions +// +//===----------------------------------------------------------------------===// +#define C_ASSERT(expr) static_assert((expr), "") +#define ATLASSERT assert + +#define CoTaskMemAlloc malloc +#define CoTaskMemFree free + +#define ARRAYSIZE(array) (sizeof(array) / sizeof(array[0])) + +#define _countof(a) (sizeof(a) / sizeof(*(a))) + +// If it is GCC, there is no UUID support and we must emulate it. +#ifndef __clang__ +#define __EMULATE_UUID 1 +#endif // __clang__ + +#ifdef __EMULATE_UUID +#define __declspec(x) +#endif // __EMULATE_UUID + +#define DECLSPEC_SELECTANY + +#ifdef __EMULATE_UUID +#define uuid(id) +#endif // __EMULATE_UUID + +#define STDMETHODCALLTYPE +#define STDMETHODIMP_(type) type STDMETHODCALLTYPE +#define STDMETHODIMP STDMETHODIMP_(HRESULT) +#define STDMETHOD_(type, name) virtual STDMETHODIMP_(type) name +#define STDMETHOD(name) STDMETHOD_(HRESULT, name) +#define EXTERN_C extern "C" + +#define UNREFERENCED_PARAMETER(P) (void)(P) + +#define RtlEqualMemory(Destination, Source, Length) \ + (!memcmp((Destination), (Source), (Length))) +#define RtlMoveMemory(Destination, Source, Length) \ + memmove((Destination), (Source), (Length)) +#define RtlCopyMemory(Destination, Source, Length) \ + memcpy((Destination), (Source), (Length)) +#define RtlFillMemory(Destination, Length, Fill) \ + memset((Destination), (Fill), (Length)) +#define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length)) +#define MoveMemory RtlMoveMemory +#define CopyMemory RtlCopyMemory +#define FillMemory RtlFillMemory +#define ZeroMemory RtlZeroMemory + +#define FALSE 0 +#define TRUE 1 + +// We ignore the code page completely on Linux. +#define GetConsoleOutputCP() 0 + +#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc) +#define DISP_E_BADINDEX _HRESULT_TYPEDEF_(0x8002000BL) +#define REGDB_E_CLASSNOTREG _HRESULT_TYPEDEF_(0x80040154L) + +// This is an unsafe conversion. If needed, we can later implement a safe +// conversion that throws exceptions for overflow cases. +#define UIntToInt(uint_arg, int_ptr_arg) *int_ptr_arg = uint_arg + +#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1) + +// Use errno to implement {Get|Set}LastError +#define GetLastError() errno +#define SetLastError(ERR) errno = ERR + +// Map these errors to equivalent errnos. +#define ERROR_SUCCESS 0L +#define ERROR_ARITHMETIC_OVERFLOW EOVERFLOW +#define ERROR_FILE_NOT_FOUND ENOENT +#define ERROR_FUNCTION_NOT_CALLED ENOSYS +#define ERROR_IO_DEVICE EIO +#define ERROR_INSUFFICIENT_BUFFER ENOBUFS +#define ERROR_INVALID_HANDLE EBADF +#define ERROR_INVALID_PARAMETER EINVAL +#define ERROR_OUT_OF_STRUCTURES ENOMEM +#define ERROR_NOT_CAPABLE EPERM +#define ERROR_NOT_FOUND ENOTSUP +#define ERROR_UNHANDLED_EXCEPTION EBADF +#define ERROR_BROKEN_PIPE EPIPE + +// Used by HRESULT <--> WIN32 error code conversion +#define SEVERITY_ERROR 1 +#define FACILITY_WIN32 7 +#define HRESULT_CODE(hr) ((hr) & 0xFFFF) +#define MAKE_HRESULT(severity, facility, code) \ + ((HRESULT)(((unsigned long)(severity) << 31) | \ + ((unsigned long)(facility) << 16) | ((unsigned long)(code)))) + +#define FILE_TYPE_UNKNOWN 0x0000 +#define FILE_TYPE_DISK 0x0001 +#define FILE_TYPE_CHAR 0x0002 +#define FILE_TYPE_PIPE 0x0003 +#define FILE_TYPE_REMOTE 0x8000 + +#define FILE_ATTRIBUTE_NORMAL 0x00000080 +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 +#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) + +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +// STGTY ENUMS +#define STGTY_STORAGE 1 +#define STGTY_STREAM 2 +#define STGTY_LOCKBYTES 3 +#define STGTY_PROPERTY 4 + +// Storage errors +#define STG_E_INVALIDFUNCTION 1L +#define STG_E_ACCESSDENIED 2L + +#define STREAM_SEEK_SET 0 +#define STREAM_SEEK_CUR 1 +#define STREAM_SEEK_END 2 + +#define HEAP_NO_SERIALIZE 0x1 +#define HEAP_ZERO_MEMORY 0x8 + +#define MB_ERR_INVALID_CHARS 0x00000008 // error for invalid chars + +// File IO + +#define CREATE_ALWAYS 2 +#define CREATE_NEW 1 +#define OPEN_ALWAYS 4 +#define OPEN_EXISTING 3 +#define TRUNCATE_EXISTING 5 + +#define FILE_SHARE_DELETE 0x00000004 +#define FILE_SHARE_READ 0x00000001 +#define FILE_SHARE_WRITE 0x00000002 + +#define GENERIC_READ 0x80000000 +#define GENERIC_WRITE 0x40000000 + +#define _atoi64 atoll +#define sprintf_s snprintf +#define _strdup strdup +#define _strnicmp strnicmp + +#define vsnprintf_s vsnprintf +#define strcat_s strcat +#define strcpy_s(dst, n, src) strncpy(dst, src, n) +#define _vscwprintf vwprintf +#define vswprintf_s vswprintf +#define swprintf_s swprintf + +#define StringCchCopyW(dst, n, src) wcsncpy(dst, src, n) + +#define OutputDebugStringW(msg) fputws(msg, stderr) + +#define OutputDebugStringA(msg) fputs(msg, stderr) +#define OutputDebugFormatA(...) fprintf(stderr, __VA_ARGS__) + +// Event Tracing for Windows (ETW) provides application programmers the ability +// to start and stop event tracing sessions, instrument an application to +// provide trace events, and consume trace events. +#define DxcEtw_DXCompilerCreateInstance_Start() +#define DxcEtw_DXCompilerCreateInstance_Stop(hr) +#define DxcEtw_DXCompilerCompile_Start() +#define DxcEtw_DXCompilerCompile_Stop(hr) +#define DxcEtw_DXCompilerDisassemble_Start() +#define DxcEtw_DXCompilerDisassemble_Stop(hr) +#define DxcEtw_DXCompilerPreprocess_Start() +#define DxcEtw_DXCompilerPreprocess_Stop(hr) +#define DxcEtw_DxcValidation_Start() +#define DxcEtw_DxcValidation_Stop(hr) + +#define UInt32Add UIntAdd +#define Int32ToUInt32 IntToUInt + +//===--------------------- HRESULT Related Macros -------------------------===// + +#define S_OK ((HRESULT)0L) +#define S_FALSE ((HRESULT)1L) + +#define E_ABORT (HRESULT)0x80004004 +#define E_ACCESSDENIED (HRESULT)0x80070005 +#define E_BOUNDS (HRESULT)0x8000000B +#define E_FAIL (HRESULT)0x80004005 +#define E_HANDLE (HRESULT)0x80070006 +#define E_INVALIDARG (HRESULT)0x80070057 +#define E_NOINTERFACE (HRESULT)0x80004002 +#define E_NOTIMPL (HRESULT)0x80004001 +#define E_NOT_VALID_STATE (HRESULT)0x8007139F +#define E_OUTOFMEMORY (HRESULT)0x8007000E +#define E_POINTER (HRESULT)0x80004003 +#define E_UNEXPECTED (HRESULT)0x8000FFFF + +#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) +#define FAILED(hr) (((HRESULT)(hr)) < 0) +#define DXC_FAILED(hr) (((HRESULT)(hr)) < 0) + +#define HRESULT_FROM_WIN32(x) \ + (HRESULT)(x) <= 0 ? (HRESULT)(x) \ + : (HRESULT)(((x) & 0x0000FFFF) | (7 << 16) | 0x80000000) + +//===----------------------------------------------------------------------===// +// +// Begin: Disable SAL Annotations +// +//===----------------------------------------------------------------------===// +#define _In_ +#define _In_z_ +#define _In_opt_ +#define _In_opt_count_(size) +#define _In_opt_z_ +#define _In_count_(size) +#define _In_bytecount_(size) + +#define _Out_ +#define _Out_opt_ +#define _Outptr_ +#define _Outptr_opt_ +#define _Outptr_result_z_ +#define _Outptr_opt_result_z_ +#define _Outptr_result_maybenull_ +#define _Outptr_result_nullonfailure_ +#define _Outptr_result_buffer_maybenull_(ptr) +#define _Outptr_result_buffer_(ptr) + +#define _COM_Outptr_ +#define _COM_Outptr_opt_ +#define _COM_Outptr_result_maybenull_ +#define _COM_Outptr_opt_result_maybenull_ + +#define THIS_ +#define THIS +#define PURE = 0 + +#define _Maybenull_ + +#define __debugbreak() + +// GCC produces erros on calling convention attributes. +#ifdef __GNUC__ +#define __cdecl +#define __CRTDECL +#define __stdcall +#define __vectorcall +#define __thiscall +#define __fastcall +#define __clrcall +#endif // __GNUC__ + +//===----------------------------------------------------------------------===// +// +// Begin: Type Definitions +// +//===----------------------------------------------------------------------===// + +#ifdef __cplusplus + +typedef unsigned char BYTE, UINT8; +typedef unsigned char *LPBYTE; + +typedef BYTE BOOLEAN; +typedef BOOLEAN *PBOOLEAN; + +typedef bool BOOL; +typedef BOOL *LPBOOL; + +typedef int INT; +typedef long LONG; +typedef unsigned int UINT; +typedef unsigned long ULONG; +typedef long long LONGLONG; +typedef long long LONG_PTR; +typedef unsigned long long ULONG_PTR; +typedef unsigned long long ULONGLONG; + +typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef DWORD *LPDWORD; + +typedef uint32_t UINT32; +typedef uint64_t UINT64; + +typedef signed char INT8, *PINT8; +typedef signed int INT32, *PINT32; + +typedef size_t SIZE_T; +typedef const char *LPCSTR; +typedef const char *PCSTR; + +typedef int errno_t; + +typedef wchar_t WCHAR; +typedef wchar_t *LPWSTR; +typedef wchar_t *PWCHAR; +typedef const wchar_t *LPCWSTR; +typedef const wchar_t *PCWSTR; + +typedef WCHAR OLECHAR; +typedef OLECHAR *BSTR; +typedef OLECHAR *LPOLESTR; +typedef char *LPSTR; + +typedef void *LPVOID; +typedef const void *LPCVOID; + +typedef std::nullptr_t nullptr_t; + +typedef signed int HRESULT; + +//===--------------------- Handle Types -----------------------------------===// + +typedef void *HANDLE; +typedef void *RPC_IF_HANDLE; + +#define DECLARE_HANDLE(name) \ + struct name##__ { \ + int unused; \ + }; \ + typedef struct name##__ *name +DECLARE_HANDLE(HINSTANCE); + +typedef void *HMODULE; + +#define STD_INPUT_HANDLE ((DWORD)-10) +#define STD_OUTPUT_HANDLE ((DWORD)-11) +#define STD_ERROR_HANDLE ((DWORD)-12) + +//===--------------------- ID Types and Macros for COM --------------------===// + +#ifdef __EMULATE_UUID +struct GUID +#else // __EMULATE_UUID +// These specific definitions are required by clang -fms-extensions. +typedef struct _GUID +#endif // __EMULATE_UUID +{ + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +} +#ifdef __EMULATE_UUID +; +#else // __EMULATE_UUID +GUID; +#endif // __EMULATE_UUID +typedef GUID CLSID; +typedef const GUID &REFGUID; +typedef const GUID &REFCLSID; + +typedef GUID IID; +typedef IID *LPIID; +typedef const IID &REFIID; +inline bool IsEqualGUID(REFGUID rguid1, REFGUID rguid2) { + // Optimization: + if (&rguid1 == &rguid2) + return true; + + return !memcmp(&rguid1, &rguid2, sizeof(GUID)); +} + +inline bool operator==(REFGUID guidOne, REFGUID guidOther) { + return !!IsEqualGUID(guidOne, guidOther); +} + +inline bool operator!=(REFGUID guidOne, REFGUID guidOther) { + return !(guidOne == guidOther); +} + +inline bool IsEqualIID(REFIID riid1, REFIID riid2) { + return IsEqualGUID(riid1, riid2); +} + +inline bool IsEqualCLSID(REFCLSID rclsid1, REFCLSID rclsid2) { + return IsEqualGUID(rclsid1, rclsid2); +} + +//===--------------------- Struct Types -----------------------------------===// + +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME, *PFILETIME, *LPFILETIME; + +typedef struct _BY_HANDLE_FILE_INFORMATION { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD dwVolumeSerialNumber; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD nNumberOfLinks; + DWORD nFileIndexHigh; + DWORD nFileIndexLow; +} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, + *LPBY_HANDLE_FILE_INFORMATION; + +typedef struct _WIN32_FIND_DATAW { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD dwReserved0; + DWORD dwReserved1; + WCHAR cFileName[260]; + WCHAR cAlternateFileName[14]; +} WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW; + +typedef union _LARGE_INTEGER { + struct { + DWORD LowPart; + DWORD HighPart; + } u; + LONGLONG QuadPart; +} LARGE_INTEGER; + +typedef LARGE_INTEGER *PLARGE_INTEGER; + +typedef union _ULARGE_INTEGER { + struct { + DWORD LowPart; + DWORD HighPart; + } u; + ULONGLONG QuadPart; +} ULARGE_INTEGER; + +typedef ULARGE_INTEGER *PULARGE_INTEGER; + +typedef struct tagSTATSTG { + LPOLESTR pwcsName; + DWORD type; + ULARGE_INTEGER cbSize; + FILETIME mtime; + FILETIME ctime; + FILETIME atime; + DWORD grfMode; + DWORD grfLocksSupported; + CLSID clsid; + DWORD grfStateBits; + DWORD reserved; +} STATSTG; + +enum tagSTATFLAG { + STATFLAG_DEFAULT = 0, + STATFLAG_NONAME = 1, + STATFLAG_NOOPEN = 2 +}; + +//===--------------------- UUID Related Macros ----------------------------===// + +#ifdef __EMULATE_UUID + +// The following macros are defined to facilitate the lack of 'uuid' on Linux. + +constexpr uint8_t nybble_from_hex(char c) { + return ((c >= '0' && c <= '9') + ? (c - '0') + : ((c >= 'a' && c <= 'f') + ? (c - 'a' + 10) + : ((c >= 'A' && c <= 'F') ? (c - 'A' + 10) + : /* Should be an error */ -1))); +} + +constexpr uint8_t byte_from_hex(char c1, char c2) { + return nybble_from_hex(c1) << 4 | nybble_from_hex(c2); +} + +constexpr uint8_t byte_from_hexstr(const char str[2]) { + return nybble_from_hex(str[0]) << 4 | nybble_from_hex(str[1]); +} + +constexpr GUID guid_from_string(const char str[37]) { + return GUID{static_cast(byte_from_hexstr(str)) << 24 | + static_cast(byte_from_hexstr(str + 2)) << 16 | + static_cast(byte_from_hexstr(str + 4)) << 8 | + byte_from_hexstr(str + 6), + static_cast( + static_cast(byte_from_hexstr(str + 9)) << 8 | + byte_from_hexstr(str + 11)), + static_cast( + static_cast(byte_from_hexstr(str + 14)) << 8 | + byte_from_hexstr(str + 16)), + {byte_from_hexstr(str + 19), byte_from_hexstr(str + 21), + byte_from_hexstr(str + 24), byte_from_hexstr(str + 26), + byte_from_hexstr(str + 28), byte_from_hexstr(str + 30), + byte_from_hexstr(str + 32), byte_from_hexstr(str + 34)}}; +} + +template inline GUID __emulated_uuidof(); + +#define CROSS_PLATFORM_UUIDOF(interface, spec) \ + struct interface; \ + template <> inline GUID __emulated_uuidof() { \ + static const IID _IID = guid_from_string(spec); \ + return _IID; \ + } + +#define __uuidof(T) __emulated_uuidof::type>() + +#define IID_PPV_ARGS(ppType) \ + __uuidof(decltype(**(ppType))), reinterpret_cast(ppType) + +#else // __EMULATE_UUID + +#ifndef CROSS_PLATFORM_UUIDOF +// Warning: This macro exists in dxcapi.h as well +#define CROSS_PLATFORM_UUIDOF(interface, spec) \ + struct __declspec(uuid(spec)) interface; +#endif + +template inline void **IID_PPV_ARGS_Helper(T **pp) { + return reinterpret_cast(pp); +} +#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType) + +#endif // __EMULATE_UUID + +// Needed for d3d headers, but fail to create actual interfaces +#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}} +#define DECLSPEC_UUID(x) +#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x) +#define DECLARE_INTERFACE(iface) struct iface +#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent + +//===--------------------- COM Interfaces ---------------------------------===// + +CROSS_PLATFORM_UUIDOF(IUnknown, "00000000-0000-0000-C000-000000000046") +struct IUnknown { + IUnknown(){}; + virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) = 0; + virtual ULONG AddRef() = 0; + virtual ULONG Release() = 0; + template HRESULT QueryInterface(Q **pp) { + return QueryInterface(__uuidof(Q), (void **)pp); + } +}; + +CROSS_PLATFORM_UUIDOF(INoMarshal, "ECC8691B-C1DB-4DC0-855E-65F6C551AF49") +struct INoMarshal : public IUnknown {}; + +CROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046") +struct IMalloc : public IUnknown { + virtual void *Alloc(SIZE_T size) = 0; + virtual void *Realloc(void *ptr, SIZE_T size) = 0; + virtual void Free(void *ptr) = 0; + virtual SIZE_T GetSize(void *pv) = 0; + virtual int DidAlloc(void *pv) = 0; + virtual void HeapMinimize(void) = 0; +}; + +CROSS_PLATFORM_UUIDOF(ISequentialStream, "0C733A30-2A1C-11CE-ADE5-00AA0044773D") +struct ISequentialStream : public IUnknown { + virtual HRESULT Read(void *pv, ULONG cb, ULONG *pcbRead) = 0; + virtual HRESULT Write(const void *pv, ULONG cb, ULONG *pcbWritten) = 0; +}; + +CROSS_PLATFORM_UUIDOF(IStream, "0000000c-0000-0000-C000-000000000046") +struct IStream : public ISequentialStream { + virtual HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, + ULARGE_INTEGER *plibNewPosition) = 0; + virtual HRESULT SetSize(ULARGE_INTEGER libNewSize) = 0; + virtual HRESULT CopyTo(IStream *pstm, ULARGE_INTEGER cb, + ULARGE_INTEGER *pcbRead, + ULARGE_INTEGER *pcbWritten) = 0; + + virtual HRESULT Commit(DWORD grfCommitFlags) = 0; + + virtual HRESULT Revert(void) = 0; + + virtual HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, + DWORD dwLockType) = 0; + + virtual HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, + DWORD dwLockType) = 0; + + virtual HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFlag) = 0; + + virtual HRESULT Clone(IStream **ppstm) = 0; +}; + +// These don't need stub implementations as they come from the DirectX Headers +// They still need the __uuidof() though +CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection, + "8E349D19-54DB-4A56-9DC9-119D87BDB804") +CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection, + "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") + +//===--------------------- COM Pointer Types ------------------------------===// + +class CAllocator { +public: + static void *Reallocate(void *p, size_t nBytes) throw(); + static void *Allocate(size_t nBytes) throw(); + static void Free(void *p) throw(); +}; + +template class CComPtrBase { +protected: + CComPtrBase() throw() { p = nullptr; } + CComPtrBase(T *lp) throw() { + p = lp; + if (p != nullptr) + p->AddRef(); + } + void Swap(CComPtrBase &other) { + T *pTemp = p; + p = other.p; + other.p = pTemp; + } + +public: + ~CComPtrBase() throw() { + if (p) { + p->Release(); + p = nullptr; + } + } + operator T *() const throw() { return p; } + T &operator*() const { return *p; } + T *operator->() const { return p; } + T **operator&() throw() { + assert(p == nullptr); + return &p; + } + bool operator!() const throw() { return (p == nullptr); } + bool operator<(T *pT) const throw() { return p < pT; } + bool operator!=(T *pT) const { return !operator==(pT); } + bool operator==(T *pT) const throw() { return p == pT; } + + // Release the interface and set to nullptr + void Release() throw() { + T *pTemp = p; + if (pTemp) { + p = nullptr; + pTemp->Release(); + } + } + + // Attach to an existing interface (does not AddRef) + void Attach(T *p2) throw() { + if (p) { + ULONG ref = p->Release(); + (void)(ref); + // Attaching to the same object only works if duplicate references are + // being coalesced. Otherwise re-attaching will cause the pointer to be + // released and may cause a crash on a subsequent dereference. + assert(ref != 0 || p2 != p); + } + p = p2; + } + + // Detach the interface (does not Release) + T *Detach() throw() { + T *pt = p; + p = nullptr; + return pt; + } + + HRESULT CopyTo(T **ppT) throw() { + assert(ppT != nullptr); + if (ppT == nullptr) + return E_POINTER; + *ppT = p; + if (p) + p->AddRef(); + return S_OK; + } + + template HRESULT QueryInterface(Q **pp) const throw() { + assert(pp != nullptr); + return p->QueryInterface(__uuidof(Q), (void **)pp); + } + + T *p; +}; + +template class CComPtr : public CComPtrBase { +public: + CComPtr() throw() {} + CComPtr(T *lp) throw() : CComPtrBase(lp) {} + CComPtr(const CComPtr &lp) throw() : CComPtrBase(lp.p) {} + T *operator=(T *lp) throw() { + if (*this != lp) { + CComPtr(lp).Swap(*this); + } + return *this; + } + + inline bool IsEqualObject(IUnknown *pOther) throw() { + if (this->p == nullptr && pOther == nullptr) + return true; // They are both NULL objects + + if (this->p == nullptr || pOther == nullptr) + return false; // One is NULL the other is not + + CComPtr punk1; + CComPtr punk2; + this->p->QueryInterface(__uuidof(IUnknown), (void **)&punk1); + pOther->QueryInterface(__uuidof(IUnknown), (void **)&punk2); + return punk1 == punk2; + } + + void ComPtrAssign(IUnknown **pp, IUnknown *lp, REFIID riid) { + IUnknown *pTemp = *pp; // takes ownership + if (lp == nullptr || FAILED(lp->QueryInterface(riid, (void **)pp))) + *pp = nullptr; + if (pTemp) + pTemp->Release(); + } + + template T *operator=(const CComPtr &lp) throw() { + if (!this->IsEqualObject(lp)) { + ComPtrAssign((IUnknown **)&this->p, lp, __uuidof(T)); + } + return *this; + } + + // NOTE: This conversion constructor is not part of the official CComPtr spec; + // however, it is needed to convert CComPtr to CComPtr where T derives + // from Q on Clang. MSVC compiles this conversion as first a call to + // CComPtr::operator T*, followed by CComPtr(T*), but Clang fails to + // compile with error: no viable conversion from 'CComPtr' to 'CComPtr'. + template + CComPtr(const CComPtr &lp) throw() : CComPtrBase(lp.p) {} + + T *operator=(const CComPtr &lp) throw() { + if (*this != lp) { + CComPtr(lp).Swap(*this); + } + return *this; + } + + CComPtr(CComPtr &&lp) throw() : CComPtrBase() { lp.Swap(*this); } + + T *operator=(CComPtr &&lp) throw() { + if (*this != lp) { + CComPtr(static_cast(lp)).Swap(*this); + } + return *this; + } +}; + +template class CSimpleArray : public std::vector { +public: + bool Add(const T &t) { + this->push_back(t); + return true; + } + int GetSize() { return this->size(); } + T *GetData() { return this->data(); } + void RemoveAll() { this->clear(); } +}; + +template class CHeapPtrBase { +protected: + CHeapPtrBase() throw() : m_pData(NULL) {} + CHeapPtrBase(CHeapPtrBase &p) throw() { + m_pData = p.Detach(); // Transfer ownership + } + explicit CHeapPtrBase(T *pData) throw() : m_pData(pData) {} + +public: + ~CHeapPtrBase() throw() { Free(); } + +protected: + CHeapPtrBase &operator=(CHeapPtrBase &p) throw() { + if (m_pData != p.m_pData) + Attach(p.Detach()); // Transfer ownership + return *this; + } + +public: + operator T *() const throw() { return m_pData; } + T *operator->() const throw() { + assert(m_pData != NULL); + return m_pData; + } + + T **operator&() throw() { + assert(m_pData == NULL); + return &m_pData; + } + + // Allocate a buffer with the given number of bytes + bool AllocateBytes(size_t nBytes) throw() { + assert(m_pData == NULL); + m_pData = static_cast(Allocator::Allocate(nBytes * sizeof(char))); + if (m_pData == NULL) + return false; + + return true; + } + + // Attach to an existing pointer (takes ownership) + void Attach(T *pData) throw() { + Allocator::Free(m_pData); + m_pData = pData; + } + + // Detach the pointer (releases ownership) + T *Detach() throw() { + T *pTemp = m_pData; + m_pData = NULL; + return pTemp; + } + + // Free the memory pointed to, and set the pointer to NULL + void Free() throw() { + Allocator::Free(m_pData); + m_pData = NULL; + } + + // Reallocate the buffer to hold a given number of bytes + bool ReallocateBytes(size_t nBytes) throw() { + T *pNew; + pNew = + static_cast(Allocator::Reallocate(m_pData, nBytes * sizeof(char))); + if (pNew == NULL) + return false; + m_pData = pNew; + + return true; + } + +public: + T *m_pData; +}; + +template +class CHeapPtr : public CHeapPtrBase { +public: + CHeapPtr() throw() {} + CHeapPtr(CHeapPtr &p) throw() : CHeapPtrBase(p) {} + explicit CHeapPtr(T *p) throw() : CHeapPtrBase(p) {} + CHeapPtr &operator=(CHeapPtr &p) throw() { + CHeapPtrBase::operator=(p); + return *this; + } + + // Allocate a buffer with the given number of elements + bool Allocate(size_t nElements = 1) throw() { + size_t nBytes = nElements * sizeof(T); + return this->AllocateBytes(nBytes); + } + + // Reallocate the buffer to hold a given number of elements + bool Reallocate(size_t nElements) throw() { + size_t nBytes = nElements * sizeof(T); + return this->ReallocateBytes(nBytes); + } +}; + +#define CComHeapPtr CHeapPtr + +//===--------------------------- BSTR Allocation --------------------------===// + +void SysFreeString(BSTR bstrString); +// Allocate string with length prefix +BSTR SysAllocStringLen(const OLECHAR *strIn, UINT ui); + +//===--------------------------- BSTR Length ------------------------------===// +unsigned int SysStringLen(const BSTR bstrString); + +//===--------------------- UTF-8 Related Types ----------------------------===// + +// Code Page +#define CP_ACP 0 +#define CP_UTF8 65001 // UTF-8 translation. + +// RAII style mechanism for setting/unsetting a locale for the specified Windows +// codepage +class ScopedLocale { + const char *m_prevLocale; + +public: + explicit ScopedLocale(uint32_t codePage) + : m_prevLocale(setlocale(LC_ALL, nullptr)) { + assert((codePage == CP_UTF8) && + "Support for Linux only handles UTF8 code pages"); + setlocale(LC_ALL, "en_US.UTF-8"); + } + ~ScopedLocale() { + if (m_prevLocale != nullptr) { + setlocale(LC_ALL, m_prevLocale); + } + } +}; + +// The t_nBufferLength parameter is part of the published interface, but not +// used here. +template class CW2AEX { +public: + CW2AEX(LPCWSTR psz) { + ScopedLocale locale(CP_UTF8); + + if (!psz) { + m_psz = NULL; + return; + } + + int len = (wcslen(psz) + 1) * 4; + m_psz = new char[len]; + std::wcstombs(m_psz, psz, len); + } + + ~CW2AEX() { delete[] m_psz; } + + operator LPSTR() const { return m_psz; } + + char *m_psz; +}; +typedef CW2AEX<> CW2A; + +// The t_nBufferLength parameter is part of the published interface, but not +// used here. +template class CA2WEX { +public: + CA2WEX(LPCSTR psz) { + ScopedLocale locale(CP_UTF8); + + if (!psz) { + m_psz = NULL; + return; + } + + int len = strlen(psz) + 1; + m_psz = new wchar_t[len]; + std::mbstowcs(m_psz, psz, len); + } + + ~CA2WEX() { delete[] m_psz; } + + operator LPWSTR() const { return m_psz; } + + wchar_t *m_psz; +}; + +typedef CA2WEX<> CA2W; + +//===--------- File IO Related Types ----------------===// + +class CHandle { +public: + CHandle(HANDLE h); + ~CHandle(); + operator HANDLE() const throw(); + +private: + HANDLE m_h; +}; + +///////////////////////////////////////////////////////////////////////////// +// CComBSTR + +class CComBSTR { +public: + BSTR m_str; + CComBSTR() : m_str(nullptr){}; + CComBSTR(int nSize, LPCWSTR sz); + ~CComBSTR() throw() { SysFreeString(m_str); } + unsigned int Length() const throw() { return SysStringLen(m_str); } + operator BSTR() const throw() { return m_str; } + + bool operator==(const CComBSTR &bstrSrc) const throw(); + + BSTR *operator&() throw() { return &m_str; } + + BSTR Detach() throw() { + BSTR s = m_str; + m_str = NULL; + return s; + } + + void Empty() throw() { + SysFreeString(m_str); + m_str = NULL; + } +}; + +//===--------- Convert argv to wchar ----------------===// +class WArgV { + std::vector WStringVector; + std::vector WCharPtrVector; + +public: + WArgV(int argc, const char **argv); + const wchar_t **argv() { return WCharPtrVector.data(); } +}; + +#endif // __cplusplus + +#endif // _WIN32 + +#endif // LLVM_SUPPORT_WIN_ADAPTER_H diff --git a/Nuake/Thirdparty/glfw_p5.lua b/Nuake/Thirdparty/glfw_p5.lua index 69cc02df..69d506d5 100644 --- a/Nuake/Thirdparty/glfw_p5.lua +++ b/Nuake/Thirdparty/glfw_p5.lua @@ -56,13 +56,13 @@ project "GLFW" files { - "glfw/src/x11_init.c", + "glfw/src/x11_init.c", "glfw/src/x11_monitor.c", "glfw/src/x11_window.c", "glfw/src/xkb_unicode.c", "glfw/src/posix_time.c", "glfw/src/posix_thread.c", - "glfw/src/posix_module.c", + "glfw/src/posix_module.c", "glfw/src/glx_context.c", "glfw/src/egl_context.c", "glfw/src/osmesa_context.c", @@ -74,6 +74,29 @@ project "GLFW" "_GLFW_X11" } + filter "system:bsd" + pic "On" + includedirs "/usr/local/include" + + files + { + "glfw/src/x11_init.c", + "glfw/src/x11_monitor.c", + "glfw/src/x11_window.c", + "glfw/src/xkb_unicode.c", + "glfw/src/posix_time.c", + "glfw/src/posix_thread.c", + "glfw/src/posix_module.c", + "glfw/src/glx_context.c", + "glfw/src/egl_context.c", + "glfw/src/osmesa_context.c", + } + + defines + { + "_GLFW_X11" + } + filter "configurations:Debug" runtime "Debug" diff --git a/Nuake/Thirdparty/msdf-atlas-gen_p5.lua b/Nuake/Thirdparty/msdf-atlas-gen_p5.lua index 53dd7532..1c505a7c 100644 --- a/Nuake/Thirdparty/msdf-atlas-gen_p5.lua +++ b/Nuake/Thirdparty/msdf-atlas-gen_p5.lua @@ -21,9 +21,9 @@ project 'msdf-gen' 'msdf-atlas-gen/msdfgen/*.h', 'msdf-atlas-gen/msdfgen/*.cpp', 'msdf-atlas-gen/msdfgen/*.hpp', - 'msdf-atlas-gen/msdfgen/Core/*.h', - 'msdf-atlas-gen/msdfgen/Core/*.hpp', - 'msdf-atlas-gen/msdfgen/Core/*.cpp', + 'msdf-atlas-gen/msdfgen/core/*.h', + 'msdf-atlas-gen/msdfgen/core/*.hpp', + 'msdf-atlas-gen/msdfgen/core/*.cpp', 'msdf-atlas-gen/msdfgen/lib/*.cpp', 'msdf-atlas-gen/msdfgen/ext/*.h', 'msdf-atlas-gen/msdfgen/ext/*.cpp' @@ -83,4 +83,4 @@ project 'msdf-atlas-gen' runtime "Release" optimize "on" -group "" \ No newline at end of file +group "" diff --git a/Nuake/Thirdparty/soloud_p5.lua b/Nuake/Thirdparty/soloud_p5.lua index 41ce52d8..0470e9a8 100644 --- a/Nuake/Thirdparty/soloud_p5.lua +++ b/Nuake/Thirdparty/soloud_p5.lua @@ -45,6 +45,16 @@ project 'Soloud' "soloud/src/backend/alsa/soloud_alsa.cpp" } + filter "system:bsd" + -- assuming we're on FreeBSD, for other *BSD you may need portaudio or miniaudio + defines { + "WITH_OSS" + } + files + { + "soloud/src/backend/oss/soloud_oss.cpp" + } + filter "configurations:Debug" cppdialect "C++17" runtime "Debug" @@ -54,4 +64,4 @@ project 'Soloud' cppdialect "C++17" runtime "Release" optimize "on" -group "" \ No newline at end of file +group "" diff --git a/Nuake/Vendors/katana-parser/foundation.c b/Nuake/Vendors/katana-parser/foundation.c index c3fd2a75..48fa8b45 100644 --- a/Nuake/Vendors/katana-parser/foundation.c +++ b/Nuake/Vendors/katana-parser/foundation.c @@ -84,7 +84,7 @@ bool katana_string_has_prefix(const char* str, const char* prefix) { size_t pre_len = strlen(prefix); size_t str_len = strlen(str); - return pre_len <= str_len && stricmp(prefix, str); + return pre_len <= str_len && strncasecmp(prefix, str, pre_len); } void katana_string_to_lowercase(struct KatanaInternalParser* parser, diff --git a/Nuake/Vendors/katana-parser/katana.tab.c b/Nuake/Vendors/katana-parser/katana.tab.c index d0f63aa5..07a9ce43 100644 --- a/Nuake/Vendors/katana-parser/katana.tab.c +++ b/Nuake/Vendors/katana-parser/katana.tab.c @@ -2795,13 +2795,13 @@ YYLTYPE yylloc = yyloc_default; case 129: { - if (!stricmp((yyvsp[0].string).data, "from")) { + if (!strcasecmp((yyvsp[0].string).data, "from")) { KatanaParserNumber number; number.val = 0; number.raw = (KatanaParserString){"from", 4}; (yyval.value) = katana_new_number_value(parser, 1, &number, KATANA_VALUE_NUMBER); } - else if (!stricmp((yyvsp[0].string).data, "to")) { + else if (!strcasecmp((yyvsp[0].string).data, "to")) { KatanaParserNumber number; number.val = 100; number.raw = (KatanaParserString){"to", 4}; @@ -2862,7 +2862,7 @@ YYLTYPE yylloc = yyloc_default; case 136: { - if (!stricmp((yyvsp[-2].string).data, "deep")) + if (!strcasecmp((yyvsp[-2].string).data, "deep")) (yyval.relation) = KatanaSelectorRelationShadowDeep; else YYERROR; diff --git a/Nuake/Vendors/katana-parser/parser.c b/Nuake/Vendors/katana-parser/parser.c index 02065c9f..8f720e7f 100644 --- a/Nuake/Vendors/katana-parser/parser.c +++ b/Nuake/Vendors/katana-parser/parser.c @@ -1458,7 +1458,7 @@ void katana_print_media_query(KatanaParser* parser, KatanaMediaQuery* query) return; } - if ( (NULL != query->type && stricmp(query->type, "all")) || query->restrictor != KatanaMediaQueryRestrictorNone) { + if ( (NULL != query->type && strcasecmp(query->type, "all")) || query->restrictor != KatanaMediaQueryRestrictorNone) { if ( NULL != query->type ) { katana_print("%s", query->type); } diff --git a/Nuake/Vendors/katana-parser/selector.c b/Nuake/Vendors/katana-parser/selector.c index c3669116..afe06a5a 100644 --- a/Nuake/Vendors/katana-parser/selector.c +++ b/Nuake/Vendors/katana-parser/selector.c @@ -450,7 +450,7 @@ unsigned calc_specificity_for_one_selector(const KatanaSelector* selector) return 0x100; case KatanaSelectorMatchTag: - return !stricmp(selector->tag->local, "*") ? 0 : 1; + return !strcmp(selector->tag->local, "*") ? 0 : 1; case KatanaSelectorMatchUnknown: case KatanaSelectorMatchPagePseudoClass: return 0; @@ -608,7 +608,7 @@ static KatanaPseudoType name_to_pseudo_type(const char* name, bool hasArguments) const KatanaNameToPseudoStruct* match = lower_bound(pseudoTypeMap, count, name); if ( match == (pseudoTypeMap + count) - || 0 != stricmp(match->string, name) ) + || 0 != strcasecmp(match->string, name) ) return KatanaPseudoUnknown; return match->type; diff --git a/Nuake/Vendors/vkb/VkBootstrap.cpp b/Nuake/Vendors/vkb/VkBootstrap.cpp index 6fc90aec..a277a796 100644 --- a/Nuake/Vendors/vkb/VkBootstrap.cpp +++ b/Nuake/Vendors/vkb/VkBootstrap.cpp @@ -26,7 +26,8 @@ #include #endif // _WIN32 -#if defined(__linux__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) +#define UNIX 1 #include #endif @@ -114,7 +115,7 @@ namespace vkb { private: std::mutex init_mutex; -#if defined(__linux__) || defined(__APPLE__) +#if defined(UNIX) void* library = nullptr; #elif defined(_WIN32) HMODULE library = nullptr; @@ -125,13 +126,13 @@ namespace vkb { if (library) { return true; } -#if defined(__linux__) - library = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL); - if (!library) library = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL); -#elif defined(__APPLE__) +#if defined(__APPLE__) library = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL); if (!library) library = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL); if (!library) library = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL); +#elif defined(UNIX) + library = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL); + if (!library) library = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL); #elif defined(_WIN32) library = LoadLibrary(TEXT("vulkan-1.dll")); #else @@ -143,14 +144,14 @@ namespace vkb { } template void load_func(T& func_dest, const char* func_name) { -#if defined(__linux__) || defined(__APPLE__) +#if defined(UNIX) func_dest = reinterpret_cast(dlsym(library, func_name)); #elif defined(_WIN32) func_dest = reinterpret_cast(GetProcAddress(library, func_name)); #endif } void close() { -#if defined(__linux__) || defined(__APPLE__) +#if defined(UNIX) dlclose(library); #elif defined(_WIN32) FreeLibrary(library); @@ -663,13 +664,13 @@ namespace vkb { bool added_window_exts = check_add_window_ext("VK_KHR_android_surface"); #elif defined(_DIRECT2DISPLAY) bool added_window_exts = check_add_window_ext("VK_KHR_display"); -#elif defined(__linux__) +#elif defined(__APPLE__) + bool added_window_exts = check_add_window_ext("VK_EXT_metal_surface"); +#elif defined(UNIX) // make sure all three calls to check_add_window_ext, don't allow short circuiting bool added_window_exts = check_add_window_ext("VK_KHR_xcb_surface"); added_window_exts = check_add_window_ext("VK_KHR_xlib_surface") || added_window_exts; added_window_exts = check_add_window_ext("VK_KHR_wayland_surface") || added_window_exts; -#elif defined(__APPLE__) - bool added_window_exts = check_add_window_ext("VK_EXT_metal_surface"); #endif if (!khr_surface_added || !added_window_exts) return make_error_code(InstanceError::windowing_extensions_not_present); @@ -2204,4 +2205,4 @@ namespace vkb { modes.push_back(VK_PRESENT_MODE_MAILBOX_KHR); modes.push_back(VK_PRESENT_MODE_FIFO_KHR); } -} // namespace vkb \ No newline at end of file +} // namespace vkb diff --git a/Nuake/premake5.lua b/Nuake/premake5.lua index b880cc31..ddea8662 100644 --- a/Nuake/premake5.lua +++ b/Nuake/premake5.lua @@ -107,20 +107,20 @@ project "Nuake" } filter "system:linux" - defines + defines { "GLFW_STATIC", "NK_LINUX" } - - links + + links { "glib-2.0" } - + buildoptions { "`pkg-config --cflags glib-2.0 pango gdk-pixbuf-2.0 atk`" } - linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0`" } - + linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0`" } + includedirs { "/usr/include/gtk-3.0/", @@ -128,6 +128,29 @@ project "Nuake" "/usr/include/glib-2.0", } + filter "system:bsd" + defines + { + "GLFW_STATIC", + "NK_LINUX", + "NK_BSD" + } + + links + { + "glib-2.0" + } + + buildoptions { "`pkg-config --cflags glib-2.0 pango gdk-pixbuf-2.0 atk`" } + linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0`" } + + includedirs + { + "/usr/local/include/gtk-3.0/", + "/usr/local/lib/glib-2.0/include", + "/usr/local/include/glib-2.0", + } + filter "system:windows" staticruntime "On" defines @@ -153,4 +176,4 @@ project "Nuake" filter "configurations:Dist" runtime "Release" - optimize "on" \ No newline at end of file + optimize "on" diff --git a/Runtime/premake5.lua b/Runtime/premake5.lua index 367d5d58..748819a4 100644 --- a/Runtime/premake5.lua +++ b/Runtime/premake5.lua @@ -1,6 +1,7 @@ project "Runtime" kind "ConsoleApp" language "C++" + cppdialect "C++20" debugdir (binaryOutputDir) targetdir (binaryOutputDir) @@ -72,22 +73,15 @@ project "Runtime" "msdf-gen", "msdf-atlas-gen", "Freetype", - "vma" + "vma", + "dxcompiler" } + libdirs { "../Nuake/Thirdparty/dxc/lib/x64" } defines { table.unpack(globalDefines) } - prebuildcommands { - '{ECHO} "Copying dxcompiler.dll to Working directory..."', - '{COPYFILE} "%{wks.location}Nuake/Thirdparty/dxc/bin/x64/dxcompiler.dll" "%{cfg.debugdir}/"', - '{ECHO} Copying Coral to Working directory...', - '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.dll" "%{cfg.debugdir}/"', - '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.runtimeconfig.json" "%{cfg.debugdir}/"', - 'xcopy /E /I /Y "%{wks.location}Data" "%{cfg.debugdir}\\Resources"' - } - filter "system:windows" cppdialect "C++20" staticruntime "On" @@ -96,6 +90,15 @@ project "Runtime" } externalincludedirs { "../Nuake/Thirdparty/Coral/Coral.Native/Include/" } + prebuildcommands { + '{ECHO} "Copying dxcompiler.dll to Working directory..."', + '{COPYFILE} "%{wks.location}Nuake/Thirdparty/dxc/bin/x64/dxcompiler.dll" "%{cfg.debugdir}/"', + '{ECHO} Copying Coral to Working directory...', + '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.dll" "%{cfg.debugdir}/"', + '{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.runtimeconfig.json" "%{cfg.debugdir}/"', + 'xcopy /E /I /Y "%{wks.location}Data" "%{cfg.debugdir}\\Resources"' + } + filter { "system:windows", "action:vs*" } flags { @@ -112,18 +115,43 @@ project "Runtime" "asound", "glib-2.0", "gtk-3", - "gobject-2.0" + "gobject-2.0" + } + + includedirs + { + "/usr/include/gtk-3.0/", + "/usr/lib/glib-2.0/include", + "/usr/include/glib-2.0", + } + + buildoptions { "`pkg-config --cflags glib-2.0 pango gdk-pixbuf-2.0 gtk+-3.0 atk glib-2.0`" } + linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0 gtk+-3.0 glib-2.0 gobject-2.0`" } + + filter "system:bsd" + links + { + "GL", + "glfw", + "glad", + "X11", + "asound", + "glib-2.0", + "gtk-3", + "gobject-2.0", + "pthread", + "execinfo" } includedirs { - "/usr/include/gtk-3.0/", - "/usr/lib/glib-2.0/include", - "/usr/include/glib-2.0", + "/usr/local/include/gtk-3.0/", + "/usr/local/lib/glib-2.0/include", + "/usr/local/include/glib-2.0", } - - buildoptions { "`pkg-config --cflags glib-2.0 pango gdk-pixbuf-2.0 gtk-3 atk tk-3.0 glib-2.0`" } - linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0 gtk-3 glib-2.0 lgobject-2.0`" } + + buildoptions { "`pkg-config --cflags glib-2.0 pango gdk-pixbuf-2.0 gtk+-3.0 atk glib-2.0`" } + linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0 gtk+-3.0 glib-2.0 gobject-2.0`" } filter "configurations:Debug" runtime "Debug" @@ -156,4 +184,4 @@ project "Runtime" { "NK_DIST", "WIN32_LEAN_AND_MEAN" - } \ No newline at end of file + } diff --git a/premake5.lua b/premake5.lua index 942211ac..7b7e5f79 100644 --- a/premake5.lua +++ b/premake5.lua @@ -19,6 +19,11 @@ newaction { end } +newoption { + trigger = "disable-dotnet", + description = "Disables dotnet build for makefile builders", +} + -- ╔═══════════════════════════════════════╗ -- ║ WORKSPACE ║ -- ╚═══════════════════════════════════════╝ @@ -53,15 +58,14 @@ workspace "Nuake" architecture "x64" outputdir = "Build/%{cfg.buildcfg}/" -binaryOutputDir = outputdir .. "Binaries/" -intBinaryOutputDir = outputdir .. "Binaries-Intermediate/" +binaryOutputDir = "%{wks.location}/" .. outputdir .. "Binaries/" +intBinaryOutputDir = "%{wks.location}/" .. outputdir .. "Binaries-Intermediate/" globalDefines = { "TRACY_ENABLE", "TRACY_ON_DEMAND", "NK_VK", "IMGUI_DEFINE_MATH_OPERATORS", - "NK_WIN" } group "Thirdparty" @@ -82,5 +86,7 @@ group "" include "Nuake/premake5.lua" include "Editor/premake5.lua" include "Runtime/premake5.lua" -include "NuakeNet/premake5.lua" -include "EditorNet/premake5.lua" +if not _OPTIONS["disable-dotnet"] then + include "NuakeNet/premake5.lua" + include "EditorNet/premake5.lua" +end