51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "imgui.h"
|
|
#include "GLFW/glfw3.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(GLFWwindow* window_handle) = 0;
|
|
|
|
virtual void shutdown();
|
|
|
|
virtual void post_shutdown() {
|
|
}
|
|
|
|
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(GLFWwindow* window_handle) = 0;
|
|
|
|
virtual void end_frame(GLFWwindow* 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:
|
|
std::shared_ptr<shader> default_vs_;
|
|
bool vsync_ = true;
|
|
};
|