static const char *filename = NULL;
unsigned show_fps = 0;
+unsigned draw_strip = 0;
static void usage(char *name)
fprintf(stderr, "\n" );
fprintf(stderr, "options:\n");
fprintf(stderr, " -fps show frames per second\n");
+ fprintf(stderr, " -strip renders a triangle strip\n");
#endif
}
{ -1, 0, 0, 1 } },
};
+static struct vertex vertices_strip[] =
+{
+ { { 0.9, 0.9, 0.0, 1.0 },
+ { 0, 0, 1, 1 },
+ { 1, 1, 0, 1 } },
+
+ { { 0.9, -0.9, 0.0, 1.0 },
+ { 1, 0, 0, 1 },
+ { 1, -1, 0, 1 } },
+
+ { {-0.9, -0.9, 0.0, 1.0 },
+ { 0, 1, 0, 1 },
+ { -1, -1, 0, 1 } },
+
+ { {-0.9, 0.9, 0.0, 1.0 },
+ { 1, 1, 0, 1 },
+ { -1, 1, 0, 1 } },
+};
+
static float constants[] =
{ 0.4, 0, 0, 1,
1, 1, 1, 1,
vbuf.stride = sizeof( struct vertex );
- vbuf.max_index = sizeof(vertices) / vbuf.stride;
vbuf.buffer_offset = 0;
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ if (draw_strip) {
+ vbuf.max_index = sizeof(vertices_strip) / vbuf.stride;
+ vbuf.buffer = screen->user_buffer_create(screen,
+ vertices_strip,
+ sizeof(vertices_strip),
+ PIPE_BIND_VERTEX_BUFFER);
+ } else {
+ vbuf.max_index = sizeof(vertices) / vbuf.stride;
+ vbuf.buffer = screen->user_buffer_create(screen,
+ vertices,
+ sizeof(vertices),
+ PIPE_BIND_VERTEX_BUFFER);
+ }
ctx->set_vertex_buffers(ctx, 1, &vbuf);
}
float clear_color[4] = {.1,.3,.5,0};
ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
- ctx->draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
+ if (draw_strip)
+ ctx->draw_arrays(ctx, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
+ else
+ ctx->draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
+
ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
#if 0
if (strcmp(argv[i], "-fps") == 0) {
show_fps = 1;
}
+ else if (strcmp(argv[i], "-strip") == 0) {
+ draw_strip = 1;
+ }
else if (i == argc - 1) {
filename = argv[i];
}