start shader

This commit is contained in:
2023-11-16 15:58:57 -06:00
parent 04dbead9a2
commit 55f629c7b5
15 changed files with 238 additions and 2 deletions

View File

@ -0,0 +1,10 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
IShaderStage.cpp
)

View File

@ -0,0 +1,58 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
namespace Dawn {
template<struct T>
class IShader {
private:
T data;
public:
/**
* Returns the currently uploaded data on the Shader.
*
* @return The uploaded data.
*/
T getData() {
return data;
}
/**
* Sets the entire data to be uploaded.
*
* @param data Data to be uploaded.
*/
void setData(const T data) {
this->data = data;
}
/**
* Initializes the shader, this needs to be called before the shader can
* be used.
*/
virtual void init() = 0;
/**
* Binds the shader as the current one, does not upload any data, somewhat
* relies on something else uploading the data.
*/
virtual void bind() = 0;
/**
* Uploads the data to the GPU.
*/
virtual void upload() = 0;
/**
* Disposes of the shader.
*/
virtual ~IShader() {
}
};
}

View File

@ -0,0 +1,18 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "IShaderStage.hpp"
using namespace Dawn;
IShaderStage::IShaderStage(const enum ShaderType type) :
type(type)
{
}
IShaderStage::~IShaderStage() {
}

View File

@ -0,0 +1,30 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
namespace Dawn {
enum ShaderType {
VERTEX,
FRAGMENT,
COMPUTE
};
class IShaderStage {
public:
/**
* Constructs a new Shader Stage.
*
* @param type Type of shader stage.
*/
IShaderStage(const enum ShaderType type);
/**
* Destroy the IShaderStage object
*/
virtual ~IShaderStage();
};
}