diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-25 23:52:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-25 23:52:01 +0300 |
commit | 45e484cc00fd131c2b3769a2277dc9b94721f09f (patch) | |
tree | 073c939ad462662df114f7cdacbac476fc5d2a49 /src/test | |
parent | 48d4aa03fac4c20f40bbc35d2395a12a4714ca2c (diff) | |
download | manaverse-45e484cc00fd131c2b3769a2277dc9b94721f09f.tar.gz manaverse-45e484cc00fd131c2b3769a2277dc9b94721f09f.tar.bz2 manaverse-45e484cc00fd131c2b3769a2277dc9b94721f09f.tar.xz manaverse-45e484cc00fd131c2b3769a2277dc9b94721f09f.zip |
In max texture test, check actual texture drawing.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/testlauncher.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
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<uint32_t*>(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<uint32_t*>(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; } |