mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-05 09:50:41 +01:00
2928a632a4
This breaks compiling. To have old values replace false with EZW_OFF and true with EWZ_AUTO. There's a bit history to this change. ZWriteFineControl got introduced after 1.8 so it was never in a released version. Basically it was needed after some changes had been made to allow shaders to have zwrite enabled independent of the material-type (which worked badly for shaders). This had caused other problems as it was then enabled too often instead. So to quickly fix those bugs and avoid breaking compatibility I had introduced a new enum ZWriteFineControl in SMaterial. This worked and didn't break compiling - but I noticed by now that introducing a second flag for this made maintainance for an already very hard to understand problem (figuring out the implementation of transparency and zwriting) even more complicated. So to keep maintance somewhat sane I decided to break compiling now and merge those two flags. The behavior should not be affected by this commit - except for users which set this flag already in their code and have to switch to the enum now. Serialization is switched on loading old files (so SMaterial has enum already and writes that out). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6026 dfc29bdd-3216-0410-991c-e03cc46cb475
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
// Copyright (C) 2008-2012 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 projection matrices
|
|
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();
|
|
|
|
stabilizeScreenBackground(driver);
|
|
|
|
logTestString("Testing driver %ls\n", driver->getName());
|
|
|
|
bool result = true;
|
|
|
|
driver->beginScene(video::ECBF_COLOR, SColor(255,0,0,0));
|
|
|
|
SMaterial mat;
|
|
mat.MaterialType = EMT_SOLID;
|
|
mat.Lighting = false;
|
|
mat.ZBuffer = false;
|
|
mat.ZWriteEnable = video::EZW_OFF;
|
|
mat.Thickness = 1;
|
|
|
|
driver->setMaterial(mat);
|
|
|
|
core::dimension2d<f32> dims(driver->getCurrentRenderTargetSize());
|
|
//apply custom projection, no offset
|
|
core::matrix4 pmtx = matrix4().buildProjectionMatrixOrthoLH(dims.Width, dims.Height, 0, 100);
|
|
driver->setTransform(ETS_PROJECTION, pmtx);
|
|
driver->setTransform(ETS_VIEW, matrix4());
|
|
driver->setTransform(ETS_WORLD, matrix4());
|
|
|
|
//the red cross appears at center
|
|
for (u32 i=0; i<10; ++i)
|
|
{
|
|
driver->draw3DLine(vector3df(0.f+i,-50.f,1.f), vector3df(0.f+i,50.f,1.f), SColor(255,255,0,0));
|
|
driver->draw3DLine(vector3df(-50.f,0.f+i,1.f), vector3df(50.f,0.f+i,1.f), SColor(255,255,0,0));
|
|
}
|
|
|
|
//apply custom projection, offset to right-top
|
|
pmtx.setTranslation(vector3df(0.7f, 0.7f, 0.f));
|
|
driver->setTransform(ETS_PROJECTION, pmtx);
|
|
driver->setTransform(ETS_VIEW, matrix4());
|
|
driver->setTransform(ETS_WORLD, matrix4());
|
|
|
|
//The green cross must be in right-top corner. But for OpenGL driver it is in left-top corner
|
|
for (u32 i=0; i<10; ++i)
|
|
{
|
|
driver->draw3DLine(vector3df(0.f+i,-50,1), vector3df(0.f+i,50,1), SColor(255,0,255,0));
|
|
driver->draw3DLine(vector3df(-50,0.f+i,1), vector3df(50,0.f+i,1), SColor(255,0,255,0));
|
|
}
|
|
|
|
driver->endScene();
|
|
|
|
result = takeScreenshotAndCompareAgainstReference(driver, "-projMat.png", 98.71f);
|
|
|
|
device->closeDevice();
|
|
device->run();
|
|
device->drop();
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
bool projectionMatrix(void)
|
|
{
|
|
bool result = true;
|
|
|
|
// TODO: Seems that software driver does not handle this projection matrix
|
|
TestWithAllDrivers(runTestWithDriver);
|
|
|
|
return result;
|
|
}
|