First render.

This commit is contained in:
2023-11-17 00:02:04 -06:00
parent 55f629c7b5
commit 490da9d0c1
43 changed files with 1039 additions and 67 deletions

View File

@ -7,9 +7,29 @@
#include "dawnlibs.hpp"
namespace Dawn {
template<struct T>
class IShader {
private:
enum ShaderParameterType {
VEC2,
VEC3,
VEC4,
MAT3,
MAT4,
COLOR,
FLOAT,
INT,
TEXTURE,
BOOLEAN
};
class IShaderBase {
public:
virtual ~IShaderBase() {
}
};
template<typename T>
class IShader : public IShaderBase {
protected:
T data;
public:

View File

@ -7,7 +7,7 @@
using namespace Dawn;
IShaderStage::IShaderStage(const enum ShaderType type) :
IShaderStage::IShaderStage(const enum ShaderStageType type) :
type(type)
{

View File

@ -7,20 +7,22 @@
#include "dawnlibs.hpp"
namespace Dawn {
enum ShaderType {
enum ShaderStageType {
VERTEX,
FRAGMENT,
COMPUTE
// COMPUTE
};
class IShaderStage {
public:
const enum ShaderStageType type;
/**
* Constructs a new Shader Stage.
*
* @param type Type of shader stage.
*/
IShaderStage(const enum ShaderType type);
IShaderStage(const enum ShaderStageType type);
/**
* Destroy the IShaderStage object

View File

@ -0,0 +1,45 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "display/shader/Shader.hpp"
namespace Dawn {
class ShaderManager {
private:
std::vector<std::shared_ptr<IShaderBase>> shaders;
public:
/**
* Retreives an instance of the shader from the shader manager. If the
* shader does not exist it will be created.
*
* @tparam T Type of shader to retreive.
* @return Shader instance.
*/
template<class T>
std::shared_ptr<T> getShader() {
auto itShaders = shaders.begin();
while(itShaders != shaders.end()) {
// auto shader = itShaders->lock();
// if(!shader) {
// itShaders = shaders.erase(itShaders);
// continue;
// }
// std::shared_ptr<T> casted = std::dynamic_pointer_cast<T>(shader);
auto shader = *itShaders;
std::shared_ptr<T> casted = std::dynamic_pointer_cast<T>(shader);
if(casted) return casted;
itShaders++;
}
auto newShader = std::make_shared<T>();
shaders.push_back(newShader);
newShader->init();
return newShader;
}
};
}