Fixed whatever was wrong with my shader

This commit is contained in:
2022-12-05 19:27:32 -08:00
parent c426dfe4d1
commit 0a4170ea3d
21 changed files with 284 additions and 61 deletions

View File

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

View File

@ -0,0 +1,44 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "ExampleSpin.hpp"
#include "scene/Scene.hpp"
#include "game/DawnGame.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "display/mesh/CubeMesh.hpp"
using namespace Dawn;
SceneItem * ExampleSpin::create(Scene *scene) {
auto item = scene->createSceneItem();
auto mr = item->addComponent<MeshRenderer>();
mr->mesh = new Mesh();
mr->mesh->createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
CubeMesh::buffer(mr->mesh, glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(1, 1, 1), 0, 0);
auto mat = item->addComponent<Material>();
item->addComponent<ExampleSpin>();
return item;
}
ExampleSpin::ExampleSpin(SceneItem *item) :
SceneItemComponent(item)
{
getScene()->eventSceneUnpausedUpdate.addListener(this, &ExampleSpin::onUnpausedUpdate);
}
void ExampleSpin::onUnpausedUpdate() {
auto quat = this->transform->getLocalRotation();
quat = glm::rotate(quat, getGame()->timeManager.delta, glm::vec3(0, 1, 0));
quat = glm::rotate(quat, getGame()->timeManager.delta / 2.0f, glm::vec3(1, 0, 0));
quat = glm::rotate(quat, getGame()->timeManager.delta / 4.0f, glm::vec3(0, 0, 1));
this->transform->setLocalRotation(quat);
}
ExampleSpin::~ExampleSpin() {
getScene()->eventSceneUnpausedUpdate.removeListener(this, &ExampleSpin::onUnpausedUpdate);
}

View File

@ -0,0 +1,19 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "display/shader/Shader.hpp"
namespace Dawn {
class ExampleSpin : public SceneItemComponent {
public:
static SceneItem * create(Scene *scene);
ExampleSpin(SceneItem *item);
void onUnpausedUpdate();
~ExampleSpin();
};
}