From c82398205a84ecdf7bf39afa38aa8c30a2ca482c Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Tue, 9 May 2023 19:38:53 +0200 Subject: [PATCH] Script component inspector, glfwErrorCallback etc... * Filling out script component inspector * adding error_callback for glfw * Measuring gflwInit time * Moving Swap interval set to be after making context current --- Editor/src/PropertyPanels/Inspector.cpp | 26 ++++++++++++++++--- YoggieEngine/src/Application.cpp | 16 ++++++++++-- YoggieEngine/src/Platform/glfw/glfwWindow.cpp | 26 ++++++++++++++----- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/Editor/src/PropertyPanels/Inspector.cpp b/Editor/src/PropertyPanels/Inspector.cpp index 95cc04e..b18c2e0 100644 --- a/Editor/src/PropertyPanels/Inspector.cpp +++ b/Editor/src/PropertyPanels/Inspector.cpp @@ -134,9 +134,29 @@ void Inspector::ShowComponents() } if (selected.HasComponent()) { - ComponentView("Scripting", [] { - ImGui::LabelText("##--", "Hello scripting"); - }); + const char* AssetNames[]{ "Script 1" , "Script 2" }; + if (ImGui::CollapsingHeader("Script", ImGuiTreeNodeFlags_Leaf)) { + + if (ImGui::Button("Select Renderable Asset")) + ImGui::OpenPopup("Scripts_list_popup"); + + if (ImGui::BeginPopup("Scripts_list_popup")) { + ImGui::Text("None"); + ImGui::Separator(); + for (int i = 0; i < IM_ARRAYSIZE(AssetNames); i++) { + if (ImGui::Selectable(AssetNames[i])) + { + } + } + ImGui::EndPopup(); + + } + + ImGui::SameLine(); + std::string scriptAssetId = ""; + ImGui::InputText("asset", scriptAssetId.data(), scriptAssetId.length(), ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_AutoSelectAll); + + } } } diff --git a/YoggieEngine/src/Application.cpp b/YoggieEngine/src/Application.cpp index 1b58cf2..b3c8568 100644 --- a/YoggieEngine/src/Application.cpp +++ b/YoggieEngine/src/Application.cpp @@ -23,14 +23,26 @@ namespace YoggieEngine { io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable; io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable; io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18); - + ImGui::StyleColorsDark(); + /* + ImGuiStyle* style = &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_TitleBg] = ImVec4(0.72f, 0.24f, 0.87f, 1.00f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.72f, 0.24f, 0.87f, 1.00f); + colors[ImGuiCol_Tab] = ImVec4(0.53f, 0.09f, 0.67f, 1.00f); + + + */ + + ImGui_ImplGlfw_InitForOpenGL((GLFWwindow*)appWindow->GetHandle(), true); ImGui_ImplOpenGL3_Init("#version 450"); ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext()); - ImGuizmo::SetOrthographic(true); + //ImGuizmo::SetOrthographic(true); init_inputSystem(appWindow); diff --git a/YoggieEngine/src/Platform/glfw/glfwWindow.cpp b/YoggieEngine/src/Platform/glfw/glfwWindow.cpp index ef41f23..e58c1ae 100644 --- a/YoggieEngine/src/Platform/glfw/glfwWindow.cpp +++ b/YoggieEngine/src/Platform/glfw/glfwWindow.cpp @@ -1,6 +1,7 @@ #include "YoggieEngine.h" #include "glfwWindow.h" - +#include +#include namespace YoggieEngine { void LoadGLExtensions() { @@ -10,6 +11,11 @@ namespace YoggieEngine { } } + + static void error_callback(int error, const char* description) { + spdlog::error("{0}", description); + } + glfwWindow::glfwWindow(const int width, const int height, const char* title) : NativeWindow() { @@ -19,15 +25,20 @@ namespace YoggieEngine { m_fullscreen = false; + glfwSetErrorCallback(error_callback); + + auto start = std::chrono::high_resolution_clock::now(); if (!glfwInit()) { spdlog::error("Failed to initialise GLFW!"); exit(-1); } + auto end = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast (end - start); + spdlog::info("GLFWInit() call took {0} milliseconds.", duration.count()); glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_TRUE); - if (m_fullscreen) { glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); } @@ -35,10 +46,7 @@ namespace YoggieEngine { if (!m_resizable) { glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); } - - if (!m_vsync) { - glfwSwapInterval(0); - } + window = glfwCreateWindow(m_width, m_height, title, NULL, NULL); @@ -49,6 +57,12 @@ namespace YoggieEngine { } SetContext(); + + + if (!m_vsync) { + glfwSwapInterval(0); + } + glfwGetFramebufferSize(window, &m_width, &m_height); LoadGLExtensions();