aboutsummaryrefslogtreecommitdiff
path: root/tests/createImage.cpp
blob: 3f82e39b02c21615a6d420860e58aff10f6a354d (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
#include "testUtils.h"

using namespace irr;

static bool testImageCreation()
{
	// create device

	IrrlichtDevice *device = createDevice(video::EDT_SOFTWARE, 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->closeDevice();
	device->run();
	device->drop();

	return result;
}

bool createImage()
{
	bool result = testImageCreation();
	return result;
}