Fixed shader alignment on windows

This commit is contained in:
2023-06-19 11:44:45 -07:00
parent 0917851287
commit 2285914c2e
5 changed files with 24 additions and 11 deletions
src
dawn/scene/components/ui/text
dawnliminal/scenes
dawnopengl/display/shader

@ -98,7 +98,7 @@ float_t UILabel::getContentHeight() {
}
void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
assertTrue(newTexts.size() < FONT_SHADER_PARTS_MAX);
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX);
int32_t nextTexture = 0;
glm::vec2 position(0, 0);
@ -149,7 +149,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
}
// Buffer shader values
fontData.textures[partIndex] = textureMap[realText.texture];
fontData.textures[partIndex].value = textureMap[realText.texture];
fontData.colors[partIndex] = realText.style.color;
// Get some texture info
@ -174,7 +174,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
glm::vec4 uvs(0, 0, 1, 1);
glm::vec4 vert(0, 0, 0, 0);
vertices.push_back(std::make_pair(vert, uvs));
fontData.fontQuadMappings[quadCountTotal] = partIndex;
fontData.quadMappings[quadCountTotal].value = partIndex;
quadCountTotal++;
}
@ -281,7 +281,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
}
// Set the part index to the quad mappings
fontData.fontQuadMappings[quadCountTotal] = partIndex;
fontData.quadMappings[quadCountTotal].value = partIndex;
quadCountTotal++;
realText.text += ch;
}

@ -28,7 +28,17 @@ namespace Dawn {
auto textboxItem = this->createSceneItem();
auto textbox = textboxItem->addComponent<UIRichTextLabel>();
textbox->richText = "<font font=\"font_main\">Hello World</font>";
textbox->alignX = UI_COMPONENT_ALIGN_STRETCH;
textbox->alignY = UI_COMPONENT_ALIGN_STRETCH;
textbox->alignment = glm::vec4(0, 0, 0, 0);
textbox->richText = std::string(
"<font font=\"font_main\" size=\"64\" style=\"italics\" color=\"MAGENTA\">"
"Hello World"
"</font>"
"<font font=\"font_main\" size=\"64\" style=\"bold\" color=\"WHITE\">"
"BBBBBB"
"</font>"
);
textbox->transform->setParent(canvas->transform);
}

@ -11,6 +11,11 @@
namespace Dawn {
typedef GLuint shaderbufferslot_t;
typedef GLuint shaderbufferlocation_t;
struct ShaderParameterBufferArrayInteger {
int32_t value;
float_t padding[3];
};
template<typename T>
class ShaderParameterBuffer : public IShaderParameterBuffer<shaderbufferslot_t> {

@ -26,8 +26,8 @@ void FontShader::compile() {
"};"
"layout (shared) uniform ub_Font {\n"
"int u_FontQuadMappings[" MACRO_STRINGIFY(FONT_SHADER_QUADS_MAX) "];\n"
"int u_FontTextures[" MACRO_STRINGIFY(FONT_SHADER_PARTS_MAX) "];\n"
"int u_FontQuadMappings[" MACRO_STRINGIFY(FONT_SHADER_QUADS_MAX) "];\n"
"vec4 u_FontColors[" MACRO_STRINGIFY(FONT_SHADER_PARTS_MAX) "];\n"
"};\n"

@ -7,18 +7,16 @@
#include "UIShader.hpp"
#include "util/macro.hpp"
#define FONT_SHADER_PARTS_MAX 8
#define FONT_SHADER_PARTS_MAX 4
#define FONT_SHADER_QUADS_MAX 1024
#define FONT_SHADER_TEXTURE_MAX 4
namespace Dawn {
#pragma pack(push, 4)
struct FontShaderBufferData {
int32_t fontQuadMappings[FONT_SHADER_QUADS_MAX];
int32_t textures[FONT_SHADER_PARTS_MAX];
struct ShaderParameterBufferArrayInteger textures[FONT_SHADER_PARTS_MAX];
struct ShaderParameterBufferArrayInteger quadMappings[FONT_SHADER_QUADS_MAX];
struct Color colors[FONT_SHADER_PARTS_MAX];
};
#pragma pack(pop)
class FontShaderBuffer : public ShaderParameterBuffer<struct FontShaderBufferData> {