From 45e484cc00fd131c2b3769a2277dc9b94721f09f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 May 2014 23:52:01 +0300 Subject: In max texture test, check actual texture drawing. --- src/test/testlauncher.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 7ed08ad50..0ba6ab97b 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -193,22 +193,66 @@ int TestLauncher::testTextures() if (sz > 16500) sz = 16500; + const uint32_t bytes1[] = + { + 0xFFFF0000U, 0xFFFFFF00U, 0xFF00FFFFU, 0xFF0000FFU, + 0xFF000000U, 0xFFFF00FFU + }; + + const uint32_t bytes2[] = + { + 0x00FF0000U, 0xFFFFFFFFU, 0x0000FF00U, 0xFF000000U, + 0x0000FF00U, 0x00000000U + }; + for (nextSize = 512; nextSize < sz; nextSize *= 2) { + mainGraphics->clearScreen(); SDL_Surface *const surface = imageHelper->create32BitSurface( nextSize, nextSize); if (!surface) break; + uint32_t *pixels = static_cast(surface->pixels); + for (int f = 0; f < 6; f ++) + pixels[f] = bytes1[f]; graphicsManager.getLastError(); graphicsManager.resetCachedError(); Image *const image = imageHelper->load(surface); + SDL_FreeSurface(surface); if (!image) break; + if (graphicsManager.getLastErrorCached() != GL_NO_ERROR) + { + delete image; + break; + } + Image *const subImage = image->getSubImage(0, 0, 10, 10); + if (!subImage) + { + delete image; break; + } + mainGraphics->drawImage(subImage, 0, 0); + mainGraphics->updateScreen(); + mainGraphics->drawImage(subImage, 0, 0); + delete subImage; + SDL_Surface *const screen = mainGraphics->getScreenshot(); + pixels = static_cast(screen->pixels); + bool fail(false); + for (int f = 0; f < 6; f ++) + { +// printf("diff: %d, %x and %x\n", f, pixels[f], bytes2[f]); + if (pixels[f] != bytes2[f]) + { + fail = true; + break; + } + } - delete image; - SDL_FreeSurface(surface); + SDL_FreeSurface(screen); + if (fail) + break; maxSize = nextSize; } -- cgit v1.2.3-70-g09d2