static void translate_ubyte_ushort( const void *in,
+ unsigned start,
unsigned nr,
void *out )
{
ushort *out_us = (ushort *)out;
unsigned i;
for (i = 0; i < nr; i++)
- out_us[i] = (ushort) in_ub[i];
+ out_us[i] = (ushort) in_ub[i+start];
}
static void translate_memcpy_ushort( const void *in,
+ unsigned start,
unsigned nr,
void *out )
{
- memcpy(out, in, nr*sizeof(short));
+ memcpy(out, &((short *)in)[start], nr*sizeof(short));
}
static void translate_memcpy_uint( const void *in,
+ unsigned start,
unsigned nr,
void *out )
{
- memcpy(out, in, nr*sizeof(int));
+ memcpy(out, &((int *)in)[start], nr*sizeof(int));
}
-static void generate_linear_ushort( unsigned nr,
+static void generate_linear_ushort( unsigned start,
+ unsigned nr,
void *out )
{
ushort *out_us = (ushort *)out;
unsigned i;
for (i = 0; i < nr; i++)
- out_us[i] = (ushort) i;
+ out_us[i] = (ushort)(i + start);
}
-static void generate_linear_uint( unsigned nr,
+static void generate_linear_uint( unsigned start,
+ unsigned nr,
void *out )
{
unsigned *out_ui = (unsigned *)out;
unsigned i;
for (i = 0; i < nr; i++)
- out_ui[i] = i;
+ out_ui[i] = i + start;
}
+/**
+ * Given a primitive type and number of vertices, return the number of vertices
+ * needed to draw the primitive with fill mode = PIPE_POLYGON_MODE_LINE using
+ * separate lines (PIPE_PRIM_LINES).
+ */
static unsigned nr_lines( unsigned prim,
unsigned nr )
{
case PIPE_PRIM_QUAD_STRIP:
return (nr - 2) / 2 * 8;
case PIPE_PRIM_POLYGON:
- return (nr - 2) * 6;
+ return 2 * nr; /* a line (two verts) for each polygon edge */
default:
assert(0);
return 0;
}
-
+/**
+ * Utility for converting unfilled polygons into points, lines, triangles.
+ * Few drivers have direct support for OpenGL's glPolygonMode.
+ * This function helps with converting triangles into points or lines
+ * when the front and back fill modes are the same. When there's
+ * different front/back fill modes, that can be handled with the
+ * 'draw' module.
+ */
int u_unfilled_generator( unsigned prim,
unsigned start,
unsigned nr,