add color in BufferVertex
This commit is contained in:
parent
c94acb14a2
commit
133b74699e
7 changed files with 23 additions and 7 deletions
|
@ -16,7 +16,7 @@ struct Curve {
|
|||
uniform isampler2D glyphs;
|
||||
uniform sampler2D curves;
|
||||
uniform sampler2D iChannel0;
|
||||
uniform vec4 color;
|
||||
//uniform vec4 color;
|
||||
|
||||
// Controls for debugging and exploring:
|
||||
|
||||
|
@ -35,6 +35,7 @@ uniform bool enableControlPointsVisualization;
|
|||
|
||||
in vec2 uv;
|
||||
flat in int bufferIndex;
|
||||
in vec4 color;
|
||||
|
||||
out vec4 result;
|
||||
|
||||
|
|
|
@ -10,12 +10,15 @@ uniform float z;
|
|||
layout (location = 0) in vec2 vertexPosition;
|
||||
layout (location = 1) in vec2 vertexUV;
|
||||
layout (location = 2) in int vertexIndex;
|
||||
layout (location = 3) in vec4 vertexColor;
|
||||
|
||||
out vec2 uv;
|
||||
flat out int bufferIndex;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * view * model * vec4(vertexPosition, z, 1.0);
|
||||
uv = vertexUV;
|
||||
bufferIndex = vertexIndex;
|
||||
color = vertexColor;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ struct Curve {
|
|||
|
||||
uniform isampler2D glyphs;
|
||||
uniform sampler2D curves;
|
||||
uniform vec4 color;
|
||||
//uniform vec4 color;
|
||||
|
||||
|
||||
// Controls for debugging and exploring:
|
||||
|
@ -35,6 +35,7 @@ uniform bool enableControlPointsVisualization;
|
|||
|
||||
in vec2 uv;
|
||||
flat in int bufferIndex;
|
||||
in vec4 color;
|
||||
|
||||
out vec4 result;
|
||||
|
||||
|
|
|
@ -10,12 +10,15 @@ uniform float z;
|
|||
layout (location = 0) in vec2 vertexPosition;
|
||||
layout (location = 1) in vec2 vertexUV;
|
||||
layout (location = 2) in int vertexIndex;
|
||||
layout (location = 3) in vec4 vertexColor;
|
||||
|
||||
out vec2 uv;
|
||||
flat out int bufferIndex;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * view * model * vec4(vertexPosition, z, 1.0);
|
||||
uv = vertexUV;
|
||||
bufferIndex = vertexIndex;
|
||||
color = vertexColor;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ struct Curve {
|
|||
uniform isamplerBuffer glyphs;
|
||||
uniform samplerBuffer curves;
|
||||
uniform sampler2D iChannel0;
|
||||
uniform vec4 color;
|
||||
//uniform vec4 color;
|
||||
|
||||
|
||||
// Controls for debugging and exploring:
|
||||
|
@ -33,6 +33,7 @@ uniform bool enableControlPointsVisualization = false;
|
|||
|
||||
in vec2 uv;
|
||||
flat in int bufferIndex;
|
||||
in vec4 color;
|
||||
|
||||
out vec4 result;
|
||||
|
||||
|
|
|
@ -8,12 +8,15 @@ uniform float z;
|
|||
layout (location = 0) in vec2 vertexPosition;
|
||||
layout (location = 1) in vec2 vertexUV;
|
||||
layout (location = 2) in int vertexIndex;
|
||||
layout (location = 3) in vec4 vertexColor;
|
||||
|
||||
out vec2 uv;
|
||||
flat out int bufferIndex;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * view * model * vec4(vertexPosition, z, 1);
|
||||
uv = vertexUV;
|
||||
bufferIndex = vertexIndex;
|
||||
color = vertexColor;
|
||||
}
|
||||
|
|
|
@ -191,6 +191,7 @@ class Font {
|
|||
struct BufferVertex {
|
||||
float x, y, u, v;
|
||||
int32_t bufferIndex;
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
/// A structure to model a given axis of a variable font.
|
||||
|
@ -407,6 +408,8 @@ class Font {
|
|||
glVertexAttribPointer(1, 2, GL_FLOAT, false, sizeof(BufferVertex), (void *)offsetof(BufferVertex, u));
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribIPointer(2, 1, GL_INT, sizeof(BufferVertex), (void *)offsetof(BufferVertex, bufferIndex));
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, false, sizeof(BufferVertex), (void *)offsetof(BufferVertex, r));
|
||||
glBindVertexArray(0);
|
||||
|
||||
uploadBuffers();
|
||||
|
@ -874,6 +877,7 @@ class Font {
|
|||
const std::vector <GlyphIdentity> & variationText,
|
||||
std::vector <BufferVertex> & vertices,
|
||||
std::vector <int32_t> & indices,
|
||||
const glm::vec4 & color = glm::vec4(1),
|
||||
const bool vFlip = false,
|
||||
const float fontSize_px = 42){
|
||||
float advanceX = 0;
|
||||
|
@ -944,10 +948,10 @@ class Font {
|
|||
glm::vec4 p3 = node.getGlobalTransformMatrix() * glm::vec4(x0, y1 + advanceY, 0, 1);
|
||||
|
||||
int32_t base = static_cast <int32_t>(vertices.size());
|
||||
vertices.push_back(BufferVertex{p0.x, p0.y, u0, v0, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{p1.x, p1.y, u1, v0, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{p2.x, p2.y, u1, v1, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{p3.x, p3.y, u0, v1, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{p0.x, p0.y, u0, v0, glyph.bufferIndex, color.r, color.g, color.b, color.a});
|
||||
vertices.push_back(BufferVertex{p1.x, p1.y, u1, v0, glyph.bufferIndex, color.r, color.g, color.b, color.a});
|
||||
vertices.push_back(BufferVertex{p2.x, p2.y, u1, v1, glyph.bufferIndex, color.r, color.g, color.b, color.a});
|
||||
vertices.push_back(BufferVertex{p3.x, p3.y, u0, v1, glyph.bufferIndex, color.r, color.g, color.b, color.a});
|
||||
|
||||
indices.insert(indices.end(), {base, base + 1, base + 2, base + 2, base + 3, base});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue