本文整理汇总了C++中IVideoDriver::getTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ IVideoDriver::getTexture方法的具体用法?C++ IVideoDriver::getTexture怎么用?C++ IVideoDriver::getTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVideoDriver
的用法示例。
在下文中一共展示了IVideoDriver::getTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
BgMovableObject::BgMovableObject(Level* L, Point position, Point scale, char* TexturePath, int t, Point mov){
movement=mov;
type = t;
IVideoDriver* driver = L->driver;
ISceneManager* smgr = L->smgr;
graphic_model= smgr->addCubeSceneNode();
graphic_model->setMaterialFlag(video::EMF_LIGHTING, true);
graphic_model->setMaterialTexture(0, driver->getTexture(TexturePath));
graphic_model->setMaterialFlag(video::EMF_LIGHTING, false);
graphic_model->setPosition(core::vector3df(position.position_x, position.position_y, position.layer));
graphic_model->setScale(core::vector3df(scale.position_x, scale.position_y, scale.layer));
graphic_model->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
}
示例2: flyCircleAnimator
/** Tests the offset capability of the fly circle animator */
bool flyCircleAnimator(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f };
for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i)
{
IBillboardSceneNode * node = smgr->addBillboardSceneNode();
// Have the animator rotate around the Z axis plane, rather than the default Y axis
ISceneNodeAnimator * animator =
smgr->createFlyCircleAnimator(vector3df(0, 0, 0), 30.f,
0.001f, vector3df(0, 0, 1),
(offsetDegrees[i] / 360.f));
if(!node || !animator)
return false;
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->addAnimator(animator);
animator->drop();
}
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0));
bool result = false;
// Don't do device->run() since I need the time to remain at 0.
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100);
}
device->drop();
return result;
}
示例3: example_helloworld
int example_helloworld()
{
// create device
IrrlichtDevice *device = startup();
if (device == 0)
return 1; // could not create selected driver.
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
/*
To let the mesh look a little bit nicer, we change its material. We
disable lighting because we do not have a dynamic light in here, and
the mesh would be totally black otherwise. Then we set the frame loop,
such that the predefined STAND animation is used. And last, we apply a
texture to the mesh. Without it the mesh would be drawn using only a
color.
*/
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
}
/*
To look at the mesh, we place a camera into 3d space at the position
(0, 30, -40). The camera looks from there to (0,5,0), which is
approximately the place where our md2 model is.
*/
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
EventReceiver_basic receiver(device);
device->setEventReceiver(&receiver);
return run ( device );
}
示例4:
ZombieLeader::~ZombieLeader()
{
delete m_pStateMachine;
// remove this scene node from parent
m_p2DSprite->remove();
// release texture resource
IVideoDriver* pDriver = IrrDvc.GetDriver();
ITexture* pTexture = pDriver->getTexture(ZOMBIELEADER_TEXTUREFILENAME);
if (pTexture)
{
pTexture->drop();
}
// remove physics model - it will be deleted in parents
//delete m_pZombiePhaysics;
}
示例5: main
int main( ) {
// Boring stuff: set up the scene, object & camera as usual
IrrlichtDevice* device = createDevice( DRIVER, dimension2d<s32>( 640, 480 ), 16, false, false, false, 0 );
IVideoDriver* driver = device->getVideoDriver( );
ISceneManager* smgr = device->getSceneManager( );
IGUIEnvironment* guienv = device->getGUIEnvironment( );
device->getFileSystem( )->changeWorkingDirectoryTo( MEDIA_DIRECTORY );
guienv->addStaticText( L"Combined Effects", rect<s32>( 10, 10, 260, 22 ), true );
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
node->setMaterialFlag( EMF_LIGHTING, false );
node->setMD2Animation( scene::EMAT_STAND );
node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );
// Interesting stuff (see previous example for full details)
IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
CEffectPostProc* ppInvert = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), PP_INVERT );
// The second effect is made exactly the same way, but takes ppInvert as the input instead of ppRenderer
CEffectPostProc* ppBlur = new CEffectPostProc( ppInvert, dimension2di( 1024, 512 ), PP_BLUR, 0.01f );
// delete ppInvert;
// These variables aren't important - they are just for showing the FPS
wchar_t tmp[255]; u8 t = 0u;
while( device->run( ) ) {
driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
ppBlur->render( NULL );
guienv->drawAll( );
driver->endScene( );
// Show the current FPS
if( ++ t == 30u ) { t = 0u; swprintf(tmp, 255, L"%ls fps:%3d", driver->getName(), driver->getFPS() ); device->setWindowCaption( tmp ); }
}
// The effects can be deleted in any order
delete ppBlur;
delete ppInvert;
delete ppRenderer;
// Back to boring stuff
device->drop();
return 0;
}
示例6: md2Animation
/** At the moment, this just verifies that the last frame of the animation produces the expected bitmap. */
bool md2Animation(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
assert(device);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
IAnimatedMeshSceneNode* node;
assert(mesh);
if(mesh)
{
node = smgr->addAnimatedMeshSceneNode(mesh);
assert(node);
if(node)
{
node->setPosition(vector3df(20, 0, 30));
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMaterialTexture(0, driver->getTexture("../media/sydney.bmp"));
node->setLoopMode(false);
(void)smgr->addCameraSceneNode();
// Just jump to the last frame since that's all we're interested in.
node->setMD2Animation(EMAT_DEATH_FALLBACK);
node->setCurrentFrame((f32)(node->getEndFrame()));
device->run();
driver->beginScene(true, true, SColor(255, 255, 255, 0));
smgr->drawAll();
driver->endScene();
}
}
bool result = takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png");
device->drop();
return result;
}
示例7: main
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
if (!device)
cout<<"error";
else
{
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
}
cout<<"hello world2";
}
示例8: defined
/*!
Startup a Windows Mobile Device
*/
IrrlichtDevice *startup()
{
// both software and burnings video can be used
E_DRIVER_TYPE driverType = EDT_SOFTWARE; // EDT_BURNINGSVIDEO;
// create device
IrrlichtDevice *device = 0;
#if defined (_IRR_USE_WINDOWS_CE_DEVICE_)
// set to standard mobile fullscreen 240x320
device = createDevice(driverType, dimension2d<u32>(240, 320), 16, true );
#else
// on PC. use window mode
device = createDevice(driverType, dimension2d<u32>(240, 320), 16, false );
#endif
if ( 0 == device )
return 0;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
// set the filesystem relative to the executable
#if defined (_IRR_WINDOWS_)
{
wchar_t buf[255];
GetModuleFileNameW ( 0, buf, 255 );
string<c16> base = buf;
base = base.subString ( 0, base.findLast ( '\\' ) + 1 );
device->getFileSystem()->registerFileArchive ( base );
}
#endif
IGUIStaticText *text = guienv->addStaticText(L"FPS: 25",
rect<s32>(140,15,200,30), false, false, 0, 100 );
guienv->addButton(core::rect<int>(200,10,238,30), 0, 2, L"Quit");
// add irrlicht logo
guienv->addImage(driver->getTexture("../../media/irrlichtlogo3.png"),
core::position2d<s32>(0,-2));
return device;
}
示例9:
Human::~Human()
{
if(m_pStateMachine != NULL)
delete m_pStateMachine;
// remove this scene node from parent
if(m_p2DSprite != NULL)
m_p2DSprite->remove();
// release texture resource
IVideoDriver* pDriver = IrrDvc.GetDriver();
ITexture* pTexture = pDriver->getTexture(HUMAN_TEXTUREFILENAME);
if (pTexture)
{
pTexture->drop();
}
// remove physics model
delete m_pHumanPhaysics;
}
示例10: 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;
}
示例11:
FugitivePlayer::~FugitivePlayer()
{
delete m_pStateMachine;
delete m_pRushLine ;
for(int i=0; i < WEAPON_INVENTORY_NUM ; i++)
{
if(m_pWeapon[i])
delete m_pWeapon[i];
}
// remove this scene node from parent
m_p2DSprite->remove();
// release texture resource
IVideoDriver* pDriver = IrrDvc.GetDriver();
ITexture* pTexture = pDriver->getTexture("Rsrc/hero.tga");
if (pTexture)
{
pTexture->drop();
}
}
示例12: BasePlayer
NaviPlayer::NaviPlayer(vector3df position,
f64 radius,
vector3df velocity,
f64 maxSpeed,
vector3df heading,
f64 mass,
vector3df scale,
f64 turnRate,
f64 maxForce)
: BasePlayer(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, PLAYER_ROLE_CHASER)
{
// get ready state machine
m_pStateMachine = new StateMachine<NaviPlayer>(this);
// start from nothing
m_pStateMachine->ChangeState(IdleNavi::Instance());
// get ready sprite
ISceneManager* pSmgr = IrrDvc.GetSmgr();
IVideoDriver* pDriver = IrrDvc.GetDriver();
m_p2DSprite = pSmgr->addBillboardSceneNode();
m_p2DSprite->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
video::ITexture* pTexture = pDriver->getTexture("Rsrc/hero.tga");
// shkim, TODO.
// why should I grap this texture here? as a result, get(+1)->grab(+1)->drop(-1) will give reference count as 1.
// that means nobody know when I release texture after using at all. how do I figure it out?
// answer is, keeping texture resource during Proc life time. it means loading texture at Proc initializing time and releasing them at Proc releasing time.
// for doing that, need to use grab/drop pair after getTexture()
pTexture->grab();
m_p2DSprite->setMaterialTexture(0, pTexture);
m_p2DSprite->setMaterialFlag(video::EMF_LIGHTING, false);
m_p2DSprite->setMaterialFlag(video::EMF_ZBUFFER, true);
m_p2DSprite->setMaterialFlag(video::EMF_ZWRITE_ENABLE, true);
m_p2DSprite->setSize(dimension2df(scale.X, scale.Y));
m_p2DSprite->setPosition(position);
m_p2DSprite->setID(ID());
m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(0.5f,0.5f);
m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.f,0.5f); // 3th sprite
}
示例13: _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;
}
示例14:
Car::~Car()
{
delete m_pStateMachine;
// remove this scene node from parent
m_p2DSprite->remove();
// release texture resource
IVideoDriver* pDriver = IrrDvc.GetDriver();
ITexture* pTexture = pDriver->getTexture("Rsrc/car.tga");
if (pTexture)
{
pTexture->drop();
}
#ifdef DRAW_CAR_3D_MODEL
// remove 3d scene node
m_pSceneNode->remove();
IrrDvc.GetSmgr()->getMeshCache()->removeMesh(m_pMesh);
#endif // DRAW_CAR_3D_MODEL
// remove physics model
delete m_pCarPhaysics;
}
示例15: main
//.........这里部分代码省略.........
core::vector3df(0.0f, -0.725f, 0.0f));
plyrNode->addAnimator(anim);
}
ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
////////////// The Sun ////////////
ILightSceneNode *sun_node;
SLight sun_data;
ISceneNode *sun_billboard;
float sun_angle = 0;
video::SColorf Diffuse_Night = video::SColorf(0.0f, 0.0f, 0.0f, 1.0f);
video::SColorf Diffuse_Day = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
sun_node = smgr->addLightSceneNode();
sun_data.Direction = vector3df(0, 0, 0);
sun_data.Type = video::ELT_DIRECTIONAL;
sun_data.AmbientColor = video::SColorf(0.1f, 0.1f, 0.1f, 1);
sun_data.SpecularColor = video::SColorf(0, 0, 0, 0);
sun_data.DiffuseColor = Diffuse_Day;
sun_data.CastShadows = true;
sun_node->setLightData(sun_data);
sun_node->setPosition(vector3df(0, 0, 0));
sun_node->setRotation(vector3df(0, 0, 0));
sun_billboard = smgr->addBillboardSceneNode(sun_node, core::dimension2d<f32>(60, 60));
if (sun_billboard)
{
sun_billboard->setPosition(vector3df(0, 0, -100));
sun_billboard->setMaterialFlag(video::EMF_LIGHTING, false);
sun_billboard->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
sun_billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
sun_billboard->setMaterialTexture(0, driver->getTexture("Assets/particlewhite.bmp"));
}
/////////// End ////////////
//------- candleLight -----//
ILightSceneNode *candleLight = smgr->addLightSceneNode();
SLight candleLight_data;
candleLight_data.Type = video::ELT_POINT;
candleLight_data.DiffuseColor = SColorf(1.0f, 0.546f, 0.016f, 1.0f);
candleLight_data.SpecularColor = video::SColorf(0, 0, 0, 0);
candleLight->setPosition(vector3df(2.43467f, 1.55795f, -3.94657));
candleLight_data.Radius = 1.5f;
candleLight->setLightData(candleLight_data);
//------- end -----//
//// Make the player
//player.AddGold(1000);
//player.SetCurrentPort(eMapDest::South);
//Item* itemCi = new Item("Iron Ore", 1);
//player.getItems()->addItem(itemCi);
//Item* itemCb = new Item("Bronze Ore", 1);
//player.getItems()->addItem(itemCb);
//Vendor vN;
//Item* itemG = new Item("Gold Ore", 1000);
//vN.getItems()->addItem(itemG);
//Vendor vS;
//Item* itemI = new Item("Iron Ore", 1000);
//vS.getItems()->addItem(itemI);
//Vendor vE;
//Item* itemB = new Item("Bronze Ore", 1000);
//vE.getItems()->addItem(itemB);