[Piglit] [PATCH 1/3] primitive-restart-draw-mode: draw front and back faces in different colors
Marek Olšák
maraeo at gmail.com
Mon Oct 29 23:38:14 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
so that triangle strip winding reset is visible after primitive restart
---
tests/general/primitive-restart-draw-mode.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tests/general/primitive-restart-draw-mode.c b/tests/general/primitive-restart-draw-mode.c
index cca89e385..5a1379748 100644
--- a/tests/general/primitive-restart-draw-mode.c
+++ b/tests/general/primitive-restart-draw-mode.c
@@ -126,34 +126,36 @@ static const struct test_desc
};
static const struct test_desc *test = NULL;
static const char vs_text[] =
"#version 110\n"
"attribute vec2 vertex;\n"
"uniform vec2 offset;\n"
"uniform vec2 window_size;\n"
- "uniform vec4 color;\n"
+ "uniform vec4 color, bcolor;\n"
"void main()\n"
"{\n"
" gl_Position = vec4((vertex + offset) / window_size * 2.0 - 1.0,\n"
" 0.0, 1.0);\n"
" gl_FrontColor = color;\n"
+ " gl_BackColor = bcolor;\n"
"}\n";
static GLuint prog;
static GLint vertex_attr;
static GLint window_size_loc;
static GLint offset_loc;
static GLint color_loc;
+static GLint bcolor_loc;
static void
print_usage_and_exit(const char *prog_name)
{
int i;
printf("Usage: %s <subtest>\n"
" where <subtest> is one of the following:\n", prog_name);
for (i = 0; i < ARRAY_SIZE(tests); i++)
printf(" %s\n", tests[i].name);
@@ -188,28 +190,33 @@ piglit_init(int argc, char **argv)
vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
prog = piglit_link_simple_program(vs, 0);
if (!prog)
piglit_report_result(PIGLIT_FAIL);
glDeleteShader(vs);
vertex_attr = glGetAttribLocation(prog, "vertex");
window_size_loc = glGetUniformLocation(prog, "window_size");
offset_loc = glGetUniformLocation(prog, "offset");
color_loc = glGetUniformLocation(prog, "color");
+ bcolor_loc = glGetUniformLocation(prog, "bcolor");
+
+ glEnable(GL_VERTEX_PROGRAM_TWO_SIDE);
}
static void
draw_pattern(int restart_pos, bool use_primitive_restart)
{
- /* Draw test pattern in blue */
+ /* Draw front faces blue and back faces red. */
glUniform4f(color_loc, 0.25, 0.25, 1.0, 1.0);
+ glUniform4f(bcolor_loc, 0.7, 0.2, 0.2, 1.0);
+
if (use_primitive_restart) {
GLubyte index_buffer[NUM_VERTICES + 1];
int i;
for (i = 0; i < restart_pos; i++) {
index_buffer[i] = i;
}
index_buffer[restart_pos] = 0xff;
for (i = restart_pos + 1; i < ARRAY_SIZE(index_buffer); i++) {
index_buffer[i] = i - 1;
--
2.17.1
More information about the Piglit
mailing list