#pragma once #include #include "imgui.h" #include "slang_handle.h" class shader; class render_target; class texture; constexpr ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); constexpr float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; class renderer { public: virtual ~renderer() = default; virtual void pre_init() {} virtual bool init(SDL_Window* window_handle) = 0; virtual void shutdown() = 0; void init_slang(const std::string& shader_path); virtual Slang::ComPtr create_slang_session(const std::string& shader_path) = 0; virtual Slang::ComPtr get_slang_session() { return session_; } virtual std::shared_ptr load_shader(const std::string& entry_name) = 0; virtual std::shared_ptr get_pixel_shader_render_default_vs(); virtual void new_frame(SDL_Window* window_handle) = 0; virtual void end_frame(SDL_Window* window_handle) = 0; virtual void resize(int width, int height) = 0; virtual std::shared_ptr create_texture(const unsigned char* data, int width, int height) = 0; virtual std::shared_ptr create_render_target(int width, int height, texture_format format) = 0; void set_vsync(const bool vsync) { vsync_ = vsync; } protected: Slang::ComPtr session_; std::shared_ptr default_vs_; bool vsync_ = true; };