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
This commit is contained in:
Nigel Barink 2023-05-09 19:38:53 +02:00
parent 43fc721413
commit c82398205a
3 changed files with 57 additions and 11 deletions

View File

@ -134,9 +134,29 @@ void Inspector::ShowComponents()
} }
if (selected.HasComponent<YoggieEngine::ScriptComponent>()) { if (selected.HasComponent<YoggieEngine::ScriptComponent>()) {
ComponentView("Scripting", [] { const char* AssetNames[]{ "Script 1" , "Script 2" };
ImGui::LabelText("##--", "Hello scripting"); 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 = "<Random_GUID>";
ImGui::InputText("asset", scriptAssetId.data(), scriptAssetId.length(), ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_AutoSelectAll);
}
} }
} }

View File

@ -23,14 +23,26 @@ namespace YoggieEngine {
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable; io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable; io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18); io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18);
ImGui::StyleColorsDark(); 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_ImplGlfw_InitForOpenGL((GLFWwindow*)appWindow->GetHandle(), true);
ImGui_ImplOpenGL3_Init("#version 450"); ImGui_ImplOpenGL3_Init("#version 450");
ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext()); ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext());
ImGuizmo::SetOrthographic(true); //ImGuizmo::SetOrthographic(true);
init_inputSystem(appWindow); init_inputSystem(appWindow);

View File

@ -1,6 +1,7 @@
#include "YoggieEngine.h" #include "YoggieEngine.h"
#include "glfwWindow.h" #include "glfwWindow.h"
#include <chrono>
#include<GLFW/glfw3.h>
namespace YoggieEngine { namespace YoggieEngine {
void LoadGLExtensions() { 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) glfwWindow::glfwWindow(const int width, const int height, const char* title)
: NativeWindow() : NativeWindow()
{ {
@ -19,15 +25,20 @@ namespace YoggieEngine {
m_fullscreen = false; m_fullscreen = false;
glfwSetErrorCallback(error_callback);
auto start = std::chrono::high_resolution_clock::now();
if (!glfwInit()) { if (!glfwInit()) {
spdlog::error("Failed to initialise GLFW!"); spdlog::error("Failed to initialise GLFW!");
exit(-1); exit(-1);
} }
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds> (end - start);
spdlog::info("GLFWInit() call took {0} milliseconds.", duration.count());
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_TRUE); glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_TRUE);
if (m_fullscreen) { if (m_fullscreen) {
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
} }
@ -35,10 +46,7 @@ namespace YoggieEngine {
if (!m_resizable) { if (!m_resizable) {
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
} }
if (!m_vsync) {
glfwSwapInterval(0);
}
window = glfwCreateWindow(m_width, m_height, title, NULL, NULL); window = glfwCreateWindow(m_width, m_height, title, NULL, NULL);
@ -49,6 +57,12 @@ namespace YoggieEngine {
} }
SetContext(); SetContext();
if (!m_vsync) {
glfwSwapInterval(0);
}
glfwGetFramebufferSize(window, &m_width, &m_height); glfwGetFramebufferSize(window, &m_width, &m_height);
LoadGLExtensions(); LoadGLExtensions();