Commit 79ba8079 authored by hybrid's avatar hybrid

Add two new test cases for user clip planes and drawVertexPrimitive

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4292 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1ea1bbaa
#include "testUtils.h"
using namespace irr;
namespace
{
// this test renders random point clouds using different primitives on top
// tests the primitives type support in general and can hint to differences
// between the drivers
bool testWithDriver(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device =
createDevice(driverType, core::dimension2du(160, 120));
if (!device)
return true;
scene::ISceneManager* smgr = device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
smgr->addCameraSceneNode(0, core::vector3df(128,128,-100), core::vector3df(128,128,128));
scene::SMeshBuffer Buffer;
Buffer.Material.Wireframe = false;
Buffer.Material.Lighting = false;
Buffer.Material.FogEnable = false;
Buffer.Material.BackfaceCulling = false;
Buffer.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
device->getRandomizer()->reset();
const u32 points=256;
Buffer.Vertices.reallocate(points);
for (u32 i=0; i<points; ++i)
{
f32 x = (f32)(1+device->getRandomizer()->rand()%points);
f32 y = (f32)(1+device->getRandomizer()->rand()%points);
f32 z = (f32)(1+device->getRandomizer()->rand()%points);
video::SColor color(255, device->getRandomizer()->rand()%255, device->getRandomizer()->rand()%255, device->getRandomizer()->rand()%255);
Buffer.Vertices.push_back( video::S3DVertex(x,y,z,0,1,0,color,0,0) );
}
Buffer.recalculateBoundingBox();
for (u32 i=0; i<Buffer.Vertices.size(); ++i)
{
Buffer.Indices.push_back(i);
}
bool result = true;
for (u32 Type=scene::EPT_POINTS; Type <= scene::EPT_POINT_SPRITES; ++Type)
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
u32 primCount = 0;
switch (Type)
{
case scene::EPT_POINTS: primCount = Buffer.Indices.size(); break;
case scene::EPT_LINE_STRIP: primCount = Buffer.Indices.size()-1; break;
case scene::EPT_LINE_LOOP: primCount = Buffer.Indices.size()-1; break;
case scene::EPT_LINES: primCount = Buffer.Indices.size()/2; break;
case scene::EPT_TRIANGLE_STRIP: primCount = Buffer.Indices.size()-2; break;
case scene::EPT_TRIANGLE_FAN: primCount = Buffer.Indices.size()-2; break;
case scene::EPT_TRIANGLES: primCount = Buffer.Indices.size()/3; break;
case scene::EPT_QUAD_STRIP: primCount = (Buffer.Indices.size()-2)/4; break;
case scene::EPT_QUADS: primCount = Buffer.Indices.size()/4; break;
case scene::EPT_POLYGON: primCount = Buffer.Indices.size()-1; break;
case scene::EPT_POINT_SPRITES: primCount = Buffer.Indices.size(); break;
default: break;
}
driver->setMaterial(Buffer.Material);
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
driver->drawVertexPrimitiveList(Buffer.getVertices(),
Buffer.getVertexCount(), Buffer.getIndices(), primCount,
video::EVT_STANDARD, (scene::E_PRIMITIVE_TYPE)Type,
video::EIT_16BIT);
driver->endScene();
core::stringc name = "-drawVPL_";
// we use character enumeration as we have more than 9 types
name.append(Type-scene::EPT_POINTS+'a');
name.append(".png");
result &= takeScreenshotAndCompareAgainstReference(driver, name.c_str());
}
device->closeDevice();
device->run();
device->drop();
return result ;
}
}
bool drawVertexPrimitive(void)
{
bool result = true;
TestWithAllDrivers(testWithDriver);
return result;
}
...@@ -105,11 +105,13 @@ int main(int argumentCount, char * arguments[]) ...@@ -105,11 +105,13 @@ int main(int argumentCount, char * arguments[])
TEST(screenshot); TEST(screenshot);
TEST(drawPixel); TEST(drawPixel);
TEST(drawRectOutline); TEST(drawRectOutline);
TEST(drawVertexPrimitive);
TEST(material); TEST(material);
TEST(renderTargetTexture); TEST(renderTargetTexture);
TEST(textureFeatures); TEST(textureFeatures);
TEST(textureRenderStates); TEST(textureRenderStates);
TEST(transparentMaterials); TEST(transparentMaterials);
TEST(userclipplane);
TEST(antiAliasing); TEST(antiAliasing);
TEST(draw2DImage); TEST(draw2DImage);
TEST(lights); TEST(lights);
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
<Unit filename="draw2DImage.cpp" /> <Unit filename="draw2DImage.cpp" />
<Unit filename="drawPixel.cpp" /> <Unit filename="drawPixel.cpp" />
<Unit filename="drawRectOutline.cpp" /> <Unit filename="drawRectOutline.cpp" />
<Unit filename="drawVertexPrimitive.cpp" />
<Unit filename="enumerateImageManipulators.cpp" /> <Unit filename="enumerateImageManipulators.cpp" />
<Unit filename="exports.cpp" /> <Unit filename="exports.cpp" />
<Unit filename="fast_atof.cpp" /> <Unit filename="fast_atof.cpp" />
...@@ -140,6 +141,7 @@ ...@@ -140,6 +141,7 @@
<Unit filename="transparentMaterials.cpp" /> <Unit filename="transparentMaterials.cpp" />
<Unit filename="triangle3d.cpp" /> <Unit filename="triangle3d.cpp" />
<Unit filename="triangleSelector.cpp" /> <Unit filename="triangleSelector.cpp" />
<Unit filename="userClipPlane.cpp" />
<Unit filename="vectorPositionDimension2d.cpp" /> <Unit filename="vectorPositionDimension2d.cpp" />
<Unit filename="videoDriver.cpp" /> <Unit filename="videoDriver.cpp" />
<Unit filename="viewPort.cpp" /> <Unit filename="viewPort.cpp" />
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
<ClCompile Include="draw2DImage.cpp" /> <ClCompile Include="draw2DImage.cpp" />
<ClCompile Include="drawPixel.cpp" /> <ClCompile Include="drawPixel.cpp" />
<ClCompile Include="drawRectOutline.cpp" /> <ClCompile Include="drawRectOutline.cpp" />
<ClCompile Include="drawVertexPrimitive.cpp" />
<ClCompile Include="enumerateImageManipulators.cpp" /> <ClCompile Include="enumerateImageManipulators.cpp" />
<ClCompile Include="exports.cpp" /> <ClCompile Include="exports.cpp" />
<ClCompile Include="fast_atof.cpp" /> <ClCompile Include="fast_atof.cpp" />
...@@ -211,6 +212,7 @@ ...@@ -211,6 +212,7 @@
<ClCompile Include="transparentMaterials.cpp" /> <ClCompile Include="transparentMaterials.cpp" />
<ClCompile Include="triangle3d.cpp" /> <ClCompile Include="triangle3d.cpp" />
<ClCompile Include="triangleSelector.cpp" /> <ClCompile Include="triangleSelector.cpp" />
<ClCompile Include="userClipPlane.cpp" />
<ClCompile Include="vectorPositionDimension2d.cpp" /> <ClCompile Include="vectorPositionDimension2d.cpp" />
<ClCompile Include="videoDriver.cpp" /> <ClCompile Include="videoDriver.cpp" />
<ClCompile Include="viewPort.cpp" /> <ClCompile Include="viewPort.cpp" />
......
...@@ -228,6 +228,10 @@ ...@@ -228,6 +228,10 @@
RelativePath=".\drawRectOutline.cpp" RelativePath=".\drawRectOutline.cpp"
> >
</File> </File>
<File
RelativePath=".\drawVertexPrimitive.cpp"
>
</File>
<File <File
RelativePath=".\enumerateImageManipulators.cpp" RelativePath=".\enumerateImageManipulators.cpp"
> >
...@@ -432,6 +436,10 @@ ...@@ -432,6 +436,10 @@
RelativePath=".\triangleSelector.cpp" RelativePath=".\triangleSelector.cpp"
> >
</File> </File>
<File
RelativePath=".\userClipPlane.cpp"
>
</File>
<File <File
RelativePath=".\vectorPositionDimension2d.cpp" RelativePath=".\vectorPositionDimension2d.cpp"
> >
......
...@@ -227,6 +227,10 @@ ...@@ -227,6 +227,10 @@
RelativePath=".\drawRectOutline.cpp" RelativePath=".\drawRectOutline.cpp"
> >
</File> </File>
<File
RelativePath=".\drawVertexPrimitive.cpp"
>
</File>
<File <File
RelativePath=".\enumerateImageManipulators.cpp" RelativePath=".\enumerateImageManipulators.cpp"
> >
...@@ -427,12 +431,16 @@ ...@@ -427,12 +431,16 @@
RelativePath=".\transparentMaterials.cpp" RelativePath=".\transparentMaterials.cpp"
> >
</File> </File>
<File
RelativePath=".\triangle3d.cpp"
>
</File>
<File <File
RelativePath=".\triangleSelector.cpp" RelativePath=".\triangleSelector.cpp"
> >
</File> </File>
<File <File
RelativePath=".\triangle3d.cpp" RelativePath=".\userClipPlane.cpp"
> >
</File> </File>
<File <File
......
#include "testUtils.h"
using namespace irr;
static bool withSphere(video::E_DRIVER_TYPE type)
{
IrrlichtDevice* device = createDevice(type, core::dimension2d<u32>(640, 480));
if (device == 0)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
smgr->addLightSceneNode(0, core::vector3df(30,30,50));
// create first sphere
scene::ISceneNode* sphere = smgr->addMeshSceneNode(smgr->addSphereMesh("sphere", 10, 64, 64));
if (sphere)
{
sphere->setPosition(core::vector3df(0,10,0));
sphere->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
// sphere->setMaterialFlag(video::EMF_WIREFRAME, true);
}
sphere = smgr->addMeshSceneNode(smgr->addHillPlaneMesh("mesh", core::dimension2df(10,10), core::dimension2du(10,10)));
sphere->setPosition(core::vector3df(0,10,0));
smgr->addCameraSceneNode(0, core::vector3df(-25,30,25), core::vector3df());
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
driver->setMaterial(video::IdentityMaterial);
driver->setClipPlane(0, core::plane3df(core::vector3df(0,18,0), core::vector3df(0,-1,0)), true);
driver->setClipPlane(1, core::plane3df(core::vector3df(0,2,0), core::vector3df(0,1,0)));
driver->setClipPlane(2, core::plane3df(core::vector3df(8,0,0), core::vector3df(-1,0,0)));
// while(device->run())
{
driver->beginScene(true, true, video::SColor(255,113,113,133));
driver->setClipPlane(3, core::plane3df(core::vector3df(-8,0,0), core::vector3df(1,0,0)), true);
driver->setClipPlane(4, core::plane3df(core::vector3df(0,0,8), core::vector3df(0,0,-1)));
driver->setClipPlane(5, core::plane3df(core::vector3df(0,0,-8), core::vector3df(0,0,1)));
driver->enableClipPlane(1, true);
driver->enableClipPlane(2, true);
driver->enableClipPlane(4, true);
driver->enableClipPlane(5, true);
smgr->drawAll();
driver->enableClipPlane(1, false);
driver->enableClipPlane(2, false);
driver->enableClipPlane(4, false);
driver->enableClipPlane(5, false);
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
driver->setMaterial(video::IdentityMaterial);
driver->draw3DLine(core::vector3df(), core::vector3df(0,0,50));
driver->endScene();
}
bool result = takeScreenshotAndCompareAgainstReference(driver, "-ucpsphere.png");
device->closeDevice();
device->drop();
return result;
}
bool userclipplane()
{
bool result = true;
TestWithAllHWDrivers(withSphere);
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