charcoal/OpenGLEngine/Application.h

54 lines
999 B
C
Raw Normal View History

2018-09-04 19:25:54 +00:00
#pragma once
#include "stdafx.h"
2018-09-04 19:25:54 +00:00
#include <glm/glm.hpp>
2018-09-04 19:25:54 +00:00
#include "GLFWInputManager.h"
2018-09-04 19:25:54 +00:00
#include "FPS.h"
// TODO: Close without rendering next frame.
2018-09-12 21:03:46 +00:00
namespace charcoal
2018-09-04 19:25:54 +00:00
{
2018-09-12 21:03:46 +00:00
using namespace glm;
class Application
{
public:
Application(int width = -1, int height = -1);
virtual ~Application() {}
2018-09-04 19:25:54 +00:00
2018-09-12 21:03:46 +00:00
int run();
2018-09-05 06:49:02 +00:00
2018-09-12 21:03:46 +00:00
const ivec2& get_screen_size() const { return m_screen_size; }
2018-09-12 21:03:46 +00:00
const GLFWInputManager& get_input_manager() const { return m_glfw_input_manager; }
2018-09-12 21:03:46 +00:00
const FPS& get_fps() const { return m_fps; }
2018-09-12 21:03:46 +00:00
protected:
// Called on initialization of the application (called by base_init)
virtual void init() = 0;
2018-09-04 19:25:54 +00:00
2018-09-12 21:03:46 +00:00
virtual void update(float delta_time, clock_t clock) = 0;
2018-09-12 21:03:46 +00:00
virtual void prerender() = 0;
2018-09-04 19:25:54 +00:00
2018-09-12 21:03:46 +00:00
virtual void render() = 0;
2018-09-04 19:25:54 +00:00
2018-09-12 21:03:46 +00:00
// Called on closing of the application (called before base_close)
virtual void close() {}
2018-09-04 19:25:54 +00:00
2018-09-12 21:03:46 +00:00
GLFWwindow* m_p_window;
2018-09-12 21:03:46 +00:00
const ivec2 m_screen_size;
2018-09-12 21:03:46 +00:00
GLFWInputManager m_glfw_input_manager;
2018-09-04 19:25:54 +00:00
2018-09-12 21:03:46 +00:00
FPS m_fps;
private:
void base_close();
};
}