start shader
This commit is contained in:
@ -6,5 +6,6 @@
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
Camera.cpp
|
||||
Material.cpp
|
||||
MeshRenderer.cpp
|
||||
)
|
16
src/dawn/component/display/Material.cpp
Normal file
16
src/dawn/component/display/Material.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Material.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void Material::onInit() {
|
||||
|
||||
}
|
||||
|
||||
void Material::onDispose() {
|
||||
|
||||
}
|
15
src/dawn/component/display/Material.hpp
Normal file
15
src/dawn/component/display/Material.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneComponent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Material : public SceneComponent {
|
||||
public:
|
||||
void onInit() override;
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -12,4 +12,4 @@ target_sources(${DAWN_TARGET_NAME}
|
||||
# Subdirs
|
||||
# add_subdirectory(font)
|
||||
add_subdirectory(mesh)
|
||||
# add_subdirectory(shader)
|
||||
add_subdirectory(shader)
|
10
src/dawn/display/shader/CMakeLists.txt
Normal file
10
src/dawn/display/shader/CMakeLists.txt
Normal 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
|
||||
)
|
58
src/dawn/display/shader/IShader.hpp
Normal file
58
src/dawn/display/shader/IShader.hpp
Normal 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() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
18
src/dawn/display/shader/IShaderStage.cpp
Normal file
18
src/dawn/display/shader/IShaderStage.cpp
Normal 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() {
|
||||
|
||||
}
|
30
src/dawn/display/shader/IShaderStage.hpp
Normal file
30
src/dawn/display/shader/IShaderStage.hpp
Normal 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();
|
||||
};
|
||||
}
|
@ -15,6 +15,7 @@ void Dawn::helloWorldScene(Scene &s) {
|
||||
|
||||
auto cameraItem = s.createSceneItem();
|
||||
auto camera = cameraItem->addComponent<Camera>();
|
||||
cameraItem->lookAt({ 3, 3, 3}, { 0, 0, 0 }, { 0, 1, 0 });
|
||||
|
||||
auto cubeMesh = std::make_shared<Mesh>();
|
||||
CubeMesh::buffer(cubeMesh, glm::vec3(-1, -1, -1), glm::vec3(1, 1, 1), 0, 0);
|
||||
|
@ -10,4 +10,5 @@ target_sources(${DAWN_TARGET_NAME}
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(mesh)
|
||||
add_subdirectory(mesh)
|
||||
add_subdirectory(shader)
|
11
src/dawnopengl/display/shader/CMakeLists.txt
Normal file
11
src/dawnopengl/display/shader/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# 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
|
||||
Shader.cpp
|
||||
ShaderStage.cpp
|
||||
)
|
6
src/dawnopengl/display/shader/Shader.cpp
Normal file
6
src/dawnopengl/display/shader/Shader.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Shader.hpp"
|
16
src/dawnopengl/display/shader/Shader.hpp
Normal file
16
src/dawnopengl/display/shader/Shader.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "display/ShaderStage.hpp"
|
||||
#include "display/IShader.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
template<struct T>
|
||||
class Shader : public IShader<T> {
|
||||
public:
|
||||
|
||||
};
|
||||
}
|
17
src/dawnopengl/display/shader/ShaderStage.cpp
Normal file
17
src/dawnopengl/display/shader/ShaderStage.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "ShaderStage.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
ShaderStage::ShaderStage(const enum ShaderType type) : type(type) {
|
||||
}
|
||||
|
||||
void ShaderStage::compile(const std::string source) {
|
||||
}
|
||||
|
||||
ShaderStage::~ShaderStage() {
|
||||
}
|
36
src/dawnopengl/display/shader/ShaderStage.hpp
Normal file
36
src/dawnopengl/display/shader/ShaderStage.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "dawnopengl.hpp"
|
||||
#include "dawnlibs.hpp"
|
||||
#include "display/shader/IShaderStage.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class ShaderStage {
|
||||
public:
|
||||
GLuint id = -1;
|
||||
const enum ShaderType type;
|
||||
|
||||
/**
|
||||
* Constructs a new ShaderStage.
|
||||
*
|
||||
* @param type The type of shader this is.
|
||||
*/
|
||||
ShaderStage(const enum ShaderType type);
|
||||
|
||||
/**
|
||||
* Compiles the shader stage.
|
||||
*
|
||||
* @param source The source code to compile.
|
||||
*/
|
||||
void compile(const std::string source);
|
||||
|
||||
/**
|
||||
* Disposes of the shader stage.
|
||||
*/
|
||||
virtual ~ShaderStage();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user