1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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)
{
}
|