Compare commits

..

2 Commits

Author SHA1 Message Date
c82398205a 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
2023-05-09 19:38:53 +02:00
43fc721413 Replacing a few std::cout with spdlog::info/error 2023-05-09 19:36:34 +02:00
12 changed files with 81 additions and 35 deletions

View File

@ -47,7 +47,7 @@ protected:
return ASSET_TYPE::File; return ASSET_TYPE::File;
} }
else { else {
std::cout << "unknown file!" << std::endl; spdlog::warn("unknown file!");
return ASSET_TYPE::Unknown; return ASSET_TYPE::Unknown;
} }
} }

View File

@ -94,11 +94,11 @@ Asset ModelLoader::LoadAsset(std::filesystem::path& path) {
aiNode* currentNode = scene->mRootNode; aiNode* currentNode = scene->mRootNode;
std::cout << "Loading meshes!" << std::endl; spdlog::info("Loading meshes!" );
auto meshes = processNode(currentNode, scene); auto meshes = processNode(currentNode, scene);
std::cout << "Model file contained " << meshes.size() << " meshes" << std::endl; spdlog::info("Model file contained {0} meshes", meshes.size() );

View File

@ -45,10 +45,10 @@ YoggieEngine::Mesh* AssetRegistry::LoadFromAssetFile(const std::filesystem::path
AssetFile.read((char*)&Enum, sizeof(uint32_t)); AssetFile.read((char*)&Enum, sizeof(uint32_t));
// print Header info // print Header info
std::cout << "File has header: " << Header << std::endl; spdlog::info("File has header: {0}", Header);
std::cout << "Vertex size: " << Vsize << std::endl; spdlog::info ( "Vertex size: {0}", Vsize );
std::cout << "Number of Vertices: " << Vnum << std::endl; spdlog::info("Number of Vertices: {0}" ,Vnum );
std::cout << "Number of Elements: " << Enum << std::endl; spdlog::info ("Number of Elements: " , Enum );
free(Header); free(Header);
@ -77,7 +77,7 @@ YoggieEngine::Mesh* AssetRegistry::LoadFromAssetFile(const std::filesystem::path
} }
else { else {
std::cout << "Failed ot open mesh " << std::endl; spdlog::error( "Failed ot open mesh " );
} }
return imported; return imported;
@ -92,7 +92,7 @@ YoggieEngine::Renderable* AssetRegistry::LoadFromSource(const std::filesystem::p
* auto model = (YoggieEngine::ModelImporter()).Import(srcPath.string()); * auto model = (YoggieEngine::ModelImporter()).Import(srcPath.string());
YoggieEngine::Mesh* exportMesh = model->renderable->mesh; YoggieEngine::Mesh* exportMesh = model->renderable->mesh;
std::filesystem::path MeshFileName = assetFolder / srcPath.filename().replace_extension(".mesh"); std::filesystem::path MeshFileName = assetFolder / srcPath.filename().replace_extension(".mesh");
std::cout << "Save path: " << MeshFileName << std::endl; spdlog::info( "Save path: {0}" , MeshFileName );
std::ofstream meshAsset; std::ofstream meshAsset;
meshAsset.open(MeshFileName, std::ios::binary); meshAsset.open(MeshFileName, std::ios::binary);
@ -102,8 +102,8 @@ YoggieEngine::Renderable* AssetRegistry::LoadFromSource(const std::filesystem::p
static const char* HEADER = "MESH"; static const char* HEADER = "MESH";
meshAsset.write(HEADER, sizeof(HEADER)); meshAsset.write(HEADER, sizeof(HEADER));
auto Vsize = sizeof(YoggieEngine::Vertex); auto Vsize = sizeof(YoggieEngine::Vertex);
std::cout << "size of vertex: " << Vsize << std::endl; spdlog::info( "size of vertex: {0}" ,Vsize );
std::cout << "Addr of vSize: " << &Vsize << std::endl; spdlog::info("Addr of vSize: {0}" , &Vsize );
auto Vnum = exportMesh->vertices.size(); auto Vnum = exportMesh->vertices.size();
auto Enum = exportMesh->elements.size(); auto Enum = exportMesh->elements.size();

View File

@ -6,7 +6,7 @@
void WriteFile(std::string& emitter, std::filesystem::path path) void WriteFile(std::string& emitter, std::filesystem::path path)
{ {
std::cout << "Writing Scene file to: " << path.u8string() << std::endl; spdlog::info( "Writing Scene file to: {0}" , path.u8string());
std::ofstream sceneFile; std::ofstream sceneFile;
sceneFile.open(path.u8string()); sceneFile.open(path.u8string());

View File

@ -31,9 +31,9 @@ public:
location = std::string(path); location = std::string(path);
break; break;
case(NFD_CANCEL): case(NFD_CANCEL):
std::cout << "NFD_CANCEL" << std::endl; spdlog::info("NFD_CANCEL" );
case (NFD_ERROR): case (NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl; spdlog::error("NFD_Error: {0}" , NFD_GetError() );
break; break;
}; };

View File

@ -40,10 +40,10 @@ public:
AssetRegistry assetManager = AssetRegistry(); AssetRegistry assetManager = AssetRegistry();
ModelLoader modelLoader = ModelLoader(); ModelLoader modelLoader = ModelLoader();
std::cout << project.GetProjectDirectory() << std::endl; spdlog::info( "{0}", project.GetProjectDirectory().string());
auto latern = modelLoader.LoadAsset(std::filesystem::path("build/debug/Models/Latern.gltf")); auto latern = modelLoader.LoadAsset(std::filesystem::path("build/debug/Models/Latern.gltf"));
std::cout << "Loaded mesh: " << latern.GetName() << std::endl; spdlog::info( "Loaded mesh: {0}" , latern.GetName() );
//ProjectInfo projectInfo(project); //ProjectInfo projectInfo(project);
//Settings settings = Settings(); //Settings settings = Settings();
@ -61,7 +61,7 @@ public:
if (sceneview.isFocused) { if (sceneview.isFocused) {
UpdateSceneCamera(sceneview); UpdateSceneCamera(sceneview);
std::cout << "Scene view in Focus!\r"; spdlog::info( "Scene view in Focus!\r");
} }
} }
@ -95,12 +95,12 @@ public:
void OnCreate() override { void OnCreate() override {
std::cout << " Layer Create!" << std::endl; spdlog::info(" Layer Create!" );
} }
void OnDestroy() override { void OnDestroy() override {
std::cout << " Layer Destroy!" << std::endl; spdlog::info( " Layer Destroy!" );
} }

View File

@ -25,7 +25,7 @@ void MainMenuBar::ApplicationMenu(Project& project) {
case(NFD_CANCEL): case(NFD_CANCEL):
break; break;
case(NFD_ERROR): case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl; spdlog::error( "NFD_Error: {0}" , NFD_GetError() );
break; break;
} }
@ -35,13 +35,13 @@ void MainMenuBar::ApplicationMenu(Project& project) {
nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path); nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path);
switch (result) { switch (result) {
case(NFD_OKAY): case(NFD_OKAY):
std::cout << "Save as: " << path << std::endl; spdlog::info( "Save as: {0}" , path );
Project::SaveProject(path, project); Project::SaveProject(path, project);
break; break;
case(NFD_CANCEL): case(NFD_CANCEL):
break; break;
case(NFD_ERROR): case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl; spdlog::error( "NFD_Error: {0}" , NFD_GetError() );
break; break;
} }
} }

View File

@ -9,7 +9,7 @@ class Project {
public: public:
Project() = default; Project() = default;
Project(const std::string& name): Name(name){} Project(const std::string& name): Name(name){}
~Project() { std::cout << "Unloading project..." << Name << std::endl; } ~Project() { spdlog::info("Unloading project {0}...", Name);}
void setName(std::string& name) { Name = name; } void setName(std::string& name) { Name = name; }
const std::string& GetName()const { return Name; } const std::string& GetName()const { return Name; }

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

@ -9,7 +9,7 @@ namespace YoggieEngine {
void EngineInstrumentation::PerfomanceSamplerInit() { void EngineInstrumentation::PerfomanceSamplerInit() {
std::cout << "Initialize perf sampler" << std::endl; spdlog::info( "Initialize perf sampler" );
/*EngineInstrumentation::frames = 0; /*EngineInstrumentation::frames = 0;
EngineInstrumentation::lastSampleTime = GetPrecisionTime();*/ EngineInstrumentation::lastSampleTime = GetPrecisionTime();*/
} }

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();