diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2018-03-23 18:16:29 -0700 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2018-03-23 18:16:29 -0700 |
commit | 81507c5001e6b19c9da239372471aceacd8eb5c2 (patch) | |
tree | aaee280000cc2ec9cb9fe65a72d2eb93e92f8dfd | |
parent | b8e7cc0e59cf21fe5f98a2d8280cf9a03d02f542 (diff) |
added heart test.
-rw-r--r-- | tests/all.py | 1 | ||||
-rw-r--r-- | tests/spec/gl-1.0/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/gl-1.0/bitmap-heart-dance.c | 122 |
3 files changed, 124 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 4cd911fab..bedf03206 100644 --- a/tests/all.py +++ b/tests/all.py @@ -722,6 +722,7 @@ with profile.test_list.group_manager( PiglitGLTest, grouptools.join('spec', '!opengl 1.0')) as g: g(['gl-1.0-beginend-coverage']) + g(['gl-1.0-bitmap-heart-dance']) g(['gl-1.0-dlist-beginend']) g(['gl-1.0-dlist-bitmap']) g(['gl-1.0-dlist-materials']) diff --git a/tests/spec/gl-1.0/CMakeLists.gl.txt b/tests/spec/gl-1.0/CMakeLists.gl.txt index e5986968c..c97a160fc 100644 --- a/tests/spec/gl-1.0/CMakeLists.gl.txt +++ b/tests/spec/gl-1.0/CMakeLists.gl.txt @@ -10,6 +10,7 @@ link_libraries ( piglit_add_executable (gl-1.0-user-clip-all-planes user-clip-all-planes.c) piglit_add_executable (gl-1.0-beginend-coverage beginend-coverage.c) +piglit_add_executable (gl-1.0-bitmap-heart-dance bitmap-heart-dance.c) piglit_add_executable (gl-1.0-blend-func blend.c) piglit_add_executable (gl-1.0-dlist-beginend dlist-beginend.c) piglit_add_executable (gl-1.0-dlist-bitmap dlist-bitmap.c) diff --git a/tests/spec/gl-1.0/bitmap-heart-dance.c b/tests/spec/gl-1.0/bitmap-heart-dance.c new file mode 100644 index 000000000..444cac847 --- /dev/null +++ b/tests/spec/gl-1.0/bitmap-heart-dance.c @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2018 Laura Ekstrand + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/** + * Test glBitmap in a methodical way using a series of heart shapes. + * Heart shape is diagram A.2 from Garnstudio free sock pattern Heart Dance + * (https://www.garnstudio.com/pattern.php?id=7440&cid=17). + * Knitting color work is basically glBitmap for knits! + * + * _ * _ _ _ * _ _ where _ = 0 + * * * * _ * * * _ * = 1 + * * * * * * * * _ + * * * * * * * * _ + * _ * * * * * _ _ + * _ _ * * * _ _ _ + * _ _ _ * _ _ _ _ + * _ _ _ _ _ _ _ _ + * + * Or: Little end Big end + * 0 1 0 0 0 1 0 0 68 0x44 0x22 + * 1 1 1 0 1 1 1 0 238 0xEE 0x77 + * 1 1 1 1 1 1 1 0 254 0xFE 0xF7 + * 1 1 1 1 1 1 1 0 254 0xFE 0xF7 + * 0 1 1 1 1 1 0 0 124 0x7C 0xE3 + * 0 0 1 1 1 0 0 0 56 0x38 0xC2 + * 0 0 0 1 0 0 0 0 16 0x10 0x80 + * 0 0 0 0 0 0 0 0 0 0x00 0x00 + * + * Laura Ekstrand + * March 2018 + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + config.window_width = 900; + config.window_height = 300; + config.khr_no_error_support = PIGLIT_NO_ERRORS; +PIGLIT_GL_TEST_CONFIG_END + +static GLubyte *refImage; +static const float red[3] = {0.502, 0.082, 0.082}; +static const float salmon[3] = {1.000, 0.353, 0.353}; +static const float pink[3] = {0.945, 0.471, 0.639}; +static const float orange[3] = {1.000, 0.286, 0.000}; +static const float ltorange[3] = {1.000, 0.514, 0.322}; +static const float yellow[3] = {1.000, 0.871, 0.133}; +static GLubyte bitmap[8] = { 0x00, 0x10, 0x38, 0x7C, + 0xFE, 0xFE, 0xEE, 0x44 }; + +static void +draw_row(const float* color, int length, + int x, int y, int spacex) { + glColor3fv(color); + glRasterPos2f(x, y); + for (int i = 0; i < length; i++) { + // A line of hearts. + glBitmap(8, 8, 2, 2, 8 + spacex, 0, bitmap); + } +} + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + unsigned numBytes = piglit_width * piglit_height * 4 * sizeof(GLubyte); + int length = 17; + int x = 50; + int spacing = 40; + + refImage = malloc(numBytes); + + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glViewport(0, 0, piglit_width, piglit_height); + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + glClear(GL_COLOR_BUFFER_BIT); + draw_row( red, length, x, 50 + 5*spacing, spacing); + draw_row( salmon, length, x, 50 + 4*spacing, spacing); + draw_row( pink, length, x, 50 + 3*spacing, spacing); + draw_row( orange, length, x, 50 + 2*spacing, spacing); + draw_row(ltorange, length, x, 50 + 1*spacing, spacing); + draw_row( yellow, length, x, 50 + 0*spacing, spacing); + + glReadPixels(0, 0, piglit_width, piglit_height, + GL_RGBA, GL_UNSIGNED_BYTE, refImage); + + piglit_present_results(); + + free(refImage); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ +} |