~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/anti-aliasing.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "testUtils.h"
 
2
 
 
3
using namespace irr;
 
4
 
 
5
static bool testLineRendering(video::E_DRIVER_TYPE type)
 
6
{
 
7
        SIrrlichtCreationParameters params;
 
8
        params.AntiAlias = 2;
 
9
        params.Bits = 16;
 
10
        params.WindowSize = core::dimension2d<u32>(160, 120);
 
11
        params.DriverType = type;
 
12
 
 
13
        IrrlichtDevice *device = createDeviceEx(params);
 
14
 
 
15
        if (!device)
 
16
                return true; // in case the driver type does not exist
 
17
 
 
18
        video::IVideoDriver* driver = device->getVideoDriver();
 
19
        // if no AntiAliasing supported, skip this test
 
20
        if (driver->getDriverAttributes().getAttributeAsInt("AntiAlias")<2)
 
21
        {
 
22
                device->closeDevice();
 
23
                device->run();
 
24
                device->drop();
 
25
                return true;
 
26
        }
 
27
 
 
28
        logTestString("Testing driver %ls\n", driver->getName());
 
29
 
 
30
        scene::ISceneManager* smgr = device->getSceneManager();
 
31
 
 
32
        scene::IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
 
33
        if (!mesh)
 
34
        {
 
35
                device->closeDevice();
 
36
                device->run();
 
37
                device->drop();
 
38
                return false;
 
39
        }
 
40
        scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
 
41
 
 
42
        if (node)
 
43
        {
 
44
                node->setMaterialFlag(video::EMF_LIGHTING, false);
 
45
                node->setMD2Animation(scene::EMAT_STAND);
 
46
                node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
 
47
        }
 
48
 
 
49
        smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0));
 
50
 
 
51
        driver->beginScene(true, true, video::SColor(255,100,101,140));
 
52
        smgr->drawAll();
 
53
        driver->draw3DBox(node->getBoundingBox(), video::SColor(0,255,0,0));
 
54
        driver->draw2DLine(core::position2di(10,10), core::position2di(100,100), video::SColor(255,0,0,0));
 
55
        driver->endScene();
 
56
 
 
57
        bool result = takeScreenshotAndCompareAgainstReference(driver, "-lineAntiAliasing.png", 99.17f );
 
58
 
 
59
        device->closeDevice();
 
60
        device->run();
 
61
        device->drop();
 
62
    return result;
 
63
 
64
 
 
65
bool antiAliasing()
 
66
{
 
67
        bool result = true;
 
68
        TestWithAllHWDrivers(testLineRendering);
 
69
        return result;
 
70
}