当前位置: 首页>>代码示例>>C++>>正文


C++ IVideoDriver::draw2DImage方法代码示例

本文整理汇总了C++中IVideoDriver::draw2DImage方法的典型用法代码示例。如果您正苦于以下问题:C++ IVideoDriver::draw2DImage方法的具体用法?C++ IVideoDriver::draw2DImage怎么用?C++ IVideoDriver::draw2DImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVideoDriver的用法示例。


在下文中一共展示了IVideoDriver::draw2DImage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runTestWithDriver

/** The test loads a texture, renders it using draw2dimage, loads another
	texture and renders the first one again. Due to the texture cache this
	can lead to rendering of the second texture in second place. */
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
	IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(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();

	ITexture* tex1 = driver->getTexture("../media/wall.bmp");

	(void)smgr->addCameraSceneNode();

	driver->beginScene(true, true, SColor(255,100,101,140));
	driver->draw2DImage(tex1, position2di(0,0));
	driver->endScene();

	driver->getTexture("../media/tools.png");

	driver->beginScene(true, true, SColor(255,100,101,140));
	driver->draw2DImage(tex1, position2di(0,0));
	driver->endScene();

	bool result = takeScreenshotAndCompareAgainstReference(driver, "-textureRenderStates.png", 100);

	device->drop();

	return result;
}
开发者ID:jivibounty,项目名称:irrlicht,代码行数:32,代码来源:textureRenderStates.cpp

示例2: draw

	//! draws the element and its children
	void CGUIImage::draw()
	{
		if (!IsVisible)
			return;

		IGUISkin* skin = Environment->getSkin();
		IVideoDriver* driver = Environment->getVideoDriver();

		if (Texture)
		{
			if (ScaleImage)
			{
				const ColourValue Colors[] = { Color, Color, Color, Color };

				driver->draw2DImage(Texture, AbsoluteRect,
					rect<SINT32>(Position2d(0, 0), dimension2di(Texture->getOriginalSize())),
					&AbsoluteClippingRect, Colors, UseAlphaChannel);
			}
			else
			{
				driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner,
					rect<SINT32>(Position2d(0, 0), dimension2di(Texture->getOriginalSize())),
					&AbsoluteClippingRect, Color, UseAlphaChannel);
			}
		}
		else
		{
			skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect);
		}

		IGUIElement::draw();
	}
开发者ID:zxycode007,项目名称:Sapphire,代码行数:33,代码来源:SapphireCGUIImage.cpp

示例3: viewPortText

/** The result should be as follows: We have three times the same image, a billboard with a cube and the text in front.
They are replicated three times, one centered in the screen without viewport, one in the upper left (qurter screen) and
one on the right (half screen). The latter is stretched due to the changed aspect ratio.
The two viewport scenes get the texture drawn over the center as well, using draw2dimage. This should mark the proper
image position with the top left corner of the texture.
Finally, each scene has a checkbox drawn at the left side, vertically centered. This will show whether GUI elements adhere
to viewports as well. */
static bool viewPortText(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();
	IGUIEnvironment* env = smgr->getGUIEnvironment();

	stabilizeScreenBackground(driver);

	env->addCheckBox(true, core::recti(10,60,28,82));

	logTestString("Testing driver %ls\n", driver->getName());

	IBillboardSceneNode * bnode = smgr->addBillboardSceneNode(0,dimension2d<f32>(32,32),core::vector3df(0,0,10));
	bnode->setMaterialFlag(video::EMF_LIGHTING, false);
	bnode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	bnode->setMaterialTexture(0, driver->getTexture("../media/fire.bmp"));

	smgr->addTextSceneNode(device->getGUIEnvironment()->getBuiltInFont(), L"TEST", video::SColor(255,255,255,255), 0);
	smgr->addCubeSceneNode();
	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

	driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
	smgr->drawAll();
	env->drawAll();
	driver->setViewPort(rect<s32>(0,0,160/2,120/2));
	smgr->drawAll();
	env->drawAll();
	driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2));
	driver->setViewPort(rect<s32>(160/2,0,160,120));
	smgr->drawAll();
	env->drawAll();
	driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2));
	driver->endScene(); 

	bool result = takeScreenshotAndCompareAgainstReference(driver, "-viewPortText.png", 98.71f);

	device->closeDevice();
	device->run();
	device->drop();

	return result;
}
开发者ID:Alberto-Izquierdo,项目名称:irrlicht,代码行数:53,代码来源:viewPort.cpp

