From ebe699196fb0f2ba3930274fdde6bf7fc48db65b Mon Sep 17 00:00:00 2001 From: Conni Bilham Date: Thu, 26 Jan 2023 16:26:10 +0000 Subject: [PATCH] Fix a few bugs with star generation --- includes/Globals.h | 4 ++-- main.cpp | 2 +- windows/window_handler.h | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/includes/Globals.h b/includes/Globals.h index 8d78066..3ef0546 100644 --- a/includes/Globals.h +++ b/includes/Globals.h @@ -10,8 +10,8 @@ #include struct Globals { - bool show_demo_window = true; - bool show_another_window = true; + bool show_demo_window = false; + bool show_another_window = false; std::string* active_log_file = new std::string("initial"); ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); diff --git a/main.cpp b/main.cpp index 6b9ffa8..e161be6 100644 --- a/main.cpp +++ b/main.cpp @@ -65,7 +65,7 @@ int main(int, char**) glfwMakeContextCurrent(window); - glfwSwapInterval(1); // Enable vsync +// glfwSwapInterval(1); // Enable vsync // Setup Dear ImGui context IMGUI_CHECKVERSION(); diff --git a/windows/window_handler.h b/windows/window_handler.h index c7b3713..a29cbae 100644 --- a/windows/window_handler.h +++ b/windows/window_handler.h @@ -22,7 +22,7 @@ int bgStarPos[1000][2]; int bgStarVel[1000][2]; -static float vel_range = 6.65f; +static float vel_range = 50.65f; void InitStars() { std::random_device rd; @@ -31,13 +31,14 @@ void InitStars() { std::uniform_int_distribution<> dis_x(0, ImGui::GetMainViewport()->Size.x); std::uniform_int_distribution<> dis_y(0, ImGui::GetMainViewport()->Size.y); - std::normal_distribution dis_v(-vel_range, vel_range + 50); + std::normal_distribution dis_v(-vel_range / 2, vel_range * 2); for (int i = 0; i < 1000; i++) { - bgStarVel[i][0] = dis_x(gen); - bgStarVel[i][1] = dis_y(gen); +// bgStarVel[i][0] = dis_v(gen); +// bgStarVel[i][1] = dis_v(gen); bgStarPos[i][0] = dis_x(gen); bgStarPos[i][1] = dis_y(gen); + bgStarVel[i][0] = dis_v(gen); bgStarVel[i][1] = dis_v(gen); } @@ -52,7 +53,7 @@ void DrawDots() ImDrawList* draw_list = ImGui::GetBackgroundDrawList(); for (int i = 0; i < 1000; i++) { - std::random_device rd; + static std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> dis_alpha(100, 150); @@ -100,7 +101,7 @@ void init() { printf("Done initializing.\n"); } void new_frame(GLFWwindow* window) { - ImGui::ShowDemoWindow(&globals->show_demo_window); +// ImGui::ShowDemoWindow(&globals->show_demo_window); if(globals->show_another_window) ImGui::ShowStyleEditor();