//вынести отрисвоку в одельный класс #include "m_time.h" #include "ComponentForModulation.h" bool f = true; // Function prototypes void APIENTRY glDebugOutput(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); void updatesin(GLfloat x, std::vector<GLfloat>& coord); // Window dimensions const GLuint WIDTH = 1920, HEIGHT = 1080; // The MAIN function, from here we start the application and run the game loop int main() { /* *** Инициализация спутника для моделирования *** */ //инициализаиця входных параметров Kepler_elements_orbit element{ 26559.81038, 0.01203, 56.6024, 106.997, 53.2777, 154.03184 }; //кеплеровские элементы орбиты satellite_parameters param{ 1,3,1.5 }; //физические парметры спутника orbit_date start_time{ 2022, 7, 19, 18,20, 0 }; //время начала моделирования orbit_date end_time{ 2022, 8, 21, 20, 20, 0 }; //время окончания моделирования double input_step = 1; // шаг моделирования в секундах Ot _mtime{}; //перевод времени в формат модифицированных юлианских дней double step = input_step/86400; double start_MJD = _mtime.convert_GDs_to_MJD(start_time); double end_MJD = _mtime.convert_GDs_to_MJD(end_time); double current_time = start_MJD + step; //создание планет Earth _earth{}; Moon _moon{ start_MJD }; Sun _sun{ start_MJD }; Satellite satellite{ start_MJD, param, element, &_moon, &_sun, &_earth }; _earth = Earth{ start_MJD, satellite.getDCS() }; std::vector<GLfloat> modeling_DCS{}; //Массив хранящий вычесленные координаты в формате вершин std::vector<GLfloat> modeling_DVS{}; //Массив хранящий вычесленные компоненты скорости в формате вершин /*modulation(satellite, current_time, end_MJD, modeling_DCS, modeling_DVS); current_time += step;*/ GLfloat max_DCS = 1; //максимальное по модулю значение координаты, необходим для масштабирования /* *** инициализация opengl *** */ std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl; // Init GLFW glfwInit(); // Set all the required options for GLFW glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); // Create a GLFWwindow object that we can use for GLFW's functions GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr); if (window == nullptr) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); // Set the required callback functions glfwSetKeyCallback(window, key_callback); GLint flags; // Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions glewExperimental = GL_TRUE; // Initialize GLEW to setup the OpenGL Function pointers if (glewInit() != GLEW_OK) { std::cout << "Failed to initialize GLEW" << std::endl; return -1; } glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); // Define the viewport dimensions int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); /* *** Инициализаицая необоходимых пременных для отображения графики *** */ Shader myShaders{ "./shaders/shader.vert", "./shaders/shader.frag" }; std::vector<GLfloat> coord_vertices{}; GLuint VAO_for_coord; glGenBuffers(1, &VAO_for_coord); glGetIntegerv(GL_CONTEXT_FLAGS, &flags); if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) { std::cout << "Success"; glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback(glDebugOutput, nullptr); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); } else { "filed"; } GLuint i = 0; GLfloat x = -0.98f; // Game loop while (!glfwWindowShouldClose(window)) { // Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions glEnable(GL_DEPTH_TEST); glfwPollEvents(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); draw_coord_axis(); // Render // Clear the colorbuffer myShaders.Use(); modulation(satellite, current_time, end_MJD, modeling_DCS, modeling_DVS); //scaling(modeling_DCS, max_DCS); draw_modulation(modeling_DCS, modeling_DVS, max_DCS, myShaders); // Swap the screen buffers glfwSwapBuffers(window); std::cout << "Start ********"; current_time = (current_time <= end_MJD)?current_time+step: current_time; for (int i = 0; i < modeling_DCS.size(); i= i+6) std::cout << "\nnumber = " << i / 6 << " 0 = " << modeling_DCS.at(i) << " 1 = " << modeling_DCS.at(i+1) << " 2 = " << modeling_DCS.at(i + 2) << " 3 = " << modeling_DCS.at(i + 3) << " 4 = " << modeling_DCS.at(i + 4) << " 5 = " << modeling_DCS.at(i + 5) << std::endl; } // Terminate GLFW, clearing any resources allocated by GLFW. glfwTerminate(); return 0; } void APIENTRY glDebugOutput(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { // ignore non-significant error/warning codes if (id == 131169 || id == 131185 || id == 131218 || id == 131204) return; std::cout << "---------------" << std::endl; std::cout << "Debug message (" << id << "): " << message << std::endl; switch (source) { case GL_DEBUG_SOURCE_API: std::cout << "Source: API"; break; case GL_DEBUG_SOURCE_WINDOW_SYSTEM: std::cout << "Source: Window System"; break; case GL_DEBUG_SOURCE_SHADER_COMPILER: std::cout << "Source: Shader Compiler"; break; case GL_DEBUG_SOURCE_THIRD_PARTY: std::cout << "Source: Third Party"; break; case GL_DEBUG_SOURCE_APPLICATION: std::cout << "Source: Application"; break; case GL_DEBUG_SOURCE_OTHER: std::cout << "Source: Other"; break; } std::cout << std::endl; switch (type) { case GL_DEBUG_TYPE_ERROR: std::cout << "Type: Error"; break; case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: std::cout << "Type: Deprecated Behaviour"; break; case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: std::cout << "Type: Undefined Behaviour"; break; case GL_DEBUG_TYPE_PORTABILITY: std::cout << "Type: Portability"; break; case GL_DEBUG_TYPE_PERFORMANCE: std::cout << "Type: Performance"; break; case GL_DEBUG_TYPE_MARKER: std::cout << "Type: Marker"; break; case GL_DEBUG_TYPE_PUSH_GROUP: std::cout << "Type: Push Group"; break; case GL_DEBUG_TYPE_POP_GROUP: std::cout << "Type: Pop Group"; break; case GL_DEBUG_TYPE_OTHER: std::cout << "Type: Other"; break; } std::cout << std::endl; switch (severity) { case GL_DEBUG_SEVERITY_HIGH: std::cout << "Severity: high"; break; case GL_DEBUG_SEVERITY_MEDIUM: std::cout << "Severity: medium"; break; case GL_DEBUG_SEVERITY_LOW: std::cout << "Severity: low"; break; case GL_DEBUG_SEVERITY_NOTIFICATION: std::cout << "Severity: notification"; break; } std::cout << std::endl; std::cout << std::endl; }