Commit 1e4a0a77 authored by cutealien's avatar cutealien

Fix screenshots under Linux/OpenGL for formats ECF_R5G6B5 (failed before) and...

Fix screenshots under Linux/OpenGL for formats ECF_R5G6B5 (failed before) and ECF_R8G8B8 (red and blue where switched). Note that R5G6B5 still has strange results when writing to file. But that's due to a bug in color-conversion, which is fixed already in 1.7 and will be merged to trunk soon.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4185 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 94968c4a
......@@ -4391,11 +4391,11 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
break;
case ECF_R5G6B5:
fmt = GL_BGR;
type = GL_UNSIGNED_SHORT_5_6_5_REV;
fmt = GL_RGB;
type = GL_UNSIGNED_SHORT_5_6_5;
break;
case ECF_R8G8B8:
fmt = GL_BGR;
fmt = GL_RGB;
type = GL_UNSIGNED_BYTE;
break;
case ECF_A8R8G8B8:
......
......@@ -5,6 +5,8 @@
using namespace irr;
// Tests screenshots features
bool testShots(video::E_DRIVER_TYPE type)
{
......@@ -33,7 +35,7 @@ bool testShots(video::E_DRIVER_TYPE type)
node->setMaterialTexture(0, driver->getTexture("../media/sydney.bmp"));
node->setLoopMode(false);
(void)smgr->addCameraSceneNode();
smgr->addCameraSceneNode();
node->setMD2Animation(scene::EMAT_DEATH_FALLBACK);
node->setCurrentFrame((f32)(node->getEndFrame()));
......@@ -48,6 +50,21 @@ bool testShots(video::E_DRIVER_TYPE type)
{
video::IImage* img = driver->createScreenShot((video::ECOLOR_FORMAT)i);
logTestString("Color Format %d %ssupported\n", i, (img && img->getColorFormat() == i)?"":"un");
#if 0 // Enable for a quick check while testing.
// If someone adds comparison images please use another scene without animation
// and maybe a texture using the full color spectrum.
if ( img )
{
irr::core::stringc screenshotFilename = "results/";
screenshotFilename += shortDriverName(driver);
screenshotFilename += "screenshot";
screenshotFilename += core::stringc(i);
screenshotFilename += ".png";
driver->writeImageToFile(img, screenshotFilename.c_str());
}
#endif
if (img)
img->drop();
}
......
......@@ -384,6 +384,21 @@ void stabilizeScreenBackground(irr::video::IVideoDriver * driver,
}
}
irr::core::stringc shortDriverName(irr::video::IVideoDriver * driver)
{
irr::core::stringc driverName = driver->getName();
// For OpenGL and Burning, chop the version number out. Other drivers have more stable version numbers.
// TA: Sorry Rogerborg. burnings video also has the version number inside;-)
// maybe you sould take the getDriverType Info for this
if(driverName.find("OpenGL") > -1)
driverName = "OpenGL";
else if(driverName.find("Burning's Video") > -1)
driverName = "Burning's Video";
return driverName;
}
bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver,
const char * fileName,
irr::f32 requiredMatch)
......@@ -413,15 +428,7 @@ bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver,
screenshot = fixedScreenshot;
}
irr::core::stringc driverName = driver->getName();
// For OpenGL and Burning, chop the version number out. Other drivers have more stable version numbers.
// TA: Sorry Rogerborg. burnings video also has the version number inside;-)
// maybe you sould take the getDriverType Info for this
if(driverName.find("OpenGL") > -1)
driverName = "OpenGL";
else if(driverName.find("Burning's Video") > -1)
driverName = "Burning's Video";
irr::core::stringc driverName = shortDriverName(driver);
irr::core::stringc referenceFilename = "media/";
referenceFilename += driverName;
......
......@@ -77,4 +77,7 @@ extern void closeTestLog();
\... optional parameters */
extern void logTestString(const char * format, ...);
//! Return a drivername for the driver which is useable in filenames
extern irr::core::stringc shortDriverName(irr::video::IVideoDriver * driver);
#endif // _TEST_UTILS_H_
Tests finished. 1 test of 1 passed.
Compiled as DEBUG
Test suite pass at GMT Mon Jun 11 15:15:12 2012
Test suite pass at GMT Tue Jun 12 20:48:10 2012
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment