Merged from trunk, revisions 3366-3387. A few bug fixes all over the place.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3388 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
531a697d6a
commit
7e236b0192
|
@ -99,6 +99,10 @@ Changes in 1.8 (??.0?.2010)
|
|||
-----------------------------
|
||||
Changes in 1.7.2 (??.??.2010)
|
||||
|
||||
- Fix blend mode setup in OpenGL driver, when using the material2d override, as pointed out by Auria
|
||||
|
||||
- Fix image creation from texture, found by dataslayer
|
||||
|
||||
- Fix crashes when taking Screenhots for DirectX in Windowed mode (thx to agamemnus for reporting)
|
||||
|
||||
- StaticText does now serialize the background color
|
||||
|
|
|
@ -90,6 +90,7 @@ class line2d
|
|||
if(equals(commonDenominator, 0.f))
|
||||
{
|
||||
// The lines are either coincident or parallel
|
||||
// if both numerators are 0, the lines are coincident
|
||||
if(equals(numeratorA, 0.f) && equals(numeratorB, 0.f))
|
||||
{
|
||||
// Try and find a common endpoint
|
||||
|
@ -97,10 +98,52 @@ class line2d
|
|||
out = start;
|
||||
else if(l.end == end || l.start == end)
|
||||
out = end;
|
||||
// now check if the two segments are disjunct
|
||||
else if (l.start.X>start.X && l.end.X>start.X && l.start.X>end.X && l.end.X>end.X)
|
||||
return false;
|
||||
else if (l.start.Y>start.Y && l.end.Y>start.Y && l.start.Y>end.Y && l.end.Y>end.Y)
|
||||
return false;
|
||||
else if (l.start.X<start.X && l.end.X<start.X && l.start.X<end.X && l.end.X<end.X)
|
||||
return false;
|
||||
else if (l.start.Y<start.Y && l.end.Y<start.Y && l.start.Y<end.Y && l.end.Y<end.Y)
|
||||
return false;
|
||||
// else the lines are overlapping to some extent
|
||||
else
|
||||
// one line is contained in the other, so for lack of a better
|
||||
// answer, pick the average of both lines
|
||||
out = ((start + end + l.start + l.end) * 0.25f);
|
||||
{
|
||||
// find the points which are not contributing to the
|
||||
// common part
|
||||
vector2d<T> maxp;
|
||||
vector2d<T> minp;
|
||||
if ((start.X>l.start.X && start.X>l.end.X && start.X>end.X) || (start.Y>l.start.Y && start.Y>l.end.Y && start.Y>end.Y))
|
||||
maxp=start;
|
||||
else if ((end.X>l.start.X && end.X>l.end.X && end.X>start.X) || (end.Y>l.start.Y && end.Y>l.end.Y && end.Y>start.Y))
|
||||
maxp=end;
|
||||
else if ((l.start.X>start.X && l.start.X>l.end.X && l.start.X>end.X) || (l.start.Y>start.Y && l.start.Y>l.end.Y && l.start.Y>end.Y))
|
||||
maxp=l.start;
|
||||
else
|
||||
maxp=l.end;
|
||||
if (maxp != start && ((start.X<l.start.X && start.X<l.end.X && start.X<end.X) || (start.Y<l.start.Y && start.Y<l.end.Y && start.Y<end.Y)))
|
||||
minp=start;
|
||||
else if (maxp != end && ((end.X<l.start.X && end.X<l.end.X && end.X<start.X) || (end.Y<l.start.Y && end.Y<l.end.Y && end.Y<start.Y)))
|
||||
minp=end;
|
||||
else if (maxp != l.start && ((l.start.X<start.X && l.start.X<l.end.X && l.start.X<end.X) || (l.start.Y<start.Y && l.start.Y<l.end.Y && l.start.Y<end.Y)))
|
||||
minp=l.start;
|
||||
else
|
||||
minp=l.end;
|
||||
|
||||
// one line is contained in the other. Pick the center
|
||||
// of the remaining points, which overlap for sure
|
||||
out = core::vector2d<T>();
|
||||
if (start != maxp && start != minp)
|
||||
out += start;
|
||||
if (end != maxp && end != minp)
|
||||
out += end;
|
||||
if (l.start != maxp && l.start != minp)
|
||||
out += l.start;
|
||||
if (l.end != maxp && l.end != minp)
|
||||
out += l.end;
|
||||
out *= 0.5f;
|
||||
}
|
||||
|
||||
return true; // coincident
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ namespace core
|
|||
CMatrix4<T>& buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point=1.0f);
|
||||
|
||||
//! Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates.
|
||||
/** Used to scale <-1,-1><1,1> to viewport, for example from von <-1,-1> <1,1> to the viewport <0,0><0,640> */
|
||||
/** Used to scale <-1,-1><1,1> to viewport, for example from <-1,-1> <1,1> to the viewport <0,0><0,640> */
|
||||
CMatrix4<T>& buildNDCToDCMatrix( const core::rect<s32>& area, f32 zScale);
|
||||
|
||||
//! Creates a new matrix as interpolated matrix from two other ones.
|
||||
|
|
|
@ -951,8 +951,8 @@ void CD3D8Driver::draw2D3DVertexPrimitiveList(const void* vertices,
|
|||
case scene::EPT_LINE_LOOP:
|
||||
{
|
||||
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
|
||||
primitiveCount, indexList, indexType, vertices, stride);
|
||||
u16 tmpIndices[] = {0, primitiveCount};
|
||||
primitiveCount - 1, indexList, indexType, vertices, stride);
|
||||
u16 tmpIndices[] = {primitiveCount - 1, 0};
|
||||
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
|
||||
1, tmpIndices, indexType, vertices, stride);
|
||||
}
|
||||
|
|
|
@ -1463,9 +1463,9 @@ void CD3D9Driver::draw2D3DVertexPrimitiveList(const void* vertices,
|
|||
else
|
||||
{
|
||||
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
|
||||
primitiveCount, indexList, indexType, vertices, stride);
|
||||
primitiveCount - 1, indexList, indexType, vertices, stride);
|
||||
|
||||
u16 tmpIndices[] = {0, primitiveCount};
|
||||
u16 tmpIndices[] = {primitiveCount - 1, 0};
|
||||
|
||||
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
|
||||
1, tmpIndices, indexType, vertices, stride);
|
||||
|
|
|
@ -578,23 +578,22 @@ public:
|
|||
{
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
||||
|
||||
pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 );
|
||||
pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
|
||||
pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
|
||||
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
pID3DDevice->SetTransform(D3DTS_TEXTURE1, &SphereMapMatrixD3D9 );
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
|
||||
|
||||
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
|
||||
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
}
|
||||
|
||||
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
@ -602,9 +601,9 @@ public:
|
|||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
|
||||
pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
|
||||
pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 );
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
|
||||
pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
|
||||
pID3DDevice->SetTransform(D3DTS_TEXTURE1, &UnitMatrixD3D9);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent. The scene managment needs to know this
|
||||
|
|
|
@ -1414,7 +1414,7 @@ IImage* CNullDriver::createImage(IImage* imageToCopy, const core::position2d<s32
|
|||
//! Creates a software image from part of a texture.
|
||||
IImage* CNullDriver::createImage(ITexture* texture, const core::position2d<s32>& pos, const core::dimension2d<u32>& size)
|
||||
{
|
||||
if (pos==core::position2di(0,0) && size == texture->getSize())
|
||||
if ((pos==core::position2di(0,0)) && (size == texture->getSize()))
|
||||
{
|
||||
IImage* image = new CImage(texture->getColorFormat(), size, texture->lock(true), false);
|
||||
texture->unlock();
|
||||
|
@ -1431,14 +1431,16 @@ IImage* CNullDriver::createImage(ITexture* texture, const core::position2d<s32>&
|
|||
core::clamp(static_cast<u32>(size.Height), 0u, texture->getSize().Height)));
|
||||
if (!clamped.isValid())
|
||||
return 0;
|
||||
void* src = texture->lock(true);
|
||||
u8* src = static_cast<u8*>(texture->lock(true));
|
||||
if (!src)
|
||||
return 0;
|
||||
IImage* image = new CImage(texture->getColorFormat(), clamped.getSize());
|
||||
void* dst = image->lock();
|
||||
for (u32 i=clamped.UpperLeftCorner.X; i<clamped.getHeight(); ++i)
|
||||
u8* dst = static_cast<u8*>(image->lock());
|
||||
for (u32 i=clamped.UpperLeftCorner.Y; i<clamped.getHeight(); ++i)
|
||||
{
|
||||
video::CColorConverter::convert_viaFormat(src, texture->getColorFormat(), clamped.getWidth(), dst, image->getColorFormat());
|
||||
src += texture->getPitch();
|
||||
dst += image->getPitch();
|
||||
}
|
||||
image->unlock();
|
||||
texture->unlock();
|
||||
|
|
|
@ -2997,8 +2997,8 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
|||
{
|
||||
setBasicRenderStates(InitMaterial2D, LastMaterial, true);
|
||||
LastMaterial = InitMaterial2D;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
if (OverrideMaterial2DEnabled)
|
||||
{
|
||||
|
|
|
@ -110,7 +110,7 @@ bool CArchiveLoaderTAR::isALoadableFileFormat(io::IReadFile* file) const
|
|||
checksum2 += c8(*p);
|
||||
}
|
||||
|
||||
if (!strcmp(fHead.Magic, "star"))
|
||||
if (!strncmp(fHead.Magic, "ustar", 5))
|
||||
{
|
||||
for (u8* p = (u8*)(&fHead.Magic[0]); p < (u8*)(&fHead) + sizeof(fHead); ++p)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ u32 CTarReader::populateFileList()
|
|||
|
||||
// USTAR archives have a filename prefix
|
||||
// may not be null terminated, copy carefully!
|
||||
if (!strcmp(fHead.Magic, "ustar"))
|
||||
if (!strncmp(fHead.Magic, "ustar", 5))
|
||||
{
|
||||
c8* np = fHead.FileNamePrefix;
|
||||
while(*np && (np - fHead.FileNamePrefix) < 155)
|
||||
|
|
|
@ -35,12 +35,13 @@ namespace io
|
|||
{
|
||||
ETLI_REGULAR_FILE_OLD = 0 ,
|
||||
ETLI_REGULAR_FILE = '0',
|
||||
ETLI_LINK_TO_ARCHIVED_FILE = '1',
|
||||
ETLI_LINK_TO_ARCHIVED_FILE = '1', // Hard link
|
||||
ETLI_SYMBOLIC_LINK = '2',
|
||||
ETLI_CHAR_SPECIAL_DEVICE = '3',
|
||||
ETLI_BLOCK_SPECIAL_DEVICE = '4',
|
||||
ETLI_DIRECTORY = '5',
|
||||
ETLI_FIFO_SPECIAL_FILE = '6'
|
||||
ETLI_FIFO_SPECIAL_FILE = '6',
|
||||
ETLI_CONTIGUOUS_FILE = '7'
|
||||
};
|
||||
|
||||
struct STarHeader
|
||||
|
|
|
@ -330,7 +330,9 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
|
|||
{
|
||||
verticesLinkIndex[i] = buffer->Vertices_2TCoords.size();
|
||||
buffer->Vertices_2TCoords.push_back( mesh->Vertices[i] );
|
||||
buffer->Vertices_2TCoords.getLast().TCoords2=mesh->TCoords2[i];
|
||||
// We have a problem with correct tcoord2 handling here
|
||||
// crash fixed for now by checking the values
|
||||
buffer->Vertices_2TCoords.getLast().TCoords2=(i<mesh->TCoords2.size())?mesh->TCoords2[i]:mesh->Vertices[i].TCoords;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
#include "testUtils.h"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
static bool addBlend2d(video::E_DRIVER_TYPE type)
|
||||
{
|
||||
SIrrlichtCreationParameters params;
|
||||
params.AntiAlias = 0;
|
||||
params.Bits = 16;
|
||||
params.WindowSize = core::dimension2d<u32>(160, 120);
|
||||
params.DriverType = type;
|
||||
|
||||
IrrlichtDevice *device = createDeviceEx(params);
|
||||
|
||||
if (!device)
|
||||
return true; // in case the driver type does not exist
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
scene::IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
|
||||
if (!mesh)
|
||||
{
|
||||
device->drop();
|
||||
return false;
|
||||
}
|
||||
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
|
||||
|
||||
if (node)
|
||||
{
|
||||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
node->setMD2Animation(scene::EMAT_STAND);
|
||||
node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
|
||||
}
|
||||
|
||||
smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0));
|
||||
|
||||
gui::IGUIEnvironment* env = device->getGUIEnvironment();
|
||||
{
|
||||
gui::IGUIElement* root = env->getRootGUIElement();
|
||||
|
||||
// create the toolbox window
|
||||
gui::IGUIWindow* wnd = env->addWindow(core::rect<s32>(0,0,800,480),
|
||||
false, L"Toolset", 0, 100);
|
||||
|
||||
// create tab control and tabs
|
||||
gui::IGUITabControl* tab = env->addTabControl(
|
||||
core::rect<s32>(2,20,800-602,480-7), wnd, true, true);
|
||||
|
||||
gui::IGUITab* t1 = tab->addTab(L"Config");
|
||||
|
||||
// add some edit boxes and a button to tab one
|
||||
env->addStaticText(L"Scale:",
|
||||
core::rect<s32>(10,20,60,45), false, false, t1);
|
||||
env->addStaticText(L"X:", core::rect<s32>(22,48,40,66), false, false, t1);
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,46,130,66), true, t1, 201);
|
||||
env->addStaticText(L"Y:", core::rect<s32>(22,82,40,96), false, false, t1);
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,76,130,96), true, t1, 202);
|
||||
env->addStaticText(L"Z:", core::rect<s32>(22,108,40,126), false, false, t1);
|
||||
env->addEditBox(L"1.0", core::rect<s32>(40,106,130,126), true, t1, 203);
|
||||
|
||||
env->addButton(core::rect<s32>(10,134,85,165), t1, 101, L"Set");
|
||||
|
||||
// quick scale buttons
|
||||
env->addButton(core::rect<s32>(65,20,95,40), t1, 102, L"* 10");
|
||||
env->addButton(core::rect<s32>(100,20,130,40), t1, 103, L"* 0.1");
|
||||
|
||||
// add transparency control
|
||||
env->addStaticText(L"GUI Transparency Control:",
|
||||
core::rect<s32>(10,200,150,225), true, false, t1);
|
||||
gui::IGUIScrollBar* scrollbar = env->addScrollBar(true,
|
||||
core::rect<s32>(10,225,150,240), t1, 104);
|
||||
scrollbar->setMax(255);
|
||||
scrollbar->setPos(255);
|
||||
|
||||
// add framerate control
|
||||
env->addStaticText(L":", core::rect<s32>(10,240,150,265), true, false, t1);
|
||||
env->addStaticText(L"Framerate:",
|
||||
core::rect<s32>(12,240,75,265), false, false, t1);
|
||||
env->addStaticText(L"", core::rect<s32>(75,240,200,265), false, false, t1,
|
||||
105);
|
||||
scrollbar = env->addScrollBar(true,
|
||||
core::rect<s32>(10,265,150,280), t1, 106);
|
||||
scrollbar->setMax(100);
|
||||
scrollbar->setMin(-100);
|
||||
scrollbar->setPos(20);
|
||||
scrollbar->setSmallStep(1);
|
||||
}
|
||||
video::SMaterial& material2D = driver->getMaterial2D();
|
||||
material2D.setFlag(video::EMF_ANTI_ALIASING, true);
|
||||
for (unsigned int n=0; n<video::MATERIAL_MAX_TEXTURES; n++)
|
||||
{
|
||||
material2D.TextureLayer[n].BilinearFilter = true;
|
||||
//material2D.TextureLayer[n].TextureWrap = ETC_CLAMP_TO_EDGE;
|
||||
material2D.TextureLayer[n].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
|
||||
material2D.TextureLayer[n].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
||||
material2D.TextureLayer[n].LODBias = 8;
|
||||
}
|
||||
material2D.AntiAliasing=video::EAAM_FULL_BASIC;
|
||||
|
||||
driver->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
smgr->drawAll();
|
||||
driver->enableMaterial2D();
|
||||
env->drawAll();
|
||||
driver->enableMaterial2D(false);
|
||||
driver->endScene();
|
||||
|
||||
bool result = takeScreenshotAndCompareAgainstReference(driver, "-addBlend2D.png" );
|
||||
|
||||
device->drop();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool twodmaterial()
|
||||
{
|
||||
bool result = addBlend2d(video::EDT_OPENGL);
|
||||
result &= addBlend2d(video::EDT_DIRECT3D9);
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#include "testUtils.h"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
static bool testImageCreation(video::E_DRIVER_TYPE driverType)
|
||||
{
|
||||
// create device
|
||||
|
||||
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(160,120));
|
||||
|
||||
if (device == 0)
|
||||
return true; // could not create selected driver.
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
video::ITexture* tex=driver->getTexture("../media/water.jpg");
|
||||
video::IImage* img1=driver->createImage(tex, core::vector2di(0,0), core::dimension2du(32,32));
|
||||
video::ITexture* tex1=driver->addTexture("new1", img1);
|
||||
video::IImage* img2=driver->createImage(tex, core::vector2di(0,0), tex->getSize());
|
||||
video::ITexture* tex2=driver->addTexture("new2", img2);
|
||||
|
||||
driver->beginScene(true, true, video::SColor(255,255,0,255));//Backbuffer background is pink
|
||||
|
||||
driver->draw2DImage(tex, core::position2d<s32>(0,0), core::recti(0,0,32,32));
|
||||
driver->draw2DImage(tex1, core::position2d<s32>(32,0));
|
||||
driver->draw2DImage(tex2, core::position2d<s32>(64,0), core::recti(0,0,32,32));
|
||||
|
||||
driver->endScene();
|
||||
|
||||
bool result = takeScreenshotAndCompareAgainstReference(driver, "-createImage.png");
|
||||
|
||||
device->drop();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool createImage()
|
||||
{
|
||||
bool result = testImageCreation(video::EDT_SOFTWARE);
|
||||
return result;
|
||||
}
|
|
@ -123,98 +123,146 @@ bool line2dIntersectWith(void)
|
|||
allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)),
|
||||
line2df(vector2df(0,2),vector2df(2,2)),
|
||||
true, vector2df(1,2));
|
||||
assert(allExpected);
|
||||
|
||||
// Crossing lines, both diagonal
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)),
|
||||
line2df(vector2df(0,2),vector2df(2,0)),
|
||||
true, vector2df(1,1));
|
||||
assert(allExpected);
|
||||
|
||||
// Non-crossing lines, horizontal and vertical
|
||||
allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)),
|
||||
line2df(vector2df(0,4),vector2df(2,4)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
|
||||
// Non-crossing lines, both diagonal
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)),
|
||||
line2df(vector2df(3,4),vector2df(4,3)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
|
||||
// Meeting at a common point
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(1,0),vector2df(2,0)),
|
||||
true, vector2df(1,0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(1,0),vector2df(0,1)),
|
||||
true, vector2df(1,0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(1,0),vector2df(0,-1)),
|
||||
true, vector2df(1,0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
|
||||
line2df(vector2df(0,1),vector2df(1,1)),
|
||||
true, vector2df(0,1));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
|
||||
line2df(vector2df(0,1),vector2df(1,-1)),
|
||||
true, vector2df(0,1));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
|
||||
line2df(vector2df(0,1),vector2df(0,2)),
|
||||
true, vector2df(0,1));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(1,0),vector2df(2,0)),
|
||||
true, vector2df(1,0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
|
||||
line2df(vector2df(1,1),vector2df(0,2)),
|
||||
true, vector2df(1,1));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
|
||||
line2df(vector2df(1,1),vector2df(2,0)),
|
||||
true, vector2df(1,1));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
|
||||
line2df(vector2df(1,1),vector2df(2,2)),
|
||||
true, vector2df(1,1));
|
||||
assert(allExpected);
|
||||
|
||||
|
||||
// Parallel lines, no intersection
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(0,1),vector2df(1,1)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
|
||||
line2df(vector2df(1,0),vector2df(1,1)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
|
||||
// Non parallel lines, no intersection
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(0,1),vector2df(0,2)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
|
||||
line2df(vector2df(1,0),vector2df(2,0)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
|
||||
// Coincident (and thus parallel) lines
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(0,0),vector2df(1,0)),
|
||||
true, vector2df(0,0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(2,0),vector2df(0,2)),
|
||||
line2df(vector2df(2,0),vector2df(0,2)),
|
||||
true, vector2df(2,0));
|
||||
assert(allExpected);
|
||||
|
||||
// Two segments of the same unlimited line, but no intersection
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
|
||||
line2df(vector2df(2,2),vector2df(3,3)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
|
||||
line2df(vector2df(2,0),vector2df(3,0)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
|
||||
line2df(vector2df(0,2),vector2df(0,3)),
|
||||
false, vector2df());
|
||||
assert(allExpected);
|
||||
|
||||
// Overlapping parallel lines
|
||||
allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)),
|
||||
line2df(vector2df(0,0),vector2df(3,0)),
|
||||
true, vector2df(1.5f, 0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)),
|
||||
line2df(vector2df(0,0),vector2df(0,3)),
|
||||
true, vector2df(0, 1.5f));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)),
|
||||
line2df(vector2df(0,0),vector2df(3,0)),
|
||||
true, vector2df(1.5f, 0));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)),
|
||||
line2df(vector2df(0,0),vector2df(0,3)),
|
||||
true, vector2df(0, 1.5f));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(1,1),vector2df(2,2)),
|
||||
line2df(vector2df(0,0),vector2df(3,3)),
|
||||
true, vector2df(1.5f, 1.5f));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(1,2),vector2df(2,1)),
|
||||
line2df(vector2df(0,3),vector2df(3,0)),
|
||||
true, vector2df(1.5f, 1.5f));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(10,8)),
|
||||
line2df(vector2df(2.5f,2.0f),vector2df(5.0f,4.0f)),
|
||||
true, vector2df(3.75f, 3.0f));
|
||||
assert(allExpected);
|
||||
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2000,1000)),
|
||||
line2df(vector2df(2,1),vector2df(2.2f,1.4f)),
|
||||
true, vector2df(2.0f, 1.0f));
|
||||
assert(allExpected);
|
||||
|
||||
if(allExpected)
|
||||
logTestString("\nAll tests passed\n");
|
||||
|
|
|
@ -96,6 +96,7 @@ int main(int argumentCount, char * arguments[])
|
|||
TEST(testGeometryCreator);
|
||||
TEST(writeImageToFile);
|
||||
TEST(meshTransform);
|
||||
TEST(createImage);
|
||||
// all driver checks
|
||||
TEST(drawPixel);
|
||||
TEST(guiDisabledMenu);
|
||||
|
@ -107,6 +108,7 @@ int main(int argumentCount, char * arguments[])
|
|||
TEST(antiAliasing);
|
||||
TEST(draw2DImage);
|
||||
TEST(lights);
|
||||
TEST(twodmaterial);
|
||||
// TODO: Needs to be fixed first.
|
||||
// TEST(projectionMatrix);
|
||||
// large scenes/long rendering
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
|
@ -171,6 +171,10 @@
|
|||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\2dmaterial.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\anti-aliasing.cpp"
|
||||
>
|
||||
|
@ -195,6 +199,10 @@
|
|||
RelativePath=".\color.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\createImage.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cursorSetVisible.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue