gs: give our test an option of rendering a strip
This commit is contained in:
parent
4d0baa73c9
commit
226ff53e63
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
static const char *filename = NULL;
|
static const char *filename = NULL;
|
||||||
unsigned show_fps = 0;
|
unsigned show_fps = 0;
|
||||||
|
unsigned draw_strip = 0;
|
||||||
|
|
||||||
|
|
||||||
static void usage(char *name)
|
static void usage(char *name)
|
||||||
|
@ -26,6 +27,7 @@ static void usage(char *name)
|
||||||
fprintf(stderr, "\n" );
|
fprintf(stderr, "\n" );
|
||||||
fprintf(stderr, "options:\n");
|
fprintf(stderr, "options:\n");
|
||||||
fprintf(stderr, " -fps show frames per second\n");
|
fprintf(stderr, " -fps show frames per second\n");
|
||||||
|
fprintf(stderr, " -strip renders a triangle strip\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +75,25 @@ static struct vertex vertices[] =
|
||||||
{ -1, 0, 0, 1 } },
|
{ -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[] =
|
static float constants[] =
|
||||||
{ 0.4, 0, 0, 1,
|
{ 0.4, 0, 0, 1,
|
||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
|
@ -171,12 +192,20 @@ static void set_vertices( void )
|
||||||
|
|
||||||
|
|
||||||
vbuf.stride = sizeof( struct vertex );
|
vbuf.stride = sizeof( struct vertex );
|
||||||
vbuf.max_index = sizeof(vertices) / vbuf.stride;
|
|
||||||
vbuf.buffer_offset = 0;
|
vbuf.buffer_offset = 0;
|
||||||
vbuf.buffer = screen->user_buffer_create(screen,
|
if (draw_strip) {
|
||||||
vertices,
|
vbuf.max_index = sizeof(vertices_strip) / vbuf.stride;
|
||||||
sizeof(vertices),
|
vbuf.buffer = screen->user_buffer_create(screen,
|
||||||
PIPE_BIND_VERTEX_BUFFER);
|
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);
|
ctx->set_vertex_buffers(ctx, 1, &vbuf);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +276,11 @@ static void draw( void )
|
||||||
float clear_color[4] = {.1,.3,.5,0};
|
float clear_color[4] = {.1,.3,.5,0};
|
||||||
|
|
||||||
ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 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);
|
ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -502,6 +535,9 @@ static void args(int argc, char *argv[])
|
||||||
if (strcmp(argv[i], "-fps") == 0) {
|
if (strcmp(argv[i], "-fps") == 0) {
|
||||||
show_fps = 1;
|
show_fps = 1;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[i], "-strip") == 0) {
|
||||||
|
draw_strip = 1;
|
||||||
|
}
|
||||||
else if (i == argc - 1) {
|
else if (i == argc - 1) {
|
||||||
filename = argv[i];
|
filename = argv[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue