Gawain: new immSkipAttrib function

Now you can explicitly skip a vertex attribute -- you don't give it a value and it won't get a copy of the previous vert's value. Useful for flat interpolated per-primitive values.

This is an advanced feature. Expect garbage in the empty spaces, and copies of garbage if you rely on the attrib copy behavior after skipping.
This commit is contained in:
Mike Erwin 2016-10-16 01:58:26 -04:00
parent a4fe823416
commit 741965615d
2 changed files with 16 additions and 0 deletions

View File

@ -592,6 +592,17 @@ void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4])
immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
}
void immSkipAttrib(unsigned attrib_id)
{
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attrib_ct);
assert(imm.vertex_idx < imm.vertex_ct);
assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
#endif
setAttribValueBit(attrib_id);
}
static void immEndVertex(void) // and move on to the next vertex
{
#if TRUST_NO_ONE
@ -619,6 +630,7 @@ static void immEndVertex(void) // and move on to the next vertex
GLubyte* data = imm.vertex_data + a->offset;
memcpy(data, data - imm.vertex_format.stride, a->sz);
// TODO: consolidate copy of adjacent attributes
}
}
}

View File

@ -54,6 +54,10 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]);
void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]);
// explicitly skip an attribute
// this advanced option kills automatic value copying for this attrib_id
void immSkipAttrib(unsigned attrib_id);
// provide one last attribute value & end the current vertex
// this is most often used for 2D or 3D position (similar to glVertex)