Uniform arrays working.

This commit is contained in:
2023-12-11 23:54:52 -06:00
parent 26bc4926ae
commit 09200c3816
18 changed files with 447 additions and 23 deletions

View File

@ -9,4 +9,5 @@ target_sources(${DAWN_TARGET_NAME}
)
# Subdirs
add_subdirectory(display)
add_subdirectory(display)
add_subdirectory(ui)

View File

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

View File

@ -0,0 +1,64 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "UICanvas.hpp"
#include "display/pass/RenderPass.hpp"
#include "display/shader/UIShader.hpp"
#include "display/mesh/QuadMesh.hpp"
using namespace Dawn;
void UICanvas::onInit() {
}
void UICanvas::onDispose() {
}
std::vector<std::shared_ptr<IRenderPass>> UICanvas::getPasses(
struct RenderPassContext &ctx
) {
std::vector<std::shared_ptr<IRenderPass>> passes;
auto selfTransform = this->getItem()->getWorldTransform();
auto mesh = std::make_shared<Mesh>();
mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
QuadMesh::buffer(mesh, glm::vec4(0, 0, 32, 32), glm::vec4(0, 0, 1, 1), 0, 0);
UIShaderData data = {
.projection = ctx.camera->getProjection(),
.view = ctx.camera->getItem()->getWorldTransform(),
.model = selfTransform
};
data.colors[0] = COLOR_WHITE;
data.colors[1] = COLOR_RED;
data.colors[2] = COLOR_GREEN;
data.colors[3] = COLOR_BLUE;
auto pass = createRenderPass<UIShader, UIShaderData>(
std::ref(*this),
data,
std::unordered_map<shadertexturebinding_t, std::shared_ptr<Texture>>(),
mesh,
MeshDrawMode::TRIANGLES,
0, -1
);
passes.push_back(pass);
auto itComponents = components.begin();
while(itComponents != components.end()) {
auto component = *itComponents;
// Get this components' quads.
auto quads = component->getQuads(selfTransform);
++itComponents;
}
return passes;
}

View File

@ -0,0 +1,28 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItem.hpp"
#include "component/display/IRenderableComponent.hpp"
#include "ui/UIComponent.hpp"
namespace Dawn {
class UICanvas :
public SceneComponent,
public IRenderableComponent
{
protected:
virtual void onInit() override;
virtual void onDispose() override;
public:
std::vector<std::shared_ptr<UIComponent>> components;
std::vector<std::shared_ptr<IRenderPass>> getPasses(
struct RenderPassContext &ctx
) override;
};
}