示例4: playIntroImage

// zobrazi plynule animaci s pruhledností, uvodního obrázku
void playIntroImage(irr::IrrlichtDevice *dev, irr::core::string<char> imagePath, u32 speed)
{
    IVideoDriver* driver = dev->getVideoDriver();
    ISceneManager* smgr = dev->getSceneManager();
    IGUIEnvironment* guienv = dev->getGUIEnvironment();

    ITexture* image = driver->getTexture(imagePath);

    core::dimension2d<u32> screenSize = driver->getScreenSize();
    core::dimension2d<u32> imageSize(image->getSize().Width, image->getSize().Height);

    u32 start_time = dev->getTimer()->getTime();
    u32 alpha = 0;
    bool up = true;
    bool done = false;
    while (dev->run() && !done)
    {
        driver->beginScene(true, true, SColor(255, 0, 0, 0)); // zacnu, s cernym pozadim

        if (alpha < 255 && up) // z 0% -> 100%
        {
            u32 now_time = dev->getTimer()->getTime();
            if (now_time - start_time > speed)
            {
                alpha++;
                start_time = now_time;
            }
        }
        else // z 100% -> 0%
        {
            up = false;
        }
        if (!up && alpha > 0)
        {
            u32 now_time = dev->getTimer()->getTime();
            if (now_time - start_time > speed)
            {
                alpha--;
                start_time = now_time;
            }
        }
        if (!up && alpha == 0) // konec animace, ukoncit smycku
        {
            done = true;
        }
        // vykresleni obrazku, pouziti vypoctu velikosti a centrování
        driver->draw2DImage(image, position2d<s32>((screenSize.Width - imageSize.Width) / 2, (screenSize.Height - imageSize.Height) / 2), core::rect<s32>(0, 0, imageSize.Width, imageSize.Height), 0, SColor(alpha, 255, 255, 255), true);

        driver->endScene();
    }
}
开发者ID:TheTypoMaster,项目名称:WorldOfWraithRPG,代码行数:52,代码来源:CIntro.cpp

示例5: doTestWith

/** Test the behaviour of makeColorKeyTexture() using both 16 bit (software)
	and 32 bit (Burning) textures, with the new behaviour and the legacy
	behaviour. */
static bool doTestWith(E_DRIVER_TYPE driverType,
						bool zeroTexels)
{
	IrrlichtDevice *device = createDevice( driverType,
											dimension2d<u32>(160, 120), 32);
	if (!device)
		return false;

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager * smgr = device->getSceneManager();

	// Draw a cube background so that we can check that the keying 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);

	ITexture * Texture = device->getVideoDriver()->getTexture("../media/portal2.bmp");

	device->getVideoDriver()->makeColorKeyTexture(Texture,
												  position2d<s32>(64,64),
												  zeroTexels);
	device->getVideoDriver()->makeColorKeyTexture(Texture,
												  position2d<s32>(64,64),
												  zeroTexels);
	(void)smgr->addCameraSceneNode();

	driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
	smgr->drawAll();

	driver->draw2DImage(Texture,
						position2di(40, 40),
						rect<s32>(0, 0, Texture->getSize().Width, Texture->getSize().Height),
						0,
						SColor(255,255,255,255),
						true);
	driver->endScene();

	char screenshotName[256];
	(void)snprintf_irr(screenshotName, 256, "-makeColorKeyTexture-%s.png",
		zeroTexels? "old" : "new");

	bool result = takeScreenshotAndCompareAgainstReference(driver, screenshotName);

	device->closeDevice();
	device->run();
	device->drop();

	return result;
}
开发者ID:Alberto-Izquierdo,项目名称:irrlicht,代码行数:52,代码来源:makeColorKeyTexture.cpp

示例6: main

