~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/lightMaps.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
// Copyright (C) 2008-2011 Christian Stehno, Colin MacDonald
 
2
// No rights reserved: this software is in the public domain.
 
3
 
 
4
#include "testUtils.h"
 
5
 
 
6
using namespace irr;
 
7
using namespace core;
 
8
using namespace scene;
 
9
using namespace video;
 
10
using namespace io;
 
11
using namespace gui;
 
12
 
 
13
//! Tests lightmaps under all drivers that support them
 
14
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
 
15
{
 
16
        IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
 
17
        if (!device)
 
18
                return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
 
19
 
 
20
        IVideoDriver* driver = device->getVideoDriver();
 
21
        ISceneManager * smgr = device->getSceneManager();
 
22
 
 
23
        logTestString("Testing driver %ls\n", driver->getName());
 
24
        if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2)
 
25
        {
 
26
                device->closeDevice();
 
27
                device->run();
 
28
                device->drop();
 
29
                return true;
 
30
        }
 
31
 
 
32
        bool result = true;
 
33
        bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
 
34
        assert(added);
 
35
 
 
36
        if(added)
 
37
        {
 
38
                ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
 
39
                assert(node);
 
40
 
 
41
                if (node)
 
42
                {
 
43
                        node->setMaterialFlag(EMF_LIGHTING, false);
 
44
                        node->setPosition(core::vector3df(-1300,-820,-1249));
 
45
                        node->setScale(core::vector3df(1, 5, 1));
 
46
 
 
47
                        (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30));
 
48
 
 
49
                        driver->beginScene(true, true, video::SColor(255,255,255,0));
 
50
                        smgr->drawAll();
 
51
                        driver->endScene();
 
52
 
 
53
                        result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96);
 
54
                }
 
55
        }
 
56
 
 
57
        device->closeDevice();
 
58
        device->run();
 
59
        device->drop();
 
60
 
 
61
        return result;
 
62
}
 
63
 
 
64
 
 
65
bool lightMaps(void)
 
66
{
 
67
        bool result = true;
 
68
        TestWithAllDrivers(runTestWithDriver);
 
69
        return result;
 
70
}
 
71