Fixed whatever was wrong with my shader
This commit is contained in:
10
src/dawn/scene/components/example/CMakeLists.txt
Normal file
10
src/dawn/scene/components/example/CMakeLists.txt
Normal 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
|
||||
)
|
44
src/dawn/scene/components/example/ExampleSpin.cpp
Normal file
44
src/dawn/scene/components/example/ExampleSpin.cpp
Normal 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);
|
||||
}
|
19
src/dawn/scene/components/example/ExampleSpin.hpp
Normal file
19
src/dawn/scene/components/example/ExampleSpin.hpp
Normal 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();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user