1
// Copyright (C) 2008-2011 Christian Stehno, Colin MacDonald
2
// No rights reserved: this software is in the public domain.
13
//! Tests projection matrices
14
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
16
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
18
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
20
IVideoDriver* driver = device->getVideoDriver();
22
logTestString("Testing driver %ls\n", driver->getName());
26
driver->beginScene(true, false, SColor(255,0,0,0));
29
mat.MaterialType = EMT_SOLID;
32
mat.ZWriteEnable = false;
35
driver->setMaterial(mat);
37
core::dimension2d<f32> dims(driver->getCurrentRenderTargetSize());
38
//apply custom projection, no offset
39
core::matrix4 pmtx = matrix4().buildProjectionMatrixOrthoLH(dims.Width, dims.Height, 0, 100);
40
driver->setTransform(ETS_PROJECTION, pmtx);
41
driver->setTransform(ETS_VIEW, matrix4());
42
driver->setTransform(ETS_WORLD, matrix4());
44
//the red cross appears at center
45
for (u32 i=0; i<10; ++i)
47
driver->draw3DLine(vector3df(0.f+i,-50.f,1.f), vector3df(0.f+i,50.f,1.f), SColor(255,255,0,0));
48
driver->draw3DLine(vector3df(-50.f,0.f+i,1.f), vector3df(50.f,0.f+i,1.f), SColor(255,255,0,0));
51
//apply custom projection, offset to right-top
52
pmtx.setTranslation(vector3df(0.7f, 0.7f, 0.f));
53
driver->setTransform(ETS_PROJECTION, pmtx);
54
driver->setTransform(ETS_VIEW, matrix4());
55
driver->setTransform(ETS_WORLD, matrix4());
57
//The green cross must be in right-top corner. But for OpenGL driver it is in left-top corner
58
for (u32 i=0; i<10; ++i)
60
driver->draw3DLine(vector3df(0.f+i,-50,1), vector3df(0.f+i,50,1), SColor(255,0,255,0));
61
driver->draw3DLine(vector3df(-50,0.f+i,1), vector3df(50,0.f+i,1), SColor(255,0,255,0));
66
result = takeScreenshotAndCompareAgainstReference(driver, "-projMat.png", 98.71f);
68
device->closeDevice();
76
bool projectionMatrix(void)
80
// TODO: Seems that software driver does not handle this projection matrix
81
TestWithAllDrivers(runTestWithDriver);