78 lines
1.4 KiB
C++
78 lines
1.4 KiB
C++
// 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 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:
|
|
/**
|
|
* 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() {
|
|
|
|
}
|
|
};
|
|
} |