Commit ed26bc8b authored by hybrid's avatar hybrid

Add test case for polygon offset (depth bias)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3655 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c512692a
...@@ -104,6 +104,7 @@ int main(int argumentCount, char * arguments[]) ...@@ -104,6 +104,7 @@ int main(int argumentCount, char * arguments[])
TEST(drawRectOutline); TEST(drawRectOutline);
TEST(guiDisabledMenu); TEST(guiDisabledMenu);
TEST(makeColorKeyTexture); TEST(makeColorKeyTexture);
TEST(material);
TEST(renderTargetTexture); TEST(renderTargetTexture);
TEST(textureFeatures); TEST(textureFeatures);
TEST(textureRenderStates); TEST(textureRenderStates);
......
#include "testUtils.h"
using namespace irr;
static bool polygonOffset(video::E_DRIVER_TYPE type)
{
IrrlichtDevice* device = createDevice(type, core::dimension2d<u32>(160, 120));
if (device == 0)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
if (!driver->queryFeature(video::EVDF_POLYGON_OFFSET))
return true;
scene::ISceneManager* smgr = device->getSceneManager();
// create first plane
scene::ISceneNode* plane = smgr->addMeshSceneNode(smgr->addHillPlaneMesh(
"plane", core::dimension2df(10,10), core::dimension2du(2,2)), 0, -1,
core::vector3df(0,0,20), core::vector3df(270,0,0));
if (plane)
{
plane->setMaterialTexture(0, driver->getTexture("../media/t351sml.jpg"));
plane->setMaterialFlag(video::EMF_LIGHTING, false);
plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true);
}
// create second plane exactly on top of the first one
scene::ISceneNode* plane2 = smgr->addMeshSceneNode(smgr->addHillPlaneMesh(
"plane2", core::dimension2df(5,5), core::dimension2du(2,2)), 0, -1,
core::vector3df(0,0,20), core::vector3df(270,0,0));
plane2->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
// test back plane to back
plane->getMaterial(0).PolygonOffsetDirection=video::EPO_BACK;
plane->getMaterial(0).PolygonOffsetFactor=7;
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-polygonBack.png");
//reset back plane
plane->getMaterial(0).PolygonOffsetFactor=0;
// test front plane to front
plane2->getMaterial(0).PolygonOffsetDirection=video::EPO_FRONT;
plane2->getMaterial(0).PolygonOffsetFactor=7;
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
result &= takeScreenshotAndCompareAgainstReference(driver, "-polygonFront.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool material()
{
bool result = polygonOffset(video::EDT_OPENGL);
result &= polygonOffset(video::EDT_DIRECT3D9);
return result;
}
\ No newline at end of file
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
<Unit filename="loadTextures.cpp" /> <Unit filename="loadTextures.cpp" />
<Unit filename="main.cpp" /> <Unit filename="main.cpp" />
<Unit filename="makeColorKeyTexture.cpp" /> <Unit filename="makeColorKeyTexture.cpp" />
<Unit filename="material.cpp" />
<Unit filename="matrixOps.cpp" /> <Unit filename="matrixOps.cpp" />
<Unit filename="md2Animation.cpp" /> <Unit filename="md2Animation.cpp" />
<Unit filename="meshLoaders.cpp" /> <Unit filename="meshLoaders.cpp" />
......
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
<ClCompile Include="loadTextures.cpp" /> <ClCompile Include="loadTextures.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="makeColorKeyTexture.cpp" /> <ClCompile Include="makeColorKeyTexture.cpp" />
<ClCompile Include="material.cpp" />
<ClCompile Include="matrixOps.cpp" /> <ClCompile Include="matrixOps.cpp" />
<ClCompile Include="md2Animation.cpp" /> <ClCompile Include="md2Animation.cpp" />
<ClCompile Include="meshLoaders.cpp" /> <ClCompile Include="meshLoaders.cpp" />
...@@ -159,4 +160,4 @@ ...@@ -159,4 +160,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -296,6 +296,10 @@ ...@@ -296,6 +296,10 @@
RelativePath=".\makeColorKeyTexture.cpp" RelativePath=".\makeColorKeyTexture.cpp"
> >
</File> </File>
<File
RelativePath=".\material.cpp"
>
</File>
<File <File
RelativePath=".\matrixOps.cpp" RelativePath=".\matrixOps.cpp"
> >
......
...@@ -295,6 +295,10 @@ ...@@ -295,6 +295,10 @@
RelativePath=".\makeColorKeyTexture.cpp" RelativePath=".\makeColorKeyTexture.cpp"
> >
</File> </File>
<File
RelativePath=".\material.cpp"
>
</File>
<File <File
RelativePath=".\matrixOps.cpp" RelativePath=".\matrixOps.cpp"
> >
......
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