Commit a9c68fef authored by Anuj Phogat's avatar Anuj Phogat

Add utility function piglit_draw_triangle

These utility functions to draw triangle would help in testing antialiasing
and depth related issues.

v2: Defined piglit_draw_triangle in terms of piglit_draw_triangle_z. Modified
    the comments
Signed-off-by: Anuj Phogat's avatarAnuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 98a17a1d
......@@ -707,6 +707,46 @@ piglit_escape_exit_key(unsigned char key, int x, int y)
glutPostRedisplay();
}
/**
* Convenience function to draw a triangle.
*/
GLvoid
piglit_draw_triangle(float x1, float y1, float x2, float y2,
float x3, float y3)
{
piglit_draw_triangle_z(0.0, x1, y1, x2, y2, x3, y3);
}
/**
* Convenience function to draw a triangle at a given depth.
*/
GLvoid
piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
float x3, float y3)
{
float verts[3][4];
verts[0][0] = x1;
verts[0][1] = y1;
verts[0][2] = z;
verts[0][3] = 1.0;
verts[1][0] = x2;
verts[1][1] = y2;
verts[1][2] = z;
verts[1][3] = 1.0;
verts[2][0] = x3;
verts[2][1] = y3;
verts[2][2] = z;
verts[2][3] = 1.0;
glVertexPointer(4, GL_FLOAT, 0, verts);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
}
/**
* Convenience function to draw an axis-aligned rectangle.
*/
......
......@@ -232,6 +232,10 @@ int piglit_use_vertex_program(void);
void piglit_require_fragment_program(void);
void piglit_require_vertex_program(void);
GLuint piglit_compile_program(GLenum target, const char* text);
GLvoid piglit_draw_triangle(float x1, float y1, float x2, float y2,
float x3, float y3);
GLvoid piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
float x3, float y3);
GLvoid piglit_draw_rect(float x, float y, float w, float h);
GLvoid piglit_draw_rect_z(float z, float x, float y, float w, float h);
GLvoid piglit_draw_rect_tex(float x, float y, float w, float h,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment