本文整理汇总了C++中IVideoDriver::drawPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ IVideoDriver::drawPixel方法的具体用法?C++ IVideoDriver::drawPixel怎么用?C++ IVideoDriver::drawPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVideoDriver
的用法示例。
在下文中一共展示了IVideoDriver::drawPixel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTestWithDriver
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(640, 480));
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
// Draw a cube to check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
// Test for offscreen values as well as onscreen.
for(s32 x = -10; x < 650; ++x)
{
s32 y = 480 * x / 640;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 480 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.jpg");
device->drop();
return result;
}
示例2: pixelAccuracy
// this test draws alternating white and black borders with
// increasing thickness. Intended use of this test is to ensure
// the corect pixel alignment within the render window.
static bool pixelAccuracy(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());
device->getSceneManager()->addCameraSceneNode();
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
u32 start=0;
for (u32 count=1; count<10; ++count)
{
for (u32 j=0; j<count; ++j)
{
for (u32 x=0; x<100-start; ++x)
{
driver->drawPixel(start+x, start, (count%2==1)?0xffffffff:0xff000000);
}
++start;
}
}
start=0;
for (u32 count=1; count<10; ++count)
{
for (u32 j=0; j<count; ++j)
{
for (u32 x=0; x<100-start; ++x)
{
driver->drawPixel(start, start+x, (count%2==1)?0xffffffff:0xff000000);
}
++start;
}
}
for (u32 x=0; x<100; ++x)
{
driver->drawPixel(x, x, 0xffff0000);
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-pixelAccuracy.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
示例3: drawLine
// this test draws lines of different lengths and compares
// them with pixel placement
// grey pixels denote start and end of the white drawn lines
// black pixels only make those grey points better visible
// yellow and magenta lines should start and end next toa black pixel,
// yellow one right to the last black pixel down, magenta below the last
// black pixel to the right
// white lines are always double drawn, lines back and forth.
static bool drawLine(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());
device->getSceneManager()->addCameraSceneNode();
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
// horizontal lines
for (u32 i=0; i<20; ++i)
{
driver->draw2DLine(core::vector2di(10,10+3*i), core::vector2di(10+2*i,10+3*i));
// mark start point
driver->drawPixel(9,10+3*i+1, video::SColor(0xff000000));
driver->drawPixel(10,10+3*i+1, video::SColor(0xff888888));
driver->drawPixel(11,10+3*i+1, video::SColor(0xff000000));
// mark end point
driver->drawPixel(9+2*i,10+3*i+1, video::SColor(0xff000000));
driver->drawPixel(10+2*i,10+3*i+1, video::SColor(0xff888888));
driver->drawPixel(11+2*i,10+3*i+1, video::SColor(0xff000000));
driver->draw2DLine(core::vector2di(10+2*i,10+3*i+2), core::vector2di(10,10+3*i+2));
}
// vertical lines
for (u32 i=0; i<20; ++i)
{
driver->draw2DLine(core::vector2di(11+3*i,10), core::vector2di(11+3*i,10+2*i));
// mark start point
driver->drawPixel(11+3*i+1,9, video::SColor(0xff000000));
driver->drawPixel(11+3*i+1,10, video::SColor(0xff888888));
driver->drawPixel(11+3*i+1,11, video::SColor(0xff000000));
// mark end point
driver->drawPixel(11+3*i+1,9+2*i, video::SColor(0xff000000));
driver->drawPixel(11+3*i+1,10+2*i, video::SColor(0xff888888));
driver->drawPixel(11+3*i+1,11+2*i, video::SColor(0xff000000));
driver->draw2DLine(core::vector2di(11+3*i+2,10+2*i), core::vector2di(11+3*i+2, 10));
}
// diagonal lines
driver->draw2DLine(core::vector2di(14,14),core::vector2di(50,68), video::SColor(0xffffff00));
driver->draw2DLine(core::vector2di(15,14),core::vector2di(69,50), video::SColor(0xffff00ff));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawLine.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
示例4: lineRender
/** Expect to see two diagonal lines overlaying a wall texture cube.
One line should run from green at the top left to red at the bottom right.
The other should run from cyan 100% transparent at the bottom left to
cyan 100% opaque at the top right. */
static bool lineRender(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();
ISceneManager * smgr = device->getSceneManager();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
// Draw a cube background so that we can check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode();
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
smgr->drawAll();
// Test for benign handling of offscreen pixel values as well as onscreen ones.
for(s32 x = -10; x < 170; ++x)
{
s32 y = 120 * x / 160;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 120 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.png", 98.81f);
device->closeDevice();
device->run();
device->drop();
return result;
}
示例5: writeImageToFile
//! Tests IVideoDriver::writeImageToFile() using IWriteFile
bool writeImageToFile(void)
{
IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, 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();
ISceneManager * smgr = device->getSceneManager();
// Draw a cube background so that we can check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
// Test for benign handling of offscreen pixel values as well as onscreen ones.
for(s32 x = -10; x < 170; ++x)
{
s32 y = 120 * x / 160;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 120 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
}
driver->endScene();
bool result = false;
IWriteFile * writtenFile = 0;
IWriteFile * memoryFile = 0;
const char * writtenFilename = 0;
const u32 BUFFER_SIZE = 160 * 120 * 4;
c8 * buffer = 0;
const char * referenceFilename = 0;
video::ECOLOR_FORMAT format;
irr::video::IImage * screenshot = driver->createScreenShot();
if(!screenshot)
{
logTestString("Failed to take screenshot\n");
assert(false);
goto cleanup;
}
format = screenshot->getColorFormat();
if(format != video::ECF_R8G8B8)
{
irr::video::IImage * fixedScreenshot = driver->createImage(video::ECF_R8G8B8, screenshot);
screenshot->drop();
if(!fixedScreenshot)
{
logTestString("Failed to convert screenshot to ECF_A8R8G8B8\n");
assert(false);
goto cleanup;
}
screenshot = fixedScreenshot;
}
buffer = new c8[BUFFER_SIZE];
writtenFilename = "results" DIR_SEP_STRING "Burning's Video-drawPixel.png";
memoryFile = device->getFileSystem()->createMemoryWriteFile(buffer, BUFFER_SIZE, writtenFilename, false);
if(!driver->writeImageToFile(screenshot, memoryFile))
{
logTestString("Failed to write png to memory file\n");
assert(false);
goto cleanup;
}
writtenFile = device->getFileSystem()->createAndWriteFile(memoryFile->getFileName());
if(!writtenFile)
{
logTestString("Can't open %s for writing.\n", writtenFilename);
assert(false);
goto cleanup;
}
if(memoryFile->getPos() != writtenFile->write(buffer, memoryFile->getPos()))
{
logTestString("Error while writing to %s.\n", writtenFilename);
assert(false);
goto cleanup;
}
writtenFile->drop();
writtenFile = 0;
referenceFilename = "media" DIR_SEP_STRING "Burning's Video-drawPixel.png";
if(!binaryCompareFiles(writtenFilename, referenceFilename))
{
logTestString("File written from memory is not the same as the reference file.\n");
assert(false);
goto cleanup;
}
result = true;
//.........这里部分代码省略.........