From 4625ca657bf678693c81b609170e3eb9ba15eb0f Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Fri, 13 May 2022 21:59:19 +0200 Subject: [PATCH] Small fix up * Added multiple ImGui windows with better widgets * Fixed cube rendering wrong * Added ImGui scripting window ( max 255 character script) --- .gitattributes | 1 + MyGraphicsEngine/ModelImporter.cpp | 2 ++ README.md | 4 +-- SandboxApplication/Renderable.cpp | 2 +- SandboxApplication/Sandbox.cpp | 46 ++++++++++++++++++++++-------- Screenshots/screen1.png | 3 ++ 6 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 .gitattributes create mode 100644 Screenshots/screen1.png diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..e86aa3a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.png filter=lfs diff=lfs merge=lfs -text diff --git a/MyGraphicsEngine/ModelImporter.cpp b/MyGraphicsEngine/ModelImporter.cpp index cce44a3..288318c 100644 --- a/MyGraphicsEngine/ModelImporter.cpp +++ b/MyGraphicsEngine/ModelImporter.cpp @@ -94,6 +94,8 @@ BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene vertices.push_back(vector); } + spdlog::info("{} == {}", mesh->mNumVertices, vertices.size()); + // Process Indices for (unsigned int i = 0; i < mesh->mNumFaces; i++) { aiFace face = mesh->mFaces[i]; diff --git a/README.md b/README.md index fd0eff7..7e591e5 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ - others ?!?!? ## Screenshots -__added soon__ - + + ## Planning see [TODO](docs/TODO.md) diff --git a/SandboxApplication/Renderable.cpp b/SandboxApplication/Renderable.cpp index 4567016..15d144c 100644 --- a/SandboxApplication/Renderable.cpp +++ b/SandboxApplication/Renderable.cpp @@ -44,7 +44,7 @@ void Renderable::Draw() { VAO.Bind(); elementBuffer.Bind(true); - glDrawElements(GL_TRIANGLES, static_cast(meshes[0].elements.size()), GL_UNSIGNED_SHORT, NULL); + glDrawElements(GL_TRIANGLES, static_cast(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL); VAO.Unbind(); } diff --git a/SandboxApplication/Sandbox.cpp b/SandboxApplication/Sandbox.cpp index 7787248..3a51e1a 100644 --- a/SandboxApplication/Sandbox.cpp +++ b/SandboxApplication/Sandbox.cpp @@ -29,6 +29,7 @@ extern "C" int main(int argc, char* argv[]) { char cwd[256]; + memset(cwd, '\0', 256); getcwd(cwd, 256); spdlog::info("Working directory: {}", cwd); @@ -76,9 +77,18 @@ int main(int argc, char* argv[]) { mixer = gau_manager_mixer(mgr); */ - + char* lua_code = new char[255]; + memset(lua_code, '\0', 255); + + bool runCode = false; + while (!GameWindow.WindowShouldClose()) { + if (runCode == true) { + luaL_dostring(L,lua_code); + runCode = false; + } + glm::mat4 tran = glm::translate(glm::mat4(), Cube.transform.Position); glm::mat4 scale = glm::scale(glm::mat4(), Cube.transform.Scale); glm::mat4 rot = @@ -89,7 +99,7 @@ int main(int argc, char* argv[]) { glm::mat4 model = tran * rot * scale; - glm::mat4 projection = glm::perspective(cam.Zoom, (800.0f / 600.0f), 0.001f, 100.0f); + glm::mat4 projection = glm::perspective(glm::radians(cam.Zoom), (800.0f / 600.0f), 0.001f, 100.0f); GameWindow.Poll(); @@ -107,19 +117,31 @@ int main(int argc, char* argv[]) { ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); - ImGui::Begin("Test"); - - ImGui::SliderFloat("Scale Y:", (float*)&Cube.transform.Scale.y, 1, 4); - ImGui::SliderFloat("Scale X:", (float*)&Cube.transform.Scale.x, 1, 4); - - ImGui::SliderFloat("Camera Zoom:", &cam.Zoom, 40, 190); - ImGui::SliderFloat("Position X:", (float*)&Cube.transform.Position.x, -9, -60); - - ImGui::SliderFloat("Rotate Y:", (float*)&Cube.transform.Rotation.y, 0, 180); - ImGui::SliderFloat("Rotate Z:", (float*)&Cube.transform.Rotation.z, 0, 180); + ImGui::Begin("Transform"); + ImGui::Text("Cube"); + ImGui::InputFloat3("Position:", (float*)&Cube.transform.Position); + ImGui::InputFloat3("Rotation:", (float*)&Cube.transform.Rotation); + ImGui::InputFloat3("Scale:", (float*)&Cube.transform.Scale); ImGui::End(); + ImGui::Begin("Camera"); + + ImGui::SliderFloat("Zoom:", &cam.Zoom, 10, 190); + + ImGui::End(); + + + ImGui::Begin("Scripting!!"); + + ImGui::InputTextMultiline("Lua Script", lua_code, 255); + runCode = ImGui::Button("Run"); + + + ImGui::End(); + + + ImGui::ShowDemoWindow(); ImGui::Render(); diff --git a/Screenshots/screen1.png b/Screenshots/screen1.png new file mode 100644 index 0000000..bdaaabf --- /dev/null +++ b/Screenshots/screen1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef5742398e9c1fe43b159f959fbc3c051d4b8e18bc73953ebd1057aafdf8e90a +size 299642