Fixed some bugs with buffers during font building

This commit is contained in:
2023-05-31 10:47:06 -07:00
parent e3d0070e95
commit 970e98f49a
14 changed files with 186 additions and 76 deletions

View File

@ -12,6 +12,7 @@ target_sources(${DAWN_TARGET_NAME}
UILabel.cpp
UIImage.cpp
UIBorder.cpp
UILabelNew.cpp
)
add_subdirectory(menu)

View File

@ -0,0 +1,58 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "UILabelNew.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
UILabelNew::UILabelNew(SceneItem *item) : UIComponentRenderable(item) {
}
void UILabelNew::onStart() {
std::cout << "Hello new Label" << std::endl;
QuadMesh::initQuadMesh(&this->mesh,
glm::vec2(0, 0), glm::vec2(0, 0),
glm::vec2(32, 32), glm::vec2(1, 1),
0.0f
);
this->shaderBuffer.init();
}
std::vector<struct ShaderPassItem> UILabelNew::getUIRenderPasses() {
auto canvas = this->getCanvas();
auto shader = getGame()->renderManager.fontShader;
struct ShaderPassItem item;
item.shader = shader;
item.mesh = &mesh;
item.matrixValues[shader->paramModel] = transform->getWorldTransform();
item.parameterBuffers[shader->bufferUiCanvas] = &canvas->shaderBuffer;
item.parameterBuffers[shader->bufferFont] = &this->shaderBuffer;
struct FontShaderBufferData fontData;
fontData.fontParts[9].color = COLOR_BLUE;
shaderBuffer.buffer(&fontData);
return { item };
}
float_t UILabelNew::getWidth() {
return 0;
}
float_t UILabelNew::getHeight() {
return 0;
}
float_t UILabelNew::getContentWidth() {
return 0;
}
float_t UILabelNew::getContentHeight() {
return 0;
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/ui/UIComponentRenderable.hpp"
#include "display/mesh/QuadMesh.hpp"
namespace Dawn {
class UILabelNew : public UIComponentRenderable {
protected:
Mesh mesh;
FontShaderBuffer shaderBuffer;
public:
UILabelNew(SceneItem *item);
void onStart() override;
std::vector<struct ShaderPassItem> getUIRenderPasses() override;
float_t getWidth() override;
float_t getHeight() override;
float_t getContentWidth() override;
float_t getContentHeight() override;
};
}