#include #include #include "rms.hpp" APP_CONTEXT *AppContext=nullptr; void OnWindowResize(GLFWwindow* window, int width, int height){ AppContext->renderer.AjustViewport(width,height); } int main(int argc, char *argv[]) { GLFWwindow* window; /* Initialize the library */ if (!glfwInit()) return -1; /* Create a windowed mode window and its OpenGL context */ window = glfwCreateWindow(WIDTH, HEIGHT, "SFML/OpenGL Ray Marching", NULL, NULL); if (!window) { glfwTerminate(); return -1; } /* Make the window's context current */ glfwMakeContextCurrent(window); // Init Renderer/OpenGL APP_CONTEXT InitContext={ Renderer(WIDTH,HEIGHT,"main.glsl"), HUD(window) }; AppContext=&InitContext; InitContext.renderer.RefreshShader(); glfwSetWindowSizeCallback(window, OnWindowResize); /* Loop until the user closes the window */ double InitTime = glfwGetTime(); double LastTime = InitTime; while (!glfwWindowShouldClose(window)) { double CurrentTime = glfwGetTime(); AppContext->hud.m_Context->time=CurrentTime-InitTime; /* Render here */ glClear(GL_COLOR_BUFFER_BIT); if(CurrentTime-LastTime >= 1){ AppContext->hud.m_Context->fps=AppContext->hud.m_Context->fps_frame_counter; AppContext->hud.m_Context->fps_frame_counter=0; LastTime=CurrentTime; } AppContext->renderer.Render(); AppContext->hud.Render(); /* Swap front and back buffers */ glfwSwapBuffers(window); /* Poll for and process events */ glfwPollEvents(); AppContext->hud.m_Context->fps_frame_counter++; } glfwTerminate(); return 0; }