41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <glad/glad.h>
|
|
|
|
#include "rendering/shader_backend.hpp"
|
|
|
|
namespace Rendering {
|
|
|
|
class OpenGLShaderBackend final : public IShaderBackend {
|
|
public:
|
|
OpenGLShaderBackend() = default;
|
|
~OpenGLShaderBackend() override;
|
|
|
|
auto init(SDL_Window* window) -> bool override;
|
|
auto loadShader(const ShaderProgramSpec& spec) -> bool override;
|
|
void render(const ShaderUniforms& uniforms) override;
|
|
void setVSync(bool vsync) override;
|
|
void cleanup() override;
|
|
[[nodiscard]] auto driverName() const -> std::string override { return "OpenGL"; }
|
|
|
|
private:
|
|
auto createFeedbackFBO(int width, int height) -> bool;
|
|
void destroyFeedbackFBO();
|
|
|
|
SDL_Window* window_{nullptr};
|
|
SDL_GLContext gl_context_{nullptr};
|
|
|
|
GLuint vao_{0};
|
|
GLuint vbo_{0};
|
|
GLuint current_program_{0};
|
|
|
|
GLuint feedback_fbo_{0};
|
|
GLuint feedback_texture_{0};
|
|
bool current_shader_uses_feedback_{false};
|
|
int feedback_channel_{-1};
|
|
int feedback_width_{0};
|
|
int feedback_height_{0};
|
|
};
|
|
|
|
} // namespace Rendering
|