Example of Rendering UI done.
This commit is contained in:
@ -11,20 +11,20 @@ std::vector<std::shared_ptr<UIComponent>> UIComponent::getChildren() {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<struct UIQuad> UIComponent::getQuads(
|
||||
std::vector<struct UIShaderQuad> UIComponent::getQuads(
|
||||
const glm::mat4 parent
|
||||
) {
|
||||
// Get self transform
|
||||
glm::mat4 transform = glm::translate(
|
||||
glm::mat4(1.0f), glm::vec3(position, 0.0f)
|
||||
glm::mat4(1.0f),
|
||||
glm::vec3(position, 0.0f)
|
||||
);
|
||||
|
||||
// Add parent transform
|
||||
transform = parent * transform;
|
||||
|
||||
// Get self quads and insert new transform.
|
||||
std::vector<struct UIQuad> quads;
|
||||
auto selfQuads = this->getSelfQuads(transform);
|
||||
std::vector<struct UIShaderQuad> quads = this->getSelfQuads(transform);
|
||||
|
||||
// Get children
|
||||
auto children = getChildren();
|
||||
|
@ -5,20 +5,20 @@
|
||||
|
||||
#pragma once
|
||||
#include "ui/UIAlign.hpp"
|
||||
#include "ui/UIQuad.hpp"
|
||||
#include "display/shader/UIShader.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class UICanvas;
|
||||
|
||||
class UIComponent {
|
||||
protected:
|
||||
virtual std::vector<struct UIQuad> getSelfQuads(
|
||||
virtual std::vector<struct UIShaderQuad> getSelfQuads(
|
||||
const glm::mat4 transform
|
||||
) = 0;
|
||||
|
||||
virtual std::vector<std::shared_ptr<UIComponent>> getChildren();
|
||||
|
||||
std::vector<struct UIQuad> getQuads(
|
||||
std::vector<struct UIShaderQuad> getQuads(
|
||||
const glm::mat4 parent
|
||||
);
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "display/Color.hpp"
|
||||
#include "display/Texture.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
struct UIQuad {
|
||||
glm::mat4 transform;
|
||||
glm::vec4 quad;
|
||||
glm::vec4 uv;
|
||||
struct Color color;
|
||||
std::shared_ptr<Texture> texture;
|
||||
|
||||
UIQuad(
|
||||
const glm::mat4 transform,
|
||||
const glm::vec4 quad,
|
||||
const glm::vec4 uv,
|
||||
const struct Color color,
|
||||
const std::shared_ptr<Texture> texture
|
||||
) :
|
||||
transform(transform),
|
||||
quad(quad),
|
||||
uv(uv),
|
||||
color(color),
|
||||
texture(texture)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
@ -7,18 +7,15 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::vector<struct UIQuad> UIRectangle::getSelfQuads(
|
||||
std::vector<struct UIShaderQuad> UIRectangle::getSelfQuads(
|
||||
const glm::mat4 transform
|
||||
) {
|
||||
std::vector<struct UIQuad> quads;
|
||||
|
||||
quads.push_back(UIQuad(
|
||||
std::vector<struct UIShaderQuad> quads;
|
||||
quads.push_back({
|
||||
transform,
|
||||
glm::vec4(0,0,size.x,size.y),
|
||||
glm::vec4(0, 0, size.x, size.y),
|
||||
uv,
|
||||
color,
|
||||
texture
|
||||
));
|
||||
|
||||
color
|
||||
});
|
||||
return quads;
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
namespace Dawn {
|
||||
class UIRectangle final : public UIComponent {
|
||||
protected:
|
||||
std::vector<struct UIQuad> getSelfQuads(
|
||||
std::vector<struct UIShaderQuad> getSelfQuads(
|
||||
const glm::mat4 transform
|
||||
) override;
|
||||
|
||||
|
Reference in New Issue
Block a user