Commit cf9e1223 authored by hybrid's avatar hybrid

Break textureRenderStates test again by adding the test case for the dangling...

Break textureRenderStates test again by adding the test case for the dangling pointer (white texture OpenGL) problem. Fix will follow later, patch exists on the tracker already.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4150 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a346804b
......@@ -110,6 +110,8 @@ bool billboardSize(void)
}
// Test billboard orientation
// Should generate a properly readable (i.e. not mirrored or flipped)
// font file display.
bool billboardOrientation(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
......
......@@ -273,15 +273,78 @@ static bool textureMatrix(video::E_DRIVER_TYPE driverType)
return result;
}
bool danglingTexturePointer()
{
// A demo of the OpenGL "white texture" bug in Irrlicht
// Author: Matt Giuca
// (Vaguely based on the Irrlicht 2D graphics tutorial)
// I have found that in some situations, when using the OpenGL driver, some
// textures appear white.
// This is caused by deleting a texture while it is active (the last texture
// read or written to), and then loading a new texture at the same memory
// location. The new texture will not be loaded properly.
// This demo triggers the bug (though there is some probability that it won't
// be triggered; just run it again until it shows a white square instead of
// the Irrlicht logo).
// This is only a problem in the OpenGL driver
irr::IrrlichtDevice* device = irr::createDevice(irr::video::EDT_OPENGL,
irr::core::dimension2d<irr::u32>(160, 120));
if (!device)
return true;
irr::video::IVideoDriver* driver = device->getVideoDriver();
// Load a texture from a file
// This binds and uploads to OpenGL texture #2.
irr::video::ITexture* logo2 = driver->getTexture("../media/irrlichtlogo2.png");
// Remove the texture from the driver (delete it from hardware)
// This leaves CurrentTexture pointing at logo2
driver->removeTexture(logo2);
// Load another texture from a file
// There is a good probability that logo3 will be allocated the same
// memory address as logo2. If that happens,
// COpenGLDriver::setActiveTexture will not bother to call glBindTextures
// (thinking that logo3 is the same texture as logo2).
// Therefore, the logo3 texture will be uploaded to texture #0, not #2.
irr::video::ITexture* logo3 = driver->getTexture("../media/irrlichtlogo3.png");
device->run();
{
driver->beginScene(true, true, irr::video::SColor(255,100,101,140));
// This is required to trigger the white appearance (this unbinds the
// texture, forcing draw2DImage to rebind the logo3 texture (#2)).
driver->setMaterial(irr::video::SMaterial());
// Since logo3 was uploaded to #0, not #2, this will bind texture #2,
// which has never been written to. OpenGL considers an empty texture
// to be white.
driver->draw2DImage(logo3, irr::core::position2d<irr::s32>(20, 20));
driver->endScene();
}
const bool result = takeScreenshotAndCompareAgainstReference(driver, "-texturePointer.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool textureRenderStates(void)
{
bool result = true;
TestWithAllDrivers(renderAndLoad);
TestWithAllDrivers(renderAndRemove);
TestWithAllDrivers(testTextureMatrixInMixedScenes);
TestWithAllDrivers(manyTextures);
TestWithAllDrivers(textureMatrix);
result &= danglingTexturePointer();
return result;
}
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