aboutsummaryrefslogtreecommitdiff
path: root/tests/lights.cpp
blob: be9341436d7962d92c02107134c8f699b1f16804 (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
// Copyright (C) 2008-2011 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.

#include "testUtils.h"

using namespace irr;

static bool testLightTypes(video::E_DRIVER_TYPE driverType)
{
	IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(128,128));
	if (!device)
		return true; // No error if device does not exist

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	if (!driver->getDriverAttributes().getAttributeAsInt("MaxLights"))
	{
		device->closeDevice();
		device->run();
		device->drop();
		return true;
	}
	logTestString("Testing driver %ls\n", driver->getName());

//	smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
	scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
	cam->setPosition(core::vector3df(0,200,0));
	cam->setTarget(core::vector3df());
	smgr->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(4,4), core::dimension2du(128,128)));
	scene::ILightSceneNode* light1 = smgr->addLightSceneNode(0, core::vector3df(-100,30,-100));
	light1->setLightType(video::ELT_POINT);
	light1->setRadius(100.f);
	light1->getLightData().DiffuseColor.set(0,1,1);
//	smgr->addCubeSceneNode(10, light1)->setMaterialFlag(video::EMF_LIGHTING, false);
	scene::ILightSceneNode* light2 = smgr->addLightSceneNode(0, core::vector3df(100,30,100));
	light2->setRotation(core::vector3df(90,0,0));
	light2->setLightType(video::ELT_SPOT);
	light2->setRadius(100.f);
	light2->getLightData().DiffuseColor.set(1,0,0);
	light2->getLightData().InnerCone=10.f;
	light2->getLightData().OuterCone=30.f;
//	smgr->addCubeSceneNode(10, light2)->setMaterialFlag(video::EMF_LIGHTING, false);
	scene::ILightSceneNode* light3 = smgr->addLightSceneNode();
	light3->setRotation(core::vector3df(15,0,0));
	light3->setLightType(video::ELT_DIRECTIONAL);
	light1->getLightData().DiffuseColor.set(0,1,0);

	driver->beginScene (true, true, 0);
	smgr->drawAll();
	driver->endScene();

	const bool result = takeScreenshotAndCompareAgainstReference(driver, "-lightType.png", 99.91f);

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

	return result;
}

bool lights(void)
{
	bool result = true;
	// no lights in sw renderer
	TestWithAllDrivers(testLightTypes);
	return result;
}