7#include "hellfire/ecs/Entity.h"
8#include "hellfire/ecs/LightComponent.h"
9#include "hellfire/ecs/RenderableComponent.h"
10#include "hellfire/graphics/backends/opengl/Framebuffer.h"
11#include "hellfire/graphics/renderer/SkyboxRenderer.h"
12#include "hellfire/graphics/shader/ShaderRegistry.h"
20 using EntityID = uint32_t;
162 const glm::mat4 &projection);
std::vector< std::unique_ptr< IApplicationPlugin > > plugins_
std::function< bool()> exit_condition_
AppInfo & get_window_info()
void on_mouse_move(float x, float y) override
void set_exit_condition(std::function< bool()> condition)
ShaderManager shader_manager_
std::unique_ptr< IWindow > window_
ShaderRegistry shader_registry_
bool call_plugins_until_consumed(Func &&func)
void on_render() override
std::unique_ptr< InputManager > input_manager_
Application(int width=800, int height=600, std::string title="hellfire Application")
void handle_cursor_warping(float x, float y) const
bool handle_first_mouse_movement(float x, float y)
void on_key_up(int key) override
void on_key_down(int key) override
void on_window_minimize(bool minimized) override
void register_plugin(std::unique_ptr< IApplicationPlugin > plugin)
Method for registering plugins.
Shader * ensure_fallback_shader()
void on_mouse_button(int button, bool pressed) override
void call_plugins(Func &&func)
uint32_t create_minimal_fallback_shader()
void on_window_resize(int width, int height) override
virtual bool on_mouse_move(float x, float y, float x_offset, float y_offset)
virtual bool on_mouse_button(int button, bool pressed)
virtual void on_end_frame()
virtual bool on_key_down(int key)
virtual void on_begin_frame()
virtual Entity * get_render_camera_override()
virtual void on_initialize(Application &app)
virtual void on_window_resize(int width, int height)
virtual void on_key_up(int keycode)
virtual void on_mouse_move(float x, float y)
virtual void on_window_resize(int width, int height)
virtual ~IWindowEventHandler()=default
virtual void on_key_down(int keycode)
virtual void on_window_minimize(bool minimized)
virtual void on_mouse_button(int button, bool pressed)
virtual void on_mouse_wheel(float delta)
virtual void set_event_handler(IWindowEventHandler *event_handler)=0
virtual bool is_key_pressed(int keycode) const =0
virtual bool should_close() const =0
virtual glm::vec2 get_mouse_position() const =0
virtual ~IWindow()=default
virtual void set_size(int width, int height)=0
virtual void poll_events()=0
virtual glm::ivec2 get_framebuffer_size() const =0
virtual void set_title(const std::string &title)=0
virtual void swap_buffers()=0
virtual void enable_vsync(bool vsync)=0
virtual glm::ivec2 get_size() const =0
virtual void * get_native_handle()=0
virtual void warp_cursor(double x, double y)=0
virtual void set_cursor_mode(CursorMode mode)=0
virtual bool create(int width, int height, const std::string &title)=0
virtual float get_elapsed_time()=0
virtual void wait_for_events()=0
virtual void make_current()=0
void draw_render_command(const RenderCommand &cmd, const glm::mat4 &view, const glm::mat4 &projection)
ShaderRegistry & get_shader_registry()
void ensure_shadow_map(Entity *light_entity, const LightComponent &light)
Shader & get_shader_for_material(const std::shared_ptr< Material > &material)
SkyboxRenderer skybox_renderer_
ShaderRegistry shader_registry_
void set_render_to_framebuffer(bool enable)
ShadowSettings shadow_settings_
std::vector< InstancedRenderCommand > opaque_instanced_objects_
bool render_to_framebuffer_
void execute_skybox_pass(Scene *scene, const glm::mat4 &view, const glm::mat4 &projection, CameraComponent *camera_comp) const
uint32_t get_object_id_texture() const
glm::mat4 calculate_light_view_proj(Entity *light_entity, LightComponent *light, const CameraComponent &camera)
std::shared_ptr< Material > shadow_material_
void draw_instanced_command(const InstancedRenderCommand &cmd, const glm::mat4 &view, const glm::mat4 &projection)
void render(Scene &scene, const Entity *camera_override)
void collect_geometry_from_scene(Scene &scene, const glm::vec3 camera_pos)
void execute_shadow_passes(Scene &scene, CameraComponent &camera)
std::unique_ptr< Framebuffer > scene_framebuffers_[2]
Shader * fallback_shader_
uint32_t fallback_program_
std::vector< RenderCommand > opaque_objects_
uint32_t get_main_output_texture() const
void resize_main_framebuffer(uint32_t width, uint32_t height)
ShaderManager shader_manager_
void execute_transparency_pass(const glm::mat4 &view, const glm::mat4 &proj)
void reset_framebuffer_data()
void execute_main_pass(Scene &scene, CameraComponent &camera)
ShadowSettings & get_shadow_settings()
uint32_t framebuffer_width_
void render_frame(Scene &scene, CameraComponent &camera)
void execute_geometry_pass(const glm::mat4 &view, const glm::mat4 &proj)
void collect_lights_from_scene(Scene &scene, CameraComponent &camera)
void store_lights_in_context(const std::vector< Entity * > &light_entities, CameraComponent &camera)
uint32_t framebuffer_height_
std::vector< RenderCommand > transparent_objects_
void draw_shadow_geometry(const glm::mat4 &light_view_proj)
std::unordered_map< Entity *, ShadowMapData > shadow_maps_
void set_fallback_shader(Shader &fallback_shader)
std::unique_ptr< OGLRendererContext > context_
void collect_render_commands_recursive(EntityID entity_id, const glm::vec3 &camera_pos)
std::vector< InstancedRenderCommand > transparent_instanced_objects_
void create_main_framebuffer(uint32_t width, uint32_t height)
Shader * get_fallback_shader() const
uint32_t compile_material_shader(std::shared_ptr< Material > material)
ShaderManager & get_shader_manager()
bool has_active_scene() const
void destroy_scene(Scene *scene)
CameraComponent * get_active_camera() const
void save_current_scene()
bool save_scene(Scene *scene)
Scene * create_scene(const std::string &name="GameScene")
Scene * load_scene(const std::filesystem::path &filename)
void create_default_scene()
std::optional< AssetID > get_scene_asset_id(Scene *scene) const
void set_active_camera(EntityID camera) const
void set_scene_asset_id(Scene *scene, AssetID id)
std::optional< AssetID > get_active_scene_asset_id() const
SceneActivatedCallback scene_activated_callback_
Scene * get_active_scene() const
void set_active_scene(Scene *scene, bool should_play=true)
bool save_scene_as(const std::string &filename, Scene *scene)
std::vector< Scene * > scenes_
std::vector< Scene * > get_scenes()
std::unordered_map< Scene *, AssetID > scene_asset_ids_
EntityID find_entity_by_name(const std::string &name)
std::vector< EntityID > get_camera_entities() const
Scene * load_scene(AssetID asset_id, const std::filesystem::path &filename)
void set_scene_activated_callback(SceneActivatedCallback callback)
void update(float delta_time)
Manages a collection of entities and their hierarchical relationships.
bool operator<(const RenderCommand &other) const
InstancedRenderableComponent * instanced_renderable
std::shared_ptr< Material > material
std::shared_ptr< Material > material
std::shared_ptr< Mesh > mesh
bool operator<(const RenderCommand &other) const
std::unique_ptr< Framebuffer > framebuffer
glm::mat4 light_view_proj