aboutsummaryrefslogtreecommitdiff
path: root/tests/lightMaps.cpp
blob: 8d968fe400865907493fca4d4319ac96f81273be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (C) 2008-2011 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.

#include "testUtils.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

//! Tests lightmaps under all drivers that support them
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
	IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
	if (!device)
		return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager * smgr = device->getSceneManager();

	logTestString("Testing driver %ls\n", driver->getName());
	if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2)
	{
		device->closeDevice();
		device->run();
		device->drop();
		return true;
	}

	bool result = true;
	bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
	assert(added);

	if(added)
	{
		ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
		assert(node);

		if (node)
		{
			node->setMaterialFlag(EMF_LIGHTING, false);
			node->setPosition(core::vector3df(-1300,-820,-1249));
			node->setScale(core::vector3df(1, 5, 1));

			(void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30));

			driver->beginScene(true, true, video::SColor(255,255,255,0));
			smgr->drawAll();
			driver->endScene();

			result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96);
		}
	}

	device->closeDevice();
	device->run();
	device->drop();

	return result;
}


bool lightMaps(void)
{
	bool result = true;
	TestWithAllDrivers(runTestWithDriver);
	return result;
}