On 03/28/2018 05:37 AM, Rhys Perry wrote:
GLES2 requires GL_RGBA to be used with GL_UNSIGNED_BYTE in glReadPixels
---
tests/util/piglit-util-gl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index df39c1c87..0504be063 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -1029,10 +1029,10 @@ read_pixels_float(GLint x, GLint y, GLsizei width,
GLsizei height,
return pixels;
}
- pixels_b = malloc(ncomponents * sizeof(GLubyte));
- glReadPixels(x, y, width, height, format, GL_UNSIGNED_BYTE, pixels_b);
+ pixels_b = malloc(width * height * 4 * sizeof(GLubyte));
+ glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_b);
for (i = 0; i < ncomponents; i++)
- pixels[i] = pixels_b[i] / 255.0;
+ pixels[i] = pixels_b[i/ncomponents*4+i%ncomponents] / 255.0;
That looks a bit inefficient to me with all the divides and mods, and a
little hard to follow at first glance.
How about something like this:
int comps = piglit_num_components(format);
int k = 0;
for (i = 0; i < width * height; i++) {
for (j = 0; j < comps; j++) {
pixels[k++] = pixels_b[i * 4 + j] / 255.0f;
}
}
-Brian
free(pixels_b);
return pixels;
}
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit