Dawn/src/dawn/component/display/material/SimpleTexturedMaterial.cpp

54 lines
1.3 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "SimpleTexturedMaterial.hpp"
using namespace Dawn;
struct Color SimpleTexturedMaterial::getColor() {
return this->data.color;
}
std::shared_ptr<Texture> SimpleTexturedMaterial::getTexture() {
return this->texture;
}
void SimpleTexturedMaterial::setTexture(std::shared_ptr<Texture> texture) {
this->texture = texture;
}
void SimpleTexturedMaterial::setColor(const struct Color color) {
this->data.color = color;
}
std::vector<std::shared_ptr<IRenderPass>> SimpleTexturedMaterial::getPasses(
struct RenderPassContext &ctx
) {
this->data.model = this->getItem()->getWorldTransform();
this->data.projection = ctx.camera->getProjection();
this->data.view = ctx.camera->getItem()->getWorldTransform();
this->data.color = COLOR_RED;
auto textures = std::unordered_map<
shadertexturebinding_t, std::shared_ptr<Texture>
>();
if(this->texture) {
this->data.hasTexture = true;
this->data.texture = 0;
textures[this->data.texture] = this->texture;
} else {
this->data.hasTexture = false;
}
return {
createRenderPass<SimpleTexturedShader, struct SimpleTexturedShaderData>(
*this,
data,
textures
)
};
}