CEGUI 动态生成 texture imageset image

CEGUI 动态生成 texture imageset image
2010-05-13 13:22

unsigned long* CMD_GUI_GetSmallMapBuf()
// render small map
{
DWORD color[6] =
{
D3DCOLOR_RGBA( 0, 0, 255, 255 ),
D3DCOLOR_RGBA( 255 , 0, 255, 255 ),
D3DCOLOR_RGBA( 0, 255, 255, 255 ),
D3DCOLOR_RGBA( 0, 255, 0, 255 ),
D3DCOLOR_RGBA( 255, 255, 0, 255 ),
D3DCOLOR_RGBA( 255, 0, 0, 255 )
};
int i = 0;
int j = 0;
static DWORD dwSmallMap[200][200];
for(i=0; i<200; i++)
{
for(j=0; j<200; j++)
{
dwSmallMap[i][j] = color[ CMD_SIM_GetMapUnit(i,j) ];
}
}
CEGUI::Size size(200, 200);
CEGUI::Point pxy(0, 0);
CEGUI::Texture* tex = ( &CEGUI::System::getSingleton().getRenderer()->createTexture(size) );
tex->loadFromMemory((void*)dwSmallMap, size, CEGUI::Texture::PF_RGBA);
CEGUI::ImagesetManager* ImgSetMgr = &CEGUI::ImagesetManager::getSingleton();
ImgSetMgr->create("SmallMap", *tex,CEGUI::XMLResourceExistsAction::XREA_REPLACE);
CEGUI::Window* pwnd = CMD_GUI_GetWindowByName("MessageBox.layout");
CEGUI::Imageset* ImgSet = &ImgSetMgr->get("SmallMap");
ImgSet->defineImage("_full_image_", pxy, size, pxy);
pwnd->getChild("MSG/background")->setProperty("Image", "set:SmallMap image:_full_image_");


return NULL;
}

=====

void CMD_GUI_ResetSmallMap()
{
int x = (int)gRSRenderer->GetCameraCenter()->x;
int y = (int)gRSRenderer->GetCameraCenter()->y;

int i = 0;
int j = 0;
for(i=0; i<200; i++)
{
for(j=0; j<200; j++)
{
//if( abs(x-i)<10 && abs(y-j)<10 )                        //rectangle small map
if( pow( (float)(x-i)*(x-i) + (y-j)*(y-j), 0.5f) < 10 )    //circle small map
dwSmallMap[i][j] = color_now[ CMD_SIM_GetMapUnit(i,j) ];
else
dwSmallMap[i][j] = color[ CMD_SIM_GetMapUnit(i,j) ];
}
}
CEGUI::Size size(200, 200);
CEGUI::Point pxy(0, 0);
CEGUI::Texture* tex = ( &CEGUI::System::getSingleton().getRenderer()->createTexture(size) );
tex->loadFromMemory((void*)dwSmallMap, size, CEGUI::Texture::PF_RGBA);
CEGUI::ImagesetManager& ImgSetMgr = CEGUI::ImagesetManager::getSingleton();
ImgSetMgr.create("SmallMap", *tex, (CEGUI::XMLResourceExistsAction)1);    //1 == CEGUI::XMLResourceExistsAction::XREA_REPLACE;
CEGUI::Window* pwnd = CMD_GUI_GetWindowByName("MYGameWindow.layout");
CEGUI::Imageset* ImgSet = &ImgSetMgr.get("SmallMap");
ImgSet->defineImage("_full_image_", pxy, size, pxy);
pwnd = pwnd->getChild("MYGameWindow/Frame");
pwnd = pwnd->getChild("MYGameWindow/SmallMap");
pwnd->setProperty("Image", "set:SmallMap image:_full_image_");

return ;
}

void CMD_GUI_DrawHeroFace()
{
MYTexture* gtex = gRSRenderer->GetHeroFaceTexture();
if(NULL == gtex)
return;
CEGUI::Size size(MC_CHARACTER_PORTRAIT_SIZE, MC_CHARACTER_PORTRAIT_SIZE);
CEGUI::Point pxy(0, 0);
CEGUI::Texture* ctex = ( &CEGUI::System::getSingleton().getRenderer()->createTexture(size) );
((CEGUI::Direct3D9Texture*)ctex)->setDirect3D9Texture( (LPDIRECT3DTEXTURE9)gtex->pData );
CEGUI::ImagesetManager& ImgSetMgr = CEGUI::ImagesetManager::getSingleton();
ImgSetMgr.create("HeroFace", *ctex, (CEGUI::XMLResourceExistsAction)1);    //1 == CEGUI::XMLResourceExistsAction::XREA_REPLACE;
CEGUI::Imageset* ImgSet = &ImgSetMgr.get("HeroFace");
ImgSet->defineImage("_full_image_", pxy, size, pxy);
CEGUI::Window* pwnd = CMD_GUI_GetWindowByName("MYGameWindow.layout");
pwnd = pwnd->getChild("MYGameWindow/Hero");
pwnd = pwnd->getChild("MYGameWindow/Hero/Face");
pwnd->setProperty("Image", "set:HeroFace image:_full_image_");

}

 转自http://hi.baidu.com/wither/blog/item/9e67991339d97b8c6438db4e.html

posted on 2011-01-05 21:13  minggoddess  阅读(754)  评论(0编辑  收藏  举报