Testing Font shader setup for arrays
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "FontShader.hpp"
|
||||
#include "display/mesh/QuadMesh.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -30,7 +31,7 @@ void FontShader::compile() {
|
||||
|
||||
"layout (std140) uniform ub_Font {\n"
|
||||
"FontShaderPart u_FontParts[" MACRO_STRINGIFY(FONT_SHADER_PARTS_MAX) "];\n"
|
||||
"int u_FontPartsCount;\n"
|
||||
"int u_FontQuadParts[" MACRO_STRINGIFY(FONT_SHADER_QUADS_MAX) "];\n"
|
||||
"};\n"
|
||||
|
||||
"uniform mat4 u_Model;\n"
|
||||
@ -38,9 +39,11 @@ void FontShader::compile() {
|
||||
"out vec4 o_VertColor;\n"
|
||||
|
||||
"void main() {\n"
|
||||
"gl_Position = u_Projection * u_View * u_Model * vec4(aPos, 1.0);\n"
|
||||
"gl_Position = u_Projection * u_View * u_Model * vec4(aPos.xy, 0, 1.0);\n"
|
||||
"o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n"
|
||||
"o_VertColor = u_FontParts[9].color;\n"
|
||||
"int quadIndex = gl_VertexID / " MACRO_STRINGIFY(QUAD_VERTICE_COUNT) ";\n"
|
||||
"int partIndex = u_FontQuadParts[quadIndex];\n"
|
||||
"o_VertColor = u_FontParts[partIndex].color;\n"
|
||||
"}",
|
||||
|
||||
// Fragment Shader
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include "UIShader.hpp"
|
||||
#include "util/macro.hpp"
|
||||
|
||||
#define FONT_SHADER_PARTS_MAX 32
|
||||
#define FONT_SHADER_PARTS_MAX 16
|
||||
#define FONT_SHADER_QUADS_MAX 16
|
||||
|
||||
namespace Dawn {
|
||||
struct FontShaderPart {
|
||||
@ -16,7 +17,7 @@ namespace Dawn {
|
||||
|
||||
struct FontShaderBufferData {
|
||||
struct FontShaderPart fontParts[FONT_SHADER_PARTS_MAX];
|
||||
int32_t fontPartsCount;
|
||||
int32_t fontQuadParts[FONT_SHADER_QUADS_MAX];
|
||||
};
|
||||
|
||||
class FontShaderBuffer : public ShaderParameterBuffer<struct FontShaderBufferData> {
|
||||
|
Reference in New Issue
Block a user