2022-10-03 18:51:34 +05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../device.hpp"
|
|
|
|
|
2022-11-18 21:50:49 +05:00
|
|
|
#include <functional>
|
|
|
|
|
2022-10-03 18:51:34 +05:00
|
|
|
|
|
|
|
namespace hpr::gpu::opengl
|
|
|
|
{
|
|
|
|
|
|
|
|
class Device : public gpu::Device
|
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
bool p_isInitialized;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
|
|
|
|
Device();
|
|
|
|
|
2022-10-27 22:27:50 +05:00
|
|
|
~Device() override;
|
2022-10-03 18:51:34 +05:00
|
|
|
|
|
|
|
|
2022-10-05 21:10:51 +05:00
|
|
|
// Member functions
|
|
|
|
|
|
|
|
// Setup
|
|
|
|
|
|
|
|
bool initialize() override;
|
|
|
|
bool destroy() override;
|
|
|
|
|
2022-11-18 21:50:49 +05:00
|
|
|
static
|
|
|
|
bool loadLoader();
|
|
|
|
|
2022-10-05 21:10:51 +05:00
|
|
|
// State
|
|
|
|
|
2022-11-18 21:50:49 +05:00
|
|
|
void faceCulling(bool enableFaceCulling, CullMode faceCullingMode) override;
|
|
|
|
|
|
|
|
// Render targets
|
|
|
|
|
|
|
|
virtual
|
|
|
|
void createScreenRenderTarget(RenderTarget** target);
|
2022-10-05 21:10:51 +05:00
|
|
|
|
|
|
|
// Buffers
|
|
|
|
|
|
|
|
void createVertexBuffer(Buffer **buffer, int size, char* data) override;
|
|
|
|
void createIndexBuffer(Buffer **buffer, int size, char* data) override;
|
2022-11-18 21:50:49 +05:00
|
|
|
void createUniformBuffer(Buffer **buffer, int size, char* data) override;
|
2022-10-05 21:10:51 +05:00
|
|
|
void useVertexBuffer(Buffer* buffer, int stride, int offset) override;
|
|
|
|
void useIndexBuffer(Buffer* buffer, int offset) override;
|
2022-11-18 21:50:49 +05:00
|
|
|
void useUniformBuffer(Buffer* buffer, int slot) override;
|
|
|
|
void editBuffer(Buffer* buffer, char* data, int size, int offset) override;
|
|
|
|
void editBuffer(Buffer* buffer, char* data) override;
|
2022-10-05 21:10:51 +05:00
|
|
|
void destroyBuffer(Buffer*& buffer) override;
|
|
|
|
|
|
|
|
// Shaders
|
|
|
|
|
|
|
|
void createVertexShader(Shader** shader, const std::string& filename, const std::string& label) override;
|
|
|
|
void createFragmentShader(Shader** shader, const std::string& filename, const std::string& label) override;
|
|
|
|
void createGeometryShader(Shader** shader, const std::string& filename, const std::string& label) override;
|
2022-11-18 21:50:49 +05:00
|
|
|
void destroyShader(Shader* shader) override;
|
2022-10-05 21:10:51 +05:00
|
|
|
|
|
|
|
// Shader programs
|
|
|
|
|
2022-11-18 21:50:49 +05:00
|
|
|
void createShaderProgram(ShaderProgram** program) override;
|
|
|
|
void attachShader(ShaderProgram* program, Shader* shader) override;
|
|
|
|
void linkProgram(ShaderProgram* program) override;
|
|
|
|
void useShaderProgram(ShaderProgram* program) override;
|
|
|
|
void destroyShaderProgram(ShaderProgram*& program, bool withShaders) override;
|
2022-10-05 21:10:51 +05:00
|
|
|
|
|
|
|
// Textures
|
|
|
|
|
2022-11-18 21:50:49 +05:00
|
|
|
void createTexture(Texture** texture, const std::string& filename) override;
|
|
|
|
void useTexture(Texture* texture, int slot) override;
|
|
|
|
void destroyTexture(Texture*& texture) override;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
void Draw(int numFaces, int indexOffset, int vertexOffset);
|
2022-10-03 18:51:34 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|