Use more stable clear color for comparison

* We need to allow for off-by-one errors in our color comparisons
This commit is contained in:
baldurk
2019-09-16 18:50:01 +01:00
parent 5e32e92205
commit f3220bd6fb
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ void main()
glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
glScissor(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
float col[] = {0.4f, 0.5f, 0.6f, 1.0f};
float col[] = {1.0f, 0.0f, 1.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, col);
glBindVertexArray(vao);
+6 -3
View File
@@ -17,13 +17,15 @@ class GL_Parameter_Zoo(rdtest.TestCase):
data = self.controller.GetTextureData(id, 0, 0)
first_pixel = struct.unpack_from("BBBB", data, 0)
val = [int(round(v * 255)) for v in rdtest.linear_to_SRGB([0.4, 0.5, 0.6, 1.0])]
val = [255, 0, 255, 255]
if not rdtest.value_compare(first_pixel, val):
raise rdtest.TestFailureException("First pixel should be clear color {}, not {}".format(val, first_pixel))
magic_pixel = struct.unpack_from("BBBB", data, (50 * tex_details.width + 320) * 4)
if not rdtest.value_compare(magic_pixel, [0, 0, 255, 127]):
# allow 127 or 128 for alpha
val = [0, 0, 255, magic_pixel[3]]
if not rdtest.value_compare(magic_pixel, val) or magic_pixel[3] not in [127, 128]:
raise rdtest.TestFailureException("Pixel @ 320,50 should be blue: {}, not {}".format(val, magic_pixel))
rdtest.log.success("Decoded pixels from texture data are correct")
@@ -43,7 +45,8 @@ class GL_Parameter_Zoo(rdtest.TestCase):
magic_pixel = struct.unpack_from("BBBB", data[-1-50], 320 * 4)
if not rdtest.value_compare(magic_pixel, [0, 0, 255, 127]):
val = [0, 0, 255, magic_pixel[3]]
if not rdtest.value_compare(magic_pixel, val) or magic_pixel[3] not in [127, 128]:
raise rdtest.TestFailureException("Pixel @ 320,50 should be blue: {}, not {}".format(val, magic_pixel))
draw = self.find_draw("Draw")