Stuff I've fixed so far.

This commit is contained in:
2023-01-19 20:24:43 -08:00
parent e60002b8dc
commit 97fd59f28d
12 changed files with 72 additions and 43 deletions

View File

@ -0,0 +1,43 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "SimpleTexturedShader.hpp"
using namespace Dawn;
void SimpleTexturedShader::compile() {
this->program.compile();
}
std::vector<struct ShaderPass> SimpleTexturedShader::getItemPasses(
MeshRenderer *mesh, Material *material
) {
SimpleTexturedMaterial *simpleMaterial = dynamic_cast<SimpleTexturedMaterial*>(material);
assertNotNull(simpleMaterial);
struct ShaderPass onlyPass;
onlyPass.shaderProgram = &program;
onlyPass.colorValues[program.paramColor] = simpleMaterial->color;
onlyPass.matrixValues[program.paramModel] = mesh->transform->getWorldTransform();
if(simpleMaterial->texture != nullptr) {
onlyPass.boolValues[program.paramHasTexture] = true;
onlyPass.textureSlots[0] = simpleMaterial->texture;
onlyPass.textureValues[program.paramTexture] = 0;
} else {
onlyPass.boolValues[program.paramHasTexture] = false;
}
std::vector<struct ShaderPass> passes;
passes.push_back(onlyPass);
return passes;
}
void SimpleTexturedShader::setGlobalParameters(
glm::mat4 cameraProjection, glm::mat4 cameraView
) {
this->program.setMatrix(this->program.paramProjection, cameraProjection);
this->program.setMatrix(this->program.paramView, cameraView);
}

View File

@ -6,6 +6,7 @@
#pragma once
#include "display/shader/Shader.hpp"
#include "SimpleTexturedShaderProgram.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class SimpleTexturedShader : public Shader {
@ -13,21 +14,14 @@ namespace Dawn {
SimpleTexturedShaderProgram program;
public:
void compile() override {
this->program.compile();
}
void compile() override;
std::vector<struct ShaderPass> getItemPasses(
MeshRenderer *mesh,
Material *material
) override {
return std::vector<struct ShaderPass>();
}
MeshRenderer *mesh, Material *material
) override;
void setGlobalParameters(
glm::mat4 cameraProjection,
glm::mat4 cameraView
) override {
}
glm::mat4 cameraProjection, glm::mat4 cameraView
) override;
};
}