• CEGUI 动态生成 texture imageset image


    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

  • 相关阅读:
    判断操作系统多久没有任何操作
    初识类的方法
    类引用
    将窗体显示在 PageControl 上。
    用批处理命令安装打印机
    减小Delphi2010程序的尺寸(关闭RTTI反射机制)
    Delphi 的编码与解码(或叫加密与解密)函数
    c# 让repeater多列显示
    合并动态数组
    [最新]Visual Assist X 破解版下载(10.6.1827)
  • 原文地址:https://www.cnblogs.com/minggoddess/p/2268699.html
Copyright © 2020-2023  润新知