Skip to content

Commit

Permalink
SDLTest_CompareSurfaces: Output RGBA values of first differing pixel
Browse files Browse the repository at this point in the history
Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed Sep 29, 2023
1 parent f3e4bff commit 87be55a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/SDL_test_compare.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
Uint8 *p, *p_reference;
int dist;
int sampleErrorX = 0, sampleErrorY = 0, sampleDist = 0;
SDL_Color sampleReference = { 0, 0, 0, 0 };
SDL_Color sampleActual = { 0, 0, 0, 0 };
Uint8 R, G, B, A;
Uint8 Rd, Gd, Bd, Ad;
char imageFilename[FILENAME_SIZE];
Expand Down Expand Up @@ -106,6 +108,14 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
sampleErrorX = i;
sampleErrorY = j;
sampleDist = dist;
sampleReference.r = Rd;
sampleReference.g = Gd;
sampleReference.b = Bd;
sampleReference.a = Ad;
sampleActual.r = R;
sampleActual.g = G;
sampleActual.b = B;
sampleActual.a = A;
}
}
}
Expand All @@ -121,6 +131,8 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
LogErrorFormat("Reference surface format", referenceSurface->format);
LogErrorFormat("Actual surface format ", surface->format);
SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist);
SDLTest_LogError("Reference pixel: R=%u G=%u B=%u A=%u", sampleReference.r, sampleReference.g, sampleReference.b, sampleReference.a);
SDLTest_LogError("Actual pixel : R=%u G=%u B=%u A=%u", sampleActual.r, sampleActual.g, sampleActual.b, sampleActual.a);
(void)SDL_snprintf(imageFilename, FILENAME_SIZE - 1, "CompareSurfaces%04d_TestOutput.bmp", _CompareSurfaceCount);
SDL_SaveBMP(surface, imageFilename);
(void)SDL_snprintf(referenceFilename, FILENAME_SIZE - 1, "CompareSurfaces%04d_Reference.bmp", _CompareSurfaceCount);
Expand Down

0 comments on commit 87be55a

Please sign in to comment.