Fixed shader alignment on windows
This commit is contained in:
@ -98,7 +98,7 @@ float_t UILabel::getContentHeight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
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;
|
int32_t nextTexture = 0;
|
||||||
glm::vec2 position(0, 0);
|
glm::vec2 position(0, 0);
|
||||||
@ -149,7 +149,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Buffer shader values
|
// Buffer shader values
|
||||||
fontData.textures[partIndex] = textureMap[realText.texture];
|
fontData.textures[partIndex].value = textureMap[realText.texture];
|
||||||
fontData.colors[partIndex] = realText.style.color;
|
fontData.colors[partIndex] = realText.style.color;
|
||||||
|
|
||||||
// Get some texture info
|
// 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 uvs(0, 0, 1, 1);
|
||||||
glm::vec4 vert(0, 0, 0, 0);
|
glm::vec4 vert(0, 0, 0, 0);
|
||||||
vertices.push_back(std::make_pair(vert, uvs));
|
vertices.push_back(std::make_pair(vert, uvs));
|
||||||
fontData.fontQuadMappings[quadCountTotal] = partIndex;
|
fontData.quadMappings[quadCountTotal].value = partIndex;
|
||||||
|
|
||||||
quadCountTotal++;
|
quadCountTotal++;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the part index to the quad mappings
|
// Set the part index to the quad mappings
|
||||||
fontData.fontQuadMappings[quadCountTotal] = partIndex;
|
fontData.quadMappings[quadCountTotal].value = partIndex;
|
||||||
quadCountTotal++;
|
quadCountTotal++;
|
||||||
realText.text += ch;
|
realText.text += ch;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,17 @@ namespace Dawn {
|
|||||||
|
|
||||||
auto textboxItem = this->createSceneItem();
|
auto textboxItem = this->createSceneItem();
|
||||||
auto textbox = textboxItem->addComponent<UIRichTextLabel>();
|
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);
|
textbox->transform->setParent(canvas->transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,11 @@ namespace Dawn {
|
|||||||
typedef GLuint shaderbufferslot_t;
|
typedef GLuint shaderbufferslot_t;
|
||||||
typedef GLuint shaderbufferlocation_t;
|
typedef GLuint shaderbufferlocation_t;
|
||||||
|
|
||||||
|
struct ShaderParameterBufferArrayInteger {
|
||||||
|
int32_t value;
|
||||||
|
float_t padding[3];
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ShaderParameterBuffer : public IShaderParameterBuffer<shaderbufferslot_t> {
|
class ShaderParameterBuffer : public IShaderParameterBuffer<shaderbufferslot_t> {
|
||||||
protected:
|
protected:
|
||||||
|
@ -26,8 +26,8 @@ void FontShader::compile() {
|
|||||||
"};"
|
"};"
|
||||||
|
|
||||||
"layout (shared) uniform ub_Font {\n"
|
"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_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"
|
"vec4 u_FontColors[" MACRO_STRINGIFY(FONT_SHADER_PARTS_MAX) "];\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
@ -7,18 +7,16 @@
|
|||||||
#include "UIShader.hpp"
|
#include "UIShader.hpp"
|
||||||
#include "util/macro.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_QUADS_MAX 1024
|
||||||
#define FONT_SHADER_TEXTURE_MAX 4
|
#define FONT_SHADER_TEXTURE_MAX 4
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
#pragma pack(push, 4)
|
|
||||||
struct FontShaderBufferData {
|
struct FontShaderBufferData {
|
||||||
int32_t fontQuadMappings[FONT_SHADER_QUADS_MAX];
|
struct ShaderParameterBufferArrayInteger textures[FONT_SHADER_PARTS_MAX];
|
||||||
int32_t textures[FONT_SHADER_PARTS_MAX];
|
struct ShaderParameterBufferArrayInteger quadMappings[FONT_SHADER_QUADS_MAX];
|
||||||
struct Color colors[FONT_SHADER_PARTS_MAX];
|
struct Color colors[FONT_SHADER_PARTS_MAX];
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
class FontShaderBuffer : public ShaderParameterBuffer<struct FontShaderBufferData> {
|
class FontShaderBuffer : public ShaderParameterBuffer<struct FontShaderBufferData> {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user