Small fix up

* Added multiple ImGui windows with better widgets
* Fixed cube rendering wrong
* Added ImGui scripting window ( max 255 character script)
This commit is contained in:
2022-05-13 21:59:19 +02:00
parent 9165e30d0e
commit 4625ca657b
6 changed files with 43 additions and 15 deletions

View File

@ -44,7 +44,7 @@ void Renderable::Draw()
{
VAO.Bind();
elementBuffer.Bind(true);
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_SHORT, NULL);
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL);
VAO.Unbind();
}

View File

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