zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    聊一聊分布式锁的设计
    github上值得关注的前端项目
    数据库水平切分的实现原理解析——分库,分表,主从,集群,负载均衡器(转)
    查询执行时间
    Autofac in webapi2
    Fluent Validation with Web Api 2
    数字转换成大写
    ABP:在多语句事务内不允许使用 CREATE DATABASE 语句
    陕西电力同业对标管理系统
    多媒体文件嵌入HTML中自动转码工具
  • 原文地址:https://www.cnblogs.com/minggoddess/p/1926795.html
Copyright © 2011-2022 走看看