43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
#pragma once
|
|
#include <SDL_video.h>
|
|
|
|
#include "imgui.h"
|
|
#include "slang_handle.h"
|
|
|
|
class pixel_shader_drawer;
|
|
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();
|
|
virtual void post_shutdown() {}
|
|
|
|
void init_slang(const std::string& shader_path);
|
|
virtual void create_slang_session(const std::string& shader_path, slang::ISession** out_session) = 0;
|
|
virtual Slang::ComPtr<slang::ISession> get_slang_session() { return session_; }
|
|
virtual std::shared_ptr<shader> load_shader(const std::string& entry_name) = 0;
|
|
virtual std::shared_ptr<shader> get_pixel_shader_render_default_vs();
|
|
virtual std::shared_ptr<pixel_shader_drawer> create_pixel_shader_drawer() = 0;
|
|
|
|
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<texture> create_texture(const unsigned char* data, int width, int height) = 0;
|
|
virtual std::shared_ptr<render_target> create_render_target(int width, int height, texture_format format) = 0;
|
|
|
|
void set_vsync(const bool vsync) { vsync_ = vsync; }
|
|
protected:
|
|
Slang::ComPtr<slang::ISession> session_;
|
|
std::shared_ptr<shader> default_vs_;
|
|
bool vsync_ = true;
|
|
};
|