gpu base started

This commit is contained in:
L-Nafaryus 2022-09-24 16:07:46 +05:00
parent 45636e5662
commit 1d51b3bed9
6 changed files with 186 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#include "context.hpp"
namespace hpr::gpu
{
Context::Context() :
p_api {DeviceAPI::Unknown}
{}
Context::Context(DeviceAPI api) :
p_api {api}
{}
Context::~Context()
{}
bool Context::checkCompability(const Context* ctx) const
{
return (ctx != nullptr) ? ctx->p_api == p_api : true;
}
}

View File

@ -0,0 +1,38 @@
#pragma once
namespace hpr::gpu
{
class Context
{
public:
enum class DeviceAPI
{
Unknown,
OpenGL,
DeviceAPICount
};
private:
DeviceAPI p_api;
public:
// Constructors
Context();
Context(DeviceAPI api);
virtual ~Context();
// Member functions
bool checkCompability(const Context* ctx) const;
};
}

View File

@ -0,0 +1,23 @@
#include "shader.hpp"
namespace hpr::gpu
{
Shader::Shader() :
Context {DeviceAPI::Unknown},
p_filename {},
p_label {}
{}
Shader::Shader(DeviceAPI api) :
Context {api},
p_filename {},
p_label {}
{}
Shader::~Shader()
{}
}

View File

@ -0,0 +1,45 @@
#pragma once
#include "context.hpp"
#include <string>
namespace hpr::gpu
{
class Shader : public Context
{
protected:
std::string p_filename;
std::string p_label;
public:
enum class ShaderType
{
Vertex,
Geometry,
Fragment,
ShaderTypeCount
};
// Constructors
Shader();
Shader(DeviceAPI api);
virtual ~Shader();
// Member functions
const std::string filename() const;
const std::string label() const;
const ShaderType shaderType() const;
};
} // end namespace hpr::gpu

View File

@ -0,0 +1,21 @@
#include "shader_program.hpp"
namespace hpr::gpu
{
ShaderProgram::ShaderProgram() :
Context {DeviceAPI::Unknown},
p_isLinked {false}
{}
ShaderProgram::ShaderProgram(DeviceAPI api) :
Context {api},
p_isLinked {false}
{}
ShaderProgram::~ShaderProgram()
{}
}

View File

@ -0,0 +1,35 @@
#pragma once
#include "context.hpp"
#include "shader.hpp"
#include <array>
namespace hpr::gpu
{
class ShaderProgram : Context
{
protected:
std::array<Shader*, (size_t)Shader::ShaderType::ShaderTypeCount> p_slots;
bool p_isLinked;
public:
// Constructors
ShaderProgram();
ShaderProgram(DeviceAPI api);
virtual ~ShaderProgram();
// Member functions
const Shader* getShader(Shader::ShaderType type) const;
};
}