int main()
{
    device = createDevice(EDT_OPENGL, dimension2d<u32>(screenWidth, screenHeight), 16,
                                          false, false, false, 0);
    if (!device)
        return 1;

    IVideoDriver* driver = device->getVideoDriver();

    MyEventReceiver receiver;
    device->setEventReceiver(&receiver);

    image = driver->getTexture("/home/fuyajun/Documents/irrlicht-1.7.2/media/fireball.bmp");

    position.set(0,0);
    direction.set(1,1);

    u32 then = device->getTimer()->getTime();

    while (device->run())
    {
        const u32 now = device->getTimer()->getTime();
        const f32 deltaTime = (f32)(now - then);
        then = now;

        update(deltaTime);

        driver->beginScene(true, true, SColor(255,255,255,255));

        driver->draw2DImage(image, position2d<s32>((s32)position.X, (s32)position.Y), rect<s32>(0, 0, 32, 32), 0, SColor(255, 255, 255, 255), true);

        driver->endScene();

        core::stringw str = L"x: ";
        str += target.X;
        str += ", y: ";
        str += target.Y;
        str += ", posX: ";
        str += position.X;
        str += ", posY: ";
        str += position.Y;

        device->setWindowCaption(str.c_str());
    }

    device->drop();

    return 0;
}
开发者ID:fuyajun1983cn,项目名称:myplayground,代码行数:49,代码来源:main.cpp

示例7: draw

void SSGUIStatusBar::draw()
{
	IVideoDriver *driver = Environment->getVideoDriver();

	if (!IsVisible)
		return;

	if (Background)
	{
		driver->draw2DImage(Background, AbsoluteRect.UpperLeftCorner, rect<s32>(position2d<s32>(0,0), Background->getOriginalSize()), 0, SColor(255,255,255,255), true);

		IGUIElement *ElementUnderCursor = Environment->getRootGUIElement()->getElementFromPoint(CursorControl->getPosition());

		s32 index = -1;
		
		while (ElementUnderCursor && ElementUnderCursor != this && ElementUnderCursor != Environment->getRootGUIElement() && index == -1)
		{
			index = RegisteredElements.binary_search(ElementUnderCursor);

			if (ElementUnderCursor != this && index == -1)
				ElementUnderCursor = ElementUnderCursor->getParent();
		}

		if (index >= 0 || ElementUnderCursor == this)
		{
			if (ElementUnderCursor->getType() == EGUIET_BUTTON)
				Label.Text = ((SSGUIButton*)ElementUnderCursor)->getHelpText().c_str();
			if (ElementUnderCursor->getType() == EGUIET_SCROLL_BAR)
				Label.Text = ((SSGUIScrollBar*)ElementUnderCursor)->getHelpText().c_str();
			if (ElementUnderCursor->getType() == EGUIET_WINDOW)
				Label.Text = ((SSGUISatelliteInfoWindow*)ElementUnderCursor)->getHelpText().c_str();
			if (ElementUnderCursor == this)
				Label.Text = HelpText.c_str();

			if (Label.Text)
				Label.Font->draw(Label.Text, Label.Rect, Label.Color, false, true);
		}
		else
			Label.Text = 0;
	}
}
开发者ID:flexoid,项目名称:SolarSystem,代码行数:41,代码来源:SSGUIStatusBar.cpp

示例8: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
    irr::IrrlichtDevice *pIrrDevice = createDevice(EDT_OPENGL,
        dimension2d<u32>(800,600),
        16,
        false,
        false,
        false);

    CString csImageTestPath(utils::GetGamePath() + L"res\\images\\brick0.png");
    CString csFontTestPath(utils::GetGamePath() + L"res\\fonts\\msyh.ttf");

    IVideoDriver* pIrrDriver = pIrrDevice->getVideoDriver();
    ITexture* Images = pIrrDriver->getTexture((LPCTSTR)csImageTestPath);
    ISceneManager* scene_mgr = pIrrDevice->getSceneManager();
    ISceneNode* cube = scene_mgr->addCubeSceneNode(100.0f);
    cube->setMaterialTexture(0, Images);
    cube->setMaterialFlag(video::EMF_LIGHTING, false);
    scene::ICameraSceneNode* camera = scene_mgr->addCameraSceneNode(0,
        core::vector3df(700,700,-700),
        core::vector3df(0,0,0));
    f32 iYPos = 0;

    pIrrDevice->setWindowCaption(L"hehehe");

    while (pIrrDevice->run())
    {
        pIrrDriver->beginScene(true, true, SColor(255,0,0,0));
        pIrrDriver->draw2DImage(Images, position2d<s32>(0,0),
            rect<s32>(0,0,800,600), 0,
            SColor(255,255,255,255), true);
        scene_mgr->drawAll();
        cube->setPosition(core::vector3df(0, iYPos, -700));
        pIrrDriver->endScene();
    }

    pIrrDevice->drop();
    return 0;
}
开发者ID:Sumxx,项目名称:gogame,代码行数:39,代码来源:main.cpp

示例9: draw

	//! draws the element and its children
	void CGUIButton::draw()
	{
		if (!IsVisible)
			return;

		IGUISkin* skin = Environment->getSkin();
		IVideoDriver* driver = Environment->getVideoDriver();

		// todo:	move sprite up and text down if the pressed state has a sprite
		const Position2d spritePos = AbsoluteRect.getCenter();

		if (!Pressed)
		{
			if (DrawBorder)
				skin->draw3DButtonPaneStandard(this, AbsoluteRect, &AbsoluteClippingRect);

			if (Image)
			{
				Position2d pos = spritePos;
				pos.x -= ImageRect.getWidth() / 2;
				pos.y -= ImageRect.getHeight() / 2;

				driver->draw2DImage(Image,
					ScaleImage ? AbsoluteRect :
					recti(pos, ImageRect.getSize()),
					ImageRect, &AbsoluteClippingRect,
					0, UseAlphaChannel);
			}
		}
		else
		{
			if (DrawBorder)
				skin->draw3DButtonPanePressed(this, AbsoluteRect, &AbsoluteClippingRect);

			if (PressedImage)
			{
				Position2d pos = spritePos;
				pos.x -= PressedImageRect.getWidth() / 2;
				pos.y -= PressedImageRect.getHeight() / 2;

				if (Image == PressedImage && PressedImageRect == ImageRect)
				{
					pos.x += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X);
					pos.y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y);
				}
				driver->draw2DImage(PressedImage,
					ScaleImage ? AbsoluteRect :
					recti(pos, PressedImageRect.getSize()),
					PressedImageRect, &AbsoluteClippingRect,
					0, UseAlphaChannel);
			}
		}

		if (SpriteBank)
		{
			// pressed / unpressed animation
			UINT32 state = Pressed ? (UINT32)EGBS_BUTTON_DOWN : (UINT32)EGBS_BUTTON_UP;
			if (ButtonSprites[state].Index != -1)
			{
				SpriteBank->draw2DSprite(ButtonSprites[state].Index, spritePos,
					&AbsoluteClippingRect, ButtonSprites[state].Color, ClickTime, Timer::getTime(),
					ButtonSprites[state].Loop, true);
			}

			// focused / unfocused animation
			state = Environment->hasFocus(this) ? (UINT32)EGBS_BUTTON_FOCUSED : (UINT32)EGBS_BUTTON_NOT_FOCUSED;
			if (ButtonSprites[state].Index != -1)
			{
				SpriteBank->draw2DSprite(ButtonSprites[state].Index, spritePos,
					&AbsoluteClippingRect, ButtonSprites[state].Color, FocusTime, Timer::getTime(),
					ButtonSprites[state].Loop, true);
			}

			// mouse over / off animation
			if (isEnabled())
			{
				state = Environment->getHovered() == this ? (UINT32)EGBS_BUTTON_MOUSE_OVER : (UINT32)EGBS_BUTTON_MOUSE_OFF;
				if (ButtonSprites[state].Index != -1)
				{
					SpriteBank->draw2DSprite(ButtonSprites[state].Index, spritePos,
						&AbsoluteClippingRect, ButtonSprites[state].Color, HoverTime, Timer::getTime(),
						ButtonSprites[state].Loop, true);
				}
			}
		}

		if (Text.size())
		{
			IGUIFont* font = getActiveFont();

			rect<SINT32> rect = AbsoluteRect;
			if (Pressed)
			{
				rect.UpperLeftCorner.x += skin->getSize(EGDS_BUTTON_PRESSED_TEXT_OFFSET_X);
				rect.UpperLeftCorner.y += skin->getSize(EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y);
			}

			if (font)
				font->draw(Text, rect,
//.........这里部分代码省略.........
开发者ID:zxycode007,项目名称:Sapphire,代码行数:101,代码来源:SapphireCGUIButton.cpp

示例10: main


//.........这里部分代码省略.........
		filterType = EFT_8PCF;
		filterType = EFT_4PCF;
*/
	dimension2du shadowDimen = dimension2du(1024,1024);
    E_FILTER_TYPE filterType = EFT_4PCF;
    filterType = EFT_NONE;
////


IrrlichtDevice* device = createDevice(EDT_OPENGL,dimension2du(800,600),32);

ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();

ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,100,.5);
cam->setPosition(vector3df(0,10,0));

// Create the effect handler, passing the device and RTT size (as a dimension2d) .
effectHandler* effect = new effectHandler(device,shadowDimen);


ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("media/terrain.bmp",0,-1,vector3df(0,0,0),vector3df(0,0,0),vector3df(1,1,1),SColor(255,255,255,255),1,ETPS_33);
terrain->setMaterialTexture(0,driver->getTexture("media/terrain.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap.jpg"));
terrain->scaleTexture(1,10);
terrain->setScale(core::vector3df(4, 0.01f, 4));
terrain->setPosition(vector3df(-120,-1.5f,-120));
terrain->setMaterialType(EMT_DETAIL_MAP);

// Make the terrain recieve a shadow with the specified filter type.
// (NOTE: 12PCF is only available in Direct3D9, all others work with OpenGL)
effect->addShadowToNode(terrain,filterType);

IAnimatedMeshSceneNode* sydney;
IAnimatedMesh* sydneymesh = smgr->getMesh("media/dwarf.x");

for(int g = 0;g < 1;g++)
{
	for(int v = 0;v < 3;v++)
	{
		sydney = smgr->addAnimatedMeshSceneNode(sydneymesh);
		sydney->setScale(vector3df(0.05f,0.05f,0.05f));
		sydney->setPosition(vector3df(g * 4,0.5f,v * 4));
		sydney->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);

		sydney->setAutomaticCulling(EAC_FRUSTUM_BOX);

		sydney->setMaterialType(EMT_SOLID);

		// Add the nodes to the depth pass so that they cast a shadow.
		effect->addNodeToDepthPass(sydney);

	}
}


effect->getLightCamera()->addAnimator(smgr->createFlyCircleAnimator(sydney->getPosition() + vector3df(0,15,0),25,0.0002f));

effect->getLightCamera()->setNearValue(5);

effect->setMaxShadowDistanceFromLight(120);

smgr->addLightSceneNode(effect->getLightCamera());


MyEventReceiver receiver(cam);
device->setEventReceiver(&receiver);

// Parent a sphere to the light camera so we can see its position.
smgr->addSphereSceneNode(1,8,effect->getLightCamera())->setMaterialFlag(EMF_LIGHTING,false);



while(device->run())
{
	wchar_t tmp[255];
	swprintf(tmp,255,L"Shadow Map Demo (FPS: %d)",driver->getFPS());
	device->setWindowCaption(tmp);

	driver->beginScene(true,true,SColor(0,0,0,0));

	// Point the light camera at one of the nodes as it rotates around them.
	effect->setLightTarget(sydney->getPosition());

	// Update the effect  handler, remember to always do this BEFORE smgr->drawAll and AFTER beginscene!
	effect->update();

	smgr->drawAll();

	// If user wishes we can display the shadow map to the screen. (May not work in OpenGL)
	if(disp2d)
		driver->draw2DImage(effect->getShadowMapTexture(),position2d<s32>(0,0));

	driver->endScene();
	//	device->sleep(5);
}

device->drop();
return 0;
}
开发者ID:tecan,项目名称:Luna,代码行数:101,代码来源:example.cpp

示例11: Draw

void StateNetwork::Draw()
{
	IVideoDriver* pDriver = Irrdevice::GetInstance()->GetVideoDriver();
	pDriver->draw2DImage(m_pBackGround,core::position2d<s32>(0,0),core::rect<s32>(0,0,800,600));
}
开发者ID:JeongSeungSU,项目名称:FightingSprit,代码行数:5,代码来源:StateNetwork.cpp


注:本文中的IVideoDriver::draw2DImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。