Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2016-08-11 07:11:48 +0300
committerMike Erwin <significant.bit@gmail.com>2016-08-11 07:11:48 +0300
commit7664d947b38e1451b973deb7488ec881bedf5dcc (patch)
tree17f3d345245536f0e557ee997f803a4bfa71a382 /source/blender/gpu/intern/gpu_immediate.c
parent4aadf7331e108e7257af07d01384ce67de5e0391 (diff)
Gawain: allow partial vertex specification
If you don’t specify a vertex’s color, it will use the color of the previous vertex. Similar for all other attributes. This matches the legacy behavior of glColor, glNormal, etc. *except* in Gawain the first vertex of each immBegin must be fully specified. There is no “current” color in the new system.
Diffstat (limited to 'source/blender/gpu/intern/gpu_immediate.c')
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 628c8d1c30d..5912570f1c4 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -621,14 +621,33 @@ void immEndVertex()
{
#if TRUST_NO_ONE
assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+ assert(imm.vertex_idx < imm.vertex_ct);
+#endif
// have all attribs been assigned values?
+ // if not, copy value from previous vertex
const unsigned short all_bits = ~(0xFFFFU << imm.vertex_format.attrib_ct);
- assert(imm.attrib_value_bits == all_bits);
-
- assert(imm.vertex_idx < imm.vertex_ct);
+ if (imm.attrib_value_bits != all_bits)
+ {
+#if TRUST_NO_ONE
+ assert(imm.vertex_idx > 0); // first vertex must have all attribs specified
#endif
+ for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
+ {
+ const uint16_t mask = 1 << a_idx;
+ if ((imm.attrib_value_bits & mask) == 0)
+ {
+ const Attrib* a = imm.vertex_format.attribs + a_idx;
+
+// printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx);
+
+ GLubyte* data = imm.vertex_data + a->offset;
+ memcpy(data, data - imm.vertex_format.stride, a->sz);
+ }
+ }
+ }
+
imm.vertex_idx++;
imm.vertex_data += imm.vertex_format.stride;
imm.attrib_value_bits = 0;