Ex:
#include <irrlicht.h>
using namespace irr;
using namespace irr::core;
using namespace irr::video;
using namespace irr::scene;
int main()
{
//获取设备对象
IrrlichtDevice *device = createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16, false, false, false, 0);
if(!device)
return 1;
device->setWindowCaption(L "Hello World!"); //设置窗体标题
IVideoDriver *driver=device->getVideoDriver(); //与纹理有关
ISceneManager *smgr=device->getSceneManager(); //获取场景管理器对象
ISceneNode *cubeNode=smgr->addCubeSceneNode(100.0f); //添加立方体
ITexture *tex=driver->getTexture( "texture.jpg"); //获取贴图纹理
cubeNode->setMaterialTexture(0,tex); //为立方体设置贴图纹理
cubeNode->setMaterialFlag(EMF_LIGHTING, false); //设置贴图与光源无关
//cubeNode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);//设置半透明Alpha通道
ICameraSceneNode *camera=smgr->addCameraSceneNode(0,vector3df(200,200,-200),vector3df(0,0,0));
//游戏循环Game Loop
while(device->run())
{
driver->beginScene( true, true,SColor(255,0,0,0)); //[[Begin
smgr->drawAll(); //全部绘制
driver->endScene(); //End]]
}
device->drop(); //删除设备对象
return 0;
}
using namespace irr;
using namespace irr::core;
using namespace irr::video;
using namespace irr::scene;
int main()
{
//获取设备对象
IrrlichtDevice *device = createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16, false, false, false, 0);
if(!device)
return 1;
device->setWindowCaption(L "Hello World!"); //设置窗体标题
IVideoDriver *driver=device->getVideoDriver(); //与纹理有关
ISceneManager *smgr=device->getSceneManager(); //获取场景管理器对象
ISceneNode *cubeNode=smgr->addCubeSceneNode(100.0f); //添加立方体
ITexture *tex=driver->getTexture( "texture.jpg"); //获取贴图纹理
cubeNode->setMaterialTexture(0,tex); //为立方体设置贴图纹理
cubeNode->setMaterialFlag(EMF_LIGHTING, false); //设置贴图与光源无关
//cubeNode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);//设置半透明Alpha通道
ICameraSceneNode *camera=smgr->addCameraSceneNode(0,vector3df(200,200,-200),vector3df(0,0,0));
//游戏循环Game Loop
while(device->run())
{
driver->beginScene( true, true,SColor(255,0,0,0)); //[[Begin
smgr->drawAll(); //全部绘制
driver->endScene(); //End]]
}
device->drop(); //删除设备对象
return 0;
}
引擎下载地址:
贴图:
上图:
本文转自 xcf007 51CTO博客,原文链接:http://blog.51cto.com/xcf007/321509
,如需转载请自行联系原